
#include "UIBB.27.09.23.au3"

; Großes UIBB Beispiel.

Global $hGUI = GUICreate('test', 800, 800, -1, -1, 0x00040000 + 0x00020000 + 0x00010000) ; Resizable GUI

GUICtrlCreateMenu('Datei') ; Beispiel Menu ohne Inhalt, kann man auch später einrichten, die UDF funktioniert trotzdem.

; Aufteilung in 3 Teile (nebeneinander, HBOX) des gesamten Bildschirms.
Global $hBOX = _UIBB_Box($UIBB_HBOX, 500, 300, $hGUI) ; Root Box mit $hGUI initialisieren!

; Links wollen wir eine Aufteilung in 3 Teile (übereinander, VBOX)
Global $hLeft = _UIBB_Box($UIBB_VBOX, 120) ; 120px breite

; Ein bisschen Platz links, oben und unten
_UIBB_SetPadding($hLeft, 5, 0, 5, 5)

; Oben: 13 Buttons (übereinander, VBOX)
Global $hLeftTop = _UIBB_Box($UIBB_VBOX, 13 * 30)
; Die 13 Buttons sollen jeweils ca. 30 px hoch sein.
For $i = 0 to 12 Step 1
	$btn = _UIBB_Insert($hLeftTop, GUICtrlCreateButton)
	GUICtrlSetData($btn, 'Button Nummer ' & $i)
	GUICtrlSetBkColor($btn, Random(0, 0xFFFFFF)) ; _UIBB_Insert gibt die original Ctrl-IDs zurück mit denen man alles wie üblich machen kann.
Next

; Mitte: Leer
Global $hLeftMid = _UIBB_Box($UIBB_EMPTY, 20, 0)

; Unten: 2 Buttons
Global $hLeftBot = _UIBB_Box($UIBB_VBOX, 2 * 30)
_UIBB_Insert($hLeftBot, GUICtrlCreateButton)
GUICtrlSetData(-1, 'Lets Go!') ; Der Zugriff via -1 funktioniert ebenfalls.
_UIBB_Insert($hLeftBot, GUICtrlCreateButton)
GUICtrlSetData(-1, 'Roter Button')
GUICtrlSetBkColor(-1, 0xFF0000)

; Allerdings muss es bevor $hLeftBot in $hLeft eingefügt wurde passieren.

; $hLeft zusammensetzen
_UIBB_Insert($hLeft, $hLeftTop)
_UIBB_Insert($hLeft, $hLeftMid)
_UIBB_Insert($hLeft, $hLeftBot)

; Die Mitte ist am größten. Hier machen wir einfach ein rotes Rechteck hin (nur 1 Element, daher egal ob VBOX oder HBOX).
Global $hMid = _UIBB_Box($UIBB_HBOX)
_UIBB_SetPadding($hMid, 10, 10, 10, 10)

Global $hMidPadded = _UIBB_Box($UIBB_HBOX) ; Groups und Tabs können kein Padding erhalten, sie füllen IMMER die komplette Box aus. Will man Padding -> Verschachteln regelt!

_UIBB_Insert($hMidPadded, GUICtrlCreateTab)
GUICtrlSetData(-1, 'Roter Button')


; VORSICHT, Tabitems können nicht skaliert werden, sie müssen also außerhalb von Boxen erzeugt werden.

GUICtrlCreateTabItem(' ')
GUICtrlSetData(-1, 'Test')
Global $hBoxTab1 = _UIBB_Box($UIBB_VBOX)
_UIBB_Insert($hBoxTab1, GUICtrlCreateLabel)
GUICtrlSetBkColor(-1, 0xDE5247)


GUICtrlCreateTabItem('Tab 2')

Global $hBoxTab2 = _UIBB_Box($UIBB_VBOX)
_UIBB_Insert($hBoxTab2, GUICtrlCreateLabel)
GUICtrlSetBkColor(-1, 0x47B7DE)

GUICtrlCreateTabItem('')

_UIBB_Insert($hMidPadded, $hBoxTab1, -1) ; -1 als Scale verursacht NONBLOCKING, die Boxen liegen als "übereinander"
_UIBB_Insert($hMidPadded, $hBoxTab2, -1)

_UIBB_Insert($hMid, $hMidPadded)

;~ _UIBB_Insert($hMid, GUICtrlCreateLabel)


; Rechts möchten wir 3 übereinanderliegende Abschnitte durch eine rote Linie getrennt (insg. also 5 Objekte)
Global $hRight = _UIBB_Box($UIBB_VBOX, 250)
_UIBB_SetPadding($hRight, 0, 10, 10, 10) ; Auf der rechten Seite ein bisschen Platz zum Fensterrand lassen.
Global $hRightTop = _UIBB_Box($UIBB_VBOX, 250)
Global $hRightLine1 = _UIBB_Box($UIBB_VBOX, 10)
_UIBB_SetPadding($hRightLine1, 0, 0, 3, 3)
Global $hRightMid = _UIBB_Box($UIBB_VBOX)
Global $hRightLine2 = _UIBB_Box($UIBB_VBOX, 10)
_UIBB_SetPadding($hRightLine2, 0, 0, 3, 3)
Global $hRightBot = _UIBB_Box($UIBB_HBOX, 130)

