SetXY Modul zur Unterstützung beim Erstellen einer Gui

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.
Benutzeravatar
hjbremer
Beiträge: 822
Registriert: 27.02.2006 22:30
Computerausstattung: von gestern
Wohnort: Neumünster

SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von hjbremer »

Die Prozedur SetXY hilft beim Plazieren von Gadgets mit Hilfe von Flags.
Diese ist für PBler gedacht, welche den FormDesigner nicht nutzen wollen
oder keine Lust haben mit der DialogLib von PB zu arbeiten, wie z.B. ich.

Anweisungen wie x = 10: y = 20 und weiter y + 30 etc werden fast überflüssig.

Und ja ich weiss, die DialogLib kann das sehr viel besser !!! aber viel Lernaufwand.

SetWidth() + SetHeight() haben noch Optimierungsbedarf. z.B. Panel im Panel
aber das sind für mich seltene Fälle die man umgehen kann.

Modul abspeichern als z.B. SetXYf.pb

Code: Alles auswählen


DeclareModule SetXY
   ;HJBremer PB 5.60 x64 April 2018 V.2.10 - alle Betriebssysteme   
      
   Enumeration 1   ;für SetXY() muß bei 1 beginnen !
      #Up      
      #Down
      #Left
      #Right
      #Top
      #TopLeft
      #TopRight
      #TopCenter
      #Bottom 
      #BottomLeft
      #BottomRight
      #BottomCenter
      #BottomCenterLeft
      #BottomCenterRight 
      #GadgetOutside       ;nur für flag2, siehe Procedure SetXY()
   EndEnumeration  
   
   Declare.i SetXY(gadgetnr, parent, flag, abstand=10, flag2=0, abstand2=10) 
      
   Declare.i SetWidth(gadget, bisgadget, flag, abstand=10)
   Declare.i SetHeight(gadget, bisgadget, flag, abstand=10)
   Declare.i SetWindowSize(window, gadget, flag, abstand=10)

EndDeclareModule

