Page 1 of 1

ContainerGadget issue

Posted: Fri Dec 10, 2010 8:53 pm
by sverson
If I create a borderless ContainerGadget inside a ContainerGadget with the same size at 0/0.
On Windows it will completely cover the parent container which is what I need.
On Linux (Ubutu) there seems to be a inner frame so it appears at 1/1 or 2/2 instead of 0/0.

How can I set this frame to '0' or at least get the size of the frame :?:
AND
How can I get the size of the MainWindow border?
As you can see, the visible area of the Linux window is not 200x200. It is smaller! :(

Does someone know the gtk_... functions to get this Linux metrics :?:

ImageImage

Code: Select all

Procedure InsertContainer(GadgetNo.i=0)
  Protected Gadget
  Gadget = ContainerGadget(#PB_Any, 0, 0, 200, 200, #PB_Container_BorderLess)
    SetGadgetColor(Gadget, #PB_Gadget_BackColor, RGB(Random($FF),Random($FF),Random($FF)))
    If GadgetNo<40
      GadgetNo+1
      InsertContainer(GadgetNo)
    EndIf
  CloseGadgetList() 
EndProcedure

If OpenWindow(0, 0, 0, 200, 200, "ContainerGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  InsertContainer()
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf 

Re: ContainerGadget issue

Posted: Sat Dec 11, 2010 12:08 am
by Vera
Hello sverson,

have a look at the german thread: Wrong positioning within ContainerGadget and see Shardik hints/links.
freak wrote:Das ist ein Gtk-Problem. Selbst ein Container ohne sichtbaren Rand hat 2 Pixel Abstand um sich herrum, damit ist die Nutzbare Fläche um 4 Pixel kleiner.
translation: This is a Gtk-problem. Even a container without visible frame has a 2 px gab around itself, so the usable area is about 4px smaller.

Apart from that, one would still expect that placing one container over the other should happen at the fixed given position, but they are also inserted, instead of overlayed.
I played around with your code and found that you could lever out this effect by substracting the frame amount while encreasing the area size to get the same result as on WIN.
Test this: Gadget = ContainerGadget(#PB_Any, -2, -2, 204, 204, #PB_Container_BorderLess)

But: doing this with more than 105 gadgets you start getting warnings about unrefined object assertions, so this can't be a clean solution after all.
Maybe it could be ok with a handfull of gadgets without further troubles.

I've got two questions:
- Can't you remove or deactivate a gadget before replacing it ?
- Is it a common way to do, to call up the same procedure from within itself ?
(Besides: you could achive the same result with a while-wend loop.)

greetings ~ Vera

Re: ContainerGadget issue

Posted: Sat Dec 11, 2010 1:10 am
by ts-soft
Another problem with your source: there is only one CloseGadgetList() for 40 Container!

Greetings
Thomas

Re: ContainerGadget issue

Posted: Sat Dec 11, 2010 1:18 am
by sverson
Hello Vera,

Thanks for your help.

I already read the german thread.
And I already use the 'dirty trick': Gadget = ContainerGadget(#PB_Any, -2, -2, 204, 204, #PB_Container_BorderLess)

What I am looking for is a function to get the value '-2' at runtime. I don't want to 'hard code' it because it may not be the same on all Linux versions / configurations.

@ts-soft: The demo above is 'non sense'. It is just to display the '-2' border on Linux.

In a very complex platform independent GUI I need to get areas structured using containers and it needs to work without clipping gadgets. So I need to find out wether there is a frame to take care of or not. On Windows it's '0' but I don't believe it will be always '-2' on Linux - have not even tested on Mac.

:wink: sverson

Re: ContainerGadget issue

Posted: Sat Dec 11, 2010 3:46 am
by freak
Actually there might even be a way to fix this. I'll have to take a closer look.

Re: ContainerGadget issue

Posted: Sun Dec 12, 2010 7:34 am
by PureLust
ts-soft wrote:Another problem with your source: there is only one CloseGadgetList() for 40 Container!
You might have a closer look at the code.
The CloseGadgetList() is fired correctly (40 times) after the last recursive call of InsertContainer().

Re: ContainerGadget issue

Posted: Sun Dec 12, 2010 9:54 am
by Shardik
sverson wrote:On Windows it's '0' but I don't believe it will be always '-2' on Linux - have not even tested on Mac.
Your code example on MacOS X 10.6.5 in PB 4.51:
Image