Page 1 of 1

SplitterGadget - I must be THICK!!!

Posted: Sun Jan 25, 2004 1:04 am
by johnfermor
Hi

I am having difficulties designing a GUI with 3 components; 1 ListIcon Gadget and 2 Editor Gadgets. There are 2 spliter gadgets that I can't seem to get working.

The screen should look like [something] this;
http://aa.1asphost.com/olympianeducatio ... isplay.bmp

The best I've managed to do is display the components with 1 active splitter. The 2nd splitter seems to have a mind of its own.

I have searched through the archives and looked at some examples but I either don't understand them or can't 'adapt' them for my needs.

I would really appreciate some guidance here or source code would be better. I think I understand the callback to resize the splitter but help here may be useful also.

Thanks in advacnce.


John
:x

Posted: Sun Jan 25, 2004 2:24 am
by freak
1) create the 3 gadgets 1, 2 and 3
2) create a splitter (gadget 4) with 1 and 2
3) create another splitter (gadget 5) with the first splitter (4) and gadget 3

this should work fine.

Note: when resizing, you may only resize the outer splitter (5), nothing else.
The others get resized automatically as a result of the resizing of the outer
splitter. If you try to resize them all, it'll get screwed up.

Timo

Posted: Sun Jan 25, 2004 8:28 am
by Danilo

Code: Select all

Procedure WindowProc(hWnd,Msg,wParam,lParam)
  result = #PB_ProcessPureBasicEvents
  If Msg = #WM_SIZE And hWnd = WindowID(0)
    ResizeGadget(5,0,0,lParam&$FFFF,(lParam>>16)&$FFFF)
    result = 0
  EndIf
  ProcedureReturn result
EndProcedure

OpenWindow(0,0,0,500,400,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget,"Split")
  CreateGadgetList(WindowID())
  SetWindowCallback(@WindowProc())

  ListIconGadget(1,0,0,0,0,"Title",200,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  EditorGadget(2,0,0,0,0)
  EditorGadget(3,0,0,0,0)

  ; splitter1: listicon and editor1
  SplitterGadget(4,0,0,500,300,1,2,#PB_Splitter_Vertical|#PB_Splitter_Separator)
    SetGadgetState(4,350) ; Set splitter width

  ; splitter2: splitter1 and editor2
  SplitterGadget(5,0,0,500,400,4,3,#PB_Splitter_Separator)
    SetGadgetState(5,300) ; Set splitter width

Repeat:Until WaitWindowEvent()=#PB_EventCloseWindow

Posted: Sun Jan 25, 2004 1:42 pm
by johnfermor
Thanks Danilo

That code does exactly what I needed and you've made it look so easy!

I'll study this and see if I can get my head around the SplitterGadget so I won't need to bother the forums again!

Many thanks for your efforts..

:D
John

Posted: Sun Jan 25, 2004 4:09 pm
by blueb
John,

As you can see: a small demo program (that works) is a great learning tool. And Danilo is the very best when it comes to freely giving out perfect demos.

Thanks Danilo 8) You're a very generous man.

I learn a lot from these forums. I've shamelessly copied a LOT of small demos. Keep it up guys, I hope to contribute more in the future.

blueb

Posted: Fri Jan 30, 2004 12:32 am
by johnfermor
Thanks BlueB

I couldn't agree with you more. Its people like Danilo who make this forum what it is.