It is currently Wed Oct 21, 2020 8:26 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadgets
PostPosted: Mon May 19, 2008 5:51 am 
Offline
Addict
Addict
User avatar

Joined: Mon May 26, 2003 3:07 pm
Posts: 1477
Location: Nantes
ToolbarPlus includefile for PB4.20 & PB4.30 (convert from PB3.94 to PB4.XX)
Open source for PBOSL
I notice the PB4 source code is simplier than my previous version in PB3.94 :lol:

:arrow: Features :
- ADDED : toolbar gadgets (button, text, spin, .... 17 gadgets supported)
- ADDED : toolbar popup menu
- ADDED : toolbar grouped toggle buttons
- ADDED : toolbar drop-down style button

:arrow: Demo Video : http://www.screencast.com/users/rineddy/folders/Jing/media/8102ac6a-9756-47fb-a19e-7b9b4c770d01

Image

Code:
;/// ToolbarPlus for PB 4.XX (open source)

;{ Utils
Macro ValidateGadgetID(Result, ID, gadget)
   If ID=#PB_Any
      ID=Result
      gadget=GadgetID(ID)
   Else
      gadget=Result
   EndIf
EndMacro
;}

;{ ToolbarPlus Functions
Structure ToolbarPlusMenu
   ToolbarPlusParent.l
   ToolbarPlus.l
   ToolbarPlusID.l
   ButtonID.l
   ButtonArrow.l
   MenuID.l
EndStructure
Global NewList ToolbarPlusMenu.ToolbarPlusMenu()

CompilerIf Defined(TBN_DROPDOWN, #PB_Constant)=#False
   #TBN_DROPDOWN=-710
   #TBSTYLE_DROPDOWN=$8
   #BTNS_WHOLEDROPDOWN=$80
CompilerEndIf

ProcedureDLL ToolbarContainerHeight() ;Get default height for toolbar gadget
   Shared ToolbarPlus
   If ToolbarPlus
      GetClientRect_(ToolbarPlus, sz.RECT)
      ProcedureReturn sz\bottom-sz\top
   EndIf
EndProcedure
ProcedureDLL ToolbarCenterGadget(ID) ;Center gadget vertically inside ToolbarContainer
   ResizeGadget(ID, #PB_Ignore, GadgetY(ID)+(ToolbarContainerHeight()-GadgetHeight(ID))/2, #PB_Ignore, #PB_Ignore)
EndProcedure
ProcedureDLL SetToolBarArrow(SimpleArrow.b=#False) ;Creates a drop-down style button
   Shared ToolbarPlusParent
   Shared ToolbarPlus
   Shared ToolbarPlusID
   
   ;get button
   Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)-1
   Protected button.TBBUTTON
   SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @button)
   If (button\fsStyle & #TBSTYLE_SEP) : ProcedureReturn 0 : EndIf
   
   ;change button style
   If SimpleArrow
      button\fsStyle=button\fsStyle | #TBSTYLE_DROPDOWN | #BTNS_WHOLEDROPDOWN
   Else
      button\fsStyle=button\fsStyle | #TBSTYLE_DROPDOWN
   EndIf
   SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
   SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos+1, button)
   
EndProcedure
ProcedureDLL SetToolBarMenu(MenuID) ;Specifies that the button will display a popup menu.
   Shared ToolbarPlusParent
   Shared ToolbarPlus
   Shared ToolbarPlusID
   
   ;get button
   Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)-1
   Protected button.TBBUTTON
   SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @button)
   If (button\fsStyle & #TBSTYLE_SEP) : ProcedureReturn 0 : EndIf
   
   ;get dropdown-arrow mode
   Protected ButtonArrow=0
   If (button\fsStyle & #TBSTYLE_DROPDOWN) : ButtonArrow=1 : EndIf
   
   AddElement(ToolbarPlusMenu())
   ToolbarPlusMenu()\ToolbarPlusParent=ToolbarPlusParent
   ToolbarPlusMenu()\ToolbarPlus=ToolbarPlus
   ToolbarPlusMenu()\ToolbarPlusID=ToolbarPlusID
   ToolbarPlusMenu()\ButtonArrow=ButtonArrow
   ToolbarPlusMenu()\ButtonID=button\idCommand
   ToolbarPlusMenu()\MenuID=MenuID
EndProcedure
ProcedureDLL SetToolBarToggle(Grouped)
   Shared ToolbarPlusParent
   Shared ToolbarPlus
   Shared ToolbarPlusID
   
   ;get button info
   Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)-1
   Protected button.TBBUTTON
   SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @button)
   If (button\fsStyle & #TBSTYLE_SEP) : ProcedureReturn 0 : EndIf
   
   ;change button
   If Grouped
      button\fsStyle=button\fsStyle | #TBSTYLE_CHECKGROUP
   Else
      button\fsStyle=button\fsStyle | #TBSTYLE_CHECK
   EndIf
   SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
   SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos+1, button)
   
