ContainerGadget issue

Linux specific forum
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

ContainerGadget issue

Post 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 
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: ContainerGadget issue

Post 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
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: ContainerGadget issue

Post by ts-soft »

Another problem with your source: there is only one CloseGadgetList() for 40 Container!

Greetings
Thomas
sverson
Enthusiast
Enthusiast
Posts: 286
Joined: Sun Jul 04, 2004 12:15 pm
Location: Germany

Re: ContainerGadget issue

Post 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
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: ContainerGadget issue

Post by freak »

Actually there might even be a way to fix this. I'll have to take a closer look.
quidquid Latine dictum sit altum videtur
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: ContainerGadget issue

Post 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().
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: ContainerGadget issue

Post 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
Post Reply