; Erstmal die Linien -> einfach ein Label mit roter Farbe
_UIBB_Insert($hRightLine1, GUICtrlCreateLabel)
GUICtrlSetBkColor(-1, 0xDE5247)
_UIBB_Insert($hRightLine2, GUICtrlCreateLabel)
GUICtrlSetBkColor(-1, 0xDE5247)

; Oben wollen wir ein Rechteck. Also wird die Höhe auch auf 250 gesetzt.
_UIBB_Insert($hRightTop, GUICtrlCreateGroup)
GUICtrlSetData(-1, 'Bildvorschau')
_UIBB_Insert($hRightTop, GUICtrlCreateIcon)
GUICtrlSetImage(-1, "shell32.dll", 22)


; In der Mitte wollen wir 3 Gruppen übereinander
Global $hRightMidTop = _UIBB_Box($UIBB_VBOX)
Global $hRightMidMid = _UIBB_Box($UIBB_VBOX)
Global $hRightMidBot = _UIBB_Box($UIBB_VBOX)

_UIBB_Insert($hRightMidTop, GUICtrlCreateGroup)
GUICtrlSetData(-1, 'Skalenfaktor 1')
_UIBB_Insert($hRightMidTop, GUICtrlCreateLabel)
GUICtrlSetData(-1, 'Eine Group muss immer eine eigene Box haben. Diese Box wird automatisch so angepasst, dass weitere Elemente einfach hinzugefügt werden können.')
_UIBB_Insert($hRightMidMid, GUICtrlCreateGroup)
GUICtrlSetData(-1, 'Skalenfaktor 1.5')
_UIBB_Insert($hRightMidMid, GUICtrlCreateLabel)
GUICtrlSetData(-1, 'Dieses Label zeigt die volle verfügbare Fläche in der Group farbig an. Die 3 Groups haben verschiedene Skalenfaktoren.')
GUICtrlSetBkColor(-1, 0x808080)
_UIBB_Insert($hRightMidBot, GUICtrlCreateGroup)
GUICtrlSetData(-1, 'Skalenfaktor 2')
_UIBB_Insert($hRightMidBot, GUICtrlCreateMonthCal)


; Unten soll es eine kleine Visitenkarte geben

_UIBB_Insert($hRightBot, GUICtrlCreateGroup)
GUICtrlSetData(-1, 'Info')

; Die besteht aus 2 Teilen nebeneinander, links 3 Radiobuttons, rechts ein Bild (graues Rechteck)
Global $hRightBotLeft = _UIBB_Box($UIBB_VBOX)
_UIBB_SetPadding($hRightBotLeft, 10, 0, 0, 0) ; Die Radio Buttons etwas nach rechts verschieben.

Global $hRadio1 = _UIBB_Insert($hRightBotLeft, GUICtrlCreateRadio)
GUICtrlSetData(-1, 'Auswahl 1')

Global $hRadio2 = _UIBB_Insert($hRightBotLeft, GUICtrlCreateRadio)
GUICtrlSetData(-1, 'Auswahl 2')

Global $hRadio3 = _UIBB_Insert($hRightBotLeft, GUICtrlCreateRadio)
GUICtrlSetData(-1, 'Auswahl 3')


; Das Bild soll einen äußeren Rand haben der Frei ist.
Global $hRightBotRight = _UIBB_Box($UIBB_VBOX)
_UIBB_Insert($hRightBotRight, GUICtrlCreateLabel)
GUICtrlSetBkColor(-1, 0xAAAAAA)

_UIBB_Insert($hRightBot, $hRightBotLeft)
_UIBB_Insert($hRightBot, $hRightBotRight)


_UIBB_Insert($hRightMid, $hRightMidTop, 1) ; Man kann (wenn man keine Pixelgrößen angibt)
_UIBB_Insert($hRightMid, $hRightMidMid, 1.5) ; auch einen Skalenfaktor zur Skalierung verwenden.
_UIBB_Insert($hRightMid, $hRightMidBot, 2) ; Er beschreibt den Anteil der Box am Verfügbaren Platz.



_UIBB_Insert($hRight, $hRightTop)
_UIBB_Insert($hRight, $hRightLine1)
_UIBB_Insert($hRight, $hRightMid)
_UIBB_Insert($hRight, $hRightLine2)
_UIBB_Insert($hRight, $hRightBot)


; $hBox zusammensetzen
_UIBB_Insert($hBOX, $hLeft)
_UIBB_Insert($hBOX, $hMid)
_UIBB_Insert($hBOX, $hRight)



_UIBB_Update($hBOX)
GUISetState()
GUIRegisterMsg(0x0005, WM_SIZE)


While True
	Switch GUIGetMsg()
		Case -3
			Exit
	EndSwitch
WEnd

Func WM_SIZE()
	$t = TimerInit() ; Im Idealfall sollte das unter 5ms sein... Es ist aber für große UIs deutlich höher...
	_UIBB_Update($hBOX)
	ConsoleWrite(TimerDiff($t) & @CRLF)
EndFunc   ;==>WM_SIZE