Module SetXY
   
   EnableExplicit

   ;auf Wunsch eines Unix-Nutzers
   CompilerIf Not Defined(rect, #PB_Structure)
      Structure rect
         top.i
         left.i
         right.i
         bottom.i
      EndStructure
   CompilerEndIf
            
   Procedure.i SetWindowSize(window, gadget, flag, abstand=10)
      ;Fenster vergrößern/verkleinern wenn nötig, nur nach unten oder rechts, kann größer Screen werden
      ;Hinweis: Fenster kann ein Window oder Container/Panel/FrameGadget sein.
      ;Hinweis: Fenster verändern, wenn Gadget nach demselben ausgerichtet wurde, ergibt Mist. siehe 1.Demo

      Protected windowx, windowbr
      Protected windowy, windowhh
      Protected ybottom, xright, diff, newvalue
      
      If IsWindow(window)
         windowx = WindowX(window): windowbr = WindowWidth(window)
         windowy = WindowY(window): windowhh = WindowHeight(window) 
      Else
         windowx = GadgetX(window): windowbr = GadgetWidth(window)
         windowy = GadgetY(window): windowhh = GadgetHeight(window) 
      EndIf
                        
      Select flag    
         Case #Right
            xright = GadgetX(gadget) + GadgetWidth(gadget) + abstand
            diff = xright - windowbr
            newvalue = windowbr + diff
            ResizeWindow(window, windowx - diff/2, #PB_Ignore, newvalue, #PB_Ignore)
            
         Case #Bottom 
            ybottom = GadgetY(gadget) + GadgetHeight(gadget) + abstand 
            diff = ybottom - windowhh
            newvalue = windowhh + diff
            ResizeWindow(window, #PB_Ignore, windowy - diff/2, #PB_Ignore, newvalue)
      EndSelect
      
      ProcedureReturn newvalue      
   EndProcedure
      
   Procedure.i SetHeight(gadget, bisgadget, flag, abstand=10)
      Protected hh
      
      If IsGadget(bisgadget)
         If flag = #Top
            hh = GadgetY(bisgadget) - GadgetY(gadget)         
         ElseIf flag = #Bottom
            hh = GadgetY(bisgadget) - GadgetY(gadget) + GadgetHeight(bisgadget)         
         EndIf            
         ResizeGadget(gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, hh - abstand)
         
      ElseIf IsWindow(bisgadget)
         If flag = #Bottom
            hh = WindowHeight(bisgadget) - GadgetY(gadget)
         EndIf         
         ResizeGadget(gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, hh - abstand)
      EndIf
   
      ProcedureReturn hh
   EndProcedure
   
   Procedure.i SetWidth(gadget, bisgadget, flag, abstand=10)
      Protected br
      
      If IsGadget(bisgadget)
         If flag = #Left
            br = GadgetX(bisgadget) - GadgetX(gadget)         
         ElseIf flag = #Right
            br = GadgetX(bisgadget) - GadgetX(gadget) + GadgetWidth(bisgadget)         
         EndIf         
         ResizeGadget(gadget, #PB_Ignore, #PB_Ignore, br - abstand, #PB_Ignore)
         
      ElseIf IsWindow(bisgadget)
         If flag = #Right
            br = WindowWidth(bisgadget) - GadgetX(gadget)
         EndIf         
         ResizeGadget(gadget, #PB_Ignore, #PB_Ignore, br - abstand, #PB_Ignore)
      EndIf
            
      ProcedureReturn br
   EndProcedure
      
   Procedure.i SetXY(gadgetnr, parent, flag, abstand=10, flag2=0, abstand2=10) 
      ;ermittelt x + y für Gadget
      
      ;flag2 = #GadgetOutside wird gesetzt wenn Parent ein Container/Panel ist 
      ;        und ein Gadget ausserhalb vom Container/Panel plaziert werden soll.
      
      Protected parenttype.s, gadgettyp, p.rect, x, y
            
      If IsGadget(gadgetnr) = 0
         Debug "Gadget existiert nicht. Nr." + gadgetnr
         ProcedureReturn
      EndIf
            
      ;Parent auswerten
      If IsGadget(parent)
         gadgettyp = GadgetType(parent)
         If flag2 = #GadgetOutside: gadgettyp = #PB_GadgetType_Unknown: EndIf 
         
         Select gadgettyp
            Case #PB_GadgetType_Container    ;minus + plus Werte sind geschätzt
               parenttype = "Container"
               p\top = 1
               p\left = 1
               p\right = GadgetWidth(parent) - 3
               p\bottom = GadgetHeight(parent) - 4
            Case #PB_GadgetType_Panel
               parenttype = "Panel"
               p\right = GadgetWidth(parent) - 5
               p\bottom = GadgetHeight(parent) - 25
            Case #PB_GadgetType_Frame
               parenttype = "Frame"
               p\top = GadgetY(parent) + 3
               p\left = GadgetX(parent) + 2
               p\right = GadgetWidth(parent) + 7
               p\bottom = GadgetHeight(parent) + 8
            Default  
               parenttype = "Gadget"
               p\top = GadgetY(parent)
               p\left = GadgetX(parent)
               p\right = GadgetX(parent) + GadgetWidth(parent)
               p\bottom = GadgetY(parent) + GadgetHeight(parent) 
         EndSelect
         
      ElseIf IsWindow(parent)
         parenttype = "Window"
         p\right = WindowWidth(parent)
         p\bottom = WindowHeight(parent)
      Else 
         Debug "Parent Gadget/Window existiert nicht. Nr." + parent
         ProcedureReturn
      EndIf
      
      ;Auswertung
      Select parenttype
         Case "Gadget"            
            Select flag
               Case #Left:
                  x = p\left - abstand - GadgetWidth(gadgetnr)
                  y = p\top             
                  
               Case #Right:      
                  x = p\right + abstand
                  y = p\top
                  
               Case #TopLeft, #Top
                  x = p\left
                  y = p\top - abstand - GadgetHeight(gadgetnr) 
                  
               Case #TopRight
                  x = p\right - GadgetWidth(gadgetnr)
                  y = p\top - abstand - GadgetHeight(gadgetnr)  
                  
               Case #TopCenter             
                  x = p\Left + (GadgetWidth(parent) / 2) - (GadgetWidth(gadgetnr) / 2)
                  y = p\top - abstand - GadgetHeight(gadgetnr)
                  
               Case #BottomLeft, #Bottom
                  x = p\left
                  y = p\bottom + abstand  
                  
               Case #BottomRight
                  x = p\right - GadgetWidth(gadgetnr)
                  y = p\bottom + abstand  
                  
               Case #BottomCenter             
                  x = p\Left + (GadgetWidth(parent) / 2) - (GadgetWidth(gadgetnr) / 2)
                  y = p\bottom + abstand
                  
               Case #BottomCenterLeft            
                  x = p\Left + (GadgetWidth(parent) / 2) - GadgetWidth(gadgetnr)
                  y = p\bottom + abstand
                  
               Case #BottomCenterRight            
                  x = p\Left + (GadgetWidth(parent) / 2) 
                  y = p\bottom + abstand
                  
               Default: Debug "unbekanntes Flag für ParentGadget - Gadgetnr." + gadgetnr   
            EndSelect
            
         Case "Window", "Container", "Panel", "Frame"    ;Gadgets sollen innerhalb sein
            Select flag
               Case #TopLeft, #Top
                  x = p\left + abstand
                  y = p\top + abstand

               Case #TopRight
                  x = p\right - abstand - GadgetWidth(gadgetnr)
                  y = p\top + abstand
                  
               Case #TopCenter                       
                  x = (p\right / 2) - (GadgetWidth(gadgetnr) / 2)
                  y = p\top + abstand
                  
               Case #BottomLeft, #Bottom
                  x = p\left + abstand
                  y = p\bottom - abstand - GadgetHeight(gadgetnr) 
                  
               Case #BottomRight
                  x = p\right - abstand - GadgetWidth(gadgetnr)
                  y = p\bottom - abstand - GadgetHeight(gadgetnr) 
                  
               Case #BottomCenter
                  x = (p\right / 2) - (GadgetWidth(gadgetnr) / 2)
                  y = p\bottom - abstand - GadgetHeight(gadgetnr) 
                  
               Case #BottomCenterLeft            
                  x = (p\right / 2) - GadgetWidth(gadgetnr)
                  y = p\bottom - abstand - GadgetHeight(gadgetnr) 
                  
               Case #BottomCenterRight            
                  x = p\right / 2
                  y = p\bottom - abstand - GadgetHeight(gadgetnr) 
                  
               Default: Debug "unbekanntes Flag für ParentWindow etc - Gadgetnr." + gadgetnr
            EndSelect
            
      EndSelect
      
      ;Schiebeflag
      Select flag2
         Case 0
         Case #Left:  x - abstand2
         Case #Right: x + abstand2
         Case #Up:    y - abstand2 
         Case #Down:  y + abstand2 
         Case #GadgetOutside: ;damit Default nicht zutrifft
         Default: Debug "unbekanntes flag2"
      EndSelect 
      
      ResizeGadget(gadgetnr, x, y, #PB_Ignore, #PB_Ignore)
      
   EndProcedure
        
EndModule

Zuletzt geändert von hjbremer am 01.05.2018 14:04, insgesamt 2-mal geändert.
Purebasic 5.70 x86 5.72 X 64 - Windows 10

Der Computer hat dem menschlichen Gehirn gegenüber nur einen Vorteil: Er wird benutzt
grüße hjbremer
Benutzeravatar
hjbremer
Beiträge: 822
Registriert: 27.02.2006 22:30
Computerausstattung: von gestern
Wohnort: Neumünster

Re: SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von hjbremer »

Und Hier ein paar Demos

Code: Alles auswählen

XIncludeFile "SetXYf.pbi"

UseModule SetXY

Enumeration 
   #main   
   #cb1 : #cb2 : #cb3 : #cb4
   #cb5 : #cb6 : #cb7 : #cb8
   #ed1 : #wb1 : #wb2 : #wb3   
EndEnumeration

OpenWindow(#main, 0, 0, 0, 0, "SetXY Demo 0", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)

ButtonGadget(#cb1, 0, 0, 80, 24, "Button cb1") : SetXY(#cb1, #main, #Top)
ButtonGadget(#cb2, 0, 0, 80, 24, "Button cb2") : SetXY(#cb2, #cb1, #Right)
ButtonGadget(#cb3, 0, 0, 80, 24, "Button cb3") : SetXY(#cb3, #cb2, #Right)
ButtonGadget(#cb4, 0, 0, 80, 24, "Button cb4") : SetXY(#cb4, #cb3, #Right)

ButtonGadget(#cb5, 0, 0, 80, 24, "Button cb5") : SetXY(#cb5, #cb1, #Bottom)
ButtonGadget(#cb6, 0, 0, 80, 24, "Button cb6") : SetXY(#cb6, #cb5, #Bottom)
ButtonGadget(#cb7, 0, 0, 80, 24, "Button cb7") : SetXY(#cb7, #cb6, #Bottom)
ButtonGadget(#cb8, 0, 0, 80, 24, "Button cb8") : SetXY(#cb8, #cb7, #Bottom)

EditorGadget(#ed1, 0, 0, 100, 50) : SetXY(#ed1, #cb5, #right)

SetWidth(#ed1, #cb4, #Right, 0) : SetHeight(#ed1, #cb8, #bottom, 0)

SetWindowSize(#main, #cb4, #Right)
SetWindowSize(#main, #cb8, #Bottom, 70)    ; 70 um Platz zu schaffen für Buttons unten

ButtonGadget(#wb1, 0, 0, 80, 24, "Button wb1") : SetXY(#wb1, #main, #BottomLeft)
ButtonGadget(#wb2, 0, 0, 80, 24, "Button wb2") : SetXY(#wb2, #main, #BottomCenter)
ButtonGadget(#wb3, 0, 0, 80, 24, "Button wb3") : SetXY(#wb3, #main, #BottomRight)

;SetWindowSize(#main, #wb3, #Right)    ;ergibt Mist

HideWindow(#main, 0)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Code: Alles auswählen

XIncludeFile "SetXYf.pbi"

UseModule SetXY

Enumeration 10
   #main
   #cb1 : #cb2 : #cb3 : #cb4 
   #cb5 : #cb6 : #cb7 : #cb8 : #cb9 : #lv
EndEnumeration

OpenWindow(#main, 0, 0, 1000, 600, "Buttons", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

ButtonGadget(#cb1, 0, 0, 80, 24, "Button cb1") : SetXY(#cb1, #Main, #Bottom)
ButtonGadget(#cb2, 0, 0, 80, 24, "Button cb2") : SetXY(#cb2, #cb1, #Right)

ButtonGadget(#cb3, 0, 0, 80, 24, "Button cb3") : SetXY(#cb3, #cb2, #Right)
ButtonGadget(#cb4, 0, 0, 80, 24, "Button cb4") : SetXY(#cb4, #cb3, #Right)

ButtonGadget(#cb5, 0, 0, 80, 24, "Button cb5") : SetXY(#cb5, #Main, #BottomRight)
ButtonGadget(#cb6, 0, 0, 60, 24, "Button cb6") : SetXY(#cb6, #cb5, #Left)

ButtonGadget(#cb8, 0, 0, 24, 24, Chr($2191)) : SetXY(#cb8, #Main, #BottomCenterLeft)
ButtonGadget(#cb9, 0, 0, 24, 24, Chr($2193)) : SetXY(#cb9, #Main, #BottomCenterRight)

ListIconGadget(#lv, 0, 0, 0, 0, "Adresse", 200) : SetXY(#lv, #Main, #top)
SetWidth(#lv, #main, #Right)
SetHeight(#lv, #cb1, #Top)


Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Code: Alles auswählen

XIncludeFile "SetXYf.pbi"
UseModule SetXY

Enumeration 10
   #main : #titel : #cb1 : #cb2 : #cb3 : #cb4 : #edi
EndEnumeration

Dim text$(10)
Dim pbnrtext(10)

Global Dim pbnrstrg(10)

Procedure SizeWindowHandler()
    
   For j = 0 To 10
      SetWidth(pbnrstrg(j) , #Main, #Right, 50)
   Next
   
   SetXY(#Titel, #Main, #TopCenter, 30) 
   SetXY(#cb1, #Main, #Bottom)
   SetXY(#cb2, #Main, #BottomCenterLeft)
   SetXY(#cb3, #Main, #BottomCenterRight)   
   SetXY(#cb4, #Main, #BottomRight)
   
   SetWidth(#edi , #Main, #Right, 50)
   SetHeight(#edi , #cb1, #Top, 15)
   
EndProcedure

For j = 0 To 10
   text$(j) = "Dies ist Infotext " + j
Next

LoadFont(1, "", 16): LoadFont(2, "", 11)

flags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_Invisible

OpenWindow(#main, 0, 0, 0, 0, "Array mit Sizegadget", flags)
BindEvent(#PB_Event_SizeWindow, @SizeWindowHandler())

TextGadget(#Titel, 0, 0, 200, 40, "Überschrift", #PB_Text_Center) 
SetGadgetFont(#titel, FontID(1))

For j = 0 To 10
   pbnrtext(j) = TextGadget(#PB_Any, 0, 0, 100, 22, text$(j), #PB_Text_Right)
   pbnrstrg(j) = StringGadget(#PB_Any, 0, 0, 350, 22, "")
   SetGadgetFont(pbnrstrg(j), FontID(2))
Next

EditorGadget(#edi, 0, 0, 0, 0, #PB_Editor_WordWrap)
SetGadgetText(#edi, "Editorgadget wird sichtbar wenn man das Fenster vergrößert")

ButtonGadget(#cb1, 0, 0, 80, 24, "Button ok") 
ButtonGadget(#cb2, 0, 0, 80, 24, "Button xyz")
ButtonGadget(#cb3, 0, 0, 80, 24, "Button Blah")
ButtonGadget(#cb4, 0, 0, 80, 24, "Button Ende") 

;SetXY Befehle

SetXY(#Titel, #Main, #TopCenter, 30)

SetXY(pbnrtext(0), #Main, #Top, 30, #Down, 50)  ;wenn Parent ein Window, dann gilt Abstand (hier 30) für X + Y !!!
SetXY(pbnrstrg(0), pbnrtext(0), #Right, 10, #Up, 3)   ;man kann es aber noch mit #Down/Right/#Up/#Left verschieben

For j = 1 To 10
   SetXY(pbnrtext(j), pbnrtext(j-1), #Bottom)
   SetXY(pbnrstrg(j), pbnrstrg(j-1), #Bottom)
Next

SetXY(#edi, pbnrstrg(10), #Bottom, 20)

SetWindowSize(#main, pbnrstrg(10), #Right, 10)    ; 
SetWindowSize(#main, pbnrstrg(10), #Bottom, 65)    ; 65 um Platz zu schaffen für Buttons unten
                                                   
SetXY(#cb1, #Main, #Bottom)
SetXY(#cb2, #Main, #BottomCenterLeft)
SetXY(#cb3, #Main, #BottomCenterRight)
SetXY(#cb4, #Main, #BottomRight)

HideWindow(#main, 0)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Purebasic 5.70 x86 5.72 X 64 - Windows 10

Der Computer hat dem menschlichen Gehirn gegenüber nur einen Vorteil: Er wird benutzt
grüße hjbremer
Benutzeravatar
hjbremer
Beiträge: 822
Registriert: 27.02.2006 22:30
Computerausstattung: von gestern
Wohnort: Neumünster

Re: SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von hjbremer »

Und nun eine Demo mit Container Framegadget und Panel

Code: Alles auswählen

XIncludeFile "SetXYf.pbi"
UseModule SetXY

Enumeration 10
   #main
   #frame   
   #fb1 : #fb2 : #fb3 : #fb4
   #fb5 : #fb6 : #fb7 : #fb8
   #fd1 : #fd2 
   
   #cont   
   #cb1 : #cb2 : #cb3 : #cb4
   #cb5 : #cb6 : #cb7 : #cb8
   #ed1 : #ed2 
   
   #pan1 : #pan2   
   #pb1 : #pb2 : #pb3 : #pb4 
   #pb5 : #pb6 : #pb7 : #pb8
   
   #wb1 : #wb1a : #wb1b : #wb2 : #wb3
EndEnumeration

OpenWindow(#main, 0, 0, 1200, 500, "Gadgets im Container etc", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)

;Frame
FrameGadget(#frame, 0, 0, 400, 400, "", #PB_Frame_Flat): SetXY(#frame, #main, #Top)

ButtonGadget(#fb1, 0, 0, 80, 24, "Button fb1") : SetXY(#fb1, #frame, #Top)
ButtonGadget(#fb2, 0, 0, 80, 24, "Button fb2") : SetXY(#fb2, #frame, #TopRight)
ButtonGadget(#fb3, 0, 0, 80, 24, "Button fb3") : SetXY(#fb3, #frame, #Bottom)
ButtonGadget(#fb4, 0, 0, 80, 24, "Button fb4") : SetXY(#fb4, #frame, #BottomRight)

ButtonGadget(#fb5, 0, 0, 80, 24, "Button fb5") : SetXY(#fb5, #fb1, #Bottom)
ButtonGadget(#fb6, 0, 0, 80, 24, "Button fb6") : SetXY(#fb6, #fb2, #Bottom)
ButtonGadget(#fb7, 0, 0, 80, 24, "Button fb7") : SetXY(#fb7, #fb3, #top)
ButtonGadget(#fb8, 0, 0, 80, 24, "Button fb8") : SetXY(#fb8, #fb4, #top)

EditorGadget(#fd1, 0, 0, 100, 50) : SetXY(#fd1, #fb1, #right)
EditorGadget(#fd2, 0, 0, 100, 50) : SetXY(#fd2, #fb5, #Bottom)

SetWidth(#fd1, #fb2, #left) : SetHeight(#fd1, #fb5, #bottom, 0)
SetWidth(#fd2, #fb6, #right, 0) : SetHeight(#fd2, #fb7, #top)

;Container
ContainerGadget(#cont, 0, 0, 400, 400, #PB_Container_Flat): SetXY(#cont, #frame, #Right, 10, #GadgetOutside)

ButtonGadget(#cb1, 0, 0, 80, 24, "Button cb1") : SetXY(#cb1, #cont, #Top)
ButtonGadget(#cb2, 0, 0, 80, 24, "Button cb2") : SetXY(#cb2, #cont, #TopRight)
ButtonGadget(#cb3, 0, 0, 80, 24, "Button cb3") : SetXY(#cb3, #cont, #Bottom)
ButtonGadget(#cb4, 0, 0, 80, 24, "Button cb4") : SetXY(#cb4, #cont, #BottomRight)

ButtonGadget(#cb5, 0, 0, 80, 24, "Button cb5") : SetXY(#cb5, #cb1, #Bottom)
ButtonGadget(#cb6, 0, 0, 80, 24, "Button cb6") : SetXY(#cb6, #cb2, #Bottom)
ButtonGadget(#cb7, 0, 0, 80, 24, "Button cb7") : SetXY(#cb7, #cb3, #top)
ButtonGadget(#cb8, 0, 0, 80, 24, "Button cb8") : SetXY(#cb8, #cb4, #top)

EditorGadget(#ed1, 0, 0, 100, 50) : SetXY(#ed1, #cb1, #right)
EditorGadget(#ed2, 0, 0, 100, 50) : SetXY(#ed2, #cb5, #Bottom)

SetWidth(#ed1, #cb2, #left) : SetHeight(#ed1, #cb5, #bottom, 0)
SetWidth(#ed2, #cb6, #right, 0) : SetHeight(#ed2, #cb7, #top)

CloseGadgetList()

;Panel
PanelGadget(#pan1, 0, 0, 0, 0): SetXY(#pan1, #cont, #Right, 10, #GadgetOutside)
   
   SetHeight(#pan1, #cont, #bottom, 0) : SetWidth(#pan1, #main, #right)
      
   AddGadgetItem (#pan1, -1, "Panel 1")
   
   ButtonGadget(#pb4, 0, 0, 80, 24, "Button pb4") : SetXY(#pb4, #pan1, #Bottom)
   
   PanelGadget (#pan2, 5, 5, 290, 250)
      AddGadgetItem(#pan2, -1, "Sub-Panel 1")
      ButtonGadget(#pb2, 0, 0, 80, 24, "Button pb2") : SetXY(#pb2, #pan2, #Top)
      ButtonGadget(#pb3, 0, 0, 80, 24, "Button pb3") : SetXY(#pb3, #pan2, #TopRight)
      
      AddGadgetItem(#pan2, -1, "Sub-Panel 2")
      ButtonGadget(#pb5, 0, 0, 80, 24, "Button pb5") : SetXY(#pb5, #pan2, #Bottom)
      
      AddGadgetItem(#pan2, -1, "Sub-Panel 3")
      ButtonGadget(#pb6, 0, 0, 80, 24, "Button pb6") : SetXY(#pb6, #pan2, #BottomRight)
      
   CloseGadgetList()
   
   AddGadgetItem (#pan1, -1,"Panel 2")
   ButtonGadget(#pb1, 0, 0, 80, 24, "Button pb1") : SetXY(#pb1, #pan1, #Bottom)
   ButtonGadget(#pb7, 0, 0, 80, 24, "Button pb7") : SetXY(#pb7, #pan1, #TopCenter)
CloseGadgetList()

ButtonGadget(#pb8, 0, 0, 80, 24, "Button pb8") : SetXY(#pb8, #pan1, #BottomCenter, 10, #GadgetOutside)

;unten
ButtonGadget(#wb1, 0, 0, 80, 24, "Button wb1") : SetXY(#wb1, #main, #BottomCenter)
ButtonGadget(#wb2, 0, 0, 80, 24, "Button wb2") : SetXY(#wb2, #main, #Bottom)
ButtonGadget(#wb3, 0, 0, 80, 24, "Button wb3") : SetXY(#wb3, #main, #BottomRight)

ButtonGadget(#wb1a, 0, 0, 80, 24, "Button wb1a") : SetXY(#wb1a, #wb1, #Left)
ButtonGadget(#wb1b, 0, 0, 80, 24, "Button wb1b") : SetXY(#wb1b, #wb1, #Right)

HideWindow(#main, 0)

;SetWindowSize() ist nicht mehr möglich, da Breite von #pan1 sich bereits am Window ausrichtet siehe Zeile 70
; auch die Buttons #wb1 bis #wb2 tun dies siehe Zeile 97 + 98

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Purebasic 5.70 x86 5.72 X 64 - Windows 10

Der Computer hat dem menschlichen Gehirn gegenüber nur einen Vorteil: Er wird benutzt
grüße hjbremer
Benutzeravatar
Kiffi
Beiträge: 10621
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Re: SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von Kiffi »

nett, danke! :allright:

Bau das hier bitte noch ein, damit die Linux-Leute es auch nutzen können:

Code: Alles auswählen

  CompilerIf Not Defined(rect, #PB_Structure)
    Structure rect
      top.i
      left.i
      right.i
      bottom.i
    EndStructure
  CompilerEndIf 
Grüße ... Peter
Hygge
Benutzeravatar
diceman
Beiträge: 347
Registriert: 06.07.2017 12:24
Kontaktdaten:

Re: SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von diceman »

Habe erst "Sexy Modul" gelesen. :lol:
Passt ja auch irgendwie.
So oder so, Good Job. :allright:
Now these points of data make a beautiful line,
And we're out of Beta, we're releasing on time.
Benutzeravatar
RSBasic
Admin
Beiträge: 8022
Registriert: 05.10.2006 18:55
Wohnort: Gernsbach
Kontaktdaten:

Re: SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von RSBasic »

Nicht schlecht, sehr hilfreich. :allright:
Aus privaten Gründen habe ich leider nicht mehr so viel Zeit wie früher. Bitte habt Verständnis dafür.
Bild
Bild
Benutzeravatar
mk-soft
Beiträge: 3700
Registriert: 24.11.2004 13:12
Wohnort: Germany

Re: SetXY Modul zur Unterstützung beim Erstellen einer Gui

Beitrag von mk-soft »

Muss noch etwas für MacOS angepasst werden,

aber sonst :allright:
Alles ist möglich, fragt sich nur wie...
Projekte ThreadToGUI / EventDesigner V3 / OOP-BaseClass-Modul
Downloads auf MyWebspace / OneDrive
Antworten