EndProcedure
ProcedureDLL ToolBarPlusCB(Window.l, message.l, wParam.l, lParam.l, Result.l) ;ToolbarPlus callback procedure.
   Shared ToolbarPlus_Toolbar.l
   Shared ToolbarPlus_ToolbarParent.l
   Shared ToolbarPlus_ButtonID.l
   Shared ToolbarPlus_PressedArrow.b
   Shared ToolbarPlus_PopupX.l
   Shared ToolbarPlus_PopupY.l
   ToolbarPlus_Toolbar=0
   ToolbarPlus_ButtonID=0
   ToolbarPlus_PressedArrow=0
   ToolbarPlus_PopupX=0
   ToolbarPlus_PopupY=0
   
   If Result<>#PB_ProcessPureBasicEvents : ProcedureReturn Result : EndIf
   
   ;detect toolbar events
   Select message
      Case #WM_COMMAND
         ToolbarPlus_Toolbar=lParam
         ToolbarPlus_ButtonID=wParam ;(wParam -> high word = 0)
         ToolbarPlus_PressedArrow=0
         
      Case #WM_NOTIFY
         *msgTB.NMTOOLBAR=lParam
         If *msgTB\hdr\code=#TBN_DROPDOWN
            ToolbarPlus_Toolbar=*msgTB\hdr\hwndFrom
            ToolbarPlus_ButtonID=*msgTB\iItem
            ToolbarPlus_PressedArrow=1
         EndIf
   EndSelect
   ;validate found results
   If ToolbarPlus_Toolbar
      Protected classname.s=Space(1000)
      Protected lg=GetClassName_(ToolbarPlus_Toolbar, @classname, Len(classname))
      classname=LCase(Left(classname, lg))
     
      If classname="toolbarwindow32"
         SendMessage_(ToolbarPlus_Toolbar, #TB_GETRECT, ToolbarPlus_ButtonID, @rc.RECT)
         MapWindowPoints_(ToolbarPlus_Toolbar, 0, @rc, 2)
         ToolbarPlus_PopupX=rc\left
         ToolbarPlus_PopupY=rc\bottom
         ToolbarPlus_ToolbarParent=GetParent_(ToolbarPlus_Toolbar)
      Else
         ToolbarPlus_Toolbar=0
         ToolbarPlus_ButtonID=0
         ToolbarPlus_PressedArrow=0
         ToolbarPlus_PopupX=0
         ToolbarPlus_PopupY=0
      EndIf
   EndIf
   
   ; ===================
   ; toolbar popup menu
   ; ===================
   If ToolbarPlus_Toolbar
      ForEach ToolbarPlusMenu()
         Protected ButtonID=ToolbarPlusMenu()\ButtonID
         Protected ButtonArrow=ToolbarPlusMenu()\ButtonArrow
         Protected ToolbarPlusParent=ToolbarPlusMenu()\ToolbarPlusParent
         Protected ToolbarPlus=ToolbarPlusMenu()\ToolbarPlus
         Protected MenuID=ToolbarPlusMenu()\MenuID
         
         If ToolbarPlus=ToolbarPlus_Toolbar And ButtonID=ToolbarPlus_ButtonID
            If IsMenu(MenuID) And ButtonArrow=ToolbarPlus_PressedArrow
               DisplayPopupMenu(MenuID, ToolbarPlus, ToolbarPlus_PopupX, ToolbarPlus_PopupY)
               ProcedureReturn 0
            EndIf
         EndIf
      Next
   EndIf
   
   ProcedureReturn Result
EndProcedure
ProcedureDLL ToolbarPlusCB_Toolbar() ;ToolbarPlusCB() -> active toolbar
   Shared ToolbarPlus_Toolbar
   ProcedureReturn ToolbarPlus_Toolbar
EndProcedure
ProcedureDLL ToolbarPlusCB_ButtonID() ;ToolbarPlusCB() -> pressed button ID
   Shared ToolbarPlus_ButtonID
   ProcedureReturn ToolbarPlus_ButtonID
EndProcedure
ProcedureDLL ToolbarPlusCB_PressedArrow() ;ToolbarPlusCB() -> pressed button arrow
   Shared ToolbarPlus_PressedArrow
   ProcedureReturn ToolbarPlus_PressedArrow
EndProcedure
ProcedureDLL ToolbarPlusCB_PopupX() ;ToolbarPlusCB() -> popup position X
   Shared ToolbarPlus_PopupX
   ProcedureReturn ToolbarPlus_PopupX
EndProcedure
ProcedureDLL ToolbarPlusCB_PopupY() ;ToolbarPlusCB() -> popup position Y
   Shared ToolbarPlus_PopupY
   ProcedureReturn ToolbarPlus_PopupY
EndProcedure
;}

