Automatic gadget resizing (nxTools)

Developed or developing a new product in PureBasic? Tell the world about it.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

:D
Good job, as usual.
Very useful.
Thanks for sharing.
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome QuimV. :)
I may look like a mule, but I'm not a complete ass.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

Thanks, srod.
That's very useful. :mrgreen:
Ollivier
Enthusiast
Enthusiast
Posts: 281
Joined: Mon Jul 23, 2007 8:30 pm
Location: FR

Post by Ollivier »

2srod

Hi! I often download your source and I find sometimes algo I needed.

So, as I never say it :

THANKS SROD ! :D Very much.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome. :)
I may look like a mule, but I'm not a complete ass.
Amnesty
User
User
Posts: 54
Joined: Wed Jul 04, 2007 4:34 pm
Location: Germany

Post by Amnesty »

Hi srod,

I ve used your great little lib for a long time, but now I ve got a little problem, and I m not sure, If I m doing something wrong.

The following code shows my problem, as you can see on the second panel, the resizing doesnt work.

Am I doing something wrong ?

regards

Amnesty

Code: Select all

XIncludeFile "nxTools_Resize.pbi"

If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SizeGadget    | #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
  PanelGadget     (0, 8, 8, 306, 203)
  AddGadgetItem (0, -1, "Works fine!")
  ListViewGadget(1, 5, 5, 288, 163)
  AddGadgetItem (0, -1,"Hmmm....")
  ListViewGadget(2, 5, 5, 288, 163)
  CloseGadgetList()
  nxTools_SetResize(0, #nxResize_Anchorall)
  nxTools_SetResize(1, #nxResize_Anchorall)
  nxTools_SetResize(2, #nxResize_Anchorall)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Ah yes, I see what is happening and I think I can guess why. Not sure I can do anything about it though.

Hang on.......
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

As soon as you issue the nxTools_SetResize() command, the library looks at the gadget in question and it's parent and records the sizes of the margins around the gadget etc.

The problem with your code is that the panel in the second tab has a zero width and height at the time you issue the nxTools_SetResize(2,...) command which causes the margins to go into 'meltdown'. :)

The fix is simple however. Force the tab to show briefly which causes PB to resize the inner panel which is the parent of the control in question - do this before using nxTools_SetResize().

Code: Select all

XIncludeFile "nxTools.pbi"


If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SizeGadget    | #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  PanelGadget     (0, 8, 8, 306, 203) 
  AddGadgetItem (0, -1, "Works fine!") 
  ListViewGadget(1, 5, 5, 288, 163) 
  AddGadgetItem (0, -1,"Hmmm....") 
  ListViewGadget(2, 5, 5, 288, 163) 
  CloseGadgetList() 
 
  nxTools_SetResize(0, #nxResize_Anchorall) 
  nxTools_SetResize(1, #nxResize_Anchorall) 

  SetGadgetState(0,1)
  SetGadgetState(0,0)
  nxTools_SetResize(2, #nxResize_Anchorall) 
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
I may look like a mule, but I'm not a complete ass.
Amnesty
User
User
Posts: 54
Joined: Wed Jul 04, 2007 4:34 pm
Location: Germany

Post by Amnesty »

Works fine.

Thank you very much for your fast help.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome. :)
I may look like a mule, but I'm not a complete ass.
Post Reply