LayoutManager, automatische Anordnung von Gadgets, Layout

Hier könnt Ihr gute, von Euch geschriebene Codes posten. Sie müssen auf jeden Fall funktionieren und sollten möglichst effizient, elegant und beispielhaft oder einfach nur cool sein.
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

Could you help me with this code please:
(a variant of one of yours)

Code: Alles auswählen



;============================================================
;    guilayout_demo.pb
;    Version 0.1 [2011/07/26]
;    Copyright (C) 2011 Ronny Krueger
;
;    This file is part of AWPB-Tools.
;
;    AWPB-Tools is free software: you can redistribute it and/or modify
;    it under the terms of the GNU Lesser General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    AWPB-Tools is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU Lesser General Public License for more details.
;
;    You should have received a copy of the GNU Lesser General Public License
;    along with AWPB-Tools.  If not, see <http://www.gnu.org/licenses/>.

EnableExplicit

XIncludeFile "awguilayout.pbi"
Enumeration
  #option_1
  #option_2
  #option_3
EndEnumeration


Define win, gdg0, gdg1, gdg2, gdg3, gdg4, gdg5
Define *sizer.AWPB_GUI_Sizer, s1.i, s2.i, s3.i

win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUI-Layout-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
  *sizer = AWPB_CreateSizerObj(win)
  If *sizer
    gdg0 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 0 20% height, 100% width")
    OptionGadget(#option_1, 30, 20, 60, 20, "Option 1")
    OptionGadget(#option_2, 30, 45, 60, 20, "Option 2")
    OptionGadget(#option_3, 30, 70, 60, 20, "Option 3")
    SetGadgetState(#option_2, 1) 
    
    gdg1 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 1 - with borders a 10 px, 20% height, 100% width")
    gdg2 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 2 - 60% height, 50% width")
    gdg3 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 3 - 30% height, 25% width")
    gdg4 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 4 - with borders a 5 px, 30% height, 25% width")
    gdg5 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 5 - 60% height, 25% width")
    
    s1   = *sizer\AddSizer(#Null, #AWPB_GUI_SIZER_VBOX, #AWPB_GUI_SIZER_REL, 100)
    *sizer\AddGadget(s1, gdg0, #AWPB_GUI_SIZER_REL, 20)
    *sizer\AddGadget(s1, gdg1, #AWPB_GUI_SIZER_REL, 20, 10, 10, 10, 10)
    s2   = *sizer\AddSizer(s1, #AWPB_GUI_SIZER_HBOX, #AWPB_GUI_SIZER_REL, 60)
    *sizer\AddGadget(s2, gdg2, #AWPB_GUI_SIZER_REL, 50)
    s3   = *sizer\AddSizer(s2, #AWPB_GUI_SIZER_VBOX, #AWPB_GUI_SIZER_REL, 25)
    *sizer\AddGadget(s3, gdg3, #AWPB_GUI_SIZER_REL, 50)
    *sizer\AddGadget(s3, gdg4, #AWPB_GUI_SIZER_REL, 50, 5, 5, 5, 5)
    *sizer\AddGadget(s2, gdg5, #AWPB_GUI_SIZER_REL, 25)
    
    *sizer\Finish()
    
    
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_SizeWindow
          *sizer\Resize()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case win
              CloseWindow(win)
              win = 0
              Break
          EndSelect
      EndSelect
    ForEver
    
    *sizer\Destroy()
  Else
    MessageRequester("Fehler", "Konnte Sizer nicht erstellen") 
  EndIf
Else
  MessageRequester("Fehler", "Konnte Fenster nicht erstellen") 
EndIf

End
I want to "layout" OptionGadgets inside a Frame3DGadget ?
I tried container but with no result. :cry:

Thank you.

Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

hello...
Mesa hat geschrieben: gdg0 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 0 20% height, 100% width")
OptionGadget(#option_1, 30, 20, 60, 20, "Option 1")
OptionGadget(#option_2, 30, 45, 60, 20, "Option 2")
OptionGadget(#option_3, 30, 70, 60, 20, "Option 3")
First, you found something like a bug in my code (I just forget to think of FrameGadgets). I'll have to change my code to support them. Should be done till monday.

Second, every OptionGadget (as well as any other gadget) has to be added by using *sizer\AddGadget().

I'll write en example when part one is finished.

regards
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Benutzeravatar
Danilo
-= Anfänger =-
Beiträge: 2284
Registriert: 29.08.2004 03:07

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Danilo »

cptdark hat geschrieben:hello...
Mesa hat geschrieben: gdg0 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 0 20% height, 100% width")
OptionGadget(#option_1, 30, 20, 60, 20, "Option 1")
OptionGadget(#option_2, 30, 45, 60, 20, "Option 2")
OptionGadget(#option_3, 30, 70, 60, 20, "Option 3")
First, you found something like a bug in my code (I just forget to think of FrameGadgets). I'll have to change my code to support them.
Frame3DGadget works fine here. I tested with:
You can't add something inside Frame3DGadget. If you do it like this:

Code: Alles auswählen

        gdg0 = Frame3DGadget(#PB_Any, 0, 0, 100, 100, "Frame 0 20% height, 100% width")
        Define old = UseGadgetList(GadgetID(gdg0))
            OptionGadget(#option_1, 30, 20, 60, 20, "Option 1")
            OptionGadget(#option_2, 30, 45, 60, 20, "Option 2")
            OptionGadget(#option_3, 30, 70, 60, 20, "Option 3")
            SetGadgetState(#option_2, 1)
        UseGadgetList(old)
the OptionGadget are inside the Frame3DGadget, but events don't work anymore.

The following code works. It is a ContainerGadget on the main window.
Inside are Frame3DGadget and the 3 OptionGadget. The Frame3D is resized by using a new *sizer2:

Code: Alles auswählen

Define *sizer2.AWPB_GUILO_Sizer = AWPB_CreateSizerObj(gdg0,#AWPB_GUILO_SIZER_CONTAINER)
I don't know how Mesa wants the OptionGadget to be resized inside the Container. (maybe use ScrollAreaGadget?)

Test code:

Code: Alles auswählen

;============================================================
;    guilayout_demo.pb
;    Version 0.1 [2011/07/26]
;    Copyright (C) 2011 Ronny Krueger
;
;    This file is part of AWPB-Tools.
;
;    AWPB-Tools is free software: you can redistribute it and/or modify
;    it under the terms of the GNU Lesser General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    AWPB-Tools is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU Lesser General Public License for more details.
;
;    You should have received a copy of the GNU Lesser General Public License
;    along with AWPB-Tools.  If not, see <http://www.gnu.org/licenses/>.

EnableExplicit

;XIncludeFile "awguilayout.pbi"
XIncludeFile "include\awpbtools\awguilayout.pbi"

Enumeration
  #option_1
  #option_2
  #option_3
EndEnumeration


Define win, gdg0, gdg1, gdg2, gdg3, gdg4, gdg5, gdg6
;Define *sizer.AWPB_GUI_Sizer, s1.i, s2.i, s3.i

Define *sizer.AWPB_GUILO_Sizer, s1.i, s2.i, s3.i

Procedure.i newFrame3DGadget(gadget,x,y,width,height,title$,flag=-1)
    Protected result
    If flag=-1
        result = Frame3DGadget(gadget,x,y,width,height,title$)
        If gadget=-1:gadget=result:EndIf
        UseGadgetList(GadgetID(gadget))
    Else
        If flag=#PB_Frame3D_Single  : flag = #PB_Container_Single : EndIf
        If flag=#PB_Frame3D_Double  : flag = #PB_Container_Double : EndIf
        If flag=#PB_Frame3D_Flat    : flag = #PB_Container_Flat   : EndIf
        result = ContainerGadget(gadget,x,y,width,height,flag)
        ;CloseGadgetList()
    EndIf
EndProcedure

Procedure MyFrame3DGadget(gadget, x, y, width, height, text$, frontcolor=0, backcolor=0, shadow=$FFFFFF)
    Protected background,container,img
    background = GetSysColor_(#COLOR_BTNFACE);GetWindowColor(window)
    container  = ContainerGadget(gadget,x,y,width,height)
    img = CreateImage(#PB_Any,width,height)
    If img And StartDrawing(ImageOutput(img))
        Box(0,0,width,height,background)
        DrawingMode(#PB_2DDrawing_Outlined)
        RoundBox(6,6,width-12,height-12,3,3,shadow)
        RoundBox(5,5,width-10,height-10,3,3,backcolor)
        DrawingFont(GetGadgetFont(#PB_Default))
        DrawText(10,0," "+text$+" ",frontcolor, background)
        StopDrawing()
        DisableGadget(ImageGadget(#PB_Any,0,0,width,height,ImageID(img)),1)
    EndIf
    ProcedureReturn container
EndProcedure

win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUI-Layout-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
  *sizer = AWPB_CreateSizerObj(win)
  If *sizer
    gdg0 = ContainerGadget(#PB_Any, 0, 0, 100, 10);,#PB_Container_Raised)
        gdg6 = Frame3DGadget(#PB_Any, 0, 0, 100, 100, "Frame 0 20% height, 100% width");:DisableGadget(gdg6,1)
        ;Define old = UseGadgetList(GadgetID(gdg0))
            OptionGadget(#option_1, 30, 20, 60, 20, "Option 1")
            OptionGadget(#option_2, 30, 45, 60, 20, "Option 2")
            OptionGadget(#option_3, 30, 70, 60, 20, "Option 3")
            SetGadgetState(#option_2, 1)
        ;UseGadgetList(old)
    CloseGadgetList()

    gdg1 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 1 - with borders a 10 px, 20% height, 100% width")
    gdg2 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 2 - 60% height, 50% width")
    gdg3 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 3 - 30% height, 25% width")
    gdg4 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 4 - with borders a 5 px, 30% height, 25% width")
    gdg5 = Frame3DGadget(#PB_Any, 0, 0, 100, 10, "Frame 5 - 60% height, 25% width")
    
    s1   = *sizer\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX, #AWPB_GUILO_SIZER_REL, 100)
    *sizer\AddGadget(s1, gdg0, #AWPB_GUILO_SIZER_REL, 20, 10, 10, 10, 0)
    *sizer\AddGadget(s1, gdg1, #AWPB_GUILO_SIZER_REL, 20, 10, 10, 10, 10)
    s2   = *sizer\AddSizer(s1, #AWPB_GUILO_SIZER_HBOX, #AWPB_GUILO_SIZER_REL, 60)
    *sizer\AddGadget(s2, gdg2, #AWPB_GUILO_SIZER_REL, 50)
    s3   = *sizer\AddSizer(s2, #AWPB_GUILO_SIZER_VBOX, #AWPB_GUILO_SIZER_REL, 25)
    *sizer\AddGadget(s3, gdg3, #AWPB_GUILO_SIZER_REL, 50)
    *sizer\AddGadget(s3, gdg4, #AWPB_GUILO_SIZER_REL, 50, 5, 5, 5, 5)
    *sizer\AddGadget(s2, gdg5, #AWPB_GUILO_SIZER_REL, 25)
    
    *sizer\Finish()

    Define *sizer2.AWPB_GUILO_Sizer = AWPB_CreateSizerObj(gdg0,#AWPB_GUILO_SIZER_CONTAINER)
    Define s4.i = *sizer2\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX, #AWPB_GUILO_SIZER_REL, 100)
    *sizer2\AddGadget(s4, gdg6, #AWPB_GUILO_SIZER_REL, 100)
    
    *sizer2\Finish()
    
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_SizeWindow
          *sizer\Resize()
          *sizer2\Resize()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case win
              CloseWindow(win)
              win = 0
              Break
          EndSelect
        Case #PB_Event_Gadget
            If EventGadget()=#option_1
                Debug "option 1"
            ElseIf EventGadget()=#option_2
                Debug "option 2"
            ElseIf EventGadget()=#option_3
                Debug "option 3"
            EndIf
      EndSelect
    ForEver
    
    *sizer\Destroy()
  Else
    MessageRequester("Fehler", "Konnte Sizer nicht erstellen") 
  EndIf
Else
  MessageRequester("Fehler", "Konnte Fenster nicht erstellen") 
EndIf

End
cya,
...Danilo
"Ein Genie besteht zu 10% aus Inspiration und zu 90% aus Transpiration" - Max Planck
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

As promised ... a new version.
Wie versprochen ... die neue Version.

Integrated into (Integriert in) AWPB-Tools: http://forums.purebasic.com/german/view ... =8&t=23313
Direct-Download: http://angelzware.bplaced.net/media/gim ... -0_1_4.zip

You should now be able to use OptionGadgets in a Frame3DGadget in a Sizer ;-)
Jetzt sollte es funktionieren, OptionGadgets in einem Frame3DGadget in einem Sizer zu benutzen ;-)

A new function allowes to add a Frame3DGadget to the sizer and define a new sizer in it. By this way you can add additional Gadgets into the frame.
Eine neue Funktion exitstier nun, um ein Frame3DGadget zu einem sizer hinzuzufügen, und ihm selbst einen Sizer zu verpassen. Auf die Art können in dem Frame weitere Gadgets angelegt werden.

By the way: The size while creating a Gadget is not relevant. It could be sized 1x1 pixels.
Übrigens: Die Größe beim erstellen eines Gadgets ist irrelevant. Sie kann bei 1x1 Pixel liegen.

Example (Beispiel):

Code: Alles auswählen

CompilerSelect #PB_Compiler_OS 
  CompilerCase #PB_OS_Windows
    IncludePath "..\include\awpbtools"
  CompilerCase #PB_OS_Linux
    IncludePath "../include/awpbtools"
CompilerEndSelect

XIncludeFile "awguilayout.pbi"

Enumeration
  #option_1
  #option_2
  #option_3
EndEnumeration

Define win, gdg0, gdg1, gdg2, gdg3, gdg4, gdg5
Define *sizer.AWPB_GUILO_Sizer, s1.i, s2.i, s3.i
Define fs0.i, fs1.i, fs2.i, fs3.i, fs4.i, fs5.i

; you can change the font if you want
; If LoadFont(1, "Arial", 15)
;   SetGadgetFont(#PB_Default, FontID(1))
; EndIf
    
win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUI-Layout-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
  *sizer = AWPB_CreateSizerObj(win)
  If *sizer
    gdg0 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 0 20% height, 100% width")
    OptionGadget(#option_1, 0, 0, 1, 1, "Option 1")
    OptionGadget(#option_2, 0, 0, 1, 1, "Option 2")
    OptionGadget(#option_3, 0, 0, 1, 1, "Option 3")
    SetGadgetState(#option_2, 1) 
        
    gdg1 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 1 - with borders a 10 px, 20% height, 100% width", #PB_Frame3D_Double)
    gdg2 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 2 - 60% height, 50% width")
    gdg3 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 3 - 30% height, 25% width", #PB_Frame3D_Double)
    gdg4 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 4 - with borders a 5 px, 30% height, 25% width")
    gdg5 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 5 - 60% height, 25% width")
    
    s1  = *sizer\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 100)
    fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_REL, 20)
   				*sizer\AddGadget(fs0, #option_1, 30)
   				*sizer\AddGadget(fs0, #option_2, 30)
   				*sizer\AddGadget(fs0, #option_3, 30)
    fs1 = *sizer\AddFramedSizer(s1, gdg1, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 20)
    s2  = *sizer\AddSizer(s1, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_REL, 60)
    fs2 = *sizer\AddFramedSizer(s2, gdg2, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    s3  = *sizer\AddSizer(s2, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 25)
    fs3 = *sizer\AddFramedSizer(s3, gdg3, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    fs4 = *sizer\AddFramedSizer(s3, gdg4, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    fs5 = *sizer\AddFramedSizer(s2, gdg5, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 25)
    
    *sizer\Finish()
      
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_SizeWindow
          *sizer\Resize()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case win
              CloseWindow(win)
              win = 0
              Break
          EndSelect
      EndSelect
    ForEver
    
    *sizer\Destroy()
  Else
    MessageRequester("Fehler", "Konnte Sizer nicht erstellen") 
  EndIf
Else
  MessageRequester("Fehler", "Konnte Fenster nicht erstellen") 
EndIf

End
Zuletzt geändert von cptdark am 08.05.2012 10:08, insgesamt 1-mal geändert.
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

Hello,

Thank you very much.

But i have a problem with the vertical position of the optiongadgets.
If i change this line:

Code: Alles auswählen

 fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_REL, 20)
by that line:

Code: Alles auswählen

 ;//***=========================CHANGE FOR VERTICAL DISPOSITION===================
    fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 20)
     ;//***===========================================================================
Optiongadgets are too spaced and never fit in the frame but if i change this code:

Code: Alles auswählen

;//***=========================CHANGE FOR VERTICAL DISPOSITION===================
    fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 20)
     ;//***===========================================================================
               *sizer\AddGadget(fs0, #option_1, 30)
               *sizer\AddGadget(fs0, #option_2, 30)
               *sizer\AddGadget(fs0, #option_3, 30)
by that code:

Code: Alles auswählen

;//***=========================CHANGE FOR VERTICAL DISPOSITION===================
    fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 20)
     ;//***===========================================================================
               *sizer\AddGadget(fs0, #option_1, 20)
               *sizer\AddGadget(fs0, #option_2, 20)
               *sizer\AddGadget(fs0, #option_3, 20)
it works very well.

But why 20 ?

résumé:

Code: Alles auswählen

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Windows
    IncludePath "..\include\awpbtools"
  CompilerCase #PB_OS_Linux
    IncludePath "../include/awpbtools"
CompilerEndSelect

XIncludeFile "awguilayout.pbi"

Enumeration
  #option_1
  #option_2
  #option_3
EndEnumeration

Define win, gdg0, gdg1, gdg2, gdg3, gdg4, gdg5
Define *sizer.AWPB_GUILO_Sizer, s1.i, s2.i, s3.i
Define fs0.i, fs1.i, fs2.i, fs3.i, fs4.i, fs5.i

; you can change the font if you want
; If LoadFont(1, "Arial", 15)
;   SetGadgetFont(#PB_Default, FontID(1))
; EndIf
   
win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUI-Layout-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
  *sizer = AWPB_CreateSizerObj(win)
  If *sizer
    gdg0 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 0 20% height, 100% width")
    OptionGadget(#option_1, 0, 0, 1, 1, "Option 1")
    OptionGadget(#option_2, 0, 0, 1, 1, "Option 2")
    OptionGadget(#option_3, 0, 0, 1, 1, "Option 3")
    SetGadgetState(#option_2, 1)
       
    gdg1 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 1 - with borders a 10 px, 20% height, 100% width", #PB_Frame3D_Double)
    gdg2 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 2 - 60% height, 50% width")
    gdg3 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 3 - 30% height, 25% width", #PB_Frame3D_Double)
    gdg4 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 4 - with borders a 5 px, 30% height, 25% width")
    gdg5 = Frame3DGadget(#PB_Any, 0, 0, 1, 1, "Frame 5 - 60% height, 25% width")
   
    s1  = *sizer\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 100)
    ;//***=========================CHANGE FOR VERTICAL DISPOSITION===================
    fs0 = *sizer\AddFramedSizer(s1, gdg0, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 20)
     ;//***===========================================================================
;                *sizer\AddGadget(fs0, #option_1, 30)
;                *sizer\AddGadget(fs0, #option_2, 30)
;                *sizer\AddGadget(fs0, #option_3, 30)
;                
               ; It works better but why ?
               *sizer\AddGadget(fs0, #option_1, 20)
               *sizer\AddGadget(fs0, #option_2, 20)
               *sizer\AddGadget(fs0, #option_3, 20)
    fs1 = *sizer\AddFramedSizer(s1, gdg1, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 20)
    s2  = *sizer\AddSizer(s1, #AWPB_GUILO_SIZER_HBOX | #AWPB_GUILO_SIZER_REL, 60)
    fs2 = *sizer\AddFramedSizer(s2, gdg2, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    s3  = *sizer\AddSizer(s2, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 25)
    fs3 = *sizer\AddFramedSizer(s3, gdg3, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    fs4 = *sizer\AddFramedSizer(s3, gdg4, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 50)
    fs5 = *sizer\AddFramedSizer(s2, gdg5, #AWPB_GUILO_SIZER_VBOX | #AWPB_GUILO_SIZER_REL, 25)
   
    *sizer\Finish()
     
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_SizeWindow
          *sizer\Resize()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case win
              CloseWindow(win)
              win = 0
              Break
          EndSelect
      EndSelect
    ForEver
   
    *sizer\Destroy()
  Else
    MessageRequester("Fehler", "Konnte Sizer nicht erstellen")
  EndIf
Else
  MessageRequester("Fehler", "Konnte Fenster nicht erstellen")
EndIf

End
Furthermore, Examples 1 and 2 doesn't work anymore.

ex1

Code: Alles auswählen


;============================================================
;    GUILOlayout_demo.pb
;    Version 0.1 [2011/07/26]
;    Copyright (C) 2011 Ronny Krueger
;
;    This file is part of AWPB-Tools.
;
;    AWPB-Tools is free software: you can redistribute it and/or modify
;    it under the terms of the GNU Lesser General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    AWPB-Tools is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU Lesser General Public License for more details.
;
;    You should have received a copy of the GNU Lesser General Public License
;    along with AWPB-Tools.  If not, see <http://www.gnu.org/licenses/>.

EnableExplicit

XIncludeFile "awGUIlayout.pbi"

Define win, gdg0, gdg1, gdg2, gdg3, gdg4, gdg5
Define *sizer.AWPB_GUILO_Sizer, s1.i, s2.i, s3.i

win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUILO-Layout-Demo", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
   *sizer = AWPB_CreateSizerObj(win)
   If *sizer
      gdg0 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "first Gadget - without borders, 20% height, 100% width", #PB_Button_MultiLine)
      gdg1 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "second Gadget - with borders a 10 px, 20% height, 100% width", #PB_Button_MultiLine)
      gdg2 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "third Gadget - without borders, 60% height, 50% width", #PB_Button_MultiLine)
      gdg3 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "fourth Gadget - without borders, 30% height, 25% width", #PB_Button_MultiLine)
      gdg4 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "fifth Gadget - with borders a 5 px, 30% height, 25% width", #PB_Button_MultiLine)
      gdg5 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "sixth Gadget - without borders, 60% height, 25% width", #PB_Button_MultiLine)
      
      s1   = *sizer\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX|#AWPB_GUILO_SIZER_REL, 100)
            *sizer\AddGadget(s1, gdg0, #AWPB_GUILO_SIZER_REL, 20)
            *sizer\AddGadget(s1, gdg1, #AWPB_GUILO_SIZER_REL, 20, 10, 10, 10, 10)
      s2   = *sizer\AddSizer(s1, #AWPB_GUILO_SIZER_HBOX|#AWPB_GUILO_SIZER_REL, 60)
            *sizer\AddGadget(s2, gdg2, #AWPB_GUILO_SIZER_REL, 50)
      s3   = *sizer\AddSizer(s2, #AWPB_GUILO_SIZER_VBOX|#AWPB_GUILO_SIZER_REL, 25)
            *sizer\AddGadget(s3, gdg3, #AWPB_GUILO_SIZER_REL, 50)
            *sizer\AddGadget(s3, gdg4, #AWPB_GUILO_SIZER_REL, 50, 5, 5, 5, 5)
            *sizer\AddGadget(s2, gdg5, #AWPB_GUILO_SIZER_REL, 25)
      
        *sizer\Finish()
            
            
      
      Repeat
         Select WaitWindowEvent()
            Case #PB_Event_SizeWindow
               *sizer\Resize()
            Case #PB_Event_CloseWindow
               Select EventWindow()
                  Case win
                     CloseWindow(win)
                     win = 0
                     Break
               EndSelect
         EndSelect
      ForEver
      
      *sizer\Destroy()
   Else
      MessageRequester("Fehler", "Konnte Sizer nicht erstellen") 
   EndIf
Else
   MessageRequester("Fehler", "Konnte Fenster nicht erstellen") 
EndIf

End
ex2:

Code: Alles auswählen

;    GUILOlayout_demo2.pb
;    Version 0.1 [2011/07/27]
;    Copyright (C) 2011 Ronny Krueger
;
;    This file is part of AWPB-Tools.
;
;    AWPB-Tools is free software: you can redistribute it and/or modify
;    it under the terms of the GNU Lesser General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.
;
;    AWPB-Tools is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU Lesser General Public License for more details.
;
;    You should have received a copy of the GNU Lesser General Public License
;    along with AWPB-Tools.  If not, see <http://www.gnu.org/licenses/>.

EnableExplicit

XIncludeFile "awGUIlayout.pbi"

Define win, con0, con1, spl0, gdg0, gdg1, gdg2, gdg3, gdg4
Define *sizerw.AWPB_GUILO_Sizer, *sizerl.AWPB_GUILO_Sizer, *sizerr.AWPB_GUILO_Sizer, s1.i, s2.i

win = OpenWindow(#PB_Any, 542, 122, 410, 410, "GUILO-Layout-Demo 2", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If IsWindow(win)
  con0 = ContainerGadget(#PB_Any, 0, 0, 100, 10, #PB_Container_Single)
     gdg0 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "first Gadget - 50% width of left side", #PB_Button_MultiLine)
      gdg1 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "second Gadget - 50% width of left side", #PB_Button_MultiLine)
  CloseGadgetList()
  con1 = ContainerGadget(#PB_Any, 0, 0, 100, 10, #PB_Container_Single)
     gdg2 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "third Gadget - 30% height of right side", #PB_Button_MultiLine)
      gdg3 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "fourth Gadget - 40% height of right side", #PB_Button_MultiLine)
      gdg4 = ButtonGadget(#PB_Any, 0, 0, 100, 10, "fifth Gadget - 30% height of right side", #PB_Button_MultiLine)
  CloseGadgetList()
  spl0 = SplitterGadget(#PB_Any, 0, 1, 100, 10, con0, con1, #PB_Splitter_Separator|#PB_Splitter_Vertical)
 
   *sizerw = AWPB_CreateSizerObj(win)
   If *sizerw
     *sizerl = AWPB_CreateSizerObj(con0)
     If *sizerl
       *sizerr = AWPB_CreateSizerObj(con1)
       If *sizerr
         *sizerw\AddGadget(#Null, spl0, #AWPB_GUILO_SIZER_REL, 100)
        
         s1 = *sizerl\AddSizer(#Null, #AWPB_GUILO_SIZER_HBOX|#AWPB_GUILO_SIZER_REL, 100)
              *sizerl\AddGadget(s1, gdg0, #AWPB_GUILO_SIZER_REL, 50)
              *sizerl\AddGadget(s1, gdg1, #AWPB_GUILO_SIZER_REL, 50)
              
         s2 = *sizerr\AddSizer(#Null, #AWPB_GUILO_SIZER_VBOX|#AWPB_GUILO_SIZER_REL, 100)
              *sizerr\AddGadget(s2, gdg2, #AWPB_GUILO_SIZER_REL, 30)
              *sizerr\AddGadget(s2, gdg3, #AWPB_GUILO_SIZER_REL, 40)
              *sizerr\AddGadget(s2, gdg4, #AWPB_GUILO_SIZER_REL, 30)
              
         *sizerw\Finish()
         *sizerl\Finish()
         *sizerr\Finish()
       
          Repeat
             Select WaitWindowEvent()
               Case #PB_Event_Gadget
                 Select EventGadget()
                   Case spl0
                       *sizerw\Resize()
                       *sizerl\Resize()
                       *sizerr\Resize()
                 EndSelect       
               Case #PB_Event_SizeWindow
                   *sizerw\Resize()
                   *sizerl\Resize()
                   *sizerr\Resize()
                Case #PB_Event_CloseWindow
                   Select EventWindow()
                      Case win
                         CloseWindow(win)
                         win = 0
                         Break
                   EndSelect
             EndSelect
          ForEver
 
         *sizerr\Destroy()
       Else
          MessageRequester("Fehler", "Konnte SizerR nicht erstellen") 
       EndIf
       *sizerl\Destroy()
     Else
        MessageRequester("Fehler", "Konnte SizerL nicht erstellen") 
     EndIf
    *sizerw\Destroy()
   Else
      MessageRequester("Fehler", "Konnte SizerW nicht erstellen") 
   EndIf
Else
   MessageRequester("Fehler", "Konnte Fenster nicht erstellen") 
EndIf

End
Thank you.

Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

Mesa hat geschrieben:But i have a problem with the vertical position of the optiongadgets.
I'll investigate.
Ich suche mal, wo der Fehler liegt.
Mesa hat geschrieben:Furthermore, Examples 1 and 2 doesn't work anymore.
You made a mistake with using the AddGadget Function. It has changed a little bit.
Du hast einen Fehler bei der AddGadget-Funktion gemacht, die Parameterliste ist etwas anders:

Code: Alles auswählen

AddGadget.b (ParentSizer.i, GadgetID.i, Size.i, BorderLeft.i = 0, BorderTop.i = 0, BorderRight.i = 0, BorderBottom.i = 0, *OnBeforeResizeCallback.AWPB_GUILO_OnBeforeResize_Proto = #Null, *OnAfterResizeCallback.AWPB_GUILO_OnAfterResize_Proto = #Null)
write it without #AWPB_GUILO_SIZER_REL, the it works
das #AWPB_GUILO_SIZER_REL darf nicht mehr angegeben werden. Dann funktioniert es wieder.

btw: what compiler (version, architecture) and wich system are you using? (win, lin) ?
übrigens: Welchen Compiler (Version/Architektur) und welches System (Windows/Linux) nutzt du?
Zuletzt geändert von cptdark am 08.05.2012 10:05, insgesamt 1-mal geändert.
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Nino
Beiträge: 1300
Registriert: 13.05.2010 09:26
Wohnort: Berlin

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Nino »

Wie war nochmal die Sprache dieses Forums? :shock:
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

Nino hat geschrieben:Wie war nochmal die Sprache dieses Forums? :shock:
Ich glaube deutsch :o

btw: ich hab meine Antworten wenigstens angepasst :mrgreen:
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Mesa
Beiträge: 16
Registriert: 03.05.2012 18:23

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von Mesa »

Hello,

@nino : Sorry, i don't speak german and i use google.translate to understand the threads of this forum, but we can create a thread in the english or french forum if it's needed. no problem.

@cptdark : I'm using Windows xp 32b (sometimes windows 7 64b) with purebasic 4.60b1.
The examples works fine now.
---------------------------------------------------------------------------------
Test with google.translate:
@nino :Sorry, ich spreche kein Deutsch und ich verwenden google.translate die Fäden dieses Forums zu verstehen, aber wir können einen Thread im Forum Englisch oder Französisch zu erstellen, wenn sie gebraucht wird. kein Problem.

@cptdark :Ich verwende Windows XP 32b (manchmal auch Windows 7 64b) mit PureBasic 4.60b1.
Die Beispiele, funktioniert jetzt.

(translation not too disgusting ? /:-> :freak: )
Mesa.
cptdark
Beiträge: 56
Registriert: 28.02.2010 14:13
Kontaktdaten:

Re: LayoutManager, automatische Anordnung von Gadgets, Layou

Beitrag von cptdark »

Mesa hat geschrieben:(translation not too disgusting ? /:-> :freak: )
Looks quite good.
Liest sich recht gut.

back to topic: Fixed (I hope) ... a change from + to - can make a big difference ;-)
zurück zum Thema: behoben (hoffe ich) ... eine Änderung von + in - kann einen großen Unterschied machen ;-)

Btw: Maybe its better not to mix #PB_Any with predefined Gadget Numbers (#option_X in your case) since you cant predict what #PB_Any will be using.
Übrigens: Eventuell ist es besser, #PB_Any und vorgegebene Gadgetnummern (#option_X in diesem Fall), da man nicht vorhersagen kann, was bei #PB_Any für ein Wert genutzt wird.

Big thanks for testing! - Vielen Dank fürs testen!
Zuletzt geändert von cptdark am 27.11.2012 22:44, insgesamt 1-mal geändert.
Manjaro x64 * Windows 10 x64 * PureBasic 5.50
planet-RK
Antworten