;{ ToolbarPlus Gadgets
ProcedureDLL CreateToolBarPlus(ID, parent) ;Create toolbar plus
   ; ====================
   ; Create
   ; ====================
   Shared ToolbarPlusParent
   Shared ToolbarPlus
   Shared ToolbarPlusID
   Result=CreateToolBar(ID, parent)
   ToolbarPlusID=ID
   ToolbarPlusParent=parent
   ValidateGadgetID(Result, ToolbarPlusID, ToolbarPlus)
   
   ; ====================
   ; Change Style
   ; ====================
   #TB_SETEXTENDEDSTYLE=$400+84
   #TB_GETEXTENDEDSTYLE=$400+85
   #TBSTYLE_EX_DRAWDDARROWS=$1
   Protected s=SendMessage_(ToolbarPlus, #TB_GETEXTENDEDSTYLE, 0, 0) | #TBSTYLE_EX_DRAWDDARROWS
   SendMessage_(ToolbarPlus, #TB_SETEXTENDEDSTYLE, 0, s)
   
   ProcedureReturn Result
EndProcedure
ProcedureDLL ToolbarContainer(ID, offsetX, width, flag=0) ;Add toolbar container
   Shared ToolbarPlusParent
   Shared ToolbarPlus
   Shared ToolbarPlusID
   
   ; ====================
   ; Prepare
   ; ====================
   Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)
   Protected separator.TBBUTTON
   ToolBarSeparator()
   ;set separator width
   SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @separator)
   separator\iBitmap=width+offsetX
   SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
   SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos, separator)
   ;get separator position
   SendMessage_(ToolbarPlus, #TB_GETITEMRECT, pos, @rc.RECT)
   
   ; ====================
   ; Create
   ; ====================
   Protected x.l=rc\left
   Protected y.l=0
   Protected h.l=ToolbarContainerHeight()
   Protected w.l=width+offsetX
   CompilerIf #PB_Compiler_Version<430
      CreateGadgetList(ToolbarPlus)
   CompilerElse
      UseGadgetList(ToolbarPlus)
   CompilerEndIf
   Result=ContainerGadget(ID, x, y, w, h, flag)
   
   ProcedureReturn Result
EndProcedure
ProcedureDLL ToolBarSpace(width=5) ;Add toolbar space
   result=ToolbarContainer(#PB_Any, width, 0)
   CloseGadgetList()
   ProcedureReturn result
EndProcedure

ProcedureDLL ToolbarComboBox(ID, offsetX, offsetY, width, height, flags=0) ;Add toolbar ComboboxGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=ComboBoxGadget(ID, offsetX, offsetY, width, height, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarCheckBox(ID, offsetX, offsetY, width, height, text$, flags=0) ;Add toolbar CheckBoxGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=CheckBoxGadget(ID, offsetX, offsetY, width, height, text$, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarOption(ID, offsetX, offsetY, width, height, text$, close.b=#False) ;Add toolbar OptionGadget (with close flag)
   Static ToolbarOptionContainerID
   If ToolbarOptionContainerID=0
      ; ====================
      ; open option list
      ; ====================
      ToolbarOptionContainerID=ToolbarContainer(#PB_Any, offsetX, width)
   Else
      Shared ToolbarPlus
      Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)
      Protected separator.TBBUTTON
      ToolBarSeparator()
      ;set separator width
      SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @separator)
      separator\iBitmap=width+offsetX
      SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
      SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos, separator)
     
      ;set container width
      offsetX+GadgetWidth(ToolbarOptionContainerID)
      ResizeGadget(ToolbarOptionContainerID, #PB_Ignore, #PB_Ignore, offsetX+width, #PB_Ignore)
     
   EndIf
   If ToolbarOptionContainerID
      ; ====================
      ; creation new option
      ; ====================
      Result=OptionGadget(ID, offsetX, offsetY, width, height, text$)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      ; ====================
      ; close option list
      ; ====================
      If close
         CloseGadgetList()
         ToolbarOptionContainerID=0
      EndIf
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarButton(ID, offsetX, offsetY, width, height, text$, flags=0) ;Add toolbar ButtonGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=ButtonGadget(ID, offsetX, offsetY, width, height, text$, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarButtonImage(ID, offsetX, offsetY, width, height, imageID, flags=0) ;Add toolbar ButtonImage
   If ToolbarContainer(#PB_Any, offsetX, width)
      CompilerIf #PB_Compiler_Version<420
         Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID)
      CompilerElse
         Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID, flags)
      CompilerEndIf
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure

ProcedureDLL ToolbarString(ID, offsetX, offsetY, width, height, content$, flags=0) ;Add toolbar StringGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=StringGadget(ID, offsetX, offsetY, width, height, content$, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarIPAddress(ID, offsetX, offsetY, width, height) ;Add toolbar IPAddressGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=IPAddressGadget(ID, offsetX, offsetY, width, height)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarHyperlink(ID, offsetX, offsetY, width, height, text$, color, flags=0) ;Add toolbar HyperLinkGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=HyperLinkGadget(ID, offsetX, offsetY, width, height, text$, color, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure

ProcedureDLL ToolbarDate(ID, offsetX, offsetY, width, height, formatDate$="", date=0, flags=0) ;Add toolbar DateGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=DateGadget(ID, offsetX, offsetY, width, height, formatDate$, date, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarProgressBar(ID, offsetX, offsetY, width, height, min, max, flags=0) ;Add toolbar ProgressBarGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=ProgressBarGadget(ID, offsetX, offsetY, width, height, min, max, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarSpin(ID, offsetX, offsetY, width, height, min, max, flags=0) ;Add toolbar SpinGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=SpinGadget(ID, offsetX, offsetY, width, height, min, max, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarTrackBar(ID, offsetX, offsetY, width, height, min, max, flags=0) ;Add toolbar TrackBarGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=TrackBarGadget(ID, offsetX, offsetY, width, height, min, max, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarScrollbar(ID, offsetX, offsetY, width, height, min, max, pageLegnth, flags=0) ;Add toolbar ScrollBarGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=ScrollBarGadget(ID, offsetX, offsetY, width, height, min, max, pageLegnth, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure

ProcedureDLL ToolbarImage(ID, offsetX, offsetY, width, height, imageID, flags=0) ;Add toolbar ImageGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=ImageGadget(ID, offsetX, offsetY, width, height, imageID, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
ProcedureDLL ToolbarText(ID, offsetX, offsetY, width, height, text$, flags=0) ;Add toolbar TextGadget
   If ToolbarContainer(#PB_Any, offsetX, width)
      Result=TextGadget(ID, offsetX, offsetY, width, height, text$, flags)
      ValidateGadgetID(Result, ID, gadget)
      ToolbarCenterGadget(ID)
      CloseGadgetList()
      ProcedureReturn Result
   EndIf
EndProcedure
;}

; ====================
; EXAMPLE
; ====================
Enumeration
   #WIN=0
   #TOOLBAR
   #BUTTON
   #COMBO
   #STRINGS
   #CHECK
   #BAR
   #BAR2
   #TEXT
   
   #CONTAINER_BOTTOM
   #TOOLBAR_BOTTOM
   #SPIN
   #IPADRESS
EndEnumeration
If OpenWindow(#WIN, 100, 100, 700, 200, "Toolbar Plus For PB 4.X", #PB_Window_SystemMenu)
   ;{/// CREATE TOOLBAR TOP
   CreateToolBarPlus(#TOOLBAR, WindowID(#WIN))
   ToolbarText(#TEXT, 0, 0, 60, 14, "ToolbarPlus")
   ToolBarSpace(40)
   ToolBarStandardButton(10, #PB_ToolBarIcon_New, #PB_ToolBar_Toggle)
   ToolBarStandardButton(11, #PB_ToolBarIcon_Save)
   ToolBarSeparator()
   CompilerIf #PB_Compiler_Version<430
      ToolbarCombobox(#COMBO, 0, 0, 40, 500)
   CompilerElse
      ToolbarCombobox(#COMBO, 0, 0, 40, #PB_Ignore)
   CompilerEndIf
   ToolBarSeparator()
   ToolbarButton(#BUTTON, 0, 0, 40, ToolbarContainerHeight()-2, "OK", #PB_Button_Toggle)
   ToolBarSeparator()
   ToolbarString(#STRINGS, 0, 0, 50, 20, "String", #PB_String_UpperCase)
   ToolbarCheckBox(#CHECK, 5, 0, 70, 20, "CheckMe")
   ToolBarSeparator()
   ToolbarOption(#PB_Any, 0, 0, 30, 20, "1")
   ToolbarOption(#PB_Any, 0, 0, 30, 20, "2")
   ToolbarOption(#PB_Any, 0, 0, 30, 20, "3", #True)
   ToolBarSeparator()
   ToolbarProgressBar(#BAR, 0, 0, 20, 20, 0, 100, #PB_ProgressBar_Vertical)
   ToolbarProgressBar(#BAR2, 5, 0, 40, 20, 0, 100)
   ToolBarSeparator()
   ToolbarHyperlink(#PB_Any, 0, 0, 150, 14, "http://www.purebasic.com", $0000FF, #PB_HyperLink_Underline)
   
   AddGadgetItem(#COMBO, -1, "A")
   AddGadgetItem(#COMBO, -1, "B")
   
   SetToolBarButtonState(#TOOLBAR, 10, 1)
   SetGadgetState(#CHECK, 1)
   SetGadgetState(#BAR, 20)
   SetGadgetState(#BAR2, 60)
   
   ToolBarToolTip(#TOOLBAR, 10, "New document")
   GadgetToolTip(#BAR, "veritcal progressbar")
   
   SetGadgetColor(#TEXT, #PB_Gadget_BackColor, RGB(255, 0, 0))
   SetGadgetColor(#TEXT, #PB_Gadget_FrontColor, RGB(255, 255, 255))
   ;}
   ;{/// CREATE TOOLBAR BOTTOM (inside ContainerGadget)
   CreateImage(0, 32, 16)
   StartDrawing(ImageOutput(0))
      Box(0, 0, 32, 16, RGB(10, 152, 100))
      Box(8, 4, 16, 8, RGB(255, 0, 0))
   StopDrawing()
   
   CreatePopupMenu(100)
   MenuItem(10, "MenuID 10")
   MenuItem(20, "MenuID 20")
   
   CompilerIf #PB_Compiler_Version<430
      CreateGadgetList(WindowID(#WIN))
   CompilerElse
      UseGadgetList(WindowID(#WIN))
   CompilerEndIf
   ContainerGadget(#CONTAINER_BOTTOM, 0, ToolBarHeight(#TOOLBAR), WindowWidth(#WIN), 32, #PB_Container_Double)
   
   CreateToolBarPlus(#TOOLBAR_BOTTOM, GadgetID(#CONTAINER_BOTTOM))
   ToolBarSeparator()
   ToolbarIPAddress(#IPADRESS, 0, 0, 120, 20)
   ToolbarDate(#PB_Any, 5, 0, 100, 20)
   ToolBarSeparator()
   ToolbarSpin(#SPIN, 0, 0, 40, 20, 0, 100, #PB_Spin_ReadOnly)
   ToolbarTrackBar(#PB_Any, 5, 0, 60, 20, 0, 10, #PB_TrackBar_Ticks)
   ToolBarSeparator()
   ToolbarScrollbar(#PB_Any, 0, 0, 64, 20, 0, 100, 10)
   ToolbarButtonImage(#PB_Any, 5, 0, 64, ToolbarContainerHeight(), ImageID(0))
   ToolBarSeparator()
   ToolBarImageButton(20, ImageID(0))
   ToolBarStandardButton(15, #PB_ToolBarIcon_Find)
   SetToolBarArrow()
   SetToolBarMenu(100)
   ToolBarStandardButton(16, #PB_ToolBarIcon_Print)
   SetToolBarArrow(#True)
   SetToolBarMenu(100)
   ToolBarStandardButton(17, #PB_ToolBarIcon_Paste)
   SetToolBarMenu(100)
   ToolBarSeparator()
   ToolBarStandardButton(100, #PB_ToolBarIcon_Help)
   SetToolBarToggle(#True)
   ToolBarStandardButton(101, #PB_ToolBarIcon_Help)
   SetToolBarToggle(#True)
   ToolBarStandardButton(102, #PB_ToolBarIcon_Help)
   SetToolBarToggle(#True)
   
   SetGadgetColor(#SPIN, #PB_Gadget_BackColor, RGB(255, 225, 10))
   SetGadgetFont(#SPIN, LoadFont(1, "Arial", 12, #PB_Font_Bold))
   SetGadgetText(#SPIN, "1")
   ;}
EndIf

Procedure mycallback(Window, message, wParam, lParam)
   Protected Result=#PB_ProcessPureBasicEvents
   ;
   ;
   ; your code
   ;
   
   ; ===============================================
   ; Enable automatic popup menu
   ; ===============================================
   Result=ToolBarPlusCB(Window, message, wParam, lParam, Result)
   
   ; ===============================================
   ; custom popup menu (without using SetToolbarMenu)
   ; ===============================================
   If ToolbarPlusCB_Toolbar()=ToolBarID(#TOOLBAR)
      If ToolbarPlusCB_ButtonID()=11 And ToolbarPlusCB_PressedArrow()=#False
         Protected owner=ToolbarPlusCB_Toolbar()
         Protected x=ToolbarPlusCB_PopupX()
         Protected y=ToolbarPlusCB_PopupY()
         DisplayPopupMenu(100, owner, x, y)
         ProcedureReturn 1
      EndIf
   EndIf
   
   ;
   ;
   ; your code
   ;
   ProcedureReturn Result
EndProcedure
SetWindowCallback(@mycallback(), #WIN)

; ====================
; EVENT LOOP
; ====================
Repeat
   e=WaitWindowEvent()
   If e=#PB_Event_ActivateWindow
      ;update ipadress
      SetGadgetState(#IPADRESS, MakeIPAddress(127, 0, 0, Random(255)))
   EndIf
   
   If e=#PB_Event_Menu
      m=EventMenu()
      Debug "menuID="+Str(m)
   EndIf
   If e=#PB_Event_Gadget
      g=EventGadget()
      t=EventType()
      Debug "gadgetID="+Str(g)+" eventType="+Str(t)+" state="+Str(GetGadgetState(g))
     
      ;update spin
      SetGadgetText(#SPIN, Str(GetGadgetState(#SPIN)))
   EndIf
Until e=#PB_Event_CloseWindow

_________________
Imagewin8.1 x64 5.31 | IDE | PB plugin | Tools | Sprite | JSON | visual tool


Last edited by eddy on Sun Jan 11, 2009 9:39 pm, edited 10 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 8:49 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10589
Location: Beyond the pale...
Very very nice. Thanks for that. 8)

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 8:53 am 
Online
Addict
Addict
User avatar

Joined: Thu Aug 07, 2003 7:01 pm
Posts: 3152
Location: United Kingdom
Very nice. :)

_________________
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 9:27 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2808
Location: Portugal, Lisbon
Good Stuff !!!

_________________
Software: http://xipa.org
Elevator Maintenance: http://central-elevadores.pt
Good web hosting!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 9:57 am 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1148
Location: Amphibios 9
Num3 wrote:
Good Stuff !!!

+1

Thanks & Greetings ... Kiffi

_________________
Hygge


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 12:12 pm 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4577
Location: Not Sydney!!! (Bad water, no goats)
"ButtonImageGadget, Incorrect number of parameter"

Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID, flags)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 1:13 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2304
Location: Argentina
Fangbeast wrote:
"ButtonImageGadget, Incorrect number of parameter"

Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID, flags)


Same here i had to comment the flags to make it works.

Very nice code!!

Thanks :)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 1:19 pm 
Offline
Addict
Addict
User avatar

Joined: Mon May 26, 2003 3:07 pm
Posts: 1477
Location: Nantes
What's wrong with this flag ? :?
Is it a new parameter ?
I tested this userlib with PB4.20b6.

PB documentation wrote:
Result = ButtonImageGadget(#Gadget, x, y, Width, Height, ImageID [, Flags])

_________________
Imagewin8.1 x64 5.31 | IDE | PB plugin | Tools | Sprite | JSON | visual tool


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 1:22 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Apr 25, 2003 7:06 pm
Posts: 2304
Location: Argentina
Version 4.10 documentation

Quote:
Result = ButtonImageGadget(#Gadget, x, y, Width, Height, ImageID)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 1:38 pm 
Offline
Addict
Addict
User avatar

Joined: Mon May 26, 2003 3:07 pm
Posts: 1477
Location: Nantes
I see

I'll add a compilerSelect for PB4.10

_________________
Imagewin8.1 x64 5.31 | IDE | PB plugin | Tools | Sprite | JSON | visual tool


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 1:46 pm 
Offline
Addict
Addict
User avatar

Joined: Mon May 26, 2003 3:07 pm
Posts: 1477
Location: Nantes
[Updated]
- version supported : PB 4.10 & PB4.20

_________________
Imagewin8.1 x64 5.31 | IDE | PB plugin | Tools | Sprite | JSON | visual tool


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 2:42 pm 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4577
Location: Not Sydney!!! (Bad water, no goats)
Thanks Eddy. Seriously good stuff.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 2:57 pm 
Offline
Addict
Addict

Joined: Wed Aug 24, 2005 8:39 am
Posts: 2736
Location: Southwest OH - USA
Wow factor :shock:

Very nice. Many thanks for sharing with us :D

cheers


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 4:28 pm 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4577
Location: Not Sydney!!! (Bad water, no goats)
Eddy, I still get the same error. Change this:

CompilerCase "410"
Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID)
CompilerCase "4.10"

To this:

CompilerCase 410
Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID)
CompilerCase 4.10


For CompilerCase, an integer is required, not a string. Now it works.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 19, 2008 6:42 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Jan 11, 2004 11:34 am
Posts: 274
Location: France
Super! :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye