From: Bryan Oakley on
On Feb 19, 4:01 pm, Georgios Petasis <peta...(a)iit.demokritos.gr>
wrote:
> Hi all,
>
> I am facing the following problem:
>
> I have a Tk toplevel. Under windows, a toplevel is composed by two
> windows: the window that corresponds to the toplevel as Tk sees it (i.e.
> we have a Tk_Win for it), and a wrapper one, that is the correct
> toplevel from the OS perspective (and we need this to hold the menubar).
>
> I do have the two windows (tk's & the wrapper) and I want to "shrink"
> the inner one, so as there is padding between the wrapper window andthe
> one seen by Tk (and we can place tk widgets in it).
> How can this be done? (Windows API is ok, I need a windows only solution).

Why do you need to "shrink" the tk window? What problem does that
solve that simply giving it a wide margin won't solve?

From: Georgios Petasis on
στις 20/2/2010 00:36, O/H Bryan Oakley έγραψε:
> On Feb 19, 4:01 pm, Georgios Petasis<peta...(a)iit.demokritos.gr>
> wrote:
>> Hi all,
>>
>> I am facing the following problem:
>>
>> I have a Tk toplevel. Under windows, a toplevel is composed by two
>> windows: the window that corresponds to the toplevel as Tk sees it (i.e.
>> we have a Tk_Win for it), and a wrapper one, that is the correct
>> toplevel from the OS perspective (and we need this to hold the menubar).
>>
>> I do have the two windows (tk's& the wrapper) and I want to "shrink"
>> the inner one, so as there is padding between the wrapper window andthe
>> one seen by Tk (and we can place tk widgets in it).
>> How can this be done? (Windows API is ok, I need a windows only solution).
>
> Why do you need to "shrink" the tk window? What problem does that
> solve that simply giving it a wide margin won't solve?
>

A complex one :-)

I am writing an extension that will add a windows ribbon
(http://msdn.microsoft.com/en-us/library/dd316910%28VS.85%29.aspx) to a
Tk window. All the code is in place, and I get no error from windows,
but the visual result is not the expected one:

http://www.ellogon.org/~petasis/tcl/Images/TkRibbon.png

For an unknown reason, Tk thinks that the wrapper window has more space
when a ribbon is added. I have the height of the ribbon, but I don't
know how to convince Tk to not take all the space :-)

Regards,

George
From: Georgios Petasis on
στις 20/2/2010 00:56, O/H Georgios Petasis έγραψε:
> στις 20/2/2010 00:36, O/H Bryan Oakley έγραψε:
>> On Feb 19, 4:01 pm, Georgios Petasis<peta...(a)iit.demokritos.gr>
>> wrote:
>>> Hi all,
>>>
>>> I am facing the following problem:
>>>
>>> I have a Tk toplevel. Under windows, a toplevel is composed by two
>>> windows: the window that corresponds to the toplevel as Tk sees it (i.e.
>>> we have a Tk_Win for it), and a wrapper one, that is the correct
>>> toplevel from the OS perspective (and we need this to hold the menubar).
>>>
>>> I do have the two windows (tk's& the wrapper) and I want to "shrink"
>>> the inner one, so as there is padding between the wrapper window andthe
>>> one seen by Tk (and we can place tk widgets in it).
>>> How can this be done? (Windows API is ok, I need a windows only
>>> solution).
>>
>> Why do you need to "shrink" the tk window? What problem does that
>> solve that simply giving it a wide margin won't solve?
>>
>
> A complex one :-)
>
> I am writing an extension that will add a windows ribbon
> (http://msdn.microsoft.com/en-us/library/dd316910%28VS.85%29.aspx) to a
> Tk window. All the code is in place, and I get no error from windows,
> but the visual result is not the expected one:
>
> http://www.ellogon.org/~petasis/tcl/Images/TkRibbon.png
>
> For an unknown reason, Tk thinks that the wrapper window has more space
> when a ribbon is added. I have the height of the ribbon, but I don't
> know how to convince Tk to not take all the space :-)
>
> Regards,
>
> George

I hope this image shows the problem better:

http://www.ellogon.org/~petasis/tcl/Images/TkRibbon-Overlap.png

(What is beneath the ribbon, is a ttk button). The tcl code for the
example is:

package require tkribbon

.. configure -bg {} -width 550 -height 350
toplevel .x -bg {} -width 400 -height 350

set ribbon1 [tkribbon::ribbon new .]
set ribbon2 [tkribbon::ribbon new .x]
pack [ttk::button .x.exit -command exit -text Exit] \
-fill both -expand 1 -padx 10 -pady 30

Any ideas?

Regards,

George
From: Georgios Petasis on
στις 20/2/2010 02:36, O/H Georgios Petasis έγραψε:
> στις 20/2/2010 00:56, O/H Georgios Petasis έγραψε:
>> στις 20/2/2010 00:36, O/H Bryan Oakley έγραψε:
>>> On Feb 19, 4:01 pm, Georgios Petasis<peta...(a)iit.demokritos.gr>
>>> wrote:
>>>> Hi all,
>>>>
>>>> I am facing the following problem:
>>>>
>>>> I have a Tk toplevel. Under windows, a toplevel is composed by two
>>>> windows: the window that corresponds to the toplevel as Tk sees it
>>>> (i.e.
>>>> we have a Tk_Win for it), and a wrapper one, that is the correct
>>>> toplevel from the OS perspective (and we need this to hold the
>>>> menubar).
>>>>
>>>> I do have the two windows (tk's& the wrapper) and I want to "shrink"
>>>> the inner one, so as there is padding between the wrapper window andthe
>>>> one seen by Tk (and we can place tk widgets in it).
>>>> How can this be done? (Windows API is ok, I need a windows only
>>>> solution).
>>>
>>> Why do you need to "shrink" the tk window? What problem does that
>>> solve that simply giving it a wide margin won't solve?
>>>
>>
>> A complex one :-)
>>
>> I am writing an extension that will add a windows ribbon
>> (http://msdn.microsoft.com/en-us/library/dd316910%28VS.85%29.aspx) to a
>> Tk window. All the code is in place, and I get no error from windows,
>> but the visual result is not the expected one:
>>
>> http://www.ellogon.org/~petasis/tcl/Images/TkRibbon.png
>>
>> For an unknown reason, Tk thinks that the wrapper window has more space
>> when a ribbon is added. I have the height of the ribbon, but I don't
>> know how to convince Tk to not take all the space :-)
>>
>> Regards,
>>
>> George
>
> I hope this image shows the problem better:
>
> http://www.ellogon.org/~petasis/tcl/Images/TkRibbon-Overlap.png
>
> (What is beneath the ribbon, is a ttk button). The tcl code for the
> example is:
>
> package require tkribbon
>
> . configure -bg {} -width 550 -height 350
> toplevel .x -bg {} -width 400 -height 350
>
> set ribbon1 [tkribbon::ribbon new .]
> set ribbon2 [tkribbon::ribbon new .x]
> pack [ttk::button .x.exit -command exit -text Exit] \
> -fill both -expand 1 -padx 10 -pady 30
>
> Any ideas?
>
> Regards,
>
> George

Of course, if I put not tk widgets, everything looks ok :-)

