SplitterGadget using CanvasGadget ver 0.8 [Windows]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4660
Joined: Sun Apr 12, 2009 6:27 am

SplitterGadget using CanvasGadget ver 0.8 [Windows]

Post by RASHAD »

Hi all
The title say it all

Code: Select all


Procedure winCB(hWnd, uMsg, wParam, lParam)
 result = #PB_ProcessPureBasicEvents
 Select uMsg
   Case #WM_SIZE
      ResizeGadget(0,#PB_Ignore,#PB_Ignore,WindowWidth(0)-20,WindowHeight(0,#PB_Window_InnerCoordinate)-40)
      ResizeGadget(1,#PB_Ignore,#PB_Ignore,#PB_Ignore, WindowHeight(0,#PB_Window_InnerCoordinate)-40)
      ResizeGadget(2,#PB_Ignore,#PB_Ignore, WindowWidth(0)-GadgetWidth(1)-4,WindowHeight(0,#PB_Window_InnerCoordinate)-40)       
              
   EndSelect   
  ProcedureReturn result 
EndProcedure

sgcolor = $D5014E

flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,800,600,"Test",Flags)

If CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100)
  AddStatusBarField(50)
  AddStatusBarField(100)
EndIf

StatusBarText(0, 0, "Area 1")
StatusBarText(0, 1, "Area 2", #PB_StatusBar_BorderLess)
StatusBarText(0, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised) 

CanvasGadget(0,10,10,780,560,#PB_Canvas_Container)
SetWindowLongPtr_(GadgetID(0),#GWL_STYLE, GetWindowLongPtr_(GadgetID(0),#GWL_STYLE)| #WS_CLIPCHILDREN)

ListIconGadget(1,0,0,188,560,"Column 0",100,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
SetWindowLongPtr_(GadgetID(1),#GWL_STYLE, GetWindowLongPtr_(GadgetID(1),#GWL_STYLE)| #WS_CLIPCHILDREN)

ListIconGadget(2,192,0,588,560,"Column 0",100,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
SetWindowLongPtr_(GadgetID(2),#GWL_STYLE, GetWindowLongPtr_(GadgetID(2),#GWL_STYLE)| #WS_CLIPCHILDREN)

    For a = 1 To 2            ; add columns to each of the first 5 listicons
      For b = 1 To 4          ; add 3 more columns to each listicon
        AddGadgetColumn(a, b, "Column " + Str(b), 65)
      Next
      For b = 0 To 2          ; add 4 items to each line of the listicons
        AddGadgetItem(a, b, "Item 0"+Chr(10)+"Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4")
      Next
    Next
    
SetWindowCallback(@winCB())

Repeat
           
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
            Quit = 1
      
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            Select EventType()
              Case #PB_EventType_MouseEnter
                    SetGadgetAttribute(0,#PB_Canvas_Cursor,#PB_Cursor_LeftRight)
                  
              Case #PB_EventType_MouseLeave
                    SetGadgetAttribute(0,#PB_Canvas_Cursor,#PB_Cursor_Default)
                                   
              Case #PB_EventType_LeftButtonDown
                    cx = GetGadgetAttribute(0,#PB_Canvas_MouseX)
                    StartDrawing(CanvasOutput(0))
                      DrawingMode(#PB_2DDrawing_XOr )
                      Box(cx,0,4,WindowHeight(0),sgcolor)
                    StopDrawing()
                    Flag = 1             
                   
              Case #PB_EventType_MouseMove
                  If Flag = 1 
                    StartDrawing(CanvasOutput(0))
                      DrawingMode(#PB_2DDrawing_XOr )
                      Box(cx,0,4,WindowHeight(0),sgcolor)
                      cx = GetGadgetAttribute(0,#PB_Canvas_MouseX)
                      Box(cx,0,4,WindowHeight(0),sgcolor)                     
                    StopDrawing()
                    SmartWindowRefresh(0,0)
                      ResizeGadget(1,#PB_Ignore,#PB_Ignore,cx,#PB_Ignore)                      
                      ResizeGadget(2,cx+4,#PB_Ignore, GadgetWidth(0)-GadgetWidth(1)-4,#PB_Ignore)
                    SmartWindowRefresh(0,1)
                  EndIf
                   
              Case #PB_EventType_LeftButtonUp
                   Flag = 0
                   StartDrawing(CanvasOutput(0))
                      DrawingMode(#PB_2DDrawing_XOr )
                      Box(cx,0,4,WindowHeight(0),sgcolor)
                   StopDrawing()
             
            EndSelect                   
        EndSelect         

  EndSelect 

Until Quit = 1
End
Last edited by RASHAD on Wed Sep 06, 2017 9:56 am, edited 1 time in total.
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: SplitterGadget using CanvasGadget ver 0.8 [Windows]

Post by Kwai chang caine »

A little bit of flickering when move the split bar, but works very well :wink:
Thanks a lot for sharing 8)
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4660
Joined: Sun Apr 12, 2009 6:27 am

Re: SplitterGadget using CanvasGadget ver 0.8 [Windows]

Post by RASHAD »

Hi KCC
Previous post updated
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: SplitterGadget using CanvasGadget ver 0.8 [Windows]

Post by Kwai chang caine »

Aaaaah !!!! very more nice now !!!! :D
Thanks a lot MASTER for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply