It is currently Thu Jan 28, 2021 2:33 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: accommodation toolbar on the object
PostPosted: Fri Oct 24, 2014 4:54 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 843
Stir the toolbar on the window
the other on the gadget in Windows Os
why it is not implemented in Linux?
Code:
 flags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered
   OpenWindow(1, 0, 0, 600, 400, "Main Form", flags )
   MainToolBar1 = CreateToolBar(1, WindowID(1))
    If MainToolBar1
        ToolBarStandardButton(0, #PB_ToolBarIcon_New)
        ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
        ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
   
      EndIf
   
   ContainerGadget(1,10,50,550,160,#PB_Container_Flat)
   MainToolBar2 = CreateToolBar(2, GadgetID(1))
    If MainToolBar2
        ToolBarStandardButton(0, #PB_ToolBarIcon_New)
        ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
        ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
   
      EndIf
 
   CloseGadgetList()
     
  Repeat :Event=WaitWindowEvent() :Until Event=#PB_Event_CloseWindow

so that it can be done
Code:
EnableExplicit

  ;XIncludeFile "/media/as/BC56CB3A56CAF3E4/Project/PureBasicDesigner/All.pbi" ;"WindowAllFunc/WaitWindowClose.pbi"
  Structure PropType
    Value.i
  EndStructure
   
  Structure PropMap
    Map PropName.PropType()
  EndStructure
   
  Global NewMap Props.PropMap()
 
  Procedure IDWindow(WindowID) 
    If MapSize(Props()) ;And Props(Str(WindowID))
      ProcedureReturn (Props(Str(WindowID))\PropName("PB_WindowID")\Value) -1
    EndIf
    ProcedureReturn -1
  EndProcedure   
 
  Procedure IDGadget(GadgetID) 
    If MapSize(Props()) ;And Props(Str(GadgetID))
      ProcedureReturn (Props(Str(GadgetID))\PropName("PB_GadgetID")\Value) -1
    EndIf
    ProcedureReturn -1
  EndProcedure
 
  Procedure IsWindowID(WindowID)
    If IsWindow(IDWindow(WindowID))
      ProcedureReturn #True
    EndIf
  EndProcedure 
 
  Procedure IsGadgetID(GadgetID)
    If IsGadget(IDGadget(GadgetID))
      ProcedureReturn #True
    EndIf 
  EndProcedure 
 
  Procedure SetWindow(Window) 
    If IsWindow(Window)
      Props(Str(WindowID(Window)))\PropName("PB_WindowID")\Value = Window +1
    EndIf 
  EndProcedure   
 
  Procedure SetGadget(Gadget) 
    If IsGadget(Gadget)
      Props(Str(GadgetID(Gadget)))\PropName("PB_GadgetID")\Value = Gadget +1
    EndIf 
  EndProcedure
 
 
 
  ProcedureDLL SetParent(ChildID,ParentID) ;Set Parent
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
      If ParentID = #False
        SetParent_(ChildID,GetDesktopWindow_())
      ElseIf IsHandle(ParentID) 
        SetParent_(ChildID, ParentID)
        If GetWindowLongPtr_(ParentID, #GWL_STYLE) & #WS_EX_COMPOSITED = #False
          SetWindowLongPtr_(ParentID,#GWL_STYLE, GetWindowLongPtr_(ParentID, #GWL_STYLE)|#WS_EX_COMPOSITED)
        EndIf
        If GetWindowLong_(ChildID, #GWL_STYLE) & #WS_CHILD = #False
          SetWindowLongPtr_(ChildID,#GWL_STYLE, GetWindowLongPtr_(ChildID, #GWL_STYLE)|#WS_CHILD|#WS_POPUP)
        EndIf
      EndIf
    CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
        Protected *Window.GTKWindow
        Protected *Widget.GtkWidget
        Protected *Fixed.GtkFixed
       
        Protected Gadget
      If Not IsWindowID(ChildID)
        If IsGadgetID(ChildID)
         *Widget.GtkWidget = ChildID :ChildID = *Widget\object
           Gadget = IDGadget(ChildID)                 
         *Widget.GtkWidget = ChildID :ChildID = *Widget\parent
         If IsGadget(Gadget) And (GadgetType(Gadget) = #PB_GadgetType_Container Or GadgetType(Gadget) = #PB_GadgetType_Panel)
           ChildID = gtk_widget_get_parent_(ChildID) ;если ContainerGadget или PanelGadget
         EndIf 
       EndIf 
       
       
       If IsWindowID(ParentID)
          *Fixed.GtkFixed = ParentID
            ParentID = *Fixed\children

       ElseIf IsGadgetID(ParentID)
         *Widget.GtkWidget = ParentID
         ParentID = *Widget\object
         Gadget = IDGadget(ParentID)                 
       
         If IsGadget(Gadget) And Not (GadgetType(Gadget) = #PB_GadgetType_Container Or GadgetType(Gadget) = #PB_GadgetType_Panel)
          *Widget.GtkWidget = ParentID
         ParentID = *Widget\parent
         
        EndIf 
         
       EndIf 
;       gtk_widget_set_parent_window_(ChildID,ParentID)
;         gtk_widget_set_parent_(ChildID,ParentID)
        gtk_widget_reparent_(ChildID,ParentID)
      EndIf 
    CompilerEndIf
  EndProcedure
 
 
  DisableExplicit
 
  CompilerIf #PB_Compiler_IsMainFile
  flags = #PB_Window_Invisible | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered
  hWnd=OpenWindow(1, 0, 0, 600, 400, "Main Form", flags ) :SetWindow(1)
     
    ;PanelGadget(1,10,50,550,160) :AddGadgetItem(1,-1,"yyy"):AddGadgetItem(1,-1,"ff"):CloseGadgetList() :SetGadget(1)
    ContainerGadget(1,10,50,550,160,#PB_Container_Flat) :CloseGadgetList() :SetGadget(1)
   
    MainToolBar = CreateToolBar(1, UseGadgetList(0));, WindowID(1))
    If MainToolBar
        ToolBarStandardButton(0, #PB_ToolBarIcon_New)
        ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
        ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
   
      EndIf
     
    ButtonGadget(111,60,220,150,40,"move") :SetGadget(111)
    ButtonGadget(112,210,220,150,40,"back1") :SetGadget(112)
    ButtonGadget(113,360,220,150,40,"back2") :SetGadget(113)
 
 
  HideWindow(1,0)
 
  Repeat
    Event=WaitWindowEvent()
    If Event=#PB_Event_Gadget
      If EventGadget()=111
      SetParent(MainToolBar, GadgetID(1))
   ElseIf EventGadget()=112
     SetParent(MainToolBar, GadgetID(111))
   ElseIf EventGadget()=113
     SetParent(MainToolBar, WindowID(1))
    EndIf
    EndIf 
  Until Event=#PB_Event_CloseWindow
CompilerEndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: accommodation toolbar on the object
PostPosted: Fri Oct 31, 2014 10:03 am 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1791
Location: Germany
In Linux only a simple modification is necessary to display the 2nd toolbar in the ContainerGadget:
Code:
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  MainToolBar2 = CreateToolBar(2, WindowID(1))
  gtk_widget_reparent_(ToolBarID(2), GadgetID(1))
CompilerElse
  MainToolBar2 = CreateToolBar(2, GadgetID(1))
CompilerEndIf

This is your complete example modified to run in Windows and Linux:
Code:
flags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered
OpenWindow(1, 0, 0, 600, 400, "Main Form", flags)
MainToolBar1 = CreateToolBar(1, WindowID(1))

If MainToolBar1
  ToolBarStandardButton(0, #PB_ToolBarIcon_New)
  ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
  ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
EndIf

ContainerGadget(1,10,50,550,160,#PB_Container_Flat)

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  MainToolBar2 = CreateToolBar(2, WindowID(1))
  gtk_widget_reparent_(ToolBarID(2), GadgetID(1))
CompilerElse
  MainToolBar2 = CreateToolBar(2, GadgetID(1))
CompilerEndIf

If MainToolBar2
  ToolBarStandardButton(3, #PB_ToolBarIcon_New)
  ToolBarStandardButton(4, #PB_ToolBarIcon_Open)
  ToolBarStandardButton(5, #PB_ToolBarIcon_Save)
EndIf

CloseGadgetList()

Repeat
  Event=WaitWindowEvent()
 
  If Event = #PB_Event_Menu
    Debug "Toolbar button " + Str(EventMenu()) + " was pressed"
  EndIf
Until Event=#PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 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