http://www.ellogon.org/~petasis/tcl/Images/TkRibbon-TwoRibbons.png

George
From: Georgios Petasis on
στις 20/2/2010 05:04, O/H Georgios Petasis έγραψε:
> στις 20/2/2010 02:36, O/H Georgios Petasis έγραψε:
>> στις 20/2/2010 00:56, O/H Georgios Petasis έγραψε:
>>> στις 20/2/2010 00:36, O/H Bryan Oakley έγραψε:
>>>> On Feb 19, 4:01 pm, Georgios Petasis<peta...(a)iit.demokritos.gr>
>>>> wrote:
>>>>> Hi all,
>>>>>
>>>>> I am facing the following problem:
>>>>>
>>>>> I have a Tk toplevel. Under windows, a toplevel is composed by two
>>>>> windows: the window that corresponds to the toplevel as Tk sees it
>>>>> (i.e.
>>>>> we have a Tk_Win for it), and a wrapper one, that is the correct
>>>>> toplevel from the OS perspective (and we need this to hold the
>>>>> menubar).
>>>>>
>>>>> I do have the two windows (tk's& the wrapper) and I want to "shrink"
>>>>> the inner one, so as there is padding between the wrapper window
>>>>> andthe
>>>>> one seen by Tk (and we can place tk widgets in it).
>>>>> How can this be done? (Windows API is ok, I need a windows only
>>>>> solution).
>>>>
>>>> Why do you need to "shrink" the tk window? What problem does that
>>>> solve that simply giving it a wide margin won't solve?
>>>>
>>>
>>> A complex one :-)
>>>
>>> I am writing an extension that will add a windows ribbon
>>> (http://msdn.microsoft.com/en-us/library/dd316910%28VS.85%29.aspx) to a
>>> Tk window. All the code is in place, and I get no error from windows,
>>> but the visual result is not the expected one:
>>>
>>> http://www.ellogon.org/~petasis/tcl/Images/TkRibbon.png
>>>
>>> For an unknown reason, Tk thinks that the wrapper window has more space
>>> when a ribbon is added. I have the height of the ribbon, but I don't
>>> know how to convince Tk to not take all the space :-)
>>>
>>> Regards,
>>>
>>> George
>>
>> I hope this image shows the problem better:
>>
>> http://www.ellogon.org/~petasis/tcl/Images/TkRibbon-Overlap.png
>>
>> (What is beneath the ribbon, is a ttk button). The tcl code for the
>> example is:
>>
>> package require tkribbon
>>
>> . configure -bg {} -width 550 -height 350
>> toplevel .x -bg {} -width 400 -height 350
>>
>> set ribbon1 [tkribbon::ribbon new .]
>> set ribbon2 [tkribbon::ribbon new .x]
>> pack [ttk::button .x.exit -command exit -text Exit] \
>> -fill both -expand 1 -padx 10 -pady 30
>>
>> Any ideas?
>>
>> Regards,
>>
>> George
>
> Of course, if I put not tk widgets, everything looks ok :-)
>
> http://www.ellogon.org/~petasis/tcl/Images/TkRibbon-TwoRibbons.png
>
> George

It cannot be done without patching Tk. So, I implemented a workaround:
I created a tk widget that is never drawn, it only occupies space.

It seems to work ok...

The other "think" that took me a lot time to discover, is that Tk
consumes WM_WINDOWPOSCHANGED & WM_WINDOWPOSCHANGED without calling
DefWindowProc. This actually stops windows ribbon from resizing!
I had to substitute the callback functions of the toplevel wrappers with:

LRESULT CALLBACK ToplevelWndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_WINDOWPOSCHANGED:
case WM_WINDOWPOSCHANGING:
DefWindowProc(hWnd, message, wParam, lParam);
break;
}
return CallWindowProc(TkRibbon_TkToplevel_WndProc,
hWnd, message, wParam, lParam);
}; /* ToplevelWndProc */

George