From b3a694f0d81560f88a12a64e61a17e26d180116e Mon Sep 17 00:00:00 2001 From: Dadido3 Date: Thu, 25 Jun 2015 19:40:39 +0200 Subject: [PATCH] Converted MDI to D3docker Use D3docker.pbi for all the windows, instead of a MDI gadget. --- D3hex.pbp | 68 +- Includes/D3docker/CustomGadget.pbi | 133 + Includes/D3docker/D3docker.pbi | 2134 +++++++++++ Includes/D3docker/Data/Close.png | Bin 0 -> 241 bytes Includes/D3docker/Data/Diamond_Bottom.png | Bin 0 -> 324 bytes Includes/D3docker/Data/Diamond_Left.png | Bin 0 -> 338 bytes Includes/D3docker/Data/Diamond_Right.png | Bin 0 -> 352 bytes .../D3docker/Data/Diamond_Root_Bottom.png | Bin 0 -> 290 bytes .../D3docker/Data/Diamond_Root_Inside.png | Bin 0 -> 304 bytes Includes/D3docker/Data/Diamond_Root_Left.png | Bin 0 -> 347 bytes Includes/D3docker/Data/Diamond_Root_Right.png | Bin 0 -> 371 bytes Includes/D3docker/Data/Diamond_Root_Top.png | Bin 0 -> 293 bytes Includes/D3docker/Data/Diamond_Tabbed.png | Bin 0 -> 324 bytes Includes/D3docker/Data/Diamond_Top.png | Bin 0 -> 319 bytes Includes/D3docker/Data/Undock.png | Bin 0 -> 232 bytes Includes/D3docker/TabBarGadget.pbi | 3216 +++++++++++++++++ Includes/Node_Editor.pbi | 9 +- .../Data_Inspector/Object_Data_Inspector.pbi | 5 +- Includes/Object/Editor/Object_Editor.pbi | 17 +- Includes/Object/Editor/Object_Editor_Goto.pbi | 5 +- .../Object/Editor/Object_Editor_Search.pbi | 5 +- Includes/Object/File/Object_File.pbi | 6 +- Includes/Object/History/Object_History.pbi | 6 +- Includes/Object/Math/Object_Math.pbi | 5 +- Includes/Object/Math/Object_MathFormula.pbi | 5 +- .../Object_Network_Terminal.pbi | 6 +- Includes/Object/Process/Object_Process.pbi | 5 +- Includes/Object/Random/Object_Random.pbi | 6 +- Includes/Object/View1D/Object_View1D.pbi | 15 +- .../Object/View1D/Object_View1D_Settings.pbi | 5 +- Includes/Object/View2D/Object_View2D.pbi | 11 +- .../Object/View2D/Object_View2D_Settings.pbi | 6 +- Includes/Window.pbi | 145 +- Main.pb | 116 +- 34 files changed, 5702 insertions(+), 227 deletions(-) create mode 100644 Includes/D3docker/CustomGadget.pbi create mode 100644 Includes/D3docker/D3docker.pbi create mode 100644 Includes/D3docker/Data/Close.png create mode 100644 Includes/D3docker/Data/Diamond_Bottom.png create mode 100644 Includes/D3docker/Data/Diamond_Left.png create mode 100644 Includes/D3docker/Data/Diamond_Right.png create mode 100644 Includes/D3docker/Data/Diamond_Root_Bottom.png create mode 100644 Includes/D3docker/Data/Diamond_Root_Inside.png create mode 100644 Includes/D3docker/Data/Diamond_Root_Left.png create mode 100644 Includes/D3docker/Data/Diamond_Root_Right.png create mode 100644 Includes/D3docker/Data/Diamond_Root_Top.png create mode 100644 Includes/D3docker/Data/Diamond_Tabbed.png create mode 100644 Includes/D3docker/Data/Diamond_Top.png create mode 100644 Includes/D3docker/Data/Undock.png create mode 100644 Includes/D3docker/TabBarGadget.pbi diff --git a/D3hex.pbp b/D3hex.pbp index fd72dc8..cd8b78b 100644 --- a/D3hex.pbp +++ b/D3hex.pbp @@ -7,7 +7,7 @@
- +
@@ -18,6 +18,10 @@ + + + + @@ -36,23 +40,23 @@ - + - + - + - + @@ -60,59 +64,59 @@ - + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - + - + - - + + - + - + @@ -128,7 +132,7 @@ - + @@ -136,7 +140,7 @@ - +
@@ -147,8 +151,8 @@ Data\Images\Icon.ico - - + + @@ -163,8 +167,8 @@ Data\Images\Icon.ico - - + + diff --git a/Includes/D3docker/CustomGadget.pbi b/Includes/D3docker/CustomGadget.pbi new file mode 100644 index 0000000..e43bff2 --- /dev/null +++ b/Includes/D3docker/CustomGadget.pbi @@ -0,0 +1,133 @@ +;-TOP +; Comment : Create custom PB gadget +; Author : eddy +; Web : http://www.purebasic.fr/english/viewtopic.php?f=12&p=418722 +; File: : CustomGadget.pbi +; Version : v0.7 + +DeclareModule CustomGadget + Prototype Events(*Params, EventWindow, EventGadget, EventType) + Prototype Call(*Gadget) + Prototype CallByItem(*Gadget, Item) + Prototype Resize(*Gadget, x.l, y.l, w.l, h.l) + Prototype.i GetInteger(*Gadget) + Prototype SetInteger(*Gadget, Value) + Prototype.s GetString(*Gadget) + Prototype SetString(*Gadget, Value$) + Prototype.s GetStringByItem(*Gadget, Item) + Prototype SetStringByItem(*Gadget, Item, Value$) + Prototype.i GetIntegerByAttribute(*Gadget, Attribute) + Prototype SetIntegerByAttribute(*Gadget, Attribute, Value) + Prototype.i GetIntegerByItem(*Gadget, Item) + Prototype SetIntegerByItemAttribute(*Gadget, Item, Attribute, Value, Column=#PB_Ignore) + Prototype.i GetIntegerByItemAttribute(*Gadget, Item, Attribute, Column=#PB_Ignore) + Prototype SetIntegerByItem(*Gadget, Item, Value) + Structure GADGET_VT + GadgetType.l ; gadget type (used by GadgetType command) + SizeOf.l ; Size of structure + + *GadgetCallback + *FreeGadget.Call + *GetGadgetState.GetInteger + *SetGadgetState.SetInteger + *GetGadgetText.GetString + *SetGadgetText.SetString + *AddGadgetItem2 + *AddGadgetItem3 + *RemoveGadgetItem.CallByItem + *ClearGadgetItems.Call + *ResizeGadget.Resize + *CountGadgetItems.GetInteger + *GetGadgetItemState.GetIntegerByItem + *SetGadgetItemState.SetIntegerByItem + *GetGadgetItemText.GetStringByItem + *SetGadgetItemText.SetStringByItem + *OpenGadgetList2 + *GadgetX.GetInteger + *GadgetY.GetInteger + *GadgetWidth.GetInteger + *GadgetHeight.GetInteger + *HideGadget.SetInteger + *AddGadgetColumn + *RemoveGadgetColumn + *GetGadgetAttribute.GetIntegerByAttribute + *SetGadgetAttribute.SetIntegerByAttribute + *GetGadgetItemAttribute.GetIntegerByItemAttribute + *SetGadgetItemAttribute.SetIntegerByItemAttribute + *SetGadgetColor + *GetGadgetColor + *SetGadgetItemColor2 + *GetGadgetItemColor2 + *SetGadgetItemData + *GetGadgetItemData + *GetRequiredSize + *SetActiveGadget + *GetGadgetFont + *SetGadgetFont + *SetGadgetItemImage + EndStructure + Structure GADGET + *Handle ; gadget OS handle + *VT.GADGET_VT ; gadget commands + *UserData ; gadget data (used by SetGadgetData) + *OldCallback ; original OS callback (used by purebasic CALLBACK) + Daten.i[4] ; ..... + EndStructure + Structure GADGET_MANAGER + GadgetCount.i ;gadget counter (optional) + *OldVT.GADGET_VT ;old commands pointers + *NewVT.GADGET_VT ;new commands pointers + Map *GadgetParams() ;gadget custom parameters + EndStructure + + Declare ManageGadgetCommands(*manager.GADGET_MANAGER, Gadget, State) + Declare ManageGadget(*manager.GADGET_MANAGER, Gadget, *params, GadgetType) + Declare UnmanageGadget(*manager.GADGET_MANAGER, Gadget) +EndDeclareModule + +Module CustomGadget + EnableExplicit + Procedure ManageGadgetCommands(*manager.GADGET_MANAGER, Gadget, State) + Protected *gadget.GADGET=IsGadget(Gadget) + If State + *gadget\VT=*manager\NewVT + Else + *gadget\VT=*manager\OldVT + EndIf + EndProcedure + Procedure ManageGadget(*manager.GADGET_MANAGER, Gadget, *params, GadgetType) + Protected *gadget.GADGET=IsGadget(Gadget) + With *manager + If \OldVT=#Null And \NewVT=#Null + ; define manager: custom events, custom VT, custom gadget type + \OldVT=*gadget\VT + \NewVT=AllocateMemory(SizeOf(GADGET_VT)) + CopyMemory(\OldVT, \NewVT, SizeOf(GADGET_VT)) + \NewVT\GadgetType=GadgetType + EndIf + ; use custom PB commands + ManageGadgetCommands(*manager, Gadget, #True) + + ; save gadget params and increment counter + \GadgetParams(""+*gadget)=*params + \GadgetCount+1 + EndWith + EndProcedure + Procedure UnmanageGadget(*manager.GADGET_MANAGER, Gadget) + Protected *gadget.GADGET=IsGadget(Gadget) + With *manager + \GadgetCount-1 + Protected *params=*manager\GadgetParams() + DeleteMapElement(*manager\GadgetParams(), ""+*Gadget) + If *params + FreeStructure(*params) + EndIf + EndWith + EndProcedure +EndModule +; IDE Options = PureBasic 5.31 (Windows - x64) +; CursorPosition = 68 +; FirstLine = 67 +; Folding = - +; EnableUnicode +; EnableXP \ No newline at end of file diff --git a/Includes/D3docker/D3docker.pbi b/Includes/D3docker/D3docker.pbi new file mode 100644 index 0000000..a68aec9 --- /dev/null +++ b/Includes/D3docker/D3docker.pbi @@ -0,0 +1,2134 @@ +; #################################################### License / Copyright ###################################### +; +; The MIT License (MIT) +; +; Copyright (c) 2015 David Vogel +; +; Permission is hereby granted, free of charge, To any person obtaining a copy +; of this software And associated documentation files (the "Software"), To deal +; in the Software without restriction, including without limitation the rights +; To use, copy, modify, merge, publish, distribute, sublicense, And/Or sell +; copies of the Software, And To permit persons To whom the Software is +; furnished To do so, subject To the following conditions: +; +; The above copyright notice And this permission notice shall be included in all +; copies Or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS Or +; IMPLIED, INCLUDING BUT Not LIMITED To THE WARRANTIES OF MERCHANTABILITY, +; FITNESS For A PARTICULAR PURPOSE And NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS Or COPYRIGHT HOLDERS BE LIABLE For ANY CLAIM, DAMAGES Or OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT Or OTHERWISE, ARISING FROM, +; OUT OF Or IN CONNECTION With THE SOFTWARE Or THE USE Or OTHER DEALINGS IN THE +; SOFTWARE. +; +; #################################################### Documentation ############################################# +; +; D3docker - D3 Docker Gadget +; +; Version History: +; - 0.000 07.06.2015 +; +; - 0.800 22.06.2015 +; - Implemented mostly everything necessary +; +; TODO: Loading and Saving layouts from/to json or xml... +; TODO: Container_Resize_Between has some problems with *Container\Max_Width or *Container\Max_Height +; TODO: Merge the Container_Docker bar with the tab bar of the tabbed container +; TODO: Allow the docking to undocked windows +; +; #################################################### Includes ################################################# + +XIncludeFile "CustomGadget.pbi" + +; ############################################################################################################### +; #################################################### Public ################################################### +; ############################################################################################################### + +DeclareModule D3docker + EnableExplicit + ; ################################################## Constants ################################################ + #PB_GadgetType_D3docker=20150607 + #Version = 800 + + ; #### Directions for placing a docker + Enumeration + #Direction_Inside + #Direction_Top + #Direction_Right + #Direction_Left + #Direction_Bottom + EndEnumeration + + ; ################################################## Functions ################################################ + Declare Window_Add(Gadget, X, Y, Width, Height, Title.s, Flags, Resize_Priority.l=0) + Declare Window_Close(Window) + Declare Window_Bounds(Window, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) + Declare Window_Set_Active(Window) + Declare Window_Get_Active(Gadget) + Declare Window_Set_Callback(Window, *Callback) + Declare Window_Get_Container(Window) + + Declare Container_Delete(Gadget, *Container) + Declare Docker_Add(Gadget, *Container, Direction, Window) + Declare Root_Get(Gadget) + + Declare Create(Gadget, X, Y, Width, Height, Parent_Window.i) + Declare Free(Gadget) + +EndDeclareModule + +; ############################################################################################################### +; #################################################### Private ################################################## +; ############################################################################################################### + +Module D3docker + ; ################################################## Init ##################################################### + UsePNGImageDecoder() + + ; ################################################## Includes ################################################# + XIncludeFile "TabBarGadget.pbi" + UseModule CustomGadget + + ; ################################################## Constants ################################################ + #Color_Gadget_Background = $707070 + #Color_Docker_Background = $B0B0B0 + #Color_Docker_Background_Active = $FF8D70 + #Color_Docker_Border = #Color_Docker_Background;$A0A0A0 + #Color_Splitter_Background = #Color_Gadget_Background + #Color_Tabbed_Background = #Color_Gadget_Background + + #Color_Button_Hover = $D0D0D0 + #Color_Button_Pressed = $909090 + + TabBarGadgetInclude\TabBarColor = #Color_Tabbed_Background + + #Container_Size_Max = 1000000 + #Container_Size_Ignore = -1 + + #Container_Docker_Bar_Height = 16 + #Container_Tabbed_Bar_Height = 20 + + Enumeration + #Container_Type_Root + #Container_Type_Docker + #Container_Type_Split_H + #Container_Type_Split_V + #Container_Type_Spliter + #Container_Type_Tabbed + EndEnumeration + + #Diamond_Size = 32 + + #Splitter_Size = 6 + + Enumeration + #Canvas_Button_State_Normal + #Canvas_Button_State_Hover + #Canvas_Button_State_Pressed + #Canvas_Button_State_Pressed_Outside + EndEnumeration + + ; ################################################## Prototypes ############################################### + Prototype Window_Callback(hWnd, Message, wParam, lParam) + + ; ################################################## Structures ############################################### + Structure Canvas_Button + X.l + Y.l + Width.l + Height.l + + Image.i + + State.l + EndStructure + + Structure Diamond + Window.i + hWnd.i + + *Gadget.GADGET + *Container.Container + + Direction.l + + X.l + Y.l + + Gadget_Canvas.i + EndStructure + + Structure Window + Window.i + hWnd.i + + *Gadget.GADGET + *Container.Container + + *Callback.Window_Callback + + Max_Width.l + Min_Width.l + Max_Height.l + Min_Height.l + + Resize_Priority.l + + Flags_Normal.l + Flags_Docked.l + + Mouse_Drag_X.l + Mouse_Drag_Y.l + Mouse_Drag_X_Offset.l + Mouse_Drag_Y_Offset.l + Mouse_Drag.l + *Mouse_Drag_Container.Container + EndStructure + + Structure Container + Type.l + + *Gadget.GADGET + *Parent.Container + + X.l + Y.l + Width.d + Height.d + + Max_Width.l + Min_Width.l + Max_Height.l + Min_Height.l + + Priority.l ; Priority for resizing + Priority_Inerhit.l + + List *Container.Container() + + Hidden.l ; #True when this and all child containers should be hidden. If it is #False, it depends on all the ancestors if it is visible + Hidden_Inherit.l + + Tabbed_Selection.l + + *Window.Window + + Gadget_Container.i + Gadget_Text.i + Gadget_Canvas.i + Gadget_TabBar.i + + ; #### Docker + Docker_Button_Close.Canvas_Button + Docker_Button_Undock.Canvas_Button + + Title.s + + Drag_X.l + Drag_Y.l + Drag.l + EndStructure + + Structure GADGET_PARAMS + Root.Container + + Parent_Window.i + + FontID.i + + List Diamond.Diamond() + List Window.Window() + *Active_Window.Window + EndStructure + + Structure Temp_Size + Size.l + Min_Size.l + Max_Size.l + + Priority.l + + Finished.l + + *Container.Container + EndStructure + + ; ################################################## Declares ################################################# + Declare Diamond_Delete(*Gadget.GADGET, *Diamond.Diamond) + + Declare _Window_Bounds(*Gadget.GADGET, *Window.Window, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) + Declare _Window_Set_Active(*Gadget.GADGET, *Window.Window, Post_Event=#False) + Declare Window_Get_By_Handle(hWnd) + Declare Window_Get_By_Number(Window) + + Declare Container_Docker_Redraw(*Gadget.GADGET, *Container.Container) + Declare Container_Tabbed_Select(*Gadget.GADGET, *Container.Container, *Selection.Container, SetGadgetState=#True) + Declare Container_Get_By_Coordinate(*Gadget.GADGET, *Container.Container, X, Y) + Declare Container_Merge_To_Parent(*Gadget.GADGET, *Container.Container) + Declare Container_Update_Limits(*Gadget.GADGET, *Container.Container) + Declare _Container_Delete(*Gadget.GADGET, *Container.Container, Iteration=0) + Declare Container_Set_Parent(*Gadget.GADGET, *Container.Container, *Parent.Container, Position) + Declare Container_Resize(*Gadget.GADGET, *Container.Container, X.l, Y.l, Width.d, Height.d, *Exclude_Resize.Container=#Null, Iteration=0) + Declare Container_Resize_Between(*Gadget.GADGET, *Container.Container, Index, Difference) + + Declare _Docker_Add(*Gadget.GADGET, *Container.Container, Direction, *Window.Window, Iteration=0) + + ; ################################################## Image Init ############################################### + Global Image_Diamond_Root_Left = CatchImage(#PB_Any, ?Diamond_Root_Left) + Global Image_Diamond_Root_Top = CatchImage(#PB_Any, ?Diamond_Root_Top) + Global Image_Diamond_Root_Right = CatchImage(#PB_Any, ?Diamond_Root_Right) + Global Image_Diamond_Root_Bottom = CatchImage(#PB_Any, ?Diamond_Root_Bottom) + Global Image_Diamond_Root_Inside = CatchImage(#PB_Any, ?Diamond_Root_Inside) + Global Image_Diamond_Left = CatchImage(#PB_Any, ?Diamond_Left) + Global Image_Diamond_Top = CatchImage(#PB_Any, ?Diamond_Top) + Global Image_Diamond_Right = CatchImage(#PB_Any, ?Diamond_Right) + Global Image_Diamond_Bottom = CatchImage(#PB_Any, ?Diamond_Bottom) + Global Image_Diamond_Tabbed = CatchImage(#PB_Any, ?Diamond_Tabbed) + Global Image_Button_Undock = CatchImage(#PB_Any, ?Button_Undock) + Global Image_Button_Close = CatchImage(#PB_Any, ?Button_Close) + + ; ################################################## Functions ################################################ + Procedure.i GetManager() + Static manager.GADGET_MANAGER + ProcedureReturn @manager + EndProcedure + + Procedure.i GetParams(*Gadget.GADGET) + Protected *manager.GADGET_MANAGER=GetManager() + ProcedureReturn *manager\GadgetParams(""+*Gadget) + EndProcedure + + Procedure.i GetParams_By_Window(hWnd) + Protected *manager.GADGET_MANAGER=GetManager() + Protected *params.GADGET_PARAMS + ForEach *manager\GadgetParams() + *params = *manager\GadgetParams() + ForEach *params\Window() + If *params\Window()\hWnd = hWnd + ProcedureReturn *params + EndIf + Next + Next + EndProcedure + + Procedure _FreeGadget(*Gadget.GADGET) + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + UnmanageGadget(GetManager(), \Root\Gadget_Container) + EndWith + EndProcedure + + Procedure _ResizeGadget(*Gadget.GADGET, x.l, y.l, w.l, h.l) + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + ManageGadgetCommands(GetManager(), \Root\Gadget_Container, #False) ;use default PB commands + SendMessage_(GadgetID(\Root\Gadget_Container), #WM_SETREDRAW, #False, 0) + ResizeGadget(\Root\Gadget_Container, x, y, w, h) + ManageGadgetCommands(GetManager(), \Root\Gadget_Container, #True) ;use custom PB commands + + Container_Resize(*Gadget, \Root, 0, 0, w, h) + EndWith + EndProcedure + + Procedure _SetGadgetState(*Gadget.GADGET, State) + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + EndWith + EndProcedure + + Procedure.i _GetGadgetState(*Gadget.GADGET) + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + EndWith + EndProcedure + + Procedure Diamond_Create(*Gadget.GADGET, *Container.Container, X, Y, Direction, hWnd) + If Not *Gadget + ProcedureReturn #Null + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + AddElement(\Diamond()) + + \Diamond()\Window = OpenWindow(#PB_Any, X, Y, #Diamond_Size, #Diamond_Size, "", #PB_Window_BorderLess | #PB_Window_NoActivate, hWnd) + \Diamond()\hWnd = WindowID(\Diamond()\Window) + \Diamond()\Gadget = *Gadget + \Diamond()\X = X + \Diamond()\Y = Y + \Diamond()\Container = *Container + \Diamond()\Direction = Direction + + \Diamond()\Gadget_Canvas = CanvasGadget(#PB_Any, 0, 0, #Diamond_Size, #Diamond_Size) + + If *Container = \Root + Select Direction + Case #Direction_Left + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Root_Left)) + Case #Direction_Top + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Root_Top)) + Case #Direction_Right + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Root_Right)) + Case #Direction_Bottom + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Root_Bottom)) + Case #Direction_Inside + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Root_Inside)) + EndSelect + Else + Select Direction + Case #Direction_Left + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Left)) + Case #Direction_Top + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Top)) + Case #Direction_Right + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Right)) + Case #Direction_Bottom + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Bottom)) + Case #Direction_Inside + SetGadgetAttribute(\Diamond()\Gadget_Canvas, #PB_Canvas_Image, ImageID(Image_Diamond_Tabbed)) + EndSelect + EndIf + + EndWith + EndProcedure + + Procedure Diamond_Delete(*Gadget.GADGET, *Diamond.Diamond) + If Not *Gadget + ProcedureReturn #Null + EndIf + If Not *Diamond + ProcedureReturn #Null + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + FreeGadget(*Diamond\Gadget_Canvas) + + ;unBindEvent(#PB_Event_MoveWindow, @Window_Callback_Move(), *Diamond\Window) + CloseWindow(*Diamond\Window) + + ForEach \Diamond() + If \Diamond() = *Diamond + DeleteElement(\Diamond()) + Break + EndIf + Next + + EndWith + EndProcedure + + Procedure Diamond_Get_By_Coordinate(*Gadget.GADGET, X, Y) + If Not *Gadget + ProcedureReturn #Null + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + ForEach \Diamond() + If X >= \Diamond()\X And X < \Diamond()\X + #Diamond_Size And Y >= \Diamond()\Y And Y < \Diamond()\Y + #Diamond_Size + ProcedureReturn \Diamond() + EndIf + Next + EndWith + ProcedureReturn #Null + EndProcedure + + Procedure Window_Callback(hWnd, Message, wParam, lParam) + Protected *Window.Window = Window_Get_By_Handle(hWnd) + Protected *params.GADGET_PARAMS + Protected *Container.Container + Protected *Diamond.Diamond + Protected *Rect.RECT + Protected rect.RECT + Protected *Points.POINTS + Protected Center_X.l, Center_Y.l + + If Not *Window + ProcedureReturn #PB_ProcessPureBasicEvents + EndIf + + Select Message + Case #WM_PARENTNOTIFY ; #WM_PARENTNOTIFY because of the canvas gadget + If *Window\Container + _Window_Set_Active(*Window\Gadget, *Window, #True) + EndIf + + Case #WM_ACTIVATE + *params = GetParams(*Window\Gadget) + With *params + Select wParam + Case #WA_ACTIVE + _Window_Set_Active(*Window\Gadget, *Window, #False) + Case #WA_CLICKACTIVE + _Window_Set_Active(*Window\Gadget, *Window, #False) + Case #WA_INACTIVE + If \Active_Window = *Window + _Window_Set_Active(*Window\Gadget, #Null, #False) + EndIf + EndSelect + EndWith + + Case #WM_EXITSIZEMOVE + *params = GetParams(*Window\Gadget) + With *params + If *Window\Mouse_Drag = #True + *Window\Mouse_Drag = #False + + SetWindowLong_(*Window\hWnd,#GWL_EXSTYLE,GetWindowLong_(*Window\hWnd, #GWL_EXSTYLE) & ~#WS_EX_LAYERED) + + *Window\Mouse_Drag_Container = #Null + + *Diamond = Diamond_Get_By_Coordinate(*Window\Gadget, *Window\Mouse_Drag_X, *Window\Mouse_Drag_Y) + If *Diamond + _Docker_Add(*Window\Gadget, *Diamond\Container, *Diamond\Direction, *Window) + EndIf + + ForEach \Diamond() + Diamond_Delete(*Window\Gadget, \Diamond()) + Next + EndIf + EndWith + + Case #WM_MOVING + *params = GetParams(*Window\Gadget) + With *params + *Rect = lParam + GetWindowRect_(GadgetID(*params\Root\Gadget_Container), rect) + If *Window\Mouse_Drag = #False + *Window\Mouse_Drag = #True + If ListSize(\Root\Container()) = 0 + Diamond_Create(*Window\Gadget, \Root, (rect\left+rect\right)/2-#Diamond_Size/2, (rect\top+rect\bottom)/2-#Diamond_Size/2, #Direction_Inside, *Window\hWnd) + Else + Diamond_Create(*Window\Gadget, \Root, rect\left, (rect\top+rect\bottom)/2-#Diamond_Size/2, #Direction_Left, *Window\hWnd) + Diamond_Create(*Window\Gadget, \Root, (rect\left+rect\right)/2-#Diamond_Size/2, rect\top, #Direction_Top, *Window\hWnd) + Diamond_Create(*Window\Gadget, \Root, rect\right-#Diamond_Size, (rect\top+rect\bottom)/2-#Diamond_Size/2, #Direction_Right, *Window\hWnd) + Diamond_Create(*Window\Gadget, \Root, (rect\left+rect\right)/2-#Diamond_Size/2, rect\bottom-#Diamond_Size, #Direction_Bottom, *Window\hWnd) + EndIf + EndIf + *Window\Mouse_Drag_X = *Rect\left + *Window\Mouse_Drag_X_Offset + *Window\Mouse_Drag_Y = *Rect\top + *Window\Mouse_Drag_Y_Offset + *Diamond = Diamond_Get_By_Coordinate(*Window\Gadget, *Window\Mouse_Drag_X, *Window\Mouse_Drag_Y) + If *Diamond + SetWindowLong_(*Window\hWnd,#GWL_EXSTYLE,GetWindowLong_(*Window\hWnd, #GWL_EXSTYLE) | #WS_EX_LAYERED) + SetLayeredWindowAttributes_(*Window\hWnd,0,127,#LWA_ALPHA) + Else + SetWindowLong_(*Window\hWnd,#GWL_EXSTYLE,GetWindowLong_(*Window\hWnd, #GWL_EXSTYLE) & ~#WS_EX_LAYERED) + ;SetLayeredWindowAttributes_(*Window\hWnd,0,255,#LWA_ALPHA) + *Container = Container_Get_By_Coordinate(*Window\Gadget, *params\Root, *Window\Mouse_Drag_X - rect\left, *Window\Mouse_Drag_Y - rect\top) + If *Window\Mouse_Drag_Container <> *Container + If *Container <> *Window\Mouse_Drag_Container + ForEach \Diamond() + If \Diamond()\Container = *Window\Mouse_Drag_Container + Diamond_Delete(*Window\Gadget, \Diamond()) + EndIf + Next + EndIf + *Window\Mouse_Drag_Container = *Container + If *Container And *Container\Type = #Container_Type_Docker + Center_X = *Container\X + *Container\Width/2 + rect\left + Center_Y = *Container\Y + *Container\Height/2 + rect\top + Diamond_Create(*Window\Gadget, *Container, Center_X - #Diamond_Size/2, Center_Y - #Diamond_Size/2, #Direction_Inside, *Window\hWnd) + Diamond_Create(*Window\Gadget, *Container, Center_X - #Diamond_Size/2 - #Diamond_Size, Center_Y - #Diamond_Size/2, #Direction_Left, *Window\hWnd) + Diamond_Create(*Window\Gadget, *Container, Center_X - #Diamond_Size/2, Center_Y - #Diamond_Size/2 - #Diamond_Size, #Direction_Top, *Window\hWnd) + Diamond_Create(*Window\Gadget, *Container, Center_X - #Diamond_Size/2 + #Diamond_Size, Center_Y - #Diamond_Size/2, #Direction_Right, *Window\hWnd) + Diamond_Create(*Window\Gadget, *Container, Center_X - #Diamond_Size/2, Center_Y - #Diamond_Size/2 + #Diamond_Size, #Direction_Bottom, *Window\hWnd) + EndIf + EndIf + EndIf + EndWith + + Case #WM_NCLBUTTONDOWN + GetWindowRect_(hWnd, rect) + *Points = @lParam + *Window\Mouse_Drag_X_Offset = *Points\x - rect\left + *Window\Mouse_Drag_Y_Offset = *Points\y - rect\top + + EndSelect + + If *Window\Callback + ProcedureReturn *Window\Callback(hWnd, Message, wParam, lParam) + Else + ProcedureReturn #PB_ProcessPureBasicEvents + EndIf + EndProcedure + + Procedure Window_Add(Gadget, X, Y, Width, Height, Title.s, Flags, Resize_Priority.l=0) + Protected *Gadget.GADGET = IsGadget(Gadget) + If Not *Gadget + ProcedureReturn #Null + EndIf + Protected Window.i + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + AddElement(\Window()) + + PushListPosition(\Window()) + Window = OpenWindow(#PB_Any, X, Y, Width, Height, Title, #PB_Window_Tool | #PB_Window_SystemMenu | Flags, WindowID(\Parent_Window)) + PopListPosition(\Window()) + + \Window()\Window = Window + \Window()\hWnd = WindowID(\Window()\Window) + \Window()\Gadget = *Gadget + ;SetWindowData(\Window()\Window, \Window()) + SetWindowCallback(@Window_Callback(), \Window()\Window) + + SmartWindowRefresh(\Window()\Window, #True) + + \Window()\Resize_Priority = Resize_Priority + + \Window()\Flags_Normal = GetWindowLong_(\Window()\hWnd, #GWL_STYLE) + \Window()\Flags_Docked = \Window()\Flags_Normal + \Window()\Flags_Docked & ~#WS_POPUP + \Window()\Flags_Docked & ~#WS_SIZEBOX + \Window()\Flags_Docked & ~#WS_DLGFRAME + \Window()\Flags_Docked & ~#WS_BORDER + \Window()\Flags_Docked | #WS_CHILD + + _Window_Set_Active(*Gadget, \Window(), #False) + + If \Window()\Flags_Normal & #WS_SIZEBOX + _Window_Bounds(*Gadget, \Window(), #PB_Default, #PB_Default, #PB_Default, #PB_Default) + Else + \Window()\Min_Width = Width + \Window()\Min_Height = Height + \Window()\Max_Width = \Window()\Min_Width + \Window()\Max_Height = \Window()\Min_Height + EndIf + + ProcedureReturn \Window()\Window + EndWith + EndProcedure + + Procedure _Window_Close(*Gadget.GADGET, *Window.Window) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Window + ProcedureReturn #False + EndIf + Protected *Container.Container + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + If \Active_Window = *Window + _Window_Set_Active(*Gadget, #Null) + EndIf + + SetWindowCallback(#Null, *Window\Window) + CloseWindow(*Window\Window) : *Window\Window = 0 + + *Container = *Window\Container + + If ChangeCurrentElement(\Window(), *Window) + DeleteElement(\Window()) + EndIf + + If *Container + _Container_Delete(*Gadget, *Window\Container) + EndIf + + EndWith + EndProcedure + + Procedure Window_Close(Window) + Protected *Window.Window = Window_Get_By_Number(Window) + If Not *Window + ProcedureReturn #False + EndIf + ProcedureReturn _Window_Close(*Window\Gadget, *Window) + EndProcedure + + Procedure _Window_Bounds(*Gadget.GADGET, *Window.Window, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Window + ProcedureReturn #False + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + If Min_Width = #PB_Default : Min_Width = GetSystemMetrics_(#SM_CXMINTRACK) : EndIf + If Min_Height = #PB_Default : Min_Height = GetSystemMetrics_(#SM_CYMINTRACK) : EndIf + If Max_Width = #PB_Default : Max_Width = GetSystemMetrics_(#SM_CXMAXTRACK) : EndIf + If Max_Height = #PB_Default : Max_Height = GetSystemMetrics_(#SM_CYMAXTRACK) : EndIf + If *Window\Flags_Normal & #WS_SIZEBOX + *Window\Min_Width = Min_Width + *Window\Min_Height = Min_Height + *Window\Max_Width = Max_Width + *Window\Max_Height = Max_Height + WindowBounds(*Window\Window, Min_Width, Min_Height, Max_Width, Max_Height) + Else + *Window\Min_Width = WindowWidth(*Window\Window) + *Window\Min_Height = WindowHeight(*Window\Window) + *Window\Max_Width = *Window\Min_Width + *Window\Max_Height = *Window\Min_Height + EndIf + + If *Window\Container + Container_Update_Limits(*Gadget, *Window\Container) + ;Container_Resize(*Gadget, *Window\Container, *Window\Container\X, *Window\Container\Y, *Window\Container\Width, *Window\Container\Height) + Container_Resize(*Gadget, \Root, 0, 0, GadgetWidth(\Root\Gadget_Container), GadgetHeight(\Root\Gadget_Container)) + EndIf + + EndWith + EndProcedure + + Procedure Window_Bounds(Window, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) + Protected *Window.Window = Window_Get_By_Number(Window) + If Not *Window + ProcedureReturn #False + EndIf + ProcedureReturn _Window_Bounds(*Window\Gadget, *Window, Min_Width, Min_Height, Max_Width, Max_Height) + EndProcedure + + Procedure _Window_Set_Active(*Gadget.GADGET, *Window.Window, Post_Event=#False) + If Not *Gadget + ProcedureReturn #False + EndIf + Protected *Old_Container.Container + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + If \Active_Window + *Old_Container = \Active_Window\Container + EndIf + + \Active_Window = *Window + + ; #### Redraw the previously active container + If *Old_Container + Container_Docker_Redraw(*Gadget, *Old_Container) + EndIf + + ; #### Redraw the active container + If *Window + If *Window\Container + ;SetActiveWindow(\Parent_Window) + Container_Docker_Redraw(*Gadget, *Window\Container) + If Post_Event + PostEvent(#PB_Event_ActivateWindow, *Window\Window, 0) + EndIf + Else + SetActiveWindow(*Window\Window) + EndIf + EndIf + + EndWith + EndProcedure + + Procedure Window_Set_Active(Window) + Protected *Window.Window = Window_Get_By_Number(Window) + If Not *Window + ProcedureReturn #False + EndIf + ProcedureReturn _Window_Set_Active(*Window\Gadget, *Window, #True) + EndProcedure + + Procedure Window_Get_Active(Gadget) + Protected *Gadget.GADGET = IsGadget(Gadget) + If Not *Gadget + ProcedureReturn 0 + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + If \Active_Window + ProcedureReturn \Active_Window\Window + Else + ProcedureReturn 0 + EndIf + EndWith + EndProcedure + + Procedure Window_Set_Callback(Window, *Callback) + Protected *Window.Window = Window_Get_By_Number(Window) + If Not *Window + ProcedureReturn #False + EndIf + *Window\Callback = *Callback + ProcedureReturn #True + EndProcedure + + Procedure Window_Get_Container(Window) + Protected *Window.Window = Window_Get_By_Number(Window) + If Not *Window + ProcedureReturn #Null + EndIf + + ProcedureReturn *Window\Container + EndProcedure + + Procedure.i Window_Get_By_Handle(hWnd) + Protected *manager.GADGET_MANAGER=GetManager() + Protected *params.GADGET_PARAMS + ForEach *manager\GadgetParams() + *params = *manager\GadgetParams() + ForEach *params\Window() + If *params\Window()\hWnd = hWnd + ProcedureReturn *params\Window() + EndIf + Next + Next + ProcedureReturn #Null + EndProcedure + + Procedure.i Window_Get_By_Number(Window) + Protected *manager.GADGET_MANAGER=GetManager() + Protected *params.GADGET_PARAMS + ForEach *manager\GadgetParams() + *params = *manager\GadgetParams() + ForEach *params\Window() + If *params\Window()\Window = Window + ProcedureReturn *params\Window() + EndIf + Next + Next + ProcedureReturn #Null + EndProcedure + + Procedure Container_Docker_Button_Redraw(*Button.Canvas_Button) + DrawingMode(#PB_2DDrawing_Default) + Select *Button\State + Case #Canvas_Button_State_Hover + Box(*Button\X, *Button\Y, *Button\Width, *Button\Height, #Color_Button_Hover) + Case #Canvas_Button_State_Pressed + Box(*Button\X, *Button\Y, *Button\Width, *Button\Height, #Color_Button_Pressed) + EndSelect + + DrawingMode(#PB_2DDrawing_AlphaBlend) + + DrawImage(ImageID(*Button\Image), *Button\X, *Button\Y) + EndProcedure + + Procedure Container_Docker_Redraw(*Gadget.GADGET, *Container.Container) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + If StartDrawing(CanvasOutput(*Container\Gadget_Canvas)) + If *Container\Window And \Active_Window = *Container\Window + Box(0, 0, *Container\Width, *Container\Height, #Color_Docker_Background_Active) + Else + Box(0, 0, *Container\Width, *Container\Height, #Color_Docker_Background) + EndIf + DrawingMode(#PB_2DDrawing_Transparent) + DrawingFont(\FontID) + DrawText(1, 1, *Container\Title, 0) + If *Container\Window And \Active_Window = *Container\Window + Box(*Container\Width-32, 0, 32, *Container\Height, #Color_Docker_Background_Active) + Else + Box(*Container\Width-32, 0, 32, *Container\Height, #Color_Docker_Background) + EndIf + Container_Docker_Button_Redraw(*Container\Docker_Button_Close) + Container_Docker_Button_Redraw(*Container\Docker_Button_Undock) + StopDrawing() + EndIf + EndWith + EndProcedure + + Procedure Container_Docker_Button_Handler(*Gadget.GADGET, *Container.Container, *Button.Canvas_Button) + Protected Event_Type = EventType() + Protected X, Y + Protected Result = #False + Protected Changed = #False + + Select Event_Type + Case #PB_EventType_LeftButtonDown + X = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseX) + Y = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseY) + If X >= *Button\X And Y >= *Button\Y And X < *Button\X + *Button\Width And Y < *Button\Y + *Button\Height + *Button\State = #Canvas_Button_State_Pressed : Changed = #True + EndIf + + Case #PB_EventType_MouseMove + X = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseX) + Y = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseY) + If X >= *Button\X And Y >= *Button\Y And X < *Button\X + *Button\Width And Y < *Button\Y + *Button\Height + Select *Button\State + Case #Canvas_Button_State_Pressed_Outside : *Button\State = #Canvas_Button_State_Pressed : Changed = #True + Case #Canvas_Button_State_Normal : *Button\State = #Canvas_Button_State_Hover : Changed = #True + EndSelect + Else + Select *Button\State + Case #Canvas_Button_State_Pressed : *Button\State = #Canvas_Button_State_Pressed_Outside : Changed = #True + Case #Canvas_Button_State_Hover : *Button\State = #Canvas_Button_State_Normal : Changed = #True + EndSelect + EndIf + + Case #PB_EventType_MouseLeave + Select *Button\State + Case #Canvas_Button_State_Hover : *Button\State = #Canvas_Button_State_Normal : Changed = #True + EndSelect + + Case #PB_EventType_LeftButtonUp + X = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseX) + Y = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseY) + If X >= *Button\X And Y >= *Button\Y And X < *Button\X + *Button\Width And Y < *Button\Y + *Button\Height + If *Button\State = #Canvas_Button_State_Pressed + Result = #True + EndIf + *Button\State = #Canvas_Button_State_Hover : Changed = #True + Else + *Button\State = #Canvas_Button_State_Normal : Changed = #True + EndIf + + EndSelect + + If Changed + Container_Docker_Redraw(*Gadget, *Container) + EndIf + + ProcedureReturn Result + EndProcedure + + Procedure Container_Docker_Callback_Gadget_Canvas() + Protected *Container.Container = GetGadgetData(EventGadget()) + Protected Event_Type = EventType() + Protected *params.GADGET_PARAMS + + If Container_Docker_Button_Handler(*Container\Gadget, *Container, *Container\Docker_Button_Close) + If *Container\Window + PostEvent(#PB_Event_CloseWindow, *Container\Window\Window, 0) + EndIf + EndIf + If Container_Docker_Button_Handler(*Container\Gadget, *Container, *Container\Docker_Button_Undock) + If *Container\Window + _Container_Delete(*Container\Gadget, *Container) + EndIf + EndIf + + EndProcedure + + Procedure Container_Callback_Gadget_Canvas() + Protected *Container.Container = GetGadgetData(EventGadget()) + Protected Event_Type = EventType() + Protected *params.GADGET_PARAMS + Protected rect.RECT + Protected Index + Protected Difference + + Select Event_Type + Case #PB_EventType_LeftButtonDown + *Container\Drag = #True + *Container\Drag_X = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseX) + *Container\Drag_Y = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseY) + + Case #PB_EventType_MouseMove + If *Container\Parent And *Container\Drag + ForEach *Container\Parent\Container() + If *Container\Parent\Container() = *Container + Index = ListIndex(*Container\Parent\Container()) + Break + EndIf + Next + Select *Container\Parent\Type + Case #Container_Type_Split_H : Difference = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseX) - *Container\Drag_X + Case #Container_Type_Split_V : Difference = GetGadgetAttribute(EventGadget(), #PB_Canvas_MouseY) - *Container\Drag_Y + EndSelect + If Difference + Container_Resize_Between(*Container\Gadget, *Container\Parent, Index, Difference) + EndIf + EndIf + + Case #PB_EventType_LeftButtonUp + *Container\Drag = #False + ;*params = GetParams(*Container\Gadget) + ;With *params + ;GetClientRect_(GadgetID(\Root\Gadget_Container), rect) + ;InvalidateRect_(GadgetID(\Root\Gadget_Container), rect, #True) + ;EndWith + + EndSelect + + EndProcedure + + Procedure Container_Callback_Gadget_TabBar() + Protected *Container.Container = GetTabBarGadgetData(EventGadget()) + Protected Event_Type = EventType() + Protected *params.GADGET_PARAMS + Protected Index + + Select Event_Type + Case #TabBarGadget_EventType_Change + ForEach *Container\Container() + If *Container\Container() = GetTabBarGadgetItemData(EventGadget(), #TabBarGadgetItem_Event) + Container_Tabbed_Select(*Container\Gadget, *Container, ListIndex(*Container\Container()), #False) + Break + EndIf + Next + + EndSelect + + EndProcedure + + Procedure Container_Hide(*Gadget.GADGET, *Container.Container, State, Iteration=0) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + If Iteration = 0 + *Container\Hidden = State + Else + *Container\Hidden_Inherit = State + EndIf + + If *Container\Hidden_Inherit Or *Container\Hidden + State = #True + EndIf + + Select *Container\Type + Case #Container_Type_Root + ForEach *Container\Container() + Container_Hide(*Gadget, *Container\Container(), State, Iteration+1) + Next + Case #Container_Type_Docker + Select State + Case #True + If *Container\Window + HideWindow(*Container\Window\Window, #True) + EndIf + HideGadget(*Container\Gadget_Canvas, #True) + Case #False + If *Container\Window + HideWindow(*Container\Window\Window, #False) + EndIf + HideGadget(*Container\Gadget_Canvas, #False) + EndSelect + Case #Container_Type_Split_H + ForEach *Container\Container() + Container_Hide(*Gadget, *Container\Container(), State, Iteration+1) + Next + Case #Container_Type_Split_V + ForEach *Container\Container() + Container_Hide(*Gadget, *Container\Container(), State, Iteration+1) + Next + Case #Container_Type_Spliter + Select State + Case #True + HideGadget(*Container\Gadget_Canvas, #True) + Case #False + HideGadget(*Container\Gadget_Canvas, #False) + EndSelect + Case #Container_Type_Tabbed + Select State + Case #True + HideGadget(*Container\Gadget_TabBar, #True) + Case #False + HideGadget(*Container\Gadget_TabBar, #False) + EndSelect + ForEach *Container\Container() + Container_Hide(*Gadget, *Container\Container(), State, Iteration+1) + Next + + EndSelect + EndWith + EndProcedure + + Procedure Container_Tabbed_Select(*Gadget.GADGET, *Container.Container, Selection, SetGadgetState=#True) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + Protected i + Protected *Selection.Container + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + If Selection > ListSize(*Container\Container())-1 + Selection = ListSize(*Container\Container())-1 + ElseIf Selection < 0 + Selection = ListSize(*Container\Container())-1 + EndIf + + *Container\Tabbed_Selection = Selection + + ForEach *Container\Container() + If ListIndex(*Container\Container()) = *Container\Tabbed_Selection + *Selection = *Container\Container() + Container_Hide(*Gadget, *Container\Container(), #False) + _Window_Set_Active(*Gadget, *Container\Container()\Window, #True) + Else + Container_Hide(*Gadget, *Container\Container(), #True) + EndIf + Next + + ; #### Set the GadgetState + If SetGadgetState And *Selection And *Container\Gadget_TabBar + For i = 0 To CountTabBarGadgetItems(*Container\Gadget_TabBar)-1 + If GetTabBarGadgetItemData(*Container\Gadget_TabBar, i) = *Selection + SetTabBarGadgetState(*Container\Gadget_TabBar, i) + Break + EndIf + Next + EndIf + + EndWith + EndProcedure + + Procedure Container_Update_Priority(*Gadget.GADGET, *Container.Container) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + Protected Temp, Min + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + Min = *Container\Priority + PushListPosition(*Container\Container()) + ForEach *Container\Container() + Temp = Container_Update_Priority(*Gadget, *Container\Container()) + If Min < Temp + Min = Temp + EndIf + Next + PopListPosition(*Container\Container()) + *Container\Priority_Inerhit = Min + ProcedureReturn Min + EndWith + EndProcedure + + Procedure Container_Update_Limits(*Gadget.GADGET, *Container.Container) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + Select *Container\Type + Case #Container_Type_Root + *Container\Min_Width = 0 + *Container\Min_Height = 0 + *Container\Max_Width = #Container_Size_Max + *Container\Max_Height = #Container_Size_Max + If FirstElement(*Container\Container()) + *Container\Min_Width = *Container\Container()\Min_Width + *Container\Min_Height = *Container\Container()\Min_Height + *Container\Max_Width = *Container\Container()\Max_Width + *Container\Max_Height = *Container\Container()\Max_Height + EndIf + Case #Container_Type_Docker + If *Container\Window + *Container\Min_Width = *Container\Window\Min_Width + *Container\Min_Height = *Container\Window\Min_Height + #Container_Docker_Bar_Height + *Container\Max_Width = *Container\Window\Max_Width + *Container\Max_Height = *Container\Window\Max_Height + #Container_Docker_Bar_Height + Else + *Container\Min_Width = 100 + *Container\Min_Height = 100 + *Container\Max_Width = #Container_Size_Max + *Container\Max_Height = #Container_Size_Max + EndIf + + Case #Container_Type_Split_H + *Container\Min_Width = 0 + *Container\Min_Height = 0 + *Container\Max_Width = 0 + *Container\Max_Height = 0;#Container_Size_Max + ForEach *Container\Container() + *Container\Min_Width + *Container\Container()\Min_Width + *Container\Max_Width + *Container\Container()\Max_Width + If *Container\Min_Height < *Container\Container()\Min_Height + *Container\Min_Height = *Container\Container()\Min_Height + EndIf + If *Container\Max_Height < *Container\Container()\Max_Height + *Container\Max_Height = *Container\Container()\Max_Height + EndIf + Next + Case #Container_Type_Split_V + *Container\Min_Width = 0 + *Container\Min_Height = 0 + *Container\Max_Width = 0;#Container_Size_Max + *Container\Max_Height = 0 + ForEach *Container\Container() + *Container\Min_Height + *Container\Container()\Min_Height + *Container\Max_Height + *Container\Container()\Max_Height + If *Container\Min_Width < *Container\Container()\Min_Width + *Container\Min_Width = *Container\Container()\Min_Width + EndIf + If *Container\Max_Width < *Container\Container()\Max_Width + *Container\Max_Width = *Container\Container()\Max_Width + EndIf + Next + Case #Container_Type_Spliter + If *Container\Parent + Select *Container\Parent\Type + Case #Container_Type_Split_H + *Container\Min_Width = #Splitter_Size + *Container\Max_Width = #Splitter_Size + *Container\Min_Height = #Container_Size_Ignore + *Container\Max_Height = #Container_Size_Ignore + Case #Container_Type_Split_V + *Container\Min_Width = #Container_Size_Ignore + *Container\Max_Width = #Container_Size_Ignore + *Container\Min_Height = #Splitter_Size + *Container\Max_Height = #Splitter_Size + EndSelect + EndIf + Case #Container_Type_Tabbed + *Container\Min_Width = 0 + *Container\Min_Height = 0 + *Container\Max_Width = 0 + *Container\Max_Height = 0 + ForEach *Container\Container() + If *Container\Min_Width < *Container\Container()\Min_Width + *Container\Min_Width = *Container\Container()\Min_Width + EndIf + If *Container\Max_Width < *Container\Container()\Max_Width + *Container\Max_Width = *Container\Container()\Max_Width + EndIf + If *Container\Min_Height < *Container\Container()\Min_Height + #Container_Tabbed_Bar_Height + *Container\Min_Height = *Container\Container()\Min_Height + #Container_Tabbed_Bar_Height + EndIf + If *Container\Max_Height < *Container\Container()\Max_Height + #Container_Tabbed_Bar_Height + *Container\Max_Height = *Container\Container()\Max_Height + #Container_Tabbed_Bar_Height + EndIf + Next + EndSelect + ; #### Recursively go throught the tree + If *Container\Parent + Container_Update_Limits(*Gadget, *Container\Parent) + EndIf + EndWith + EndProcedure + + Procedure Container_Add(*Gadget.GADGET, X.l, Y.l, Width.l, Height.l, Type, *Window.Window=#Null) + If Not *Gadget + ProcedureReturn #Null + EndIf + Protected *Container.Container + Protected GWL_Style + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + *Container = AllocateStructure(Container) + *Container\Gadget = *Gadget + *Container\Type = Type + *Container\X = X + *Container\Y = Y + *Container\Width = Width + *Container\Height = Height + *Container\Window = *Window + + Select *Container\Type + Case #Container_Type_Docker + OpenGadgetList(\Root\Gadget_Container) + *Container\Gadget_Canvas = CanvasGadget(#PB_Any, *Container\X, *Container\Y, *Container\Width, #Container_Docker_Bar_Height) + *Container\Docker_Button_Close\Width = 16 : *Container\Docker_Button_Close\Height = 16 : *Container\Docker_Button_Close\Image = Image_Button_Close + *Container\Docker_Button_Undock\Width = 16 : *Container\Docker_Button_Undock\Height = 16 : *Container\Docker_Button_Undock\Image = Image_Button_Undock + BindGadgetEvent(*Container\Gadget_Canvas, @Container_Docker_Callback_Gadget_Canvas()) : SetGadgetData(*Container\Gadget_Canvas, *Container) + If *Container\Window + *Container\Priority = *Container\Window\Resize_Priority + *Container\Title = GetWindowTitle(*Window\Window) + *Container\Window\Container = *Container + EndIf + CloseGadgetList() + If *Container\Window + SetWindowLong_(*Container\Window\hWnd, #GWL_STYLE, *Container\Window\Flags_Docked) + SetParent_(*Container\Window\hWnd, GadgetID(\Root\Gadget_Container)) + ResizeWindow(*Container\Window\Window, *Container\X, *Container\Y+#Container_Docker_Bar_Height, *Container\Width, *Container\Height-#Container_Docker_Bar_Height) + PostEvent(#PB_Event_SizeWindow, *Container\Window\Window, 0) + EndIf + + Case #Container_Type_Split_H + + Case #Container_Type_Split_V + + Case #Container_Type_Spliter + OpenGadgetList(\Root\Gadget_Container) + *Container\Gadget_Canvas = CanvasGadget(#PB_Any, *Container\X, *Container\Y, *Container\Width, *Container\Height) + BindGadgetEvent(*Container\Gadget_Canvas, @Container_Callback_Gadget_Canvas()) : SetGadgetData(*Container\Gadget_Canvas, *Container) + CloseGadgetList() + + Case #Container_Type_Tabbed + OpenGadgetList(\Root\Gadget_Container) + *Container\Gadget_TabBar = TabBarGadget(#PB_Any, *Container\X, *Container\Y, *Container\Width, #Container_Tabbed_Bar_Height, #TabBarGadget_None, \Parent_Window) + BindGadgetEvent(*Container\Gadget_TabBar, @Container_Callback_Gadget_TabBar()) : SetTabBarGadgetData(*Container\Gadget_TabBar, *Container) + CloseGadgetList() + + Default + FreeStructure(*Container) : *Container = #Null + EndSelect + EndWith + + ; #### Merge containers of the same type + ForEach *Container\Container() + If *Container\Container()\Type = *Container\Type + Container_Merge_To_Parent(*Gadget, *Container\Container()) + EndIf + Next + + ProcedureReturn *Container + EndProcedure + + Procedure _Container_Delete(*Gadget.GADGET, *Container.Container, Iteration=0) + If Not *Gadget + ProcedureReturn #Null + EndIf + If Not *Container + ProcedureReturn #Null + EndIf + Protected Splitter_Bool + Protected rect.RECT + Protected i + Protected Active_Gadget.i + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + ForEach *Container\Container() + _Container_Delete(*Gadget, *Container\Container(), Iteration+1) + Next + + If *Container\Parent + ; #### Remove pointer from the parent + ForEach *Container\Parent\Container() + If *Container\Parent\Container() = *Container + DeleteElement(*Container\Parent\Container()) + Break + EndIf + Next + + ; #### Remove tab if the parent is #Container_Type_Tabbed + If *Container\Parent\Type = #Container_Type_Tabbed And *Container\Parent\Gadget_TabBar + For i = 0 To CountTabBarGadgetItems(*Container\Parent\Gadget_TabBar)-1 + If GetTabBarGadgetItemData(*Container\Parent\Gadget_TabBar, i) = *Container + RemoveTabBarGadgetItem(*Container\Parent\Gadget_TabBar, i) + Container_Tabbed_Select(*Gadget, *Container\Parent, *Container\Parent\Tabbed_Selection) + Break + EndIf + Next + EndIf + EndIf + + ; #### Remove splitters + If *Container\Parent And Iteration = 0 + Splitter_Bool = #False + ForEach *Container\Parent\Container() + Select *Container\Parent\Container()\Type + Case #Container_Type_Spliter + If Splitter_Bool = #False Or ListIndex(*Container\Parent\Container()) = ListSize(*Container\Parent\Container())-1 + _Container_Delete(*Gadget, *Container\Parent\Container(), Iteration+1) + ;FirstElement(*Container\Parent\Container()) + EndIf + Splitter_Bool = #False + Default + Splitter_Bool = #True + EndSelect + Next + EndIf + + ; #### Update limits and resize + If *Container\Parent And Iteration = 0 + Container_Update_Limits(*Gadget, *Container\Parent) + Container_Resize(*Gadget, \Root, 0, 0, GadgetWidth(\Root\Gadget_Container), GadgetHeight(\Root\Gadget_Container)) + EndIf + + ; #### Clean tree + If *Container\Parent And Iteration = 0 + If ListSize(*Container\Parent\Container()) < 2 + Container_Merge_To_Parent(*Gadget, *Container\Parent) + EndIf + EndIf + + ; #### Unregister events, Unparent window + Select *Container\Type + Case #Container_Type_Docker + If IsGadget(*Container\Gadget_Canvas) : UnbindGadgetEvent(*Container\Gadget_Canvas, @Container_Docker_Callback_Gadget_Canvas()) : EndIf + If *Container\Window And IsWindow(*Container\Window\Window) + GetWindowRect_(GadgetID(\Root\Gadget_Container), rect) + Active_Gadget = GetActiveGadget() + SetWindowLong_(*Container\Window\hWnd, #GWL_STYLE, *Container\Window\Flags_Normal) + SetParent_(*Container\Window\hWnd, #Null) + If Active_Gadget : SetActiveGadget(Active_Gadget) : EndIf + rect\left + *Container\X + rect\top + *Container\Y + #Container_Docker_Bar_Height + rect\right = rect\left + *Container\Width + rect\bottom = rect\top + *Container\Height - #Container_Docker_Bar_Height + AdjustWindowRectEx_(rect, GetWindowLong_(*Container\Window\hWnd, #GWL_STYLE), #Null, GetWindowLong_(*Container\Window\hWnd, #GWL_EXSTYLE)) + ResizeWindow(*Container\Window\Window, rect\left, rect\top, *Container\Width, *Container\Height-#Container_Docker_Bar_Height) + *Container\Window\Container = #Null + EndIf + + Case #Container_Type_Spliter + If IsGadget(*Container\Gadget_Canvas) : UnbindGadgetEvent(*Container\Gadget_Canvas, @Container_Callback_Gadget_Canvas()) : EndIf + + Case #Container_Type_Tabbed + If IsGadget(*Container\Gadget_TabBar) : UnbindGadgetEvent(*Container\Gadget_TabBar, @Container_Callback_Gadget_TabBar()) : EndIf + + EndSelect + + ; #### Free gadgets.... + If IsGadget(*Container\Gadget_Canvas) : FreeGadget(*Container\Gadget_Canvas) : EndIf + If IsGadget(*Container\Gadget_Text) : FreeGadget(*Container\Gadget_Text) : EndIf + If IsGadget(*Container\Gadget_Container) : FreeGadget(*Container\Gadget_Container) : EndIf + If IsGadget(*Container\Gadget_TabBar) : FreeTabBarGadget(*Container\Gadget_TabBar) : EndIf + + FreeStructure(*Container) + + EndWith + EndProcedure + + Procedure Container_Delete(Gadget, *Container.Container) + ProcedureReturn _Container_Delete(IsGadget(Gadget), *Container) + EndProcedure + + Procedure Container_Get_By_Coordinate(*Gadget.GADGET, *Container.Container, X, Y) + If Not *Gadget + ProcedureReturn #Null + EndIf + If Not *Container + ProcedureReturn #Null + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + If X >= *Container\X And Y >= *Container\Y And X < *Container\X + *Container\Width And Y < *Container\Y + *Container\Height And *Container\Hidden = #False And *Container\Hidden_Inherit = #False + ForEach *Container\Container() + If X >= *Container\Container()\X And Y >= *Container\Container()\Y And X < *Container\Container()\X + *Container\Container()\Width And Y < *Container\Container()\Y + *Container\Container()\Height And *Container\Container()\Hidden = #False And *Container\Container()\Hidden_Inherit = #False + ProcedureReturn Container_Get_By_Coordinate(*Gadget, *Container\Container(), X, Y) + EndIf + Next + + ProcedureReturn *Container + EndIf + EndWith + + ProcedureReturn #Null + EndProcedure + + Procedure Container_Merge_To_Parent(*Gadget.GADGET, *Container.Container) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + If Not *Container\Parent + ProcedureReturn #False + EndIf + Protected List_Index + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + ForEach *Container\Parent\Container() + If *Container\Parent\Container() = *Container + List_Index = ListIndex(*Container\Parent\Container()) + Break + EndIf + Next + While LastElement(*Container\Container()) + Container_Set_Parent(*Gadget, *Container\Container(), *Container\Parent, List_Index) + Wend + + _Container_Delete(*Gadget, *Container) + + ; #### Merge containers of the same type + If *Container\Parent + ForEach *Container\Parent\Container() + If *Container\Parent\Container()\Type = *Container\Parent\Type + Container_Merge_To_Parent(*Gadget, *Container\Parent\Container()) + EndIf + Next + EndIf + + EndWith + EndProcedure + + Procedure Container_Set_Parent(*Gadget.GADGET, *Container.Container, *Parent.Container, Position) + If Not *Gadget + ProcedureReturn #Null + EndIf + If Not *Container + ProcedureReturn #Null + EndIf + If Not *Parent + ProcedureReturn #Null + EndIf + Protected Index, i + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + If *Container\Parent + ; #### Detach from old parent + ForEach *Container\Parent\Container() + If *Container\Parent\Container() = *Container + DeleteElement(*Container\Parent\Container()) + Break + EndIf + Next + Container_Update_Limits(*Gadget, *Container\Parent) + + ; #### Remove tab if the parent is #Container_Type_Tabbed + If *Container\Parent\Type = #Container_Type_Tabbed And *Container\Parent\Gadget_TabBar + For i = 0 To CountTabBarGadgetItems(*Container\Parent\Gadget_TabBar)-1 + If GetTabBarGadgetItemData(*Container\Parent\Gadget_TabBar, i) = *Container + RemoveTabBarGadgetItem(*Container\Parent\Gadget_TabBar, i) + Break + EndIf + Next + EndIf + EndIf + + *Container\Parent = *Parent + If Position >= 0 And SelectElement(*Container\Parent\Container(), Position) + InsertElement(*Container\Parent\Container()) + Else + LastElement(*Container\Parent\Container()) + AddElement(*Container\Parent\Container()) + EndIf + *Container\Parent\Container() = *Container + + Select *Container\Parent\Type + Case #Container_Type_Tabbed + Index = AddTabBarGadgetItem(*Container\Parent\Gadget_TabBar, #PB_Default, *Container\Title) + SetTabBarGadgetItemData(*Container\Parent\Gadget_TabBar, Index, *Container) + Container_Tabbed_Select(*Gadget, *Container\Parent, Position) + ;UpdateTabBarGadget(*Container\Parent\Gadget_TabBar) + + EndSelect + + Container_Hide(*Gadget, *Container\Parent, *Container\Parent\Hidden) + + Container_Update_Priority(*Gadget, \Root) + Container_Update_Limits(*Gadget, *Container) + ;Container_Resize(*Gadget, \Root, 0, 0, GadgetWidth(\Root\Gadget_Container), GadgetHeight(\Root\Gadget_Container)) + + EndWith + EndProcedure + + Procedure Container_Resize(*Gadget.GADGET, *Container.Container, X.l, Y.l, Width.d, Height.d, *Resize_Lowpriority.Container=#Null, Iteration=0) + If Not *Gadget + ProcedureReturn #False + EndIf + If Not *Container + ProcedureReturn #False + EndIf + ;Protected Effective_Size.d + Protected Position + Protected Scale.d, Total_Size.l + ;Protected Temp_Size.d, Position.d + Protected Old_Size, Difference + Protected Found + Protected NewList Temp_Size.Temp_Size() + Protected NewList Priority.l() + Protected hWnd, rect.RECT + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + If Width < 0 : Width = 0 : EndIf + If Height < 0 : Height = 0 : EndIf + If *Container\Min_Width >= 0 And Width < *Container\Min_Width : Width = *Container\Min_Width : EndIf + If *Container\Min_Height >= 0 And Height < *Container\Min_Height : Height = *Container\Min_Height : EndIf + If *Container\Max_Width >= 0 And Width > *Container\Max_Width : Width = *Container\Max_Width : EndIf + If *Container\Max_Height >= 0 And Height > *Container\Max_Height : Height = *Container\Max_Height : EndIf + + If Iteration = 0 + SendMessage_(GadgetID(\Root\Gadget_Container), #WM_SETREDRAW, #False, 0) + EndIf + + Select *Container\Type + Case #Container_Type_Root + ForEach *Container\Container() + Container_Resize(*Gadget, *Container\Container(), X, Y, Width, Height, *Resize_Lowpriority, Iteration+1) + Next + + Case #Container_Type_Split_H + ForEach *Container\Container() + AddElement(Temp_Size()) + Temp_Size()\Container = *Container\Container() + Temp_Size()\Min_Size = *Container\Container()\Min_Width + Temp_Size()\Max_Size = *Container\Container()\Max_Width + If Temp_Size()\Container = *Resize_Lowpriority + Temp_Size()\Priority = -2147483648 + Else + Temp_Size()\Priority = *Container\Container()\Priority_Inerhit + EndIf + Temp_Size()\Size = *Container\Container()\Width + If Temp_Size()\Min_Size >= 0 And Temp_Size()\Size < Temp_Size()\Min_Size : Temp_Size()\Size = Temp_Size()\Min_Size : EndIf + If Temp_Size()\Max_Size >= 0 And Temp_Size()\Size > Temp_Size()\Max_Size : Temp_Size()\Size = Temp_Size()\Max_Size : EndIf + Old_Size + Temp_Size()\Size + Found = #False + ForEach Priority() + If Priority() = Temp_Size()\Priority + Found = #True + Break + EndIf + Next + If Not Found + AddElement(Priority()) + Priority() = Temp_Size()\Priority + EndIf + Next + + Difference = Width - Old_Size + + SortList(Priority(), #PB_Sort_Descending) + + ForEach Priority() + Repeat + Found = #False + Total_Size = 0 + ; #### Get the total size of all elements of a specific priority + ForEach Temp_Size() + If Temp_Size()\Priority = Priority() And Not Temp_Size()\Finished + Total_Size + Temp_Size()\Size + EndIf + Next + Scale = Difference / Total_Size + ; #### Scale the elements of a specific priority + ForEach Temp_Size() + If Temp_Size()\Priority = Priority() And Not Temp_Size()\Finished + + Difference - Temp_Size()\Size * Scale + Temp_Size()\Size * (Scale + 1) + If Temp_Size()\Size < Temp_Size()\Min_Size + Found = #True + Difference + (Temp_Size()\Size - Temp_Size()\Min_Size) + Temp_Size()\Size = Temp_Size()\Min_Size + Temp_Size()\Finished = #True + ElseIf Temp_Size()\Max_Size >= 0 And Temp_Size()\Size > Temp_Size()\Max_Size + Found = #True + Difference + (Temp_Size()\Size - Temp_Size()\Max_Size) + Temp_Size()\Size = Temp_Size()\Max_Size + Temp_Size()\Finished = #True + EndIf + EndIf + Next + + Until Not Found + Next + + Position = X + ForEach Temp_Size() + Container_Resize(*Gadget, Temp_Size()\Container, Position, Y, Temp_Size()\Size, Height, *Resize_Lowpriority, Iteration+1) + Position + Temp_Size()\Size + Next + + Case #Container_Type_Split_V + ForEach *Container\Container() + AddElement(Temp_Size()) + Temp_Size()\Container = *Container\Container() + Temp_Size()\Min_Size = *Container\Container()\Min_Height + Temp_Size()\Max_Size = *Container\Container()\Max_Height + If Temp_Size()\Container = *Resize_Lowpriority + Temp_Size()\Priority = -2147483648 + Else + Temp_Size()\Priority = *Container\Container()\Priority_Inerhit + EndIf + Temp_Size()\Size = *Container\Container()\Height + If Temp_Size()\Min_Size >= 0 And Temp_Size()\Size < Temp_Size()\Min_Size : Temp_Size()\Size = Temp_Size()\Min_Size : EndIf + If Temp_Size()\Max_Size >= 0 And Temp_Size()\Size > Temp_Size()\Max_Size : Temp_Size()\Size = Temp_Size()\Max_Size : EndIf + Old_Size + Temp_Size()\Size + Found = #False + ForEach Priority() + If Priority() = Temp_Size()\Priority + Found = #True + Break + EndIf + Next + If Not Found + AddElement(Priority()) + Priority() = Temp_Size()\Priority + EndIf + Next + + Difference = Height - Old_Size + + SortList(Priority(), #PB_Sort_Descending) + + ForEach Priority() + Repeat + Found = #False + Total_Size = 0 + ; #### Get the total size of all elements of a specific priority + ForEach Temp_Size() + If Temp_Size()\Priority = Priority() And Not Temp_Size()\Finished + Total_Size + Temp_Size()\Size + EndIf + Next + Scale = Difference / Total_Size + ; #### Scale the elements of a specific priority + ForEach Temp_Size() + If Temp_Size()\Priority = Priority() And Not Temp_Size()\Finished + + Difference - Temp_Size()\Size * Scale + Temp_Size()\Size * (Scale + 1) + If Temp_Size()\Size < Temp_Size()\Min_Size + Found = #True + Difference + (Temp_Size()\Size - Temp_Size()\Min_Size) + Temp_Size()\Size = Temp_Size()\Min_Size + Temp_Size()\Finished = #True + ElseIf Temp_Size()\Max_Size >= 0 And Temp_Size()\Size > Temp_Size()\Max_Size + Found = #True + Difference + (Temp_Size()\Size - Temp_Size()\Max_Size) + Temp_Size()\Size = Temp_Size()\Max_Size + Temp_Size()\Finished = #True + EndIf + EndIf + Next + + Until Not Found + Next + + Position = Y + ForEach Temp_Size() + Container_Resize(*Gadget, Temp_Size()\Container, X, Position, Width, Temp_Size()\Size, *Resize_Lowpriority, Iteration+1) + Position + Temp_Size()\Size + Next + + Case #Container_Type_Spliter + If *Container\Parent + Select *Container\Parent\Type + Case #Container_Type_Split_H + ;Height = *Container\Parent\Height + SetGadgetAttribute(*Container\Gadget_Canvas, #PB_Canvas_Cursor, #PB_Cursor_LeftRight) + Case #Container_Type_Split_V + ;Width = *Container\Parent\Width + SetGadgetAttribute(*Container\Gadget_Canvas, #PB_Canvas_Cursor, #PB_Cursor_UpDown) + EndSelect + EndIf + + Case #Container_Type_Tabbed + ForEach *Container\Container() + Container_Resize(*Gadget, *Container\Container(), X, Y+#Container_Tabbed_Bar_Height, Width, Height-#Container_Tabbed_Bar_Height, *Resize_Lowpriority, Iteration+1) + Next + + EndSelect + + ;If *Container\X <> X Or *Container\Y <> Y Or *Container\Width <> Width Or *Container\Height <> Height + *Container\X = X + *Container\Y = Y + *Container\Width = Width + *Container\Height = Height + + Select *Container\Type + Case #Container_Type_Docker + ResizeGadget(*Container\Gadget_Canvas, *Container\X, *Container\Y, *Container\Width, #Container_Docker_Bar_Height) + *Container\Docker_Button_Close\X = *Container\Width - 16 + *Container\Docker_Button_Undock\X = *Container\Width - 32 + Container_Docker_Redraw(*Gadget, *Container) + If *Container\Window + ResizeWindow(*Container\Window\Window, *Container\X, *Container\Y+#Container_Docker_Bar_Height, *Container\Width, *Container\Height-#Container_Docker_Bar_Height) + EndIf + + Case #Container_Type_Spliter + ResizeGadget(*Container\Gadget_Canvas, *Container\X, *Container\Y, *Container\Width, *Container\Height) + If StartDrawing(CanvasOutput(*Container\Gadget_Canvas)) + Box(0, 0, *Container\Width, *Container\Height, #Color_Splitter_Background) + If *Container\Parent + Select *Container\Parent\Type + Case #Container_Type_Split_H + ;Box(1, 0, *Container\Width-2, *Container\Height, #Color_Docker_Border) + Case #Container_Type_Split_V + ;Box(0, 1, *Container\Width, *Container\Height-2, #Color_Docker_Border) + EndSelect + EndIf + StopDrawing() + EndIf + + Case #Container_Type_Tabbed + ResizeGadget(*Container\Gadget_TabBar, *Container\X, *Container\Y, *Container\Width, #Container_Tabbed_Bar_Height) + UpdateTabBarGadget(*Container\Gadget_TabBar) + + EndSelect + ;EndIf + + ; TODO: Fix flickering when resizing window + If Iteration = 0 + SendMessage_(GadgetID(\Root\Gadget_Container), #WM_SETREDRAW, #True, 0) + GetClientRect_(GadgetID(\Root\Gadget_Container), rect) + InvalidateRect_(GadgetID(\Root\Gadget_Container), rect, #False) + ;UpdateWindow_(GadgetID(\Root\Gadget_Container)) + EndIf + + EndWith + EndProcedure + + Procedure Container_Resize_Between(*Gadget.GADGET, *Container.Container, Index, Difference) + If Not *Gadget + ProcedureReturn 0 + EndIf + If Not *Container + ProcedureReturn 0 + EndIf + If *Container\Type <> #Container_Type_Split_H And *Container\Type <> #Container_Type_Split_V + ProcedureReturn 0 + EndIf + If Index <= 0 Or Index >= ListSize(*Container\Container()) + ProcedureReturn 0 + EndIf + Protected Temp_Size_Difference + Protected rect.RECT + Protected Position + Protected NewList Temp_Size.Temp_Size() + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + + Select *Container\Type + Case #Container_Type_Split_H + ForEach *Container\Container() + AddElement(Temp_Size()) + Temp_Size()\Container = *Container\Container() + Temp_Size()\Size = *Container\Container()\Width + Temp_Size()\Min_Size = *Container\Container()\Min_Width + Temp_Size()\Max_Size = *Container\Container()\Max_Width + Next + Case #Container_Type_Split_V + ForEach *Container\Container() + AddElement(Temp_Size()) + Temp_Size()\Container = *Container\Container() + Temp_Size()\Size = *Container\Container()\Height + Temp_Size()\Min_Size = *Container\Container()\Min_Height + Temp_Size()\Max_Size = *Container\Container()\Max_Height + Next + EndSelect + + If SelectElement(Temp_Size(), Index-1) + Temp_Size_Difference = Difference + Repeat + Temp_Size()\Size + Temp_Size_Difference + Temp_Size_Difference = 0 + If Temp_Size()\Size < Temp_Size()\Min_Size + Temp_Size_Difference = Temp_Size()\Size - Temp_Size()\Min_Size + Temp_Size()\Size = Temp_Size()\Min_Size + ElseIf Temp_Size()\Size > Temp_Size()\Max_Size + Temp_Size_Difference = Temp_Size()\Size - Temp_Size()\Max_Size + Temp_Size()\Size = Temp_Size()\Max_Size + EndIf + Until Not PreviousElement(Temp_Size()) + EndIf + + If SelectElement(Temp_Size(), Index) + Temp_Size_Difference - Difference + Repeat + Temp_Size()\Size + Temp_Size_Difference + Temp_Size_Difference = 0 + If Temp_Size()\Size < Temp_Size()\Min_Size + Temp_Size_Difference = Temp_Size()\Size - Temp_Size()\Min_Size + Temp_Size()\Size = Temp_Size()\Min_Size + ElseIf Temp_Size()\Size > Temp_Size()\Max_Size + Temp_Size_Difference = Temp_Size()\Size - Temp_Size()\Max_Size + Temp_Size()\Size = Temp_Size()\Max_Size + EndIf + Until Not NextElement(Temp_Size()) + EndIf + If SelectElement(Temp_Size(), Index-1) + Temp_Size()\Size + Temp_Size_Difference + EndIf + + SendMessage_(GadgetID(\Root\Gadget_Container), #WM_SETREDRAW, #False, 0) + + Select *Container\Type + Case #Container_Type_Split_H + Position = *Container\X + ForEach Temp_Size() + Container_Resize(*Gadget, Temp_Size()\Container, Position, Temp_Size()\Container\Y, Temp_Size()\Size, Temp_Size()\Container\Height, #Null, 1) + Position + Temp_Size()\Size + Next + Case #Container_Type_Split_V + Position = *Container\Y + ForEach Temp_Size() + Container_Resize(*Gadget, Temp_Size()\Container, Temp_Size()\Container\X, Position, Temp_Size()\Container\Width, Temp_Size()\Size, #Null, 1) + Position + Temp_Size()\Size + Next + EndSelect + + SendMessage_(GadgetID(\Root\Gadget_Container), #WM_SETREDRAW, #True, 0) + + GetClientRect_(GadgetID(\Root\Gadget_Container), rect) + InvalidateRect_(GadgetID(\Root\Gadget_Container), rect, #False) + UpdateWindow_(GadgetID(\Root\Gadget_Container)) + ;RedrawWindow_(GadgetID(\Root\Gadget_Container), 0, 0, 0) + + ;Container_Resize(*Gadget, *Container, *Container\X, *Container\Y, *Container\Width, *Container\Height) + ;Container_Resize(*Gadget, \Root, 0, 0, GadgetWidth(\Root\Gadget_Container), GadgetHeight(\Root\Gadget_Container)) + + EndWith + EndProcedure + + Procedure _Docker_Add(*Gadget.GADGET, *Container.Container, Direction, *Window.Window, Iteration=0) + If Not *Gadget + ProcedureReturn #Null + EndIf + If Not *Container + ProcedureReturn #Null + EndIf + If Not *Window + ProcedureReturn #Null + EndIf + Protected Parent_Position + Protected *Docker.Container, *Container_Split.Container, *Container_Spliter.Container, *Container_Tabbed.Container + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + If *Container\Parent + ; #### *Container has a parent + + ForEach *Container\Parent\Container() + If *Container\Parent\Container() = *Container + Parent_Position = ListIndex(*Container\Parent\Container()) + Break + EndIf + Next + Select *Container\Parent\Type + Case #Container_Type_Split_H + *Docker = Container_Add(*Gadget, 0, 0, WindowWidth(*Window\Window), WindowHeight(*Window\Window)+#Container_Docker_Bar_Height, #Container_Type_Docker, *Window) + Select Direction + Case #Direction_Left + *Container_Spliter = Container_Add(*Gadget, 0, 0, #Splitter_Size, 0, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Docker, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container\Parent, Parent_Position+1) + Case #Direction_Right + *Container_Spliter = Container_Add(*Gadget, 0, 0, #Splitter_Size, 0, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Docker, *Container\Parent, Parent_Position+1) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container\Parent, Parent_Position+1) + Case #Direction_Top + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_V) + *Container_Spliter = Container_Add(*Gadget, 0, 0, 0, #Splitter_Size, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Bottom + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_V) + *Container_Spliter = Container_Add(*Gadget, 0, 0, 0, #Splitter_Size, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 1) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Inside + *Container_Tabbed = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Tabbed) + Container_Set_Parent(*Gadget, *Container_Tabbed, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Tabbed, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Tabbed, 1) + EndSelect + + Case #Container_Type_Split_V + *Docker = Container_Add(*Gadget, 0, 0, WindowWidth(*Window\Window), WindowHeight(*Window\Window)+#Container_Docker_Bar_Height, #Container_Type_Docker, *Window) + Select Direction + Case #Direction_Top + *Container_Spliter = Container_Add(*Gadget, 0, 0, 0, #Splitter_Size, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Docker, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container\Parent, Parent_Position+1) + Case #Direction_Bottom + *Container_Spliter = Container_Add(*Gadget, 0, 0, 0, #Splitter_Size, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Docker, *Container\Parent, Parent_Position+1) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container\Parent, Parent_Position+1) + Case #Direction_Left + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_H) + *Container_Spliter = Container_Add(*Gadget, 0, 0, #Splitter_Size, 0, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Right + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_H) + *Container_Spliter = Container_Add(*Gadget, 0, 0, #Splitter_Size, 0, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 1) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Inside + *Container_Tabbed = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Tabbed) + Container_Set_Parent(*Gadget, *Container_Tabbed, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Tabbed, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Tabbed, 1) + EndSelect + + Case #Container_Type_Tabbed + Select Direction + Case #Direction_Top, #Direction_Bottom, #Direction_Left, #Direction_Right + *Docker = _Docker_Add(*Gadget, *Container\Parent, Direction, *Window, Iteration+1) + Case #Direction_Inside + *Docker = Container_Add(*Gadget, 0, 0, WindowWidth(*Window\Window), WindowHeight(*Window\Window)+#Container_Docker_Bar_Height, #Container_Type_Docker, *Window) + Container_Set_Parent(*Gadget, *Docker, *Container\Parent, -1) + EndSelect + + Case #Container_Type_Root + *Docker = Container_Add(*Gadget, 0, 0, WindowWidth(*Window\Window), WindowHeight(*Window\Window)+#Container_Docker_Bar_Height, #Container_Type_Docker, *Window) + Select Direction + Case #Direction_Top + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_V) + *Container_Spliter = Container_Add(*Gadget, 0, 0, 0, #Splitter_Size, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Bottom + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_V) + *Container_Spliter = Container_Add(*Gadget, 0, 0, 0, #Splitter_Size, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 1) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Left + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_H) + *Container_Spliter = Container_Add(*Gadget, 0, 0, #Splitter_Size, 0, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Right + *Container_Split = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Split_H) + *Container_Spliter = Container_Add(*Gadget, 0, 0, #Splitter_Size, 0, #Container_Type_Spliter) + Container_Set_Parent(*Gadget, *Container_Split, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Split, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Split, 1) + Container_Set_Parent(*Gadget, *Container_Spliter, *Container_Split, 1) + Case #Direction_Inside + *Container_Tabbed = Container_Add(*Gadget, 0, 0, *Container\Width, *Container\Height, #Container_Type_Tabbed) + Container_Set_Parent(*Gadget, *Container_Tabbed, *Container\Parent, Parent_Position) + Container_Set_Parent(*Gadget, *Container, *Container_Tabbed, 0) + Container_Set_Parent(*Gadget, *Docker, *Container_Tabbed, 1) + EndSelect + + EndSelect + Else + ; #### *Container has no parent + If FirstElement(*Container\Container()) + *Docker = _Docker_Add(*Gadget, *Container\Container(), Direction, *Window, Iteration+1) + Else + *Docker = Container_Add(*Gadget, 0, 0, WindowWidth(*Window\Window), WindowHeight(*Window\Window)+#Container_Docker_Bar_Height, #Container_Type_Docker, *Window) + Container_Set_Parent(*Gadget, *Docker, *Container, 0) + EndIf + EndIf + + ; #### Merge containers of the same type + If *Container\Parent + ForEach *Container\Parent\Container() + If *Container\Parent\Container()\Type = *Container\Parent\Type + Container_Merge_To_Parent(*Gadget, *Container\Parent\Container()) + EndIf + Next + EndIf + + If *Docker And Iteration = 0 + Container_Resize(*Gadget, \Root, 0, 0, GadgetWidth(\Root\Gadget_Container), GadgetHeight(\Root\Gadget_Container), *Docker) + EndIf + + EndWith + + ProcedureReturn *Docker + EndProcedure + + Procedure Docker_Add(Gadget, *Container.Container, Direction, Window) + Protected *Window.Window = Window_Get_By_Number(Window) + If Not *Container + ProcedureReturn #Null + EndIf + If Not *Window + ProcedureReturn #Null + EndIf + ProcedureReturn _Docker_Add(IsGadget(Gadget), *Container, Direction, *Window) + EndProcedure + + Procedure Root_Get(Gadget) + Protected *Gadget.GADGET = IsGadget(Gadget) + If Not *Gadget + ProcedureReturn #False + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + ProcedureReturn \Root + EndWith + EndProcedure + + Procedure Create(Gadget, X, Y, Width, Height, Parent_Window.i) + Protected Style_Flags + If Not Parent_Window + ProcedureReturn #Null + EndIf + Protected Result = ContainerGadget(Gadget, 0, 0, 0, 0, #PB_Container_BorderLess) + If Result + If Gadget=#PB_Any : Gadget = Result : EndIf + + ; #### initialize custom params and custom manager + Protected *params.GADGET_PARAMS = AllocateStructure(GADGET_PARAMS) + Protected *manager.GADGET_MANAGER = GetManager() + ManageGadget(*manager, Gadget, *params, #PB_GadgetType_D3docker) + + SetGadgetColor(Result, #PB_Gadget_BackColor, #Color_Gadget_Background) + + ; #### create and save custom elements and custom params + With *params + \Root\Gadget_Container = Gadget + + \Parent_Window = Parent_Window + + \FontID = GetGadgetFont(#PB_Default) + + CloseGadgetList() + EndWith + + ; #### define custom PB commands + With *manager\NewVT + ;\FreeGadget = @_FreeGadget() + ;\GetGadgetState = @_GetGadgetState() + ;\SetGadgetState = @_SetGadgetState() + \ResizeGadget = @_ResizeGadget() + EndWith + + ; #### redraw gadget once and reset its state + ResizeGadget(Gadget, X, Y, Width, Height) + + ProcedureReturn Result + EndIf + EndProcedure + + Procedure Free(Gadget) + Protected *Gadget.GADGET = IsGadget(Gadget) + If Not *Gadget + ProcedureReturn #False + EndIf + Protected *params.GADGET_PARAMS=GetParams(*Gadget) + With *params + While FirstElement(\Window()) + _Window_Close(*Gadget, \Window()) + Wend + + While FirstElement(\Diamond()) + Diamond_Delete(*Gadget, \Diamond()) + Wend + + While FirstElement(\Root\Container()) + _Container_Delete(*Gadget, \Root\Container()) + Wend + + FreeGadget(\Root\Gadget_Container) + EndWith + EndProcedure + + ; ################################################## Data Section ############################################# + DataSection + Diamond_Root_Left: : IncludeBinary "Data/Diamond_Root_Left.png" + Diamond_Root_Top: : IncludeBinary "Data/Diamond_Root_Top.png" + Diamond_Root_Right: : IncludeBinary "Data/Diamond_Root_Right.png" + Diamond_Root_Bottom: : IncludeBinary "Data/Diamond_Root_Bottom.png" + Diamond_Root_Inside: : IncludeBinary "Data/Diamond_Root_Inside.png" + Diamond_Left: : IncludeBinary "Data/Diamond_Left.png" + Diamond_Top: : IncludeBinary "Data/Diamond_Top.png" + Diamond_Right: : IncludeBinary "Data/Diamond_Right.png" + Diamond_Bottom: : IncludeBinary "Data/Diamond_Bottom.png" + Diamond_Tabbed: : IncludeBinary "Data/Diamond_Tabbed.png" + Button_Undock: : IncludeBinary "Data/Undock.png" + Button_Close: : IncludeBinary "Data/Close.png" + EndDataSection + +EndModule +; IDE Options = PureBasic 5.31 (Windows - x64) +; CursorPosition = 1631 +; FirstLine = 1602 +; Folding = -------- +; EnableUnicode +; EnableXP \ No newline at end of file diff --git a/Includes/D3docker/Data/Close.png b/Includes/D3docker/Data/Close.png new file mode 100644 index 0000000000000000000000000000000000000000..6984009701adfa44f98fa8a0dcddcda3d235fb77 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@pBu^K|5DWjMJ%M};1{}`i|GgK_n6hErj)n623;9nOY>xN1>3E8-c*o+& zv2JgZIRb4oZM)qs89qOw#Nd^m>h85c+d9ZfcG~Jy>7R cyyVAB8tyxjmxjCx2HM8p>FVdQ&MBb@0NG|vt^fc4 literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Bottom.png b/Includes/D3docker/Data/Diamond_Bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..be32c20632d7599cb6c9adc79ec79fd221f000e8 GIT binary patch literal 324 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!Gcf2Wf-oa{^q>DgL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@pt)4E9As*gur&;s081T4UKEP|i$No(2LZMvLd*OS%lQ=}49{1Al4`#8R zx3IX!@KS`^t&bH4ww<&&ZIGcH$z#;l`E<>HrfZ?gJg2$#J&yKlbv$Nx(CZ@;$MRS{ zwFu3)0~XKz@8$-v8f>RLuKL#CUF9%EPT=WL##OcJ3kq!J@>hjkVP5nrn4wy4$Mm(Y zr>^w2-!W_9?WOtibq_jBlGtCnje++Nw|v|+*>k&u1LiJgk~(#Q{hrd54)Y(|JAfWw N@O1TaS?83{1OSN=c3uDg literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Left.png b/Includes/D3docker/Data/Diamond_Left.png new file mode 100644 index 0000000000000000000000000000000000000000..62bd90a5c16f339ede4b522b0796aa1dd1b1e8bb GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!Gcf2WfiUB$M|URy1tm&cBT9nv(@M${i&7a15;OBk^zu?m6ioCC z^h{G*jZ%SX4tu&dhIn|Noo2|_V!*?4_W*wdAOAD?3m@g8?%!+O>~ZAjp4N%((F=~; z6bw~Tl9IV-At%0O^|{S`$u}1?H(T@xJ>L9JG$DCbNo2|W+c$jXKdz8>Ke=tL_Ed&X zx66)bYAj$0ZS^wX$$f8H_d$MzRtQs#$x^Y|g+*`AC^~3lG@i9MsZN-F$2wR0a+=Mb wJw}K1|DM~-`tif_n@maaae_9g96c|%7p%I{(c6E04bVFbp00i_>zopr05iURx&QzG literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Right.png b/Includes/D3docker/Data/Diamond_Right.png new file mode 100644 index 0000000000000000000000000000000000000000..3bb2c271f1b456a40e8500a0c6e2f9509cf07487 GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!Gcf2Wf-oa{^q>DgL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@pi=HlyAs*gWr#bR98}P6cH_CsIkvn7m;8^vJU8|RwzS9cv6b-&P%bE3@ zPrl+(m2)Z|XWwRit@T;w@r-zr=4K1N&U2rCT5rfT^4+9UB(q-qe)@gx2No)~esC!C zUH{tLoO0fQY3jQk;t=FLpW)ld)hwJ7 zu3S=YsQskn$fUCM3unUoJzf(SJaucCP?Y`Ayik=o=}OQ(qr3WlubrQk#Bf~SKH6ZP he4Jcy_<@Nk{FgnhbezAgZ2 literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Root_Bottom.png b/Includes/D3docker/Data/Diamond_Root_Bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..dd52dd1e08e60652027cede29496e52cc8471ad9 GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={WSkfJR9T^xl_H+M9WCij$3p^r= z85r~wL70&}`p&q9iy!t)x7$D3zfgF*C13FE6!3!9>qM&os5wC>5w?ou`Xq zh==#vX@-0)20Scx5Aav;@jsKl@KOD~(Ce`09(oGtTI;uMNJ3pTG&|dXTHI$ rs_on{>atnS?HTK@M>BSc{bg`Y=-n|#Zrg02%Naaf{an^LB{Ts5X(DV7 literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Root_Left.png b/Includes/D3docker/Data/Diamond_Root_Left.png new file mode 100644 index 0000000000000000000000000000000000000000..f6820cd2e61f247949909b1fec206143249395a1 GIT binary patch literal 347 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={WSkfJR9T^xl_H+M9WCij$3p^r= z85r~wL70&}`p=)$uvpnI6{T`Pi*H^rZna_7RwM?EXx?}^7b@Z8p1dfAp zej6(HalHG(uI=#8c}9chyy)257QbFUSaE;*qT20=8&+-lep`DD!^1}A;yHJ04st%L z*!$;C2g8xyYZxX@VBOfLV#}zc$eqOOS;geyBzA;t(ifJF7M%`Wm6x0XoRJe!?>Q&| zWjl2oR8kzHv~O*D|NbbawnN3Qd$W$6U(*nCaaYv!$jDnJm93&O-`53;T-&xy=bx3u ntMc_P#KRWUxeAKg%t(;;bAQre$}&Y2=t%}oS3j3^P67l5F0y7%yP48Fx7_r_vqe9p-%yce>HfPX>B7zb9ywu} zuI7thY**ntySZ6|v7~cBLgb1}jq~^Q?>NXlkNM59th1}>*0gI^ZGO&spuH;lm6h>t zmR&A7j?*q~n|V|HS9`$mjV#w6%zU8DCF(HUV~WFjXIXWx5BrtU^Tc8N=Qo*N2z3g* zs9o{cCYm8uDUfL|f9afb?gic|UJJf2>`UgnH09gfGj^O}A);UR&a7pMRhpI{vr>n@ z{kdh6{{my4iYvq~+~&~Rv;4uS>KATDF0Z(Kzf-oW@zTL%g@MmLirWj%m@Xiw z)NXKoV-l08T0kb`ex9}nDS kc>Isb56f~+rM3?Yb}mm^>=_UL20E9))78&qol`;+0335``2YX_ literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Tabbed.png b/Includes/D3docker/Data/Diamond_Tabbed.png new file mode 100644 index 0000000000000000000000000000000000000000..379d5333c4ab60d5b84339604e67eac05886de00 GIT binary patch literal 324 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={WSkfJR9T^xl_H+M9WCij$3p^r= z85r~wL70&}`pV2@8|Mn^IBLMD;d##vhrA?L_@(AZ&Ox=83(-B zk`CCst~X!0hBad2CI(B5tFHv2PR;VP-OSLYekF0%s&=6(!snkjpDlgNs3w>22uhr1 z-0}QMjQRO+wfJ9ITbf@j)juz`^#aSa)#t@B-W<+uxyL2pv4Fp*A$rneg)@Ob-!OQ( L`njxgN@xNAm3Mbs literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Diamond_Top.png b/Includes/D3docker/Data/Diamond_Top.png new file mode 100644 index 0000000000000000000000000000000000000000..770cc46ef2d0e28fde90fb88711f14e44f8ab906 GIT binary patch literal 319 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={W7>k44ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!Gcf2Wf-oa{^q>DgL5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33 zJ=4@yqg0@p4W2HJAs*gur#bR9DDbdUUzGnLBmc(!%d_eo*QRDMyE!je)S0-sec6S% z1zIjgT76^u)-xZQ_Q{T%O_;&TRH$Jz#59AstF+4a{V(28G+QpDt zy=PXgOQ#Y;*WtZ6?K4FSUimZbOVv#{+r!|$l4;Vah9z1GEB7;Pcs}QLR<}UWKBLr^ zw@Y_^`FeZOUp}6sKc8+h`CjHSuiGQA=+j?@4?FHLiI{w3ntI_%$8iO9J)qkeJYD@< J);T3K0RTh>cFq6* literal 0 HcmV?d00001 diff --git a/Includes/D3docker/Data/Undock.png b/Includes/D3docker/Data/Undock.png new file mode 100644 index 0000000000000000000000000000000000000000..38e076caa2ebf7cba9a85d8f42edb6d42431cd10 GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXPVk-lnPXn=IP=X zV&T8G=OSN&0SEK<|MtCoOP07EQu$TTxp%IP@oyJR^(jS8y7_k%b^9m0Z134(gTe~DWM4f6bw(H literal 0 HcmV?d00001 diff --git a/Includes/D3docker/TabBarGadget.pbi b/Includes/D3docker/TabBarGadget.pbi new file mode 100644 index 0000000..cf2fce9 --- /dev/null +++ b/Includes/D3docker/TabBarGadget.pbi @@ -0,0 +1,3216 @@ +;|------------------------------------------------------------------------------------------------- +;| +;| Title : TabBarGadget +;| Version : 1.5 Beta 2 (2014-09-02) +;| Copyright : UnionBytes +;| (Martin Guttmann alias STARGÅTE) +;| PureBasic : 5.20+ +;| String Format : Ascii, Unicode +;| Operating System : Windows, Linux, MacOS +;| Processor : x86, x64 +;| +;|------------------------------------------------------------------------------------------------- +;| +;| Description : Gadget for displaying and using tabs like in the browser +;| +;| Forum Topic : http://www.purebasic.fr/german/viewtopic.php?f=8&t=24788 +;| http://www.purebasic.fr/english/viewtopic.php?f=12&t=47588 +;| Website : http://www.unionbytes.de/includes/tabbargadget/ +;| +;| Documentation : http://help.unionbytes.de/tbg/ +;| +;|------------------------------------------------------------------------------------------------- + + + + + +EnableExplicit + + + + + +;|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +;- 1. Constants / Konstanten +;|__________________________________________________________________________________________________ + + + +; Attribute für das TabBarGadget +Enumeration + #TabBarGadget_None = 0<<0 + #TabBarGadget_CloseButton = 1<<0 + #TabBarGadget_NewTab = 1<<1 + #TabBarGadget_TextCutting = 1<<2 + #TabBarGadget_MirroredTabs = 1<<3 + #TabBarGadget_Vertical = 1<<4 + #TabBarGadget_NoTabMoving = 1<<5 + #TabBarGadget_MultiLine = 1<<6 + #TabBarGadget_BottomLine = 1<<7 + #TabBarGadget_PopupButton = 1<<8 + #TabBarGadget_Editable = 1<<9 + #TabBarGadget_MultiSelect = 1<<10 + #TabBarGadget_CheckBox = 1<<11 + #TabBarGadget_SelectedCloseButton = 1<<12 + #TabBarGadget_ReverseOrdering = 1<<13 + #TabBarGadget_ImageSize = 1<<23 + #TabBarGadget_TabTextAlignment = 1<<24 + #TabBarGadget_ScrollPosition = 1<<25 + #TabBarGadget_NormalTabLength = 1<<26 ; für Später + #TabBarGadget_MaxTabLength = 1<<27 + #TabBarGadget_MinTabLength = 1<<28 + #TabBarGadget_TabRounding = 1<<29 +EndEnumeration + +; Ereignisse von TabBarGadgetEvent +Enumeration #PB_EventType_FirstCustomValue + #TabBarGadget_EventType_Pushed + #TabBarGadget_EventType_Updated ; Das Gadget hat sich aktualisiert (intern) + #TabBarGadget_EventType_Change ; Der aktive Tab wurde geändert + #TabBarGadget_EventType_Resize ; Die größe der Leiste hat sich geändert + #TabBarGadget_EventType_NewItem ; ein neuer Tab wird angefordert + #TabBarGadget_EventType_CloseItem ; ein Tab soll geschlossen werden + #TabBarGadget_EventType_SwapItem ; der aktive Tab wurde verschoben + #TabBarGadget_EventType_EditItem ; der Text einer Karte wurde geändert + #TabBarGadget_EventType_CheckBox ; der Status der Checkbox hat sich geändert + #TabBarGadget_EventType_PopupButton ; der Popup-Button wurde gedrückt +EndEnumeration + + + + +; Positionskonstanten für "Item"-Befehle +Enumeration + #TabBarGadgetItem_None = -1 + #TabBarGadgetItem_NewTab = -2 + #TabBarGadgetItem_Selected = -3 + #TabBarGadgetItem_Event = -4 +EndEnumeration + +; Status-Konstanten +Enumeration + #TabBarGadget_Disabled = 1<<0 + #TabBarGadget_Selected = 1<<1 + #TabBarGadget_Checked = 1<<2 +EndEnumeration + +; Status-Konstanten +Enumeration + #TabBarGadgetUpdate_Directly = 0 + #TabBarGadgetUpdate_PostEvent = 1 +EndEnumeration + +#TabBarGadget_DefaultHeight = 1 + + + +; Interne Konstanten +#TabBarGadget_PreviousArrow = 1<<30 +#TabBarGadget_NextArrow = 1<<31 +#TabBarGadgetItem_DisableFace = -1 +#TabBarGadgetItem_NormalFace = 0 +#TabBarGadgetItem_HoverFace = 1 +#TabBarGadgetItem_ActiveFace = 2 +#TabBarGadgetItem_MoveFace = 3 + + + + +;|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +;- 2. Structures / Strukturen +;|__________________________________________________________________________________________________ + + + +; Sortierter Eintrag für die Textkürzung +Structure TabBarGadgetSortedItem + *Item.TabBarGadgetItem ; Registerkarte + Characters.i ; Anzahl der Buchstaben +EndStructure + +; Aktuelle Parameter eine Kartenzeile +Structure TabBarGadgetRow + Length.i ; Aktuelle Länge einer Zeile + Items.i ; Aktuelle Anzahl der Tabs +EndStructure + +; Farben für einen Eintrag +Structure TabBarGadgetItemColor + Text.i ; Textfarbe + Background.i ; Hintergrundfarbe +EndStructure + +; Lage und Größe einer Registerkarte +Structure TabBarGadgetItemLayout + X.i ; X-Position + Y.i ; Y-Position + Width.i ; (innere) Breite + Height.i ; (innere) Höhe + PaddingX.i ; Vergrößerung (z.B. bei aktiver Registerkarte) + PaddingY.i ; + CrossX.i ; Position des Schließen-X + CrossY.i ; + TextX.i ; Textposition + TextY.i ; + CheckX.i ; Checkbox-Position + CheckY.i ; + ImageX.i ; Icon-Position + ImageY.i ; +EndStructure + +; Registerkarte +Structure TabBarGadgetItem + Text.s ; Text + ShortText.s ; verkürzter Text + Color.TabBarGadgetItemColor ; Farbattribute + Image.i ; Bild (Kopie vom Original) + DrawedImage.i ; Bild (Kopie ggf. rotiert) + DataValue.i ; Benutzer-Daten-Wert + Attributes.i ; Attribute + Disabled.i ; Deaktiviert + Selected.i ; Aktuell ausgewählt + Checked.i ; Abgehakt + ToolTip.s ; ToolTop + Length.i ; Länge in Pixel (TEMP) + Row.i ; Zeile (TEMP) + Position.i ; Position (TEMP) + Visible.i ; Sichtbar und wird gezeichnet (TEMP) + Face.i ; Aussehen (TEMP) + Layout.TabBarGadgetItemLayout ; Layout der Karte (TEMP) + *PreviousSelectedItem.TabBarGadgetItem ; Zuvor ausgewählter Tab +EndStructure + +; Tooltips +Structure TabBarGadgetToolTip + *Current ; Aktuelle ToolTip-Adresse + *Old ; Alte ToolTip-Adresse + ItemText.s ; Text für die Registerkarte + NewText.s ; Text für die "Neu"-Registerkarte + CloseText.s ; Text für den Schließen-Button +EndStructure + +; Editierte Karte +Structure TabBarGadgetEditor + *Item.TabBarGadgetItem ; Zu Bearbeitende Karte + OldText.s ; Alter Text vor dem Bearbeiten + Cursor.i ; Cursor-Position + Selection.i ; Textmarkierungslänge + Selectable.i ; Ob die Mausbewegung zu einer Textmarkierung führt +EndStructure + +; Layout der Leiste +Structure TabBarGadgetLayout + PreviousButtonX.i ; Position des "zurück" Navigationspfeil + PreviousButtonY.i + NextButtonX.i ; Position des "vor" Navigationspfeil + NextButtonY.i + PopupButtonX.i ; Position des Popup-Pfeils + PopupButtonY.i + ButtonWidth.i ; Größe der Buttons + ButtonHeight.i + ButtonSize.i +EndStructure + +; Registerkartenleiste +Structure TabBarGadget + Number.i ; #Nummer + Window.i ; Fenster-Nummer + FontID.i ; Schrift + DataValue.i ; Benutzer-Daten-Wert + Attributes.i ; Attribute + List Item.TabBarGadgetItem() ; Registerkarten + NewTabItem.TabBarGadgetItem ; "Neu"-Registerkarte + *SelectedItem.TabBarGadgetItem ; ausgewählte Registerkarte + *MoveItem.TabBarGadgetItem ; bewegte Registerkarte + *HoverItem.TabBarGadgetItem ; hervorgehobene Registerkarte + HoverClose.i ; Schließenbutton hervorgehoben + HoverCheck.i ; Checkbox hervorgehoben + HoverArrow.i ; Navigationbutton hervorgehoben + *ReadyToMoveItem.TabBarGadgetItem ; Registerkarte die bereit ist bewegt zu werden + *LockedItem.TabBarGadgetItem ; Registerkarte angeschlagen wurde (für Klicks) + LockedClose.i ; Schließenbutton angeschlagen + LockedCheck.i ; Schließenbutton angeschlagen + LockedArrow.i ; Navigationsbutton angeschlagen + SaveMouseX.i ; gespeicherte Mausposition + SaveMouseY.i ; gespeicherte Mausposition + MouseX.i ; X-Mausposition + MouseY.i ; Y-Mausposition + Event.i ; letztes Ereignis + EventTab.i ; Registerkartenposition auf der das letzte Ereignis war + Shift.i ; Verschiebung der Leiste + LastShift.i ; Maximale sinnvolle Verschiebung + FocusingSelectedTab.i ; muss die ausgewählte Registerkarte fokussiert werden + MaxLength.i ; maximal nutzbare Länge für Karten + Length.i ; Länge aller sichtbaren Karten + Radius.i ; Radius der Kartenrundung + MinTabLength.i ; minimale Länge einer Karte + MaxTabLength.i ; maximale Länge einer Karte + NormalTabLength.i ; normale Länge einer Karte + TabTextAlignment.i ; Textausrichtung + ToolTip.TabBarGadgetToolTip ; ToolTip + TabSize.i ; Größer einer Registerkarte + Rows.i ; Anzahl der Zeilen + Resized.i ; Das Gadget muss vergrößert werden + Editor.TabBarGadgetEditor ; Editor für eine Karte + Layout.TabBarGadgetLayout ; Layout der Leiste + UpdatePosted.i ; Nach einem PostEvent #True +EndStructure + +; Timer für das kontinuierliche Scrollen +Structure TabBarGadget_Timer + *TabBarGadget.TabBarGadget ; TabBarGadget-ID + Type.i ; Modus (Scrollen) + Mutex.i ; Mutex zur Sicherung +EndStructure + +; Include für das Registerkartenleisten-Gadget +Structure TabBarGadgetInclude + TabBarColor.i ; Hintergrundfarbe des Gadgets + FaceColor.i ; Hintergrundfarbe einer Karte + HoverColorPlus.i ; Farbänderung für den Hover-Effekt + ActivColorPlus.i ; Farbänderung für aktuell ausgewählte Karten + BorderColor.i ; Rahmenfarbe + TextColor.i ; Textfarbe + PaddingX.i ; Innenabstand (Text zu Rahmen) + PaddingY.i ; Innenabstand (Text zu Rahmen) + Margin.i ; Außenabstand (Rahmen zu Gadget-Rand) + ImageSpace.i ; Freiraum zwischen Bild und Text + CloseButtonSize.i ; Größe des Schließenkreuzes + CheckBoxSize.i + ImageSize.i + ArrowSize.i ; Größe des Navigationspfeils + ArrowWidth.i ; + ArrowHeight.i ; + Radius.i ; Radius der Abrundung der Karte + MinTabLength.i ; Mimimale Länge einer Karte + MaxTabLength.i ; Maximale Länge einer Karte + TabTextAlignment.i + VerticalTextBugFix.f + NormalTabLength.i ; [für später] + FadeOut.i ; Länge der Farbausblendung bei einer Navigation + WheelDirection.i ; Scrollrichtung bei Mausradbewegung + RowDirection.i ; Reihenfolge der Zeilen + EnableDoubleClickForNewTab.i ; Doppelklick ins "Leere" erzeigt ein Ereignis + EnableMiddleClickForCloseTab.i ; Mittelklick auf eine Karte erzeigt ein Ereignis + Timer.TabBarGadget_Timer ; Timer für das kontinuierliche Scrollen +EndStructure + + + + + +;|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +;- 3. Initializations / Initialisierungen +;|__________________________________________________________________________________________________ + + + +Global TabBarGadgetInclude.TabBarGadgetInclude +Declare TabBarGadget_Timer(Null.i) + +; Diese Werte können sowohl im Include, als auch im Hauptcode später über TabBarGadgetInclude\Feld geändert werden. +With TabBarGadgetInclude + CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Windows + \TabBarColor = $FF<<24 | GetSysColor_(#COLOR_BTNFACE) + \BorderColor = $FF<<24 | GetSysColor_(#COLOR_3DSHADOW) + \FaceColor = $FF<<24 | GetSysColor_(#COLOR_BTNFACE) + \TextColor = $FF<<24 | GetSysColor_(#COLOR_BTNTEXT) + CompilerDefault + \TabBarColor = $FFD0D0D0 + \BorderColor = $FF808080 + \FaceColor = $FFD0D0D0 + \TextColor = $FF000000 + CompilerEndSelect + \HoverColorPlus = $FF101010 + \ActivColorPlus = $FF101010 + \PaddingX = 6 ; Space from tab border to text + \PaddingY = 5 ; Space from tab border to text + \Margin = 4 ; Space from tab to border + \ImageSpace = 3 ; Space from image zu text + \ImageSize = 16 + \CloseButtonSize = 13 ; Size of the close cross + \CheckBoxSize = 10 + \ArrowSize = 5 ; Size of the Arrow in the button in navigation + \ArrowWidth = 12 ; Width of the Arrow-Button in navigation + \ArrowHeight = 18 ; Height of the Arrow-Button in navigation + \Radius = 3 ; Radius of the edge of the tab + \TabTextAlignment = -1 + \VerticalTextBugFix = 1.05 + \MinTabLength = 0 + \MaxTabLength = 10000 + \NormalTabLength = 150 + \FadeOut = 32 ; Length of fade out to the navi + \WheelDirection = -1 + \RowDirection = 1 ; not used + \EnableDoubleClickForNewTab = #True + \EnableMiddleClickForCloseTab = #True + \Timer\Mutex = CreateMutex() + CompilerIf #PB_Compiler_Thread + CreateThread(@TabBarGadget_Timer(), #Null) + CompilerEndIf +EndWith + + + + + + +;|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +;- 4. Procedures & Macros / Prozeduren & Makros +;|__________________________________________________________________________________________________ + + + +;- 4.1 Private procedures for internal calculations ! Not for use ! +;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ + + + +; Gitb die Adresse (ID) der Registerkarte zurück. +; Position kann eine Konstante, Position oder ID sein. +Procedure.i TabBarGadget_ItemID(*TabBarGadget.TabBarGadget, Position.i) ; Code OK + + With *TabBarGadget + + Select Position + Case #TabBarGadgetItem_Event + ProcedureReturn TabBarGadget_ItemID(*TabBarGadget, \EventTab) + Case #TabBarGadgetItem_Selected + If \SelectedItem + ChangeCurrentElement(\Item(), \SelectedItem) + ProcedureReturn @\Item() + Else + ProcedureReturn #Null + EndIf + Case #TabBarGadgetItem_NewTab + ProcedureReturn @\NewTabItem + Case #TabBarGadgetItem_None + ProcedureReturn #Null + Default + If Position >= 0 And Position < ListSize(\Item()) + ProcedureReturn SelectElement(\Item(), Position) + ElseIf Position >= ListSize(\Item()) + ForEach \Item() + If @\Item() = Position + ProcedureReturn @\Item() + EndIf + Next + EndIf + EndSelect + + EndWith + +EndProcedure + + + +; Gibt die Ressourcen einer Registerkarte wieder frei. +Procedure TabBarGadget_ClearItem(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) ; Code OK + + If *Item\Image + FreeImage(*Item\Image) + EndIf + If *Item\DrawedImage + FreeImage(*Item\DrawedImage) + EndIf + +EndProcedure + + + +; Wählt die angegebene Karte aus und aktualisiert die Select-Hierarchie +Procedure TabBarGadget_SelectItem(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) ; Code OK + + If *TabBarGadget\Attributes & #TabBarGadget_MultiSelect = #False + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\Selected = #False + Next + EndIf + If *Item + *Item\Selected = #True + If *Item <> *TabBarGadget\SelectedItem + *Item\PreviousSelectedItem = *TabBarGadget\SelectedItem + EndIf + *TabBarGadget\FocusingSelectedTab = #True + EndIf + *TabBarGadget\SelectedItem = *Item + +EndProcedure + + + +; Wählt die angegebene Karte ab und aktualisiert die Select-Hierarchie +Procedure TabBarGadget_UnselectItem(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) ; Code OK + + *Item\Selected = #False + ForEach *TabBarGadget\Item() + If *TabBarGadget\Item()\PreviousSelectedItem = *Item + If *Item\PreviousSelectedItem <> *TabBarGadget\Item() + *TabBarGadget\Item()\PreviousSelectedItem = *Item\PreviousSelectedItem + Else + *TabBarGadget\Item()\PreviousSelectedItem = #Null + EndIf + EndIf + Next + If *TabBarGadget\SelectedItem = *Item ; Auswahl muss geändert werden + *TabBarGadget\SelectedItem = *Item\PreviousSelectedItem + If *TabBarGadget\SelectedItem + *TabBarGadget\SelectedItem\Selected = #True + EndIf + EndIf + +EndProcedure + + + +; Entfernt die Registerkarte und aktualisiert die Select-Hierarchie +Procedure TabBarGadget_RemoveItem(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) ; Code OK + + TabBarGadget_ClearItem(*TabBarGadget, *Item) + If *TabBarGadget\SelectedItem + TabBarGadget_UnselectItem(*TabBarGadget, *Item) + If *TabBarGadget\SelectedItem = #Null + ChangeCurrentElement(*TabBarGadget\Item(), *Item) + If NextElement(*TabBarGadget\Item()) + TabBarGadget_SelectItem(*TabBarGadget.TabBarGadget, *TabBarGadget\Item()) + ElseIf PreviousElement(*TabBarGadget\Item()) + TabBarGadget_SelectItem(*TabBarGadget.TabBarGadget, *TabBarGadget\Item()) + EndIf + EndIf + Else + TabBarGadget_UnselectItem(*TabBarGadget, *Item) + EndIf + + ChangeCurrentElement(*TabBarGadget\Item(), *Item) + DeleteElement(*TabBarGadget\Item()) + +EndProcedure + + + +; Gibt #True zurück, wenn die Maus innerhalb des Rechtecks ist. +; Width und Height können auch negativ sein. +Procedure.i TabBarGadget_MouseIn(*TabBarGadget.TabBarGadget, X.i, Y.i, Width.i, Height.i) ; Code OK + + With *TabBarGadget + + If Width < 0 : X + Width : Width * -1 : EndIf + If Height < 0 : Y + Height : Height * -1 : EndIf + If \MouseX >= X And \MouseX < X+Width And \MouseY >= Y And \MouseY < Y+Height + ProcedureReturn #True + EndIf + + EndWith + +EndProcedure + + + +; Farbaddition +Procedure.i TabBarGadget_ColorPlus(Color.i, Plus.i) ; Code OK + + If Color&$FF + Plus&$FF < $FF + Color + Plus&$FF + Else + Color | $FF + EndIf + If Color&$FF00 + Plus&$FF00 < $FF00 + Color + Plus&$FF00 + Else + Color | $FF00 + EndIf + If Color&$FF0000 + Plus&$FF0000 < $FF0000 + Color + Plus&$FF0000 + Else + Color | $FF0000 + EndIf + + ProcedureReturn Color + +EndProcedure + + + +; Farbsubtraktion +Procedure.i TabBarGadget_ColorMinus(Color.i, Minus.i) ; Code OK + + If Color&$FF - Minus&$FF > 0 + Color - Minus&$FF + Else + Color & $FFFFFF00 + EndIf + If Color&$FF00 - Minus&$FF00 > 0 + Color - Minus&$FF00 + Else + Color & $FFFF00FF + EndIf + If Color&$FF0000 - Minus&$FF0000 > 0 + Color - Minus&$FF0000 + Else + Color & $FF00FFFF + EndIf + + ProcedureReturn Color + +EndProcedure + + + +; Zeichnet ein (Schließen-)Kreuz +Procedure TabBarGadget_DrawCross(X.i, Y.i, Size.i, Color.i) ; Code OK + + Protected Alpha.i = Alpha(Color)/4 + + Line(X , Y+1 , Size-1, Size-1, Color&$FFFFFF|Alpha<<24) + Line(X+1, Y , Size-1, Size-1, Color&$FFFFFF|Alpha<<24) + Line(X , Y+Size-2, Size-1, -Size+1, Color&$FFFFFF|Alpha<<24) + Line(X+1, Y+Size-1, Size-1, -Size+1, Color&$FFFFFF|Alpha<<24) + Line(X , Y , Size , Size , Color) + Line(X , Y+Size-1, Size , -Size , Color) + +EndProcedure + + + +; Zeichnet einen Button +Procedure TabBarGadget_DrawButton(X.i, Y.i, Width.i, Height.i, Type.i, Color, Vertical.i=#False) ; Code OK + + If Type + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient) + ResetGradientColors() + If Type = 1 + GradientColor(0.0, TabBarGadget_ColorPlus(Color, $404040)) + GradientColor(0.5, Color) + GradientColor(1.0, TabBarGadget_ColorMinus(Color, $404040)) + ElseIf Type = -1 + GradientColor(1.0, TabBarGadget_ColorPlus(Color, $404040)) + GradientColor(0.5, Color) + GradientColor(0.0, TabBarGadget_ColorMinus(Color, $404040)) + EndIf + If Vertical + LinearGradient(X, Y, X+Width-1, Y) + RoundBox(X, Y, Width, Height, 3, 3) + DrawingMode(#PB_2DDrawing_Outlined|#PB_2DDrawing_AlphaBlend) + RoundBox(X, Y, Width, Height, 3, 3, TabBarGadgetInclude\BorderColor&$FFFFFF|$80<<24) + Else + LinearGradient(X, Y, X, Y+Height-1) + RoundBox(X, Y, Width, Height, 3, 3) + DrawingMode(#PB_2DDrawing_Outlined|#PB_2DDrawing_AlphaBlend) + RoundBox(X, Y, Width, Height, 3, 3, TabBarGadgetInclude\BorderColor&$FFFFFF|$80<<24) + EndIf + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend) + EndIf + +EndProcedure + + + +; Zeichnet einen Pfeil +Procedure TabBarGadget_DrawArrow(X.i, Y.i, Type.i, Color.i, Attributes.i=#Null) ; Code OK + + Protected Index.i, Alpha.i = Alpha(Color)/4 + + With TabBarGadgetInclude + If Attributes & #TabBarGadget_Vertical + If Attributes & #TabBarGadget_MirroredTabs + Select Type + Case #TabBarGadget_PopupButton + X - \ArrowSize/2-1 + For Index = 1 To \ArrowSize + Line(X+Index, Y-Index, 1, Index*2, Color) + Next + LineXY(X, Y-1, X+\ArrowSize, Y-1-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + Else + Select Type + Case #TabBarGadget_PopupButton + X + \ArrowSize/2 + For Index = 1 To \ArrowSize + Line(X-Index, Y-Index, 1, Index*2, Color) + Next + LineXY(X, Y-1, X-\ArrowSize, Y-1-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X-\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + EndIf + If Attributes & #TabBarGadget_MirroredTabs XOr Attributes & #TabBarGadget_ReverseOrdering + Select Type + Case #TabBarGadget_PreviousArrow + Y - \ArrowSize/2-1 + For Index = 1 To \ArrowSize + Line(X-Index, Y+Index, Index*2, 1, Color) + Next + LineXY(X-1, Y, X-1-\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + Case #TabBarGadget_NextArrow + Y + \ArrowSize/2 + For Index = 1 To \ArrowSize + Line(X-Index, Y-Index, Index*2, 1, Color) + Next + LineXY(X-1, Y, X-1-\ArrowSize, Y-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y-\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + Else + Select Type + Case #TabBarGadget_PreviousArrow + Y + \ArrowSize/2 + For Index = 1 To \ArrowSize + Line(X-Index, Y-Index, Index*2, 1, Color) + Next + LineXY(X-1, Y, X-1-\ArrowSize, Y-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y-\ArrowSize, Color&$FFFFFF|Alpha<<24) + Case #TabBarGadget_NextArrow + Y - \ArrowSize/2-1 + For Index = 1 To \ArrowSize + Line(X-Index, Y+Index, Index*2, 1, Color) + Next + LineXY(X-1, Y, X-1-\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + EndIf + Else + Select Type + Case #TabBarGadget_PopupButton + Y + \ArrowSize/2 + For Index = 1 To \ArrowSize + Line(X-Index, Y-Index, Index*2, 1, Color) + Next + LineXY(X-1, Y, X-1-\ArrowSize, Y-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y-\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + If Attributes & #TabBarGadget_ReverseOrdering + Select Type + Case #TabBarGadget_PreviousArrow + X + \ArrowSize/2 + For Index = 1 To \ArrowSize + Line(X-Index, Y-Index, 1, Index*2, Color) + Next + LineXY(X, Y-1, X-\ArrowSize, Y-1-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X-\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + Case #TabBarGadget_NextArrow + X - \ArrowSize/2-1 + For Index = 1 To \ArrowSize + Line(X+Index, Y-Index, 1, Index*2, Color) + Next + LineXY(X, Y-1, X+\ArrowSize, Y-1-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + Else + Select Type + Case #TabBarGadget_PreviousArrow + X - \ArrowSize/2-1 + For Index = 1 To \ArrowSize + Line(X+Index, Y-Index, 1, Index*2, Color) + Next + LineXY(X, Y-1, X+\ArrowSize, Y-1-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X+\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + Case #TabBarGadget_NextArrow + X + \ArrowSize/2 + For Index = 1 To \ArrowSize + Line(X-Index, Y-Index, 1, Index*2, Color) + Next + LineXY(X, Y-1, X-\ArrowSize, Y-1-\ArrowSize, Color&$FFFFFF|Alpha<<24) + LineXY(X, Y, X-\ArrowSize, Y+\ArrowSize, Color&$FFFFFF|Alpha<<24) + EndSelect + EndIf + EndIf + EndWith + +EndProcedure + + + +; Gibt die Länge der Registerkate zurück. +Procedure.i TabBarGadget_ItemLength(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) ; Code OK + + Protected TextLength.i = TextWidth(*Item\ShortText) + Protected Length.i = 2 * TabBarGadgetInclude\PaddingX + Protected Characters.i, VerticalTextBugFix.f = 1.0 + + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + TextLength * TabBarGadgetInclude\VerticalTextBugFix ; 5% länger, wegen Ungenaugikeit von TextWidth bei Rotation + VerticalTextBugFix = TabBarGadgetInclude\VerticalTextBugFix + EndIf + If *Item\Attributes & #TabBarGadget_CloseButton Or (*Item\Attributes & #TabBarGadget_SelectedCloseButton And *Item\Selected) + Length + TabBarGadgetInclude\CloseButtonSize-4 + TabBarGadgetInclude\ImageSpace + EndIf + If *Item\Attributes & #TabBarGadget_CheckBox + Length + TabBarGadgetInclude\CheckBoxSize + TabBarGadgetInclude\ImageSpace + EndIf + If *Item\Image + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + Length + ImageHeight(*Item\Image) + Else + Length + ImageWidth(*Item\Image) + EndIf + If *Item\ShortText + Length + TabBarGadgetInclude\ImageSpace + EndIf + ElseIf *Item = *TabBarGadget\NewTabItem And *Item\Text = "" + Length + 16 + EndIf + If *Item <> *TabBarGadget\NewTabItem + If TextLength+Length < *TabBarGadget\MinTabLength + Length = *TabBarGadget\MinTabLength-TextLength + EndIf + If TextLength+Length > *TabBarGadget\MaxTabLength + Characters = Len(*Item\Text) + Repeat + Characters - 1 + TextLength = TextWidth(Left(*Item\Text, Characters)+"..")*VerticalTextBugFix + Until Characters = 1 Or TextLength+Length <= *TabBarGadget\MaxTabLength + *Item\ShortText = Left(*Item\Text, Characters) + ".." + EndIf + EndIf + + ProcedureReturn TextLength + Length + +EndProcedure + + + +; Gibt den maximal zur verfügungstehenden Platz für Registerkarten zurück. +Procedure.i TabBarGadget_MaxLength(*TabBarGadget.TabBarGadget, WithNewTab.i=#True) ; Code OK + + Protected Length.i + + With *TabBarGadget + If \Attributes & #TabBarGadget_Vertical + Length = OutputHeight() - TabBarGadgetInclude\Margin*2 + Else + Length = OutputWidth() - TabBarGadgetInclude\Margin*2 + EndIf + If \Attributes & #TabBarGadget_NewTab And WithNewTab + Length - *TabBarGadget\NewTabItem\Length + 1 + EndIf + If \Attributes & #TabBarGadget_PreviousArrow + Length - TabBarGadgetInclude\ArrowWidth + EndIf + If \Attributes & #TabBarGadget_NextArrow + Length - TabBarGadgetInclude\ArrowWidth + If \Attributes & #TabBarGadget_NewTab + Length - TabBarGadgetInclude\Margin + EndIf + EndIf + If \Attributes & #TabBarGadget_PopupButton + Length - TabBarGadgetInclude\ArrowHeight + EndIf + EndWith + + ProcedureReturn Length + +EndProcedure + + + +; Führt eine Textkürzung durch, bis alle Karte in die Leiste passen. +Procedure.i TabBarGadget_TextCutting(*TabBarGadget.TabBarGadget) ; Code OK + + Protected NewList SortedItem.TabBarGadgetSortedItem() + Protected *SortedItem.TabBarGadgetSortedItem + Protected MaxLength.i = 1, Length.i + + With *TabBarGadget + + ; Der Textlänge nach (groß -> klein) sortierte Einträge anlegen. + ForEach \Item() + \Item()\ShortText = \Item()\Text + \Item()\Length = TabBarGadget_ItemLength(*TabBarGadget, @\Item()) + If *TabBarGadget\Editor\Item <> \Item() + LastElement(SortedItem()) + *SortedItem = AddElement(SortedItem()) + *SortedItem\Item = @\Item() + *SortedItem\Characters = Len(\Item()\Text) + While PreviousElement(SortedItem()) And *SortedItem\Item\Length > SortedItem()\Item\Length + SwapElements(SortedItem(), @SortedItem(), *SortedItem) + ChangeCurrentElement(SortedItem(), *SortedItem) + Wend + EndIf + MaxLength + \Item()\Length - 1 + Next + + ; Textkürzung durchführen, bis alle Karte in die maximale Breite passen. + While MaxLength > \MaxLength And FirstElement(SortedItem()) + *SortedItem = @SortedItem() + If *SortedItem\Characters > 3 And *SortedItem\Item\Length > \MinTabLength + *SortedItem\Characters - 1 + *SortedItem\Item\ShortText = Left(*SortedItem\Item\Text, *SortedItem\Characters)+".." + Length = TabBarGadget_ItemLength(*TabBarGadget, *SortedItem\Item) + MaxLength - (*SortedItem\Item\Length-Length) + *SortedItem\Item\Length = Length + While NextElement(SortedItem()) And *SortedItem\Item\Length < SortedItem()\Item\Length + SwapElements(SortedItem(), @SortedItem(), *SortedItem) + ChangeCurrentElement(SortedItem(), *SortedItem) + Wend + Else + DeleteElement(SortedItem()) + EndIf + Wend + + EndWith + + ProcedureReturn MaxLength + +EndProcedure + + + +; Rotiert das Image abhängig von der Leistenausrichtung +Procedure TabBarGadget_RotateImage(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) ; Code OK + + Protected LastX.i = ImageWidth(*Item\Image)-1 + Protected LastY.i = ImageHeight(*Item\Image)-1 + Protected Dim Pixel.l(LastX, LastY) + Protected Y.i, X.i, RotatedImage.i + + If *Item\DrawedImage + FreeImage(*Item\DrawedImage) + EndIf + + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + If StartDrawing(ImageOutput(*Item\Image)) + DrawingMode(#PB_2DDrawing_AllChannels) + For Y = 0 To LastY + For X = 0 To LastX + Pixel(X, Y) = Point(X, Y) + Next + Next + StopDrawing() + EndIf + CompilerIf #PB_Compiler_Version >= 520 + *Item\DrawedImage = CreateImage(#PB_Any, TabBarGadgetInclude\ImageSize, TabBarGadgetInclude\ImageSize, 32, #PB_Image_Transparent) + CompilerElse + *Item\DrawedImage = CreateImage(#PB_Any, TabBarGadgetInclude\ImageSize, TabBarGadgetInclude\ImageSize, 32|#PB_Image_Transparent) + CompilerEndIf + If StartDrawing(ImageOutput(*Item\DrawedImage)) + DrawingMode(#PB_2DDrawing_AllChannels) + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + For Y = 0 To LastY + For X = 0 To LastX + Plot(LastY-Y, X, Pixel(X, Y)) + Next + Next + Else + For Y = 0 To LastY + For X = 0 To LastX + Plot(Y, LastX-X, Pixel(X, Y)) + Next + Next + EndIf + StopDrawing() + EndIf + Else + *Item\DrawedImage = CopyImage(*Item\Image, #PB_Any) + EndIf + +EndProcedure + + + +; (Er-)setz ein neues Icon für die Karte +Procedure TabBarGadget_ReplaceImage(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem, NewImageID.i=#Null) ; Code OK + + If *Item\Image + FreeImage(*Item\Image) + *Item\Image = #Null + EndIf + If *Item\DrawedImage + FreeImage(*Item\DrawedImage) + *Item\DrawedImage = #Null + EndIf + If NewImageID + CompilerIf #PB_Compiler_Version >= 520 + *Item\Image = CreateImage(#PB_Any, TabBarGadgetInclude\ImageSize, TabBarGadgetInclude\ImageSize, 32, #PB_Image_Transparent) + CompilerElse + *Item\Image = CreateImage(#PB_Any, TabBarGadgetInclude\ImageSize, TabBarGadgetInclude\ImageSize, 32|#PB_Image_Transparent) + CompilerEndIf + StartDrawing(ImageOutput(*Item\Image)) + DrawingMode(#PB_2DDrawing_AlphaBlend) + DrawImage(NewImageID, 0, 0, TabBarGadgetInclude\ImageSize, TabBarGadgetInclude\ImageSize) + StopDrawing() + TabBarGadget_RotateImage(*TabBarGadget, *Item) + EndIf + +EndProcedure + + + +; Berechnet das Layout einer Karte +Procedure TabBarGadget_ItemLayout(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) + + Protected TextAreaLength.i = *Item\Length - 2 * TabBarGadgetInclude\PaddingX + Protected NextSelected.i, PreviousSelected.i + + PushListPosition(*TabBarGadget\Item()) + If *Item\Selected + ChangeCurrentElement(*TabBarGadget\Item(), *Item) + If NextElement(*TabBarGadget\Item()) And *TabBarGadget\Item()\Selected + NextSelected = #True + EndIf + ChangeCurrentElement(*TabBarGadget\Item(), *Item) + If PreviousElement(*TabBarGadget\Item()) And *TabBarGadget\Item()\Selected + PreviousSelected = #True + EndIf + EndIf + PopListPosition(*TabBarGadget\Item()) + + With TabBarGadgetInclude + + If *Item\Attributes & #TabBarGadget_CloseButton Or (*Item\Attributes & #TabBarGadget_SelectedCloseButton And *Item\Selected) + TextAreaLength - (TabBarGadgetInclude\CloseButtonSize-4 + TabBarGadgetInclude\ImageSpace) + EndIf + If *Item\Attributes & #TabBarGadget_CheckBox + TextAreaLength - (TabBarGadgetInclude\CheckBoxSize + TabBarGadgetInclude\ImageSpace) + EndIf + If *Item\Image + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + TextAreaLength - (ImageHeight(*Item\Image)+TabBarGadgetInclude\ImageSpace) + Else + TextAreaLength - (ImageWidth(*Item\Image)+TabBarGadgetInclude\ImageSpace) + EndIf + EndIf + + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + *Item\Layout\Height = *Item\Length + *Item\Layout\Width = *TabBarGadget\TabSize + 1 + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + *Item\Layout\X = *TabBarGadget\TabSize * *Item\Row; - 1 + Else + *Item\Layout\X = OutputWidth() - *TabBarGadget\TabSize * (*Item\Row+1) + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering XOr *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + *Item\Layout\Y = *Item\Position + Else + *Item\Layout\Y = OutputHeight() - *Item\Position - *Item\Length + EndIf + If *Item\Selected + *Item\Layout\Width + \Margin + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs = 0 + *Item\Layout\X - \Margin + EndIf + EndIf + *Item\Layout\PaddingX = \PaddingY + *Item\Layout\PaddingY = \PaddingX + *Item\Layout\CrossX = *Item\Layout\X + (*Item\Layout\Width-\CloseButtonSize)/2 + *Item\Layout\CheckX = *Item\Layout\X + (*Item\Layout\Width-\CheckBoxSize)/2 + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + *Item\Layout\TextX = *Item\Layout\X + (*Item\Layout\Width+TextHeight("|"))/2 + Else + *Item\Layout\TextX = *Item\Layout\X + (*Item\Layout\Width-TextHeight("|"))/2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs XOr *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + *Item\Layout\CrossY = *Item\Layout\Y + *Item\Layout\Height - (\CloseButtonSize-3) - *Item\Layout\PaddingY + *Item\Layout\TextY = *Item\Layout\Y + *Item\Layout\PaddingY + (TextAreaLength-TextWidth(*Item\ShortText)*\VerticalTextBugFix) * (*TabBarGadget\TabTextAlignment+1)/2 + If *Item\Image + *Item\Layout\ImageX = *Item\Layout\X + (*Item\Layout\Width-ImageWidth(*Item\Image))/2 + *Item\Layout\ImageY = *Item\Layout\Y + *Item\Layout\PaddingY + *Item\Layout\TextY + ImageHeight(*Item\Image) + \ImageSpace + EndIf + If *Item\Attributes & #TabBarGadget_CheckBox + *Item\Layout\TextY + \CheckBoxSize + \ImageSpace + EndIf + *Item\Layout\CheckY = *Item\Layout\TextY-\CheckBoxSize-\ImageSpace ;-hier + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering : *Item\Layout\TextY + TextWidth(*Item\ShortText)*\VerticalTextBugFix : EndIf + Else + *Item\Layout\CrossY = *Item\Layout\Y + (-3) + *Item\Layout\PaddingY + *Item\Layout\TextY = *Item\Layout\Y + *Item\Layout\Height - *Item\Layout\PaddingY - (TextAreaLength-TextWidth(*Item\ShortText)*\VerticalTextBugFix) * (*TabBarGadget\TabTextAlignment+1)/2 + If *Item\Image + *Item\Layout\ImageX = *Item\Layout\X + (*Item\Layout\Width-ImageWidth(*Item\Image))/2 + *Item\Layout\ImageY = *Item\Layout\Y + *Item\Layout\Height-ImageHeight(*Item\Image) - *Item\Layout\PaddingY + *Item\Layout\TextY - ImageHeight(*Item\Image) - \ImageSpace + EndIf + If *Item\Attributes & #TabBarGadget_CheckBox + *Item\Layout\TextY - \CheckBoxSize - \ImageSpace + EndIf + *Item\Layout\CheckY = *Item\Layout\TextY+\ImageSpace + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering : *Item\Layout\TextY - TextWidth(*Item\ShortText)*\VerticalTextBugFix : EndIf + EndIf + If *Item\Selected + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs XOr *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + If PreviousSelected = #False + *Item\Layout\Y - \Margin/2 + *Item\Layout\Height + \Margin/2 + EndIf + If NextSelected = #False + *Item\Layout\Height + \Margin/2 + EndIf + Else + If NextSelected = #False + *Item\Layout\Y - \Margin/2 + *Item\Layout\Height + \Margin/2 + EndIf + If PreviousSelected = #False + *Item\Layout\Height + \Margin/2 + EndIf + EndIf + EndIf + Else + *Item\Layout\Width = *Item\Length + *Item\Layout\Height = *TabBarGadget\TabSize + 1 + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + *Item\Layout\X = OutputWidth() - *Item\Position - *Item\Length + Else + *Item\Layout\X = *Item\Position + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + *Item\Layout\Y = *TabBarGadget\TabSize * *Item\Row; - 1 + Else + *Item\Layout\Y = OutputHeight() - *TabBarGadget\TabSize * (*Item\Row+1) + EndIf + If *Item\Selected + *Item\Layout\Height + \Margin + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs = 0 + *Item\Layout\Y - \Margin + EndIf + EndIf + *Item\Layout\PaddingX = \PaddingX + *Item\Layout\PaddingY = \PaddingY + *Item\Layout\CrossY = *Item\Layout\Y + (*Item\Layout\Height-\CloseButtonSize)/2 + *Item\Layout\CheckY = *Item\Layout\Y + (*Item\Layout\Height-\CheckBoxSize)/2 + *Item\Layout\TextY = *Item\Layout\Y + (*Item\Layout\Height-TextHeight("|"))/2 + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + *Item\Layout\CrossX = *Item\Layout\X + (-3) + *Item\Layout\PaddingX + *Item\Layout\TextX = *Item\Layout\X + *Item\Layout\Width-TextWidth(*Item\ShortText) - *Item\Layout\PaddingX - (TextAreaLength-TextWidth(*Item\ShortText)) * (*TabBarGadget\TabTextAlignment+1)/2 + If *Item\Image + *Item\Layout\ImageX = *Item\Layout\X + *Item\Layout\Width-ImageWidth(*Item\Image) - *Item\Layout\PaddingX + *Item\Layout\ImageY = *Item\Layout\Y + (*Item\Layout\Height-ImageHeight(*Item\Image))/2 + *Item\Layout\TextX - ImageWidth(*Item\Image) - \ImageSpace + EndIf + If *Item\Attributes & #TabBarGadget_CheckBox + *Item\Layout\TextX - \CheckBoxSize - \ImageSpace + EndIf + *Item\Layout\CheckX = *Item\Layout\TextX + TextWidth(*Item\ShortText) + \ImageSpace + Else + *Item\Layout\CrossX = *Item\Layout\X + *Item\Layout\Width - (\CloseButtonSize-3) - *Item\Layout\PaddingX + *Item\Layout\TextX = *Item\Layout\X + *Item\Layout\PaddingX + (TextAreaLength-TextWidth(*Item\ShortText)) * (*TabBarGadget\TabTextAlignment+1)/2 + If *Item\Image + *Item\Layout\ImageX = *Item\Layout\X + *Item\Layout\PaddingX + *Item\Layout\ImageY = *Item\Layout\Y + (*Item\Layout\Height-ImageHeight(*Item\Image))/2 + *Item\Layout\TextX + ImageWidth(*Item\Image) + \ImageSpace + EndIf + If *Item\Attributes & #TabBarGadget_CheckBox + *Item\Layout\TextX + \CheckBoxSize + \ImageSpace + EndIf + *Item\Layout\CheckX = *Item\Layout\TextX - \CheckBoxSize - \ImageSpace + EndIf + If *Item\Selected + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + If NextSelected = #False + *Item\Layout\X - \Margin/2 + *Item\Layout\Width + \Margin/2 + EndIf + If PreviousSelected = #False + *Item\Layout\Width + \Margin/2 + EndIf + Else + If PreviousSelected = #False + *Item\Layout\X - \Margin/2 + *Item\Layout\Width + \Margin/2 + EndIf + If NextSelected = #False + *Item\Layout\Width + \Margin/2 + EndIf + EndIf + EndIf + EndIf + + EndWith + +EndProcedure + + + +; Berechnet das Layout +Procedure TabBarGadget_Layout(*TabBarGadget.TabBarGadget) + + Protected Shift.i + + With TabBarGadgetInclude + + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + Shift = -TabBarGadgetInclude\Margin + Else + Shift = TabBarGadgetInclude\Margin + EndIf + + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + *TabBarGadget\Layout\ButtonHeight = \ArrowWidth + *TabBarGadget\Layout\ButtonWidth = \ArrowHeight + *TabBarGadget\Layout\ButtonSize = \ArrowHeight + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs XOr *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\PopupButtonX = (OutputWidth()+Shift) / 2 + *TabBarGadget\Layout\PopupButtonY = OutputHeight() - *TabBarGadget\Layout\ButtonSize / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PreviousArrow + *TabBarGadget\Layout\PreviousButtonX = (OutputWidth()+Shift) / 2 + *TabBarGadget\Layout\PreviousButtonY = *TabBarGadget\Layout\ButtonHeight / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_NextArrow + *TabBarGadget\Layout\NextButtonX = (OutputWidth()+Shift) / 2 + *TabBarGadget\Layout\NextButtonY = OutputHeight() - *TabBarGadget\Layout\ButtonHeight / 2 + If *TabBarGadget\Attributes & #TabBarGadget_NewTab + *TabBarGadget\Layout\NextButtonY - *TabBarGadget\NewTabItem\Length-TabBarGadgetInclude\Margin + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\NextButtonY - *TabBarGadget\Layout\ButtonSize + EndIf + EndIf + Else + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\PopupButtonX = (OutputWidth()+Shift) / 2 + *TabBarGadget\Layout\PopupButtonY = *TabBarGadget\Layout\ButtonSize / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PreviousArrow + *TabBarGadget\Layout\PreviousButtonX = (OutputWidth()+Shift) / 2 + *TabBarGadget\Layout\PreviousButtonY = OutputHeight() - *TabBarGadget\Layout\ButtonHeight / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_NextArrow + *TabBarGadget\Layout\NextButtonX = (OutputWidth()+Shift) / 2 + *TabBarGadget\Layout\NextButtonY = *TabBarGadget\Layout\ButtonHeight / 2 + If *TabBarGadget\Attributes & #TabBarGadget_NewTab + *TabBarGadget\Layout\NextButtonY + *TabBarGadget\NewTabItem\Length+TabBarGadgetInclude\Margin + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\NextButtonY + *TabBarGadget\Layout\ButtonSize + EndIf + EndIf + EndIf + Else + *TabBarGadget\Layout\ButtonHeight = \ArrowHeight + *TabBarGadget\Layout\ButtonWidth = \ArrowWidth + *TabBarGadget\Layout\ButtonSize = \ArrowHeight + If *TabBarGadget\Attributes & #TabBarGadget_ReverseOrdering + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\PopupButtonX = *TabBarGadget\Layout\ButtonSize / 2 + *TabBarGadget\Layout\PopupButtonY = (OutputHeight()+Shift) / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PreviousArrow + *TabBarGadget\Layout\PreviousButtonX = OutputWidth() - *TabBarGadget\Layout\ButtonWidth / 2 + *TabBarGadget\Layout\PreviousButtonY = (OutputHeight()+Shift) / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_NextArrow + *TabBarGadget\Layout\NextButtonX = *TabBarGadget\Layout\ButtonWidth / 2 + *TabBarGadget\Layout\NextButtonY = (OutputHeight()+Shift) / 2 + If *TabBarGadget\Attributes & #TabBarGadget_NewTab + *TabBarGadget\Layout\NextButtonX + *TabBarGadget\NewTabItem\Length+TabBarGadgetInclude\Margin + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\NextButtonX + *TabBarGadget\Layout\ButtonSize + EndIf + EndIf + Else + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\PopupButtonX = OutputWidth() - *TabBarGadget\Layout\ButtonSize / 2 + *TabBarGadget\Layout\PopupButtonY = (OutputHeight()+Shift) / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PreviousArrow + *TabBarGadget\Layout\PreviousButtonX = *TabBarGadget\Layout\ButtonWidth / 2 + *TabBarGadget\Layout\PreviousButtonY = (OutputHeight()+Shift) / 2 + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_NextArrow + *TabBarGadget\Layout\NextButtonX = OutputWidth() - *TabBarGadget\Layout\ButtonWidth / 2 + *TabBarGadget\Layout\NextButtonY = (OutputHeight()+Shift) / 2 + If *TabBarGadget\Attributes & #TabBarGadget_NewTab + *TabBarGadget\Layout\NextButtonX - *TabBarGadget\NewTabItem\Length-TabBarGadgetInclude\Margin + EndIf + If *TabBarGadget\Attributes & #TabBarGadget_PopupButton + *TabBarGadget\Layout\NextButtonX - *TabBarGadget\Layout\ButtonSize + EndIf + EndIf + EndIf + + EndIf + + EndWith + +EndProcedure + + + +; Zeichnet eine Karte +Procedure TabBarGadget_DrawItem(*TabBarGadget.TabBarGadget, *Item.TabBarGadgetItem) + + Protected X.i, Y.i, LayoutX.i, LayoutY.i, LayoutWidth.i, LayoutHeight.i, Padding.i + Protected Color.i, Width.i, Height.i, Text.s, Len.i, Angle.i + + With TabBarGadgetInclude + + ; Orientierung der Registerkarte + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + LayoutX = -*TabBarGadget\Radius-1 + EndIf + LayoutWidth = *TabBarGadget\Radius + Else + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + LayoutY = -*TabBarGadget\Radius-1 + EndIf + LayoutHeight = *TabBarGadget\Radius + EndIf + + ; Aussehen + ResetGradientColors() + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + If *TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + LinearGradient(*Item\Layout\X+*Item\Layout\Width-1, 0, *Item\Layout\X, 0) + Else + LinearGradient(*Item\Layout\X, 0, *Item\Layout\X+*Item\Layout\Width-1, 0) + EndIf + Else + If #False ;*TabBarGadget\Attributes & #TabBarGadget_MirroredTabs + LinearGradient(0, *Item\Layout\Y+*Item\Layout\Height-1, 0, *Item\Layout\Y) + Else + LinearGradient(0, *Item\Layout\Y, 0, *Item\Layout\Y+*Item\Layout\Height-1) + EndIf + EndIf + Select *Item\Face + Case #TabBarGadgetItem_MoveFace + Color = TabBarGadget_ColorPlus(*Item\Color\Background, \ActivColorPlus) + GradientColor(0.0, TabBarGadget_ColorPlus(Color, $FF101010)&$FFFFFF|$C0<<24) + GradientColor(0.5, Color&$FFFFFF|$C0<<24) + GradientColor(1.0, TabBarGadget_ColorMinus(Color, $FF101010)&$FFFFFF|$C0<<24) + Case #TabBarGadgetItem_DisableFace + GradientColor(0.0, TabBarGadget_ColorPlus(*Item\Color\Background, $FF202020)&$FFFFFF|$80<<24) + GradientColor(0.5, *Item\Color\Background&$FFFFFF|$80<<24) + GradientColor(0.6, TabBarGadget_ColorMinus(*Item\Color\Background, $FF101010)&$FFFFFF|$80<<24) + GradientColor(1.0, TabBarGadget_ColorMinus(*Item\Color\Background, $FF303030)&$FFFFFF|$80<<24) + Case #TabBarGadgetItem_NormalFace + GradientColor(0.0, TabBarGadget_ColorPlus(*Item\Color\Background, $FF202020)) + GradientColor(0.5, *Item\Color\Background) + GradientColor(0.6, TabBarGadget_ColorMinus(*Item\Color\Background, $FF101010)) + GradientColor(1.0, TabBarGadget_ColorMinus(*Item\Color\Background, $FF303030)) + Case #TabBarGadgetItem_HoverFace + Color = TabBarGadget_ColorPlus(*Item\Color\Background, \HoverColorPlus) + GradientColor(0.0, TabBarGadget_ColorPlus(Color, $FF202020)) + GradientColor(0.5, Color) + GradientColor(0.6, TabBarGadget_ColorMinus(Color, $FF101010)) + GradientColor(1.0, TabBarGadget_ColorMinus(Color, $FF303030)) + Case #TabBarGadgetItem_ActiveFace + Color = TabBarGadget_ColorPlus(*Item\Color\Background, \ActivColorPlus) + GradientColor(0.0, TabBarGadget_ColorPlus(Color, $FF101010)) + GradientColor(0.5, Color) + GradientColor(1.0, TabBarGadget_ColorMinus(Color, $FF101010)) + EndSelect + +; ; andere ausgewählte Nachbarn +; If *Item <> *TabBarGadget\NewTabItem And *Item\Selected +; PushListPosition(*TabBarGadget\Item()) +; ChangeCurrentElement(*TabBarGadget\Item(), *Item) +; If NextElement(*TabBarGadget\Item()) And *TabBarGadget\Item()\Selected +; LayoutWidth - \Margin/2 +; EndIf +; ChangeCurrentElement(*TabBarGadget\Item(), *Item) +; If PreviousElement(*TabBarGadget\Item()) And *TabBarGadget\Item()\Selected +; LayoutX + \Margin/2 +; LayoutWidth - \Margin/2 +; EndIf +; PopListPosition(*TabBarGadget\Item()) +; EndIf + + ; Registerkarte zeichnen + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient) + RoundBox(*Item\Layout\X+LayoutX, *Item\Layout\Y+LayoutY, *Item\Layout\Width+LayoutWidth, *Item\Layout\Height+LayoutHeight, *TabBarGadget\Radius, *TabBarGadget\Radius) + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Outlined) + If *Item\Disabled + RoundBox(*Item\Layout\X+LayoutX, *Item\Layout\Y+LayoutY, *Item\Layout\Width+LayoutWidth, *Item\Layout\Height+LayoutHeight, *TabBarGadget\Radius, *TabBarGadget\Radius, \BorderColor&$FFFFFF|$80<<24) + Else + RoundBox(*Item\Layout\X+LayoutX, *Item\Layout\Y+LayoutY, *Item\Layout\Width+LayoutWidth, *Item\Layout\Height+LayoutHeight, *TabBarGadget\Radius, *TabBarGadget\Radius, \BorderColor) + EndIf + DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend) + + If *TabBarGadget\Attributes & #TabBarGadget_Vertical + Angle = 90 + 180*Bool(*TabBarGadget\Attributes&#TabBarGadget_MirroredTabs) + If *Item\Image + If *Item\DrawedImage = #Null + *Item\DrawedImage = TabBarGadget_RotateImage(*Item\Image, Angle) + EndIf + If *Item\Disabled + DrawAlphaImage(ImageID(*Item\DrawedImage), *Item\Layout\ImageX, *Item\Layout\ImageY, $40) + Else + DrawAlphaImage(ImageID(*Item\DrawedImage), *Item\Layout\ImageX, *Item\Layout\ImageY, $FF) + EndIf + EndIf + If *Item\Disabled + DrawRotatedText(*Item\Layout\TextX, *Item\Layout\TextY, *Item\ShortText, Angle, *Item\Color\Text&$FFFFFF|$40<<24) + Else + DrawRotatedText(*Item\Layout\TextX, *Item\Layout\TextY, *Item\ShortText, Angle, *Item\Color\Text) + EndIf + Else + If *Item\Image + If *Item\Disabled + DrawAlphaImage(ImageID(*Item\Image), *Item\Layout\ImageX, *Item\Layout\ImageY, $40) + Else + DrawAlphaImage(ImageID(*Item\Image), *Item\Layout\ImageX, *Item\Layout\ImageY, $FF) + EndIf + EndIf + If *Item\Disabled + DrawText(*Item\Layout\TextX, *Item\Layout\TextY, *Item\ShortText, *Item\Color\Text&$FFFFFF|$40<<24) + Else + DrawText(*Item\Layout\TextX, *Item\Layout\TextY, *Item\ShortText, *Item\Color\Text) + If *TabBarGadget\Editor\Item = *Item + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_XOr) + If *TabBarGadget\Editor\Selection < 0 + LayoutX = TextWidth(Left(*Item\Text, *TabBarGadget\Editor\Cursor+*TabBarGadget\Editor\Selection))-1 + LayoutWidth = TextWidth(Left(*Item\Text, *TabBarGadget\Editor\Cursor)) - LayoutX + Box(*Item\Layout\TextX+LayoutX, *Item\Layout\TextY, LayoutWidth, TextHeight("|")) + Else + LayoutX = TextWidth(Left(*Item\Text, *TabBarGadget\Editor\Cursor))-1 + LayoutWidth = TextWidth(Left(*Item\Text, *TabBarGadget\Editor\Cursor+*TabBarGadget\Editor\Selection)) - LayoutX + Box(*Item\Layout\TextX+LayoutX, *Item\Layout\TextY, LayoutWidth, TextHeight("|")) + EndIf + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent) + EndIf + EndIf + EndIf + + ; CheckBox + If *Item\Attributes & #TabBarGadget_CheckBox + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Outlined) + If *TabBarGadget\HoverItem = *Item And *TabBarGadget\HoverCheck + RoundBox(*Item\Layout\CheckX, *Item\Layout\CheckY, \CheckBoxSize, \CheckBoxSize, 2, 2, *Item\Color\Text) + ElseIf *Item\Disabled + RoundBox(*Item\Layout\CheckX, *Item\Layout\CheckY, \CheckBoxSize, \CheckBoxSize, 2, 2, \BorderColor&$FFFFFF|$40<<24) + Else + RoundBox(*Item\Layout\CheckX, *Item\Layout\CheckY, \CheckBoxSize, \CheckBoxSize, 2, 2, \BorderColor) + EndIf + If *Item\Checked + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient) + LinearGradient(*Item\Layout\CheckX+2, *Item\Layout\CheckY+2, *Item\Layout\CheckX+\CheckBoxSize-2, *Item\Layout\CheckY+\CheckBoxSize-2) + ResetGradientColors() + If *Item\Disabled + GradientColor(0, *Item\Color\Text&$FFFFFF|$20000000) + GradientColor(0.5, *Item\Color\Text&$FFFFFF|$30000000) + GradientColor(1, *Item\Color\Text&$FFFFFF|$20000000) + Else + GradientColor(0, *Item\Color\Text&$FFFFFF|$80000000) + GradientColor(0.5, *Item\Color\Text&$FFFFFF|$C0000000) + GradientColor(1, *Item\Color\Text&$FFFFFF|$80000000) + EndIf + Box(*Item\Layout\CheckX+2, *Item\Layout\CheckY+2, \CheckBoxSize-4, \CheckBoxSize-4) + EndIf + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Transparent) + EndIf + + ; Schließen-Schaltfläche + If *Item\Attributes & #TabBarGadget_CloseButton Or (*Item\Attributes & #TabBarGadget_SelectedCloseButton And *Item\Selected) + If *TabBarGadget\HoverItem = *Item And *TabBarGadget\HoverClose + If *TabBarGadget\LockedClose And *TabBarGadget\LockedItem = *Item + TabBarGadget_DrawButton(*Item\Layout\CrossX, *Item\Layout\CrossY, \CloseButtonSize, \CloseButtonSize, -1, *Item\Color\Background, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + Else + TabBarGadget_DrawButton(*Item\Layout\CrossX, *Item\Layout\CrossY, \CloseButtonSize, \CloseButtonSize, 1, *Item\Color\Background, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + EndIf + EndIf + If *Item\Disabled + TabBarGadget_DrawCross(*Item\Layout\CrossX+3, *Item\Layout\CrossY+3, \CloseButtonSize-6, *Item\Color\Text&$FFFFFF|$40<<24) + Else + TabBarGadget_DrawCross(*Item\Layout\CrossX+3, *Item\Layout\CrossY+3, \CloseButtonSize-6, *Item\Color\Text) + EndIf + EndIf + + EndWith + +EndProcedure + + + +; Verwaltet die Ereignisse beim Editieren einer Karte +Procedure TabBarGadget_Examine_Editor(*TabBarGadget.TabBarGadget) + + Protected MinDistance.i, Distance.i, Index.i + + With *TabBarGadget + + If \Editor\Item + + If TabBarGadget_MouseIn(*TabBarGadget, \Editor\Item\Layout\X, \Editor\Item\Layout\Y, \Editor\Item\Layout\Width, \Editor\Item\Layout\Height) + SetGadgetAttribute(\Number, #PB_Canvas_Cursor, #PB_Cursor_IBeam) + Else + SetGadgetAttribute(\Number, #PB_Canvas_Cursor, #PB_Cursor_Default) + EndIf + + Select EventType() + Case #PB_EventType_LeftDoubleClick + If \Editor\Item = \HoverItem + \Editor\Cursor = 0 + \Editor\Selection = Len(\Editor\Item\Text) + \Editor\Selectable = #False + EndIf + Case #PB_EventType_LeftButtonDown + If \Editor\Item = \HoverItem + \Editor\Cursor = 0 + \Editor\Selection = 0 + \Editor\Selectable = #True + MinDistance = $FFFF + For Index = Len(\Editor\Item\Text) To 0 Step -1 + Distance = Abs(\Editor\Item\Layout\TextX+TextWidth(Left(\Editor\Item\Text, Index))-\MouseX) + If Distance < MinDistance + \Editor\Cursor = Index + MinDistance = Distance + EndIf + Next + Else + If \Editor\OldText <> \Editor\Item\Text + ChangeCurrentElement(\Item(), \Editor\Item) + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_EditItem, ListIndex(\Item())) + EndIf + \Editor\Item = #Null + ProcedureReturn #Null + EndIf + Case #PB_EventType_MouseMove + If \Editor\Item = \HoverItem And \Editor\Selectable + \Editor\Selection = 0 + MinDistance = $FFFF + For Index = Len(\Editor\Item\Text) To 0 Step -1 + Distance = Abs(\Editor\Item\Layout\TextX+TextWidth(Left(\Editor\Item\Text, Index))-\MouseX) + If Distance < MinDistance + \Editor\Selection = Index-\Editor\Cursor + MinDistance = Distance + EndIf + Next + EndIf + Case #PB_EventType_LeftButtonUp + \Editor\Selectable = #False + Case #PB_EventType_Input + If \Editor\Selection > 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + Mid(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection+1) + \Editor\Selection = 0 + ElseIf \Editor\Selection < 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection) + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Cursor + \Editor\Selection + \Editor\Selection = 0 + EndIf + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + Chr(GetGadgetAttribute(\Number, #PB_Canvas_Input)) + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Item\ShortText = \Editor\Item\Text + \Editor\Cursor + 1 + Case #PB_EventType_KeyDown + Select GetGadgetAttribute(\Number, #PB_Canvas_Key) + Case #PB_Shortcut_Return + If \Editor\OldText <> \Editor\Item\Text + ChangeCurrentElement(\Item(), \Editor\Item) + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_EditItem, ListIndex(\Item())) + EndIf + \Editor\Item = #Null + ProcedureReturn #Null + Case #PB_Shortcut_Escape + \Editor\Item\Text = \Editor\OldText + \Editor\Item\ShortText = \Editor\Item\Text + \Editor\Item = #Null + ProcedureReturn #Null + Case #PB_Shortcut_Left + If GetGadgetAttribute(\Number, #PB_Canvas_Modifiers) & #PB_Canvas_Shift + If \Editor\Cursor+\Editor\Selection > 0 + \Editor\Selection - 1 + EndIf + Else + \Editor\Selection = 0 + If \Editor\Cursor > 0 + \Editor\Cursor - 1 + EndIf + EndIf + Case #PB_Shortcut_Right + If GetGadgetAttribute(\Number, #PB_Canvas_Modifiers) & #PB_Canvas_Shift + If \Editor\Cursor+\Editor\Selection < Len(\Editor\Item\Text) + \Editor\Selection + 1 + EndIf + Else + \Editor\Selection = 0 + If \Editor\Cursor < Len(\Editor\Item\Text) + \Editor\Cursor + 1 + EndIf + EndIf + Case #PB_Shortcut_Home + \Editor\Cursor = 0 + Case #PB_Shortcut_End + \Editor\Cursor = Len(\Editor\Item\Text) + Case #PB_Shortcut_Back + If \Editor\Selection > 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + Mid(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection+1) + \Editor\Selection = 0 + ElseIf \Editor\Selection < 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection) + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Cursor + \Editor\Selection + \Editor\Selection = 0 + ElseIf \Editor\Cursor > 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor-1) + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Cursor - 1 + EndIf + Case #PB_Shortcut_Delete + If \Editor\Selection > 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + Mid(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection+1) + \Editor\Selection = 0 + ElseIf \Editor\Selection < 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection) + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Cursor + \Editor\Selection + \Editor\Selection = 0 + ElseIf \Editor\Cursor < Len(\Editor\Item\Text) + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + Mid(\Editor\Item\Text, \Editor\Cursor+2) + EndIf + Case #PB_Shortcut_C + If GetGadgetAttribute(\Number, #PB_Canvas_Modifiers) & #PB_Canvas_Control + If \Editor\Selection > 0 + SetClipboardText(Mid(\Editor\Item\Text, \Editor\Cursor+1, \Editor\Selection)) + ElseIf \Editor\Selection < 0 + SetClipboardText(Mid(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection+1, -\Editor\Selection)) + EndIf + EndIf + Case #PB_Shortcut_V + If GetGadgetAttribute(\Number, #PB_Canvas_Modifiers) & #PB_Canvas_Control + If \Editor\Selection > 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + Mid(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection+1) + \Editor\Selection = 0 + ElseIf \Editor\Selection < 0 + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor+\Editor\Selection) + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Cursor + \Editor\Selection + \Editor\Selection = 0 + EndIf + \Editor\Item\Text = Left(\Editor\Item\Text, \Editor\Cursor) + GetClipboardText() + Mid(\Editor\Item\Text, \Editor\Cursor+1) + \Editor\Item\ShortText = \Editor\Item\Text + \Editor\Cursor + Len(GetClipboardText()) + EndIf + EndSelect + \Editor\Item\ShortText = \Editor\Item\Text + Case #PB_EventType_LostFocus + If \Editor\OldText <> \Editor\Item\Text + ChangeCurrentElement(\Item(), \Editor\Item) + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_EditItem, ListIndex(\Item())) + EndIf + \Editor\Item = #Null + EndSelect + + Else + + SetGadgetAttribute(\Number, #PB_Canvas_Cursor, #PB_Cursor_Default) + + EndIf + + EndWith + +EndProcedure + + + +; Ermittelt das Aussehen und die Lage der Tabs +Procedure TabBarGadget_Examine(*TabBarGadget.TabBarGadget) + + Protected MinLength.i, X.i, Y.i, Shift.i, MousePosition.i, Row.i + Protected Index.i, Distance.i, MinDistance.i + + With *TabBarGadget + + ; Initialisierung + \ToolTip\Current = #Null + \MouseX = GetGadgetAttribute(\Number, #PB_Canvas_MouseX) + \MouseY = GetGadgetAttribute(\Number, #PB_Canvas_MouseY) + \Event = #Null + \EventTab = #TabBarGadgetItem_None + \HoverItem = #Null + \HoverClose = #False + \HoverCheck = #False + \HoverArrow = #Null + DrawingFont(\FontID) + + ; Hover bei Registerkarten + If \MoveItem = #Null + + ForEach \Item() + If \Item()\Visible And TabBarGadget_MouseIn(*TabBarGadget, \Item()\Layout\X, \Item()\Layout\Y, \Item()\Layout\Width-1, \Item()\Layout\Height-1) + \HoverItem = \Item() + EndIf + Next + If \Attributes & #TabBarGadget_NewTab And TabBarGadget_MouseIn(*TabBarGadget, \NewTabItem\Layout\X, \NewTabItem\Layout\Y, \NewTabItem\Layout\Width-1, \NewTabItem\Layout\Height-1) + \HoverItem = \NewTabItem + EndIf + + EndIf + + ; Navigation + If \Attributes & (#TabBarGadget_PreviousArrow|#TabBarGadget_NextArrow) + + If EventType() = #PB_EventType_MouseWheel + \Shift + TabBarGadgetInclude\WheelDirection * GetGadgetAttribute(\Number, #PB_Canvas_WheelDelta) + If \Shift < 0 + \Shift = 0 + ElseIf \Shift > \LastShift + \Shift = \LastShift + EndIf + EndIf + + LockMutex(TabBarGadgetInclude\Timer\Mutex) + TabBarGadgetInclude\Timer\Type = #Null + If \Attributes & #TabBarGadget_PreviousArrow + If TabBarGadget_MouseIn(*TabBarGadget, \Layout\PreviousButtonX-\Layout\ButtonWidth/2, \Layout\PreviousButtonY-\Layout\ButtonHeight/2, \Layout\ButtonWidth, \Layout\ButtonHeight) + \HoverArrow = #TabBarGadget_PreviousArrow + \HoverItem = #Null + TabBarGadgetInclude\Timer\Type = #TabBarGadget_PreviousArrow + Select EventType() + Case #PB_EventType_LeftButtonDown + \LockedArrow = #TabBarGadget_PreviousArrow + TabBarGadgetInclude\Timer\TabBarGadget = *TabBarGadget + Case #PB_EventType_LeftButtonUp + If \LockedArrow = \HoverArrow And \Shift > 0 + \Shift - 1 + EndIf + EndSelect + EndIf + EndIf + If \Attributes & #TabBarGadget_NextArrow + If TabBarGadget_MouseIn(*TabBarGadget, \Layout\NextButtonX-\Layout\ButtonWidth/2, \Layout\NextButtonY-\Layout\ButtonHeight/2, \Layout\ButtonWidth, \Layout\ButtonHeight) + \HoverArrow = #TabBarGadget_NextArrow + \HoverItem = #Null + TabBarGadgetInclude\Timer\Type = #TabBarGadget_NextArrow + Select EventType() + Case #PB_EventType_LeftButtonDown + \LockedArrow = #TabBarGadget_NextArrow + TabBarGadgetInclude\Timer\TabBarGadget = *TabBarGadget + Case #PB_EventType_LeftButtonUp + If \LockedArrow = \HoverArrow And \Shift < \LastShift + \Shift + 1 + EndIf + EndSelect + EndIf + EndIf + UnlockMutex(TabBarGadgetInclude\Timer\Mutex) + + EndIf + + ; Popup-Button + If \Attributes & #TabBarGadget_PopupButton + If TabBarGadget_MouseIn(*TabBarGadget, \Layout\PopupButtonX-\Layout\ButtonSize/2, \Layout\PopupButtonY-\Layout\ButtonSize/2, \Layout\ButtonSize, \Layout\ButtonSize) + \HoverArrow = #TabBarGadget_PopupButton + \HoverItem = #Null + Select EventType() + Case #PB_EventType_LeftButtonDown + \LockedArrow = #TabBarGadget_PopupButton + Case #PB_EventType_LeftButtonUp + If \LockedArrow = \HoverArrow + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_PopupButton, -1) + EndIf + EndSelect + EndIf + EndIf + + ; Registerkarten + If \HoverItem + + ; Tooltip aktualisieren & Schließenbutton & Checkbox + If \HoverItem\ToolTip + \ToolTip\Current = @\HoverItem\ToolTip + Else + \ToolTip\Current = @\HoverItem\Text + EndIf + If ( \HoverItem\Attributes & #TabBarGadget_CloseButton Or (\HoverItem\Attributes & #TabBarGadget_SelectedCloseButton And \HoverItem\Selected) ) And \Editor\Item <> \HoverItem + If TabBarGadget_MouseIn(*TabBarGadget, \HoverItem\Layout\CrossX, \HoverItem\Layout\CrossY, TabBarGadgetInclude\CloseButtonSize, TabBarGadgetInclude\CloseButtonSize) + \HoverClose = \HoverItem + \ToolTip\Current = @\ToolTip\CloseText + Select EventType() + Case #PB_EventType_LeftButtonDown + \LockedClose = \HoverItem + Case #PB_EventType_LeftButtonUp + If \LockedClose = \HoverClose + ChangeCurrentElement(\Item(), \LockedClose) + \EventTab = ListIndex(\Item()) + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_CloseItem, \EventTab) + EndIf + EndSelect + EndIf + EndIf + If \HoverItem\Attributes & #TabBarGadget_CheckBox And \HoverItem\Disabled = #False And \Editor\Item <> \HoverItem + If TabBarGadget_MouseIn(*TabBarGadget, \HoverItem\Layout\CheckX, \HoverItem\Layout\CheckY, TabBarGadgetInclude\CheckBoxSize, TabBarGadgetInclude\CheckBoxSize) + \HoverCheck = \HoverItem + Select EventType() + Case #PB_EventType_LeftButtonDown + \LockedCheck = \HoverItem + Case #PB_EventType_LeftButtonUp + If \LockedCheck = \HoverCheck + ChangeCurrentElement(\Item(), \LockedCheck) + \EventTab = ListIndex(\Item()) + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_CheckBox, \EventTab) + \HoverItem\Checked = 1 - \HoverItem\Checked + EndIf + EndSelect + EndIf + EndIf + + ; Ereignisverwaltung + If \HoverItem = \NewTabItem + \EventTab = #TabBarGadgetItem_NewTab + \ToolTip\Current = @\ToolTip\NewText + Else + ChangeCurrentElement(\Item(), \HoverItem) + \EventTab = ListIndex(\Item()) + EndIf + Select EventType() + Case #PB_EventType_LeftButtonDown + \LockedItem = \HoverItem + If \LockedItem = \NewTabItem + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_NewItem, \EventTab) + ElseIf \LockedClose = #False And \LockedCheck = #False + If \HoverItem\Disabled = #False + If \Attributes & #TabBarGadget_MultiSelect And GetGadgetAttribute(\Number, #PB_Canvas_Modifiers) & #PB_Canvas_Control + If \HoverItem\Selected + TabBarGadget_UnselectItem(*TabBarGadget, \HoverItem) + Else + TabBarGadget_SelectItem(*TabBarGadget, \HoverItem) + EndIf + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_Change, \EventTab) + Else + ForEach \Item() + \Item()\Selected = #False + Next + If \SelectedItem <> \HoverItem + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_Change, \EventTab) + EndIf + TabBarGadget_SelectItem(*TabBarGadget, \HoverItem) + EndIf + EndIf + If Not \Attributes & #TabBarGadget_NoTabMoving And \Editor\Item = #Null + \ReadyToMoveItem = \HoverItem + \SaveMouseX = \MouseX + \SaveMouseY = \MouseY + EndIf + EndIf + Case #PB_EventType_MiddleButtonDown + \LockedItem = \HoverItem + Case #PB_EventType_MiddleButtonUp + If TabBarGadgetInclude\EnableMiddleClickForCloseTab And \LockedItem = \HoverItem And \LockedItem <> \NewTabItem And \LockedItem <> \Editor\Item + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_CloseItem, \EventTab) + \MoveItem = #Null + \ReadyToMoveItem = #Null + EndIf + \LockedItem = #Null + Case #PB_EventType_MouseMove + If \ReadyToMoveItem + If Abs(\SaveMouseX-\MouseX) > 4 Or Abs(\SaveMouseY-\MouseY) > 4 + \MoveItem = \ReadyToMoveItem + If \Attributes & (#TabBarGadget_NextArrow|#TabBarGadget_PreviousArrow) + LockMutex(TabBarGadgetInclude\Timer\Mutex) + TabBarGadgetInclude\Timer\TabBarGadget = *TabBarGadget + UnlockMutex(TabBarGadgetInclude\Timer\Mutex) + EndIf + EndIf + EndIf + Case #PB_EventType_LeftDoubleClick + If \Attributes & #TabBarGadget_Editable And \HoverItem\Disabled = #False + \Editor\Item = \HoverItem + \Editor\OldText = \Editor\Item\Text + EndIf + EndSelect + + EndIf + + ; Editor + TabBarGadget_Examine_Editor(*TabBarGadget) + + ; Sonstiges + Select EventType() + Case #PB_EventType_LeftButtonUp + \LockedClose = #False + \LockedCheck = #False + \MoveItem = #Null + \ReadyToMoveItem = #Null + \LockedArrow = #Null + LockMutex(TabBarGadgetInclude\Timer\Mutex) + TabBarGadgetInclude\Timer\TabBarGadget = #Null + UnlockMutex(TabBarGadgetInclude\Timer\Mutex) + Case #PB_EventType_MouseLeave + \HoverItem = #Null + Case #PB_EventType_LeftDoubleClick + If TabBarGadgetInclude\EnableDoubleClickForNewTab And \HoverArrow = #Null And \HoverItem = #Null + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_NewItem, \EventTab) + EndIf + EndSelect + If (\Shift <= 0 And \HoverArrow = #TabBarGadget_PreviousArrow) Or (\Shift >= \LastShift And \HoverArrow = #TabBarGadget_NextArrow) + \HoverArrow = #False + EndIf + + ; Registerkartenverschiebung: Verschiebungspartner suchen und tauschen + If \MoveItem + \EventTab = \MoveItem + If \Attributes & #TabBarGadget_Vertical + If \Attributes & #TabBarGadget_MultiLine + If \Attributes & #TabBarGadget_MirroredTabs + Row = Int((\MouseX-TabBarGadgetInclude\Margin)/\TabSize) + Else + Row = Int(\Rows-(\MouseX-TabBarGadgetInclude\Margin)/\TabSize) + EndIf + If Row < 0 : Row = 0 : ElseIf Row >= \Rows : Row = \Rows-1 : EndIf + MousePosition = Row*\MaxLength + \MouseY + Else + MousePosition = \MouseY + EndIf + If Not (\Attributes & #TabBarGadget_MirroredTabs XOr \Attributes & #TabBarGadget_ReverseOrdering) + MousePosition = OutputHeight() - MousePosition + EndIf + Else + If \Attributes & #TabBarGadget_MultiLine + If \Attributes & #TabBarGadget_MirroredTabs + Row = Int((\MouseY-TabBarGadgetInclude\Margin)/\TabSize) + Else + Row = Int(\Rows-(\MouseY-TabBarGadgetInclude\Margin)/\TabSize) + EndIf + If Row < 0 : Row = 0 : ElseIf Row >= \Rows : Row = \Rows-1 : EndIf + MousePosition = Row*\MaxLength + \MouseX + Else + MousePosition = \MouseX + EndIf + If \Attributes & #TabBarGadget_ReverseOrdering + MousePosition = OutputWidth() - MousePosition + EndIf + EndIf + If Not \Event + ChangeCurrentElement(\Item(), \MoveItem) + While NextElement(\Item()) + If MousePosition > \Item()\Position + \MaxLength*\Item()\Row + SwapElements(\Item(), @\Item(), \MoveItem) + \Item()\Position = \MoveItem\Position + \MoveItem\Position = \Item()\Position + \Item()\Length + \Event = #TabBarGadget_EventType_SwapItem + PushListPosition(\Item()) + ChangeCurrentElement(\Item(), \MoveItem) + \EventTab = ListIndex(\Item()) + PopListPosition(\Item()) + EndIf + Wend + EndIf + If Not \Event + ChangeCurrentElement(\Item(), \MoveItem) + While PreviousElement(\Item()) And ListIndex(\Item()) >= \Shift-1 + If \MoveItem\Length < \Item()\Length + MinLength = \MoveItem\Length + Else + MinLength = \Item()\Length + EndIf + If MousePosition < \Item()\Position + \MaxLength*\Item()\Row + MinLength + SwapElements(\Item(), @\Item(), \MoveItem) + \MoveItem\Position = \Item()\Position + \Item()\Position = \MoveItem\Position + \MoveItem\Length + \Event = #TabBarGadget_EventType_SwapItem + PushListPosition(\Item()) + ChangeCurrentElement(\Item(), \MoveItem) + \EventTab = ListIndex(\Item()) + PopListPosition(\Item()) + EndIf + Wend + EndIf + If \Event = #TabBarGadget_EventType_SwapItem + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_SwapItem, \EventTab) + EndIf + EndIf + + ; ToolTip aktualisieren + If \ToolTip\Current <> \ToolTip\Old + If \ToolTip\Current = #Null + GadgetToolTip(\Number, "") + ElseIf \ToolTip\Current = @\ToolTip\NewText Or \ToolTip\Current = @\ToolTip\CloseText + GadgetToolTip(\Number, PeekS(\ToolTip\Current)) + ElseIf \HoverItem And \ToolTip\Current = @\HoverItem\ToolTip + GadgetToolTip(\Number, PeekS(\ToolTip\Current)) + Else + GadgetToolTip(\Number, ReplaceString(\ToolTip\ItemText, "%ITEM", PeekS(\ToolTip\Current))) + EndIf + \ToolTip\Old = \ToolTip\Current + EndIf + + EndWith + +EndProcedure + + + +; Ermittelt das Aussehen und die Lage der Tabs +Procedure TabBarGadget_Update(*TabBarGadget.TabBarGadget) + + Protected FocusingSelectedTab.i + Protected ShowLength.i, X.i + Protected OldAttributes.i + Protected Difference.f, Factor.f, Position.i, Length.i, MaxWidth.i, MousePosition.i + Protected *Item.TabBarGadgetItem, Row.i, Rows.i=1 + Protected *Current, *Last, AddLength.i, RowCount.i + Protected Dim Row.TabBarGadgetRow(0) + + With *TabBarGadget + + ; Vorbereitung + DrawingFont(\FontID) + \Attributes & ~(#TabBarGadget_PreviousArrow|#TabBarGadget_NextArrow) ; erstmal keine Navigation + If \TabSize = 0 + If \Attributes & #TabBarGadget_Vertical + If GadgetWidth(\Number) > 1 + \TabSize = OutputWidth() - TabBarGadgetInclude\Margin + Else + \TabSize = TextHeight("|") + TabBarGadgetInclude\PaddingY*2 + EndIf + Else + If GadgetHeight(\Number) > 1 + \TabSize = OutputHeight() - TabBarGadgetInclude\Margin + Else + \TabSize = TextHeight("|") + TabBarGadgetInclude\PaddingY*2 + EndIf + EndIf + EndIf + If \Attributes & #TabBarGadget_NewTab + \NewTabItem\Length = TabBarGadget_ItemLength(*TabBarGadget, \NewTabItem) + \NewTabItem\Row = 0 + EndIf + + ; Mehrzeilige Registerkartenleiste + If \Attributes & #TabBarGadget_MultiLine + + \MaxLength = TabBarGadget_MaxLength(*TabBarGadget) + \Length = \MaxLength + \Shift = 0 + + ; Breiten ermitteln + Length = 1 + ForEach \Item() + \Item()\Row = 0 + \Item()\Length = TabBarGadget_ItemLength(*TabBarGadget, \Item()) + \Item()\Visible = #True + Length - 1 + \Item()\Length + Next + + ; Mehrere Zeilen einrichten + If Length > \MaxLength + Row = 0 + Row(Row)\Length = 1 + ForEach \Item() + If NextElement(\Item()) + PreviousElement(\Item()) + MaxWidth = TabBarGadget_MaxLength(*TabBarGadget, #False) + Else + LastElement(\Item()) + MaxWidth = TabBarGadget_MaxLength(*TabBarGadget) + EndIf + If Row(Row)\Length-1+\Item()\Length > MaxWidth And Row(Row)\Items > 0 + Row + 1 + ReDim Row(Row) + Row(Row)\Length = 1 + EndIf + Row(Row)\Length - 1 + \Item()\Length + Row(Row)\Items + 1 + \Item()\Row = Row + Next + Else + Row(Row)\Length = Length + EndIf + Rows = Row+1 + + ; Verbreitern + If Rows > 1 + MaxWidth = TabBarGadget_MaxLength(*TabBarGadget, #False) + ForEach \Item() + AddLength = (MaxWidth-Row(\Item()\Row)\Length)/Row(\Item()\Row)\Items + If \Item()\Row <> Rows-1 Or AddLength < 0 + \Item()\Length + AddLength + Row(\Item()\Row)\Length + AddLength + Row(\Item()\Row)\Items - 1 + EndIf + Next + EndIf + + ; Positionen errechnen + Length = TabBarGadgetInclude\Margin + Row = 0 + ForEach \Item() + If Row <> \Item()\Row + Row + 1 + Length = TabBarGadgetInclude\Margin + EndIf + \Item()\Position = Length + Length + \Item()\Length - 1 + Next + If Row(Rows-1)\Length > TabBarGadget_MaxLength(*TabBarGadget) And LastElement(\Item()) + \Item()\Length = TabBarGadget_MaxLength(*TabBarGadget, #False) + Rows + 1 + \NewTabItem\Row = Rows-1 + \NewTabItem\Position = TabBarGadgetInclude\Margin + Else + \NewTabItem\Row = Rows-1 + \NewTabItem\Position = TabBarGadgetInclude\Margin+Row(\NewTabItem\Row)\Length - 1 + EndIf + + ; Einzeilige Registerkartenleiste + Else + + \MaxLength = TabBarGadget_MaxLength(*TabBarGadget) + + ; ggf. Textkürzung + If \Attributes & #TabBarGadget_TextCutting + \Length = TabBarGadget_TextCutting(*TabBarGadget) + If \Length <= \MaxLength + \Shift = 0 + EndIf + EndIf + + ; Breiten ermitteln + \Length = 1 + ForEach \Item() + \Item()\Length = TabBarGadget_ItemLength(*TabBarGadget, \Item()) + \Item()\Row = 0 + \Length + \Item()\Length-1 + Next + + ; Navigation nötig ? + If \Length > \MaxLength + \Attributes | (#TabBarGadget_PreviousArrow | #TabBarGadget_NextArrow) + \MaxLength = TabBarGadget_MaxLength(*TabBarGadget) + Else + ;\Shift = 0 + EndIf + + ; LastShift ermitteln + If LastElement(\Item()) + \LastShift = ListIndex(\Item()) + ShowLength = \Item()\Length + While PreviousElement(\Item()) + If ShowLength + \Item()\Length - 1 > \MaxLength - Bool(ListIndex(\Item())>0)*TabBarGadgetInclude\FadeOut + Break + Else + ShowLength + \Item()\Length - 1 + \LastShift - 1 + EndIf + Wend + Else + \LastShift = 0 + EndIf + + ; ggf. aktuell ausgewählte Registerkarte in den sichtbaren Bereich bringen + If \FocusingSelectedTab And \SelectedItem + ChangeCurrentElement(\Item(), \SelectedItem) + If ListIndex(\Item()) <= \Shift + \Shift = ListIndex(\Item()) + Else + While \Shift < \LastShift And SelectElement(\Item(), \Shift) + ShowLength = \Item()\Length + If \Item() = \SelectedItem + Break + EndIf + While NextElement(\Item()) + If ShowLength + \Item()\Length - 1 > \MaxLength - (Bool(\Shift>0)+Bool(\Shift<\LastShift))*TabBarGadgetInclude\FadeOut + \Shift + 1 + Break + ElseIf \Item() = \SelectedItem + Break 2 + EndIf + ShowLength + \Item()\Length - 1 + Wend + Wend + EndIf + \FocusingSelectedTab = #False + EndIf + + If \Shift > \LastShift + \Shift = \LastShift + EndIf + \MaxLength - (Bool(\Shift>0)+Bool(\Shift<\LastShift))*TabBarGadgetInclude\FadeOut + + ; Position der Tabs + + ; vorherige Registerkarte + If \Attributes & #TabBarGadget_PreviousArrow + If \Shift > 0 + ForEach \Item() + \Item()\Position = -$FFFF + \Item()\Visible = #False + If ListIndex(\Item()) >= \Shift-1 : Break : EndIf + Next + Position = TabBarGadgetInclude\ArrowWidth + TabBarGadgetInclude\Margin + TabBarGadgetInclude\FadeOut + SelectElement(\Item(), \Shift-1) + \Item()\Position = Position - \Item()\Length + 1 + \Item()\Visible = #True + Else + Position = TabBarGadgetInclude\ArrowWidth + TabBarGadgetInclude\Margin + EndIf + Else + Position = TabBarGadgetInclude\Margin + EndIf + + ; sichtbare Registerkarten + \Length = 0 + If SelectElement(\Item(), \Shift) + Repeat + \Item()\Position = Position + \Length + \Item()\Visible = #True + If \Length + \Item()\Length - 1 > \MaxLength + Break + EndIf + \Length + \Item()\Length - 1 + Until Not NextElement(\Item()) + EndIf + + ; nächste Registerkarte + If \Attributes & #TabBarGadget_NextArrow And ListIndex(\Item()) <> -1 + If ListIndex(\Item()) <> ListSize(\Item())-1 + \Item()\Position = Position + \Length + \Length + \Item()\Length - 1 + \Item()\Visible = #True + If NextElement(\Item()) + \Item()\Position = Position + \Length + \Item()\Visible = #True + EndIf + EndIf + If \Attributes & #TabBarGadget_NewTab + If \Attributes & #TabBarGadget_Vertical + \NewTabItem\Position = OutputHeight()-\NewTabItem\Length-TabBarGadgetInclude\Margin/2 + Else + \NewTabItem\Position = OutputWidth()-\NewTabItem\Length-TabBarGadgetInclude\Margin/2 + EndIf + If \Attributes & #TabBarGadget_PopupButton + \NewTabItem\Position - TabBarGadgetInclude\ArrowHeight + EndIf + EndIf + While NextElement(\Item()) + \Item()\Position = $FFFF + \Item()\Visible = #False + Wend + Else + If \Attributes & #TabBarGadget_NewTab + \NewTabItem\Position = Position + \Length + EndIf + EndIf + + Row(0)\Length = Position - TabBarGadgetInclude\Margin+\Length+1 + + EndIf + + ; Größenänderung des Gadgets + If Rows <> \Rows And (EventType() >= #PB_EventType_FirstCustomValue Or GetGadgetAttribute(\Number, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton = #False) + StopDrawing() + If \Attributes & #TabBarGadget_Vertical + ResizeGadget(\Number, #PB_Ignore, #PB_Ignore, Rows*\TabSize+TabBarGadgetInclude\Margin, #PB_Ignore) + Else + ResizeGadget(\Number, #PB_Ignore, #PB_Ignore, #PB_Ignore, Rows*\TabSize+TabBarGadgetInclude\Margin) + EndIf + PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_Resize, -1) + StartDrawing(CanvasOutput(\Number)) + DrawingFont(\FontID) + \Resized = #True + \Rows = Rows + EndIf + + ; Animation der bewegten Registerkarte + If \MoveItem + If \Attributes & #TabBarGadget_Vertical + If \Attributes & #TabBarGadget_MirroredTabs XOr \Attributes & #TabBarGadget_ReverseOrdering + MousePosition = \MouseY + Else + MousePosition = OutputHeight()-\MouseY-1 + EndIf + Else + If \Attributes & #TabBarGadget_ReverseOrdering + MousePosition = OutputWidth()-\MouseX-1 + Else + MousePosition = \MouseX + EndIf + EndIf + Difference = Abs(\MoveItem\Position-(MousePosition-\MoveItem\Length/2)) + If Difference > 24 + Position = MousePosition - \MoveItem\Length/2 + Else + Factor = Pow(Difference/24, 2) + Position = \MoveItem\Position*(1-Factor) + (MousePosition-\MoveItem\Length/2)*Factor + EndIf + If \Attributes & #TabBarGadget_PreviousArrow = #Null + If Position < TabBarGadgetInclude\Margin + Position = TabBarGadgetInclude\Margin + EndIf + ElseIf \Shift <= 0 And Position < TabBarGadgetInclude\Margin + TabBarGadgetInclude\ArrowWidth + Position = TabBarGadgetInclude\Margin + TabBarGadgetInclude\ArrowWidth + EndIf + If (\Attributes & #TabBarGadget_NextArrow = #Null Or \Shift >= \LastShift) And Position + \MoveItem\Length + 1 - TabBarGadgetInclude\Margin > Row(\MoveItem\Row)\Length - 1 + Position = Row(\MoveItem\Row)\Length + TabBarGadgetInclude\Margin - \MoveItem\Length + EndIf + \MoveItem\Position = Position + EndIf + + ; Aussehen + ForEach \Item() + If \Item()\Disabled + \Item()\Face = #TabBarGadgetItem_DisableFace + ElseIf \Item() = \MoveItem + \Item()\Face = #TabBarGadgetItem_MoveFace + ElseIf \Item() = \SelectedItem Or \Item()\Selected + \Item()\Face = #TabBarGadgetItem_ActiveFace + ElseIf \Item() = \HoverItem + \Item()\Face = #TabBarGadgetItem_HoverFace + Else + \Item()\Face = #TabBarGadgetItem_NormalFace + EndIf + TabBarGadget_ItemLayout(*TabBarGadget, \Item()) + Next + If \NewTabItem = \HoverItem + \NewTabItem\Face = #TabBarGadgetItem_HoverFace + Else + \NewTabItem\Face = #TabBarGadgetItem_NormalFace + EndIf + TabBarGadget_ItemLayout(*TabBarGadget, \NewTabItem) + TabBarGadget_Layout(*TabBarGadget) + + *TabBarGadget\UpdatePosted = #False + + EndWith + +EndProcedure + + + +; Zeichnet das gesamte TabBarGadget +Procedure TabBarGadget_Draw(*TabBarGadget.TabBarGadget) + + Protected X.i, Y.i, Size.i, SelectedItemDrawed.i, MoveItemDrawed.i, Row.i, *LastItem + + With *TabBarGadget + + ; Initialisierung + DrawingFont(\FontID) + DrawingMode(#PB_2DDrawing_AllChannels) + Box(0, 0, OutputWidth(), OutputHeight(), TabBarGadgetInclude\TabBarColor) + DrawingMode(#PB_2DDrawing_AlphaBlend) + + ; Sichtbare Registerkarten + *LastItem = LastElement(\Item()) + For Row = \Rows-1 To 0 Step -1 + If *LastItem + PushListPosition(\Item()) + While \Item()\Row >= Row + If \Item()\Visible And \Item()\Selected = #False And \Item() <> \MoveItem + TabBarGadget_DrawItem(*TabBarGadget, \Item()) + EndIf + If Not PreviousElement(\Item()) + Break + EndIf + Wend + EndIf + ; ggf. "Neu"-Registerkarte (wenn keine Navigation) + If \NewTabItem\Row = Row And \Attributes & #TabBarGadget_NewTab And \Attributes & #TabBarGadget_NextArrow = #Null + TabBarGadget_DrawItem(*TabBarGadget, \NewTabItem) + EndIf + ; ggf. Unterlinien + If Row = 0 And \Attributes & #TabBarGadget_BottomLine + If \Attributes & #TabBarGadget_Vertical + If \Attributes & #TabBarGadget_MirroredTabs + Line(0, 0, 1, OutputHeight(), TabBarGadgetInclude\BorderColor) + Else + Line(OutputWidth()-1, 0, 1, OutputHeight(), TabBarGadgetInclude\BorderColor) + EndIf + Else + If \Attributes & #TabBarGadget_MirroredTabs + Line(0, 0, OutputWidth(), 1, TabBarGadgetInclude\BorderColor) + Else + Line(0, OutputHeight()-1, OutputWidth(), 1, TabBarGadgetInclude\BorderColor) + EndIf + EndIf + EndIf + ; ggf. aktive Registerkarte + If *LastItem + PopListPosition(\Item()) + While \Item()\Row >= Row + If \Item()\Visible And \Item()\Selected = #True And \Item() <> \MoveItem + TabBarGadget_DrawItem(*TabBarGadget, \Item()) + EndIf + If Not PreviousElement(\Item()) + Break + EndIf + Wend + EndIf + ; ggf. bewegte Registerkarte + If \MoveItem And \MoveItem\Row = Row + TabBarGadget_DrawItem(*TabBarGadget, \MoveItem) + EndIf + Next + + ; Navigationsausblendung + DrawingMode(#PB_2DDrawing_AlphaBlend|#PB_2DDrawing_Gradient) + ResetGradientColors() + GradientColor(0.0, TabBarGadgetInclude\TabBarColor&$FFFFFF) + GradientColor(0.5, TabBarGadgetInclude\TabBarColor&$FFFFFF|$A0<<24) + GradientColor(1.0, TabBarGadgetInclude\TabBarColor&$FFFFFF|$FF<<24) + Size = TabBarGadgetInclude\Margin + TabBarGadgetInclude\ArrowWidth + TabBarGadgetInclude\FadeOut + If \Attributes & #TabBarGadget_PreviousArrow And \Shift + If \Attributes & #TabBarGadget_Vertical + If \Attributes & #TabBarGadget_MirroredTabs XOr \Attributes & #TabBarGadget_ReverseOrdering + LinearGradient(0, Size, 0, Size-TabBarGadgetInclude\FadeOut) + Box(0, 0, OutputWidth(), Size) + Else + LinearGradient(0, OutputHeight()-Size, 0, OutputHeight()-Size+TabBarGadgetInclude\FadeOut) + Box(0, OutputHeight()-Size, OutputWidth(), Size) + EndIf + Else + If \Attributes & #TabBarGadget_ReverseOrdering + LinearGradient(OutputWidth()-Size, 0, OutputWidth()-Size+TabBarGadgetInclude\FadeOut, 0) + Box(OutputWidth()-Size, 0, Size, OutputHeight()) + Else + LinearGradient(Size, 0, Size-TabBarGadgetInclude\FadeOut, 0) + Box(0, 0, Size, OutputHeight()) + EndIf + EndIf + EndIf + If \Attributes & #TabBarGadget_NextArrow And \Shift < \LastShift + If \Attributes & #TabBarGadget_NewTab + Size + \NewTabItem\Length+TabBarGadgetInclude\Margin + EndIf + If \Attributes & #TabBarGadget_PopupButton + Size + TabBarGadgetInclude\ArrowHeight + EndIf + If \Attributes & #TabBarGadget_Vertical + If \Attributes & #TabBarGadget_MirroredTabs XOr \Attributes & #TabBarGadget_ReverseOrdering + LinearGradient(0, OutputHeight()-Size, 0, OutputHeight()-Size+TabBarGadgetInclude\FadeOut) + Box(0, OutputHeight()-Size, OutputWidth(), Size) + Else + LinearGradient(0, Size, 0, Size-TabBarGadgetInclude\FadeOut) + Box(0, 0, OutputWidth(), Size) + EndIf + Else + If \Attributes & #TabBarGadget_ReverseOrdering + LinearGradient(Size, 0, Size-TabBarGadgetInclude\FadeOut, 0) + Box(0, 0, Size, OutputHeight()) + Else + LinearGradient(OutputWidth()-Size, 0, OutputWidth()-Size+TabBarGadgetInclude\FadeOut, 0) + Box(OutputWidth()-Size, 0, Size, OutputHeight()) + EndIf + EndIf + EndIf + + ; Navigation + DrawingMode(#PB_2DDrawing_AlphaBlend) + If \Attributes & #TabBarGadget_PreviousArrow + If \HoverArrow = #TabBarGadget_PreviousArrow + If \HoverArrow = \LockedArrow + TabBarGadget_DrawButton(\Layout\PreviousButtonX-\Layout\ButtonWidth/2, \Layout\PreviousButtonY-\Layout\ButtonHeight/2, \Layout\ButtonWidth, \Layout\ButtonHeight, -1, TabBarGadgetInclude\FaceColor, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + Else + TabBarGadget_DrawButton(\Layout\PreviousButtonX-\Layout\ButtonWidth/2, \Layout\PreviousButtonY-\Layout\ButtonHeight/2, \Layout\ButtonWidth, \Layout\ButtonHeight, 1, TabBarGadgetInclude\FaceColor, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + EndIf + TabBarGadget_DrawArrow(\Layout\PreviousButtonX, \Layout\PreviousButtonY, #TabBarGadget_PreviousArrow, TabBarGadgetInclude\TextColor, *TabBarGadget\Attributes) + ElseIf \Shift > 0 + TabBarGadget_DrawArrow(\Layout\PreviousButtonX, \Layout\PreviousButtonY, #TabBarGadget_PreviousArrow, TabBarGadgetInclude\TextColor&$FFFFFF|$80<<24, *TabBarGadget\Attributes) + Else + TabBarGadget_DrawArrow(\Layout\PreviousButtonX, \Layout\PreviousButtonY, #TabBarGadget_PreviousArrow, TabBarGadgetInclude\TextColor&$FFFFFF|$20<<24, *TabBarGadget\Attributes) + EndIf + EndIf + If \Attributes & #TabBarGadget_NextArrow + If \HoverArrow = #TabBarGadget_NextArrow + If \HoverArrow = \LockedArrow + TabBarGadget_DrawButton(\Layout\NextButtonX-\Layout\ButtonWidth/2, \Layout\NextButtonY-\Layout\ButtonHeight/2, \Layout\ButtonWidth, \Layout\ButtonHeight, -1, TabBarGadgetInclude\FaceColor, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + Else + TabBarGadget_DrawButton(\Layout\NextButtonX-\Layout\ButtonWidth/2, \Layout\NextButtonY-\Layout\ButtonHeight/2, \Layout\ButtonWidth, \Layout\ButtonHeight, 1, TabBarGadgetInclude\FaceColor, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + EndIf + TabBarGadget_DrawArrow(\Layout\NextButtonX, \Layout\NextButtonY, #TabBarGadget_NextArrow, TabBarGadgetInclude\TextColor, *TabBarGadget\Attributes) + ElseIf \Shift < \LastShift + TabBarGadget_DrawArrow(\Layout\NextButtonX, \Layout\NextButtonY, #TabBarGadget_NextArrow, TabBarGadgetInclude\TextColor&$FFFFFF|$80<<24, *TabBarGadget\Attributes) + Else + TabBarGadget_DrawArrow(\Layout\NextButtonX, \Layout\NextButtonY, #TabBarGadget_NextArrow, TabBarGadgetInclude\TextColor&$FFFFFF|$20<<24, *TabBarGadget\Attributes) + EndIf + EndIf + + ; "Neu"-Registerkarten (wenn Navigation) + If \Attributes & #TabBarGadget_NewTab And \Attributes & #TabBarGadget_NextArrow + TabBarGadget_DrawItem(*TabBarGadget, \NewTabItem) + EndIf + + ; Popup-Button + If \Attributes & #TabBarGadget_PopupButton + If \HoverArrow = #TabBarGadget_PopupButton + If \HoverArrow = \LockedArrow + TabBarGadget_DrawButton(\Layout\PopupButtonX-\Layout\ButtonSize/2, \Layout\PopupButtonY-\Layout\ButtonSize/2, \Layout\ButtonSize, \Layout\ButtonSize, -1, TabBarGadgetInclude\FaceColor, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + Else + TabBarGadget_DrawButton(\Layout\PopupButtonX-\Layout\ButtonSize/2, \Layout\PopupButtonY-\Layout\ButtonSize/2, \Layout\ButtonSize, \Layout\ButtonSize, 1, TabBarGadgetInclude\FaceColor, *TabBarGadget\Attributes & #TabBarGadget_Vertical) + EndIf + TabBarGadget_DrawArrow(\Layout\PopupButtonX, \Layout\PopupButtonY, #TabBarGadget_PopupButton, TabBarGadgetInclude\TextColor, *TabBarGadget\Attributes) + Else + TabBarGadget_DrawArrow(\Layout\PopupButtonX, \Layout\PopupButtonY, #TabBarGadget_PopupButton, TabBarGadgetInclude\TextColor&$FFFFFF|$80<<24, *TabBarGadget\Attributes) + EndIf + EndIf + + EndWith + +EndProcedure + + + +; Dauerschleife für das automatische Scrollen in der Navigation +Procedure TabBarGadget_Timer(Null.i) ; Code OK + + With TabBarGadgetInclude\Timer + Repeat + If \TabBarGadget + Delay(250) + Repeat + LockMutex(\Mutex) + If \TabBarGadget + PostEvent(#PB_Event_Gadget, \TabBarGadget\Window, \TabBarGadget\Number, #TabBarGadget_EventType_Pushed, \Type) + UnlockMutex(\Mutex) + Else + UnlockMutex(\Mutex) + Break + EndIf + Delay(150) + ForEver + Else + Delay(50) + EndIf + ForEver + EndWith + +EndProcedure + + + +; Sendet ein Ereignis, um die Registerkarte zu aktualisieren. +Procedure TabBarGadget_PostUpdate(*TabBarGadget.TabBarGadget) ; Code OK + + If *TabBarGadget\UpdatePosted = #False + *TabBarGadget\UpdatePosted = #True + PostEvent(#PB_Event_Gadget, *TabBarGadget\Window, *TabBarGadget\Number, #TabBarGadget_EventType_Updated, -1) + EndIf + +EndProcedure + + + +; Callback für BindGadgetEvent() +Procedure TabBarGadget_Callback() ; Code OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(EventGadget()) + + If EventType() >= #PB_EventType_FirstCustomValue + *TabBarGadget\EventTab = EventData() + Select EventType() + Case #TabBarGadget_EventType_Pushed + Select EventData() + Case #TabBarGadget_PreviousArrow + If *TabBarGadget\Shift > 0 + *TabBarGadget\Shift - 1 + EndIf + Case #TabBarGadget_NextArrow + If *TabBarGadget\Shift < *TabBarGadget\LastShift + *TabBarGadget\Shift + 1 + EndIf + EndSelect + If StartDrawing(CanvasOutput(*TabBarGadget\Number)) + TabBarGadget_Update(*TabBarGadget) + TabBarGadget_Draw(*TabBarGadget) + StopDrawing() + EndIf + Case #TabBarGadget_EventType_Updated + If StartDrawing(CanvasOutput(*TabBarGadget\Number)) + TabBarGadget_Update(*TabBarGadget) + TabBarGadget_Draw(*TabBarGadget) + StopDrawing() + EndIf + EndSelect + Else + If StartDrawing(CanvasOutput(*TabBarGadget\Number)) + TabBarGadget_Examine(*TabBarGadget) + TabBarGadget_Update(*TabBarGadget) + TabBarGadget_Draw(*TabBarGadget) + StopDrawing() + EndIf + EndIf + +EndProcedure + + + + + +;- 4.2 Procedures for the TabBarGadget +;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ + + + +; Führt eine Aktualisierung (Neuzeichnung) des Gadgets durch. +Procedure UpdateTabBarGadget(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + If StartDrawing(CanvasOutput(Gadget)) + TabBarGadget_Update(*TabBarGadget) + TabBarGadget_Draw(*TabBarGadget) + StopDrawing() + EndIf + +EndProcedure + + + +; Gibt das angegebene TabBarGadget wieder frei. +Procedure FreeTabBarGadget(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + UnbindGadgetEvent(Gadget, @TabBarGadget_Callback()) + + ForEach *TabBarGadget\Item() + TabBarGadget_ClearItem(*TabBarGadget, *TabBarGadget\Item()) + Next + ClearStructure(*TabBarGadget, TabBarGadget) + FreeMemory(*TabBarGadget) + FreeGadget(Gadget) + +EndProcedure + + + +; Erstellt ein neus TabBarGadget. +Procedure.i TabBarGadget(Gadget.i, X.i, Y.i, Width.i, Height.i, Attributes.i, Window.i) ; Code OK + + Protected *TabBarGadget.TabBarGadget = AllocateMemory(SizeOf(TabBarGadget)) + Protected Result.i, OldGadgetList.i, DummyGadget.i + + InitializeStructure(*TabBarGadget, TabBarGadget) + ;OldGadgetList = UseGadgetList(WindowID(Window)) + Result = CanvasGadget(Gadget, X, Y, Width, Height, #PB_Canvas_Keyboard) + ;UseGadgetList(OldGadgetList) + If Gadget = #PB_Any + Gadget = Result + EndIf + SetGadgetData(Gadget, *TabBarGadget) + + With *TabBarGadget + \Attributes = Attributes + \Number = Gadget + \Window = Window + \NewTabItem\Color\Text = TabBarGadgetInclude\TextColor + \NewTabItem\Color\Background = TabBarGadgetInclude\FaceColor + \Radius = TabBarGadgetInclude\Radius + \MinTabLength = TabBarGadgetInclude\MinTabLength + \MaxTabLength = TabBarGadgetInclude\MaxTabLength + \NormalTabLength = TabBarGadgetInclude\NormalTabLength + \TabTextAlignment = TabBarGadgetInclude\TabTextAlignment + CompilerSelect #PB_Compiler_OS + CompilerCase #PB_OS_Windows + \FontID = GetGadgetFont(#PB_Default) + CompilerDefault + DummyGadget = TextGadget(#PB_Any, 0, 0, 10, 10, "Dummy") + \FontID = GetGadgetFont(DummyGadget) + FreeGadget(DummyGadget) + CompilerEndSelect + \EventTab = #TabBarGadgetItem_None + EndWith + + BindGadgetEvent(Gadget, @TabBarGadget_Callback()) + ;BindEvent(#PB_Event_Gadget, @TabBarGadget_Callback(), #PB_All, Gadget, #PB_All) ; Aktuelle nicht benutzbar + UpdateTabBarGadget(Gadget) + + ProcedureReturn Result + +EndProcedure + + + +; Fügt eine Registerkarte an die angegebenen Position ein. +Procedure.i AddTabBarGadgetItem(Gadget.i, Position.i, Text.s, ImageID.i=#Null, DataValue.i=#Null) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + Protected *Item.TabBarGadgetItem + + If Position = #TabBarGadgetItem_NewTab + *TabBarGadget\Attributes | #TabBarGadget_NewTab + *Item = @*TabBarGadget\NewTabItem + ElseIf TabBarGadget_ItemID(*TabBarGadget, Position) + *Item = InsertElement(*TabBarGadget\Item()) + Else + LastElement(*TabBarGadget\Item()) + *Item = AddElement(*TabBarGadget\Item()) + Position = ListIndex(*TabBarGadget\Item()) + EndIf + + With *Item + \Text = Text + \ShortText = Text + TabBarGadget_ReplaceImage(*TabBarGadget, *Item, ImageID) + \DataValue = DataValue + \Color\Text = TabBarGadgetInclude\TextColor + \Color\Background = TabBarGadgetInclude\FaceColor + If *Item <> @*TabBarGadget\NewTabItem + \Attributes = *TabBarGadget\Attributes + EndIf + EndWith + + TabBarGadget_PostUpdate(*TabBarGadget) + + ProcedureReturn Position + +EndProcedure + + + +; Gibt die einmalige ID der angegebenen Registerkarte zurück. +Procedure.i TabBarGadgetItemID(Gadget.i, Position.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + ProcedureReturn TabBarGadget_ItemID(*TabBarGadget, Position) + +EndProcedure + + + +; Entfernt die Registerkarte mit der angegebenen Position. +Procedure RemoveTabBarGadgetItem(Gadget.i, Position.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + If Position = #TabBarGadgetItem_NewTab + *TabBarGadget\Attributes & ~#TabBarGadget_NewTab + ElseIf TabBarGadget_ItemID(*TabBarGadget, Position) + TabBarGadget_RemoveItem(*TabBarGadget, *TabBarGadget\Item()) + EndIf + + TabBarGadget_PostUpdate(*TabBarGadget) + +EndProcedure + + + +; Entfernt alle Registerkarten aus der Leiste. +Procedure ClearTabBarGadgetItems(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + ForEach *TabBarGadget\Item() + TabBarGadget_ClearItem(*TabBarGadget, *TabBarGadget\Item()) + Next + ClearList(*TabBarGadget\Item()) + *TabBarGadget\SelectedItem = #Null + + TabBarGadget_PostUpdate(*TabBarGadget) + +EndProcedure + + + +; Gibt die Anzahl der Registerkarten zurück. +Procedure.i CountTabBarGadgetItems(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + ProcedureReturn ListSize(*TabBarGadget\Item()) + +EndProcedure + + + + + +;- 4.3 Set- & Get-Prozeduren +;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ + + + +; Setz einen ToolTip für die Registerkartenleiste (für die Registerkarten, die "Neu"-Registerkarte und den Schließenbutton) +Procedure TabBarGadgetToolTip(Gadget.i, ItemText.s="", NewText.s="", CloseText.s="") ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + *TabBarGadget\ToolTip\ItemText = ItemText + *TabBarGadget\ToolTip\NewText = NewText + *TabBarGadget\ToolTip\CloseText = CloseText + +EndProcedure + + + +; Setz einen ToolTip für die Registerkarte. +Procedure TabBarGadgetItemToolTip(Gadget.i, Tab.i, Text.s) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + *Item\ToolTip = Text + EndIf + +EndProcedure + + + +; Ändert den Wert eines Attributs der Registerkartenleiste. +Procedure SetTabBarGadgetAttribute(Gadget.i, Attribute.i, Value.i, Overwrite.i=#True) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + Select Attribute + Case #TabBarGadget_CloseButton, #TabBarGadget_SelectedCloseButton, #TabBarGadget_NewTab, #TabBarGadget_NoTabMoving, #TabBarGadget_BottomLine, + #TabBarGadget_MultiLine, #TabBarGadget_PopupButton, #TabBarGadget_Editable, #TabBarGadget_CheckBox, #TabBarGadget_ReverseOrdering + If Value + *TabBarGadget\Attributes | Attribute + If Overwrite + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\Attributes | Attribute + Next + EndIf + Else + *TabBarGadget\Attributes & ~Attribute + If Overwrite + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\Attributes & ~Attribute + Next + EndIf + EndIf + Case #TabBarGadget_MultiSelect + If Value + *TabBarGadget\Attributes | Attribute + Else + *TabBarGadget\Attributes & ~Attribute + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\Selected = #False + Next + If *TabBarGadget\SelectedItem + *TabBarGadget\SelectedItem\Selected = #True + EndIf + EndIf + Case #TabBarGadget_TextCutting + If Value + *TabBarGadget\Attributes | Attribute + Else + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\ShortText = *TabBarGadget\Item()\Text + Next + *TabBarGadget\Attributes & ~Attribute + EndIf + Case #TabBarGadget_MirroredTabs, #TabBarGadget_Vertical + *TabBarGadget\Rows = 0 + If Value + *TabBarGadget\Attributes | Attribute + Else + *TabBarGadget\Attributes & ~Attribute + EndIf + ForEach *TabBarGadget\Item() + If *TabBarGadget\Item()\Image + TabBarGadget_RotateImage(*TabBarGadget, *TabBarGadget\Item()) + EndIf + Next + If *TabBarGadget\NewTabItem\Image + TabBarGadget_RotateImage(*TabBarGadget, *TabBarGadget\NewTabItem) + EndIf + Case #TabBarGadget_TabRounding + *TabBarGadget\Radius = Value + Case #TabBarGadget_MinTabLength + *TabBarGadget\MinTabLength = Value + Case #TabBarGadget_TabTextAlignment + *TabBarGadget\TabTextAlignment = Value + Case #TabBarGadget_MaxTabLength + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\ShortText = *TabBarGadget\Item()\Text + Next + *TabBarGadget\MaxTabLength = Value + Case #TabBarGadget_ScrollPosition + If Value < 0 + *TabBarGadget\Shift = 0 + ElseIf Value > *TabBarGadget\LastShift + *TabBarGadget\Shift = *TabBarGadget\LastShift + Else + *TabBarGadget\Shift = Value + EndIf + EndSelect + + TabBarGadget_PostUpdate(*TabBarGadget) + +EndProcedure + + + +; Gibt den Wert eines Attributs der Registerkartenleiste zurück. +Procedure.i GetTabBarGadgetAttribute(Gadget.i, Attribute.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + Select Attribute + Case #TabBarGadget_CloseButton, #TabBarGadget_SelectedCloseButton, #TabBarGadget_NewTab, #TabBarGadget_MirroredTabs, #TabBarGadget_TextCutting, + #TabBarGadget_NoTabMoving, #TabBarGadget_BottomLine, #TabBarGadget_MultiLine, #TabBarGadget_PopupButton, #TabBarGadget_Editable, + #TabBarGadget_MultiSelect, #TabBarGadget_Vertical, #TabBarGadget_CheckBox, #TabBarGadget_ReverseOrdering + If *TabBarGadget\Attributes & Attribute + ProcedureReturn #True + Else + ProcedureReturn #False + EndIf + Case #TabBarGadget_TabRounding + ProcedureReturn *TabBarGadget\Radius + Case #TabBarGadget_MinTabLength + ProcedureReturn *TabBarGadget\MinTabLength + Case #TabBarGadget_MaxTabLength + ProcedureReturn *TabBarGadget\MaxTabLength + Case #TabBarGadget_ScrollPosition + ProcedureReturn *TabBarGadget\Shift + Case #TabBarGadget_TabTextAlignment + ProcedureReturn *TabBarGadget\TabTextAlignment + EndSelect + +EndProcedure + + + +; Ändert den Daten-Wert der Registerkartenleiste. +Procedure SetTabBarGadgetData(Gadget.i, DataValue.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + *TabBarGadget\DataValue = DataValue + +EndProcedure + + + +; Gibt den Daten-Wert der Registerkartenleiste zurück. +Procedure.i GetTabBarGadgetData(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + ProcedureReturn *TabBarGadget\DataValue + +EndProcedure + + + +; Ändert die zu nutzende Schrift. +Procedure SetTabBarGadgetFont(Gadget.i, FontID.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + If FontID = #PB_Default + *TabBarGadget\FontID = GetGadgetFont(#PB_Default) + Else + *TabBarGadget\FontID = FontID + EndIf + + TabBarGadget_PostUpdate(*TabBarGadget) + +EndProcedure + + + +; Ändert den Status der Registerkartenleiste. +Procedure SetTabBarGadgetState(Gadget.i, State.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + Protected *Item.TabBarGadgetItem + + ForEach *TabBarGadget\Item() + *TabBarGadget\Item()\Selected = #False + Next + Select State + Case #TabBarGadgetItem_None, #TabBarGadgetItem_NewTab + *TabBarGadget\SelectedItem = #Null + Case #TabBarGadgetItem_Selected + Default + *Item = TabBarGadget_ItemID(*TabBarGadget, State) + If *Item + TabBarGadget_SelectItem(*TabBarGadget, *Item) + EndIf + EndSelect + + TabBarGadget_PostUpdate(*TabBarGadget) + +EndProcedure + + + +; Gibt den Status der Registerkartenleiste zurück. +Procedure.i GetTabBarGadgetState(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + If *TabBarGadget\SelectedItem + ChangeCurrentElement(*TabBarGadget\Item(), *TabBarGadget\SelectedItem) + ProcedureReturn ListIndex(*TabBarGadget\Item()) + EndIf + + ProcedureReturn #TabBarGadgetItem_None + +EndProcedure + + + +; Wechselt zur der Registerkarte mit dem angegebenen Text +Procedure SetTabBarGadgetText(Gadget.i, Text.s) ; Code OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + *TabBarGadget\SelectedItem = #Null + ForEach *TabBarGadget\Item() + If *TabBarGadget\Item()\Text = Text + SetTabBarGadgetState(Gadget, @*TabBarGadget\Item()) + Break + EndIf + Next + +EndProcedure + + + +; Gibt den Text der aktuell ausgewählten Registerkarte zurück. +Procedure.s GetTabBarGadgetText(Gadget.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + If *TabBarGadget\SelectedItem + ProcedureReturn *TabBarGadget\SelectedItem\Text + EndIf + +EndProcedure + + + +; Ändert die Attribute der angegebenen Registerkarte. +Procedure SetTabBarGadgetItemAttribute(Gadget.i, Tab.i, Attribute.i, Value.i) + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + Protected *Item.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Tab) + + If *Item And *Item <> *TabBarGadget\NewTabItem + Select Attribute + Case #TabBarGadget_CloseButton, #TabBarGadget_SelectedCloseButton, #TabBarGadget_CheckBox + If Value + *Item\Attributes | Attribute + Else + *Item\Attributes & ~Attribute + EndIf + EndSelect + TabBarGadget_PostUpdate(*TabBarGadget) + EndIf + +EndProcedure + + + +; Gibt den Status der angegebenen Registerkarte zurück. +Procedure.i GetTabBarGadgetItemAttribute(Gadget.i, Tab.i, Attribute.i) + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + Protected State.i + + If *Item + Select Attribute + Case #TabBarGadget_CloseButton, #TabBarGadget_SelectedCloseButton, #TabBarGadget_CheckBox + If *Item\Attributes & Attribute + ProcedureReturn #True + Else + ProcedureReturn #False + EndIf + EndSelect + EndIf + +EndProcedure + + + +; Ändert den Datenwert der angegebenen Registerkarte. +Procedure SetTabBarGadgetItemData(Gadget.i, Tab.i, DataValue.i) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + *Item\DataValue = DataValue + EndIf + +EndProcedure + + + +; Gibt den Datenwert der angegebenen Registerkarte zurück. +Procedure.i GetTabBarGadgetItemData(Gadget.i, Tab.i) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + ProcedureReturn *Item\DataValue + EndIf + +EndProcedure + + + +; Ändert die Farbe der angegebenen Registerkarte. +Procedure SetTabBarGadgetItemColor(Gadget.i, Tab.i, Type.i, Color.i) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + Select Type + Case #PB_Gadget_FrontColor + If Color = #PB_Default + Color = TabBarGadgetInclude\TextColor + EndIf + *Item\Color\Text = Color | $FF<<24 + Case #PB_Gadget_BackColor + If Color = #PB_Default + Color = TabBarGadgetInclude\FaceColor + EndIf + *Item\Color\Background = Color | $FF<<24 + EndSelect + TabBarGadget_PostUpdate(GetGadgetData(Gadget)) + EndIf + +EndProcedure + + + +; Gibt die Farbe der angegebenen Registerkarte zurück. +Procedure.i GetTabBarGadgetItemColor(Gadget.i, Tab.i, Type.i) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + Select Type + Case #PB_Gadget_FrontColor + ProcedureReturn *Item\Color\Text + Case #PB_Gadget_BackColor + ProcedureReturn *Item\Color\Background + EndSelect + EndIf + +EndProcedure + + + +; Ändert das Icon der angegebenen Registerkarte. +Procedure SetTabBarGadgetItemImage(Gadget.i, Tab.i, ImageID.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + Protected *Item.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Tab) + + If *Item + TabBarGadget_ReplaceImage(*TabBarGadget, *Item, ImageID) + TabBarGadget_PostUpdate(*TabBarGadget) + EndIf + +EndProcedure + + + +; Ändert die Position der angegebenen Registerkarte (die Registerkarte wird also verschoben). +Procedure SetTabBarGadgetItemPosition(Gadget.i, Tab.i, Position.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + Protected *NewItem.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Position) + Protected *Item.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Tab) + + If *Item And *Item <> *TabBarGadget\NewTabItem + If *NewItem And *NewItem <> *TabBarGadget\NewTabItem + MoveElement(*TabBarGadget\Item(), #PB_List_Before, *NewItem) + Else + MoveElement(*TabBarGadget\Item(), #PB_List_Last) + EndIf + TabBarGadget_PostUpdate(*TabBarGadget) + EndIf + +EndProcedure + + + +; Gibt die Position der angegebenen Registerkarte zurück. +Procedure GetTabBarGadgetItemPosition(Gadget.i, Tab.i) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + + With *TabBarGadget + + Select Tab + Case #TabBarGadgetItem_Event + ProcedureReturn \EventTab + Case #TabBarGadgetItem_Selected + If \SelectedItem + ChangeCurrentElement(\Item(), \SelectedItem) + ProcedureReturn ListIndex(\Item()) + Else + ProcedureReturn #TabBarGadgetItem_None + EndIf + Case #TabBarGadgetItem_NewTab, #TabBarGadgetItem_None + ProcedureReturn Tab + Default + If Tab >= 0 And Tab < ListSize(\Item()) + ProcedureReturn Tab + ElseIf Tab >= ListSize(\Item()) + ForEach \Item() + If @\Item() = Tab + ProcedureReturn ListIndex(\Item()) + EndIf + Next + ProcedureReturn #TabBarGadgetItem_None + EndIf + EndSelect + + EndWith + +EndProcedure + + + +; Ändert den Status der angegebenen Registerkarte. +Procedure SetTabBarGadgetItemState(Gadget.i, Tab.i, State.i, Mask.i=#TabBarGadget_Disabled|#TabBarGadget_Selected|#TabBarGadget_Checked) ; Code OK, Hilfe OK + + Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget) + Protected *Item.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Tab) + + If *Item And *Item <> *TabBarGadget\NewTabItem + If Mask & #TabBarGadget_Disabled + *Item\Disabled = Bool(State&#TabBarGadget_Disabled) + EndIf + If Mask & #TabBarGadget_Checked + *Item\Checked = Bool(State&#TabBarGadget_Checked) + EndIf + If Mask & #TabBarGadget_Selected + If State & #TabBarGadget_Selected + TabBarGadget_SelectItem(*TabBarGadget, *Item) + Else + TabBarGadget_UnselectItem(*TabBarGadget, *Item) + EndIf + EndIf + TabBarGadget_PostUpdate(*TabBarGadget) + EndIf + +EndProcedure + + + +; Gibt den Status der angegebenen Registerkarte zurück. +Procedure.i GetTabBarGadgetItemState(Gadget.i, Tab.i) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + ProcedureReturn (*Item\Disabled*#TabBarGadget_Disabled) | (*Item\Selected*#TabBarGadget_Selected) | (*Item\Checked*#TabBarGadget_Checked) + EndIf + +EndProcedure + + + +; Ändert den Text der angegebenen Registerkarte. +Procedure SetTabBarGadgetItemText(Gadget.i, Tab.i, Text.s) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + *Item\Text = Text + *Item\ShortText = Text + TabBarGadget_PostUpdate(GetGadgetData(Gadget)) + EndIf + +EndProcedure + + + +; Gibt den Text der angegebenen Registerkarte zurück. +Procedure.s GetTabBarGadgetItemText(Gadget.i, Tab.i) ; Code OK, Hilfe OK + + Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab) + + If *Item + ProcedureReturn *Item\Text + EndIf + +EndProcedure + + + +; IDE Options = PureBasic 5.31 (Windows - x64) +; CursorPosition = 2568 +; FirstLine = 2342 +; Folding = --8v--4-f- +; EnableXP +; EnableCompileCount = 35 +; EnableBuildCount = 0 \ No newline at end of file diff --git a/Includes/Node_Editor.pbi b/Includes/Node_Editor.pbi index f0adb13..3c521de 100644 --- a/Includes/Node_Editor.pbi +++ b/Includes/Node_Editor.pbi @@ -894,8 +894,8 @@ Procedure Node_Editor_Event_SizeWindow() ResizeGadget(Node_Editor\Canvas, #PB_Ignore, #PB_Ignore, WindowWidth(Node_Editor\Window\ID)-150, WindowHeight(Node_Editor\Window\ID)-ToolBarHeight) ResizeGadget(Node_Editor\TreeList, WindowWidth(Node_Editor\Window\ID)-150, #PB_Ignore, 150, WindowHeight(Node_Editor\Window\ID)-ToolBarHeight) - Node_Editor\Redraw = #True - ;Node_Editor_Canvas_Redraw() + ;Node_Editor\Redraw = #True + Node_Editor_Canvas_Redraw() EndProcedure Procedure Node_Editor_Event_ActivateWindow() @@ -977,7 +977,7 @@ Procedure Node_Editor_Open() Protected ToolBarHeight If Node_Editor\Window = #Null - Node_Editor\Window = Window_Create(#Null, "Node Editor", "Node Editor", #PB_Ignore, #PB_Ignore, 500, 500) + Node_Editor\Window = Window_Create(#Null, "Node Editor", "Node Editor", #True, #PB_Ignore, #PB_Ignore, 500, 500, #True, 20) ; #### Toolbar Node_Editor\ToolBar = CreateToolBar(#PB_Any, WindowID(Node_Editor\Window\ID)) @@ -1085,7 +1085,8 @@ DataSection Node_Editor_Icon_Align: : IncludeBinary "../Data/Icons/Node_Align.png" EndDataSection ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 979 +; FirstLine = 972 ; Folding = ---- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Data_Inspector/Object_Data_Inspector.pbi b/Includes/Object/Data_Inspector/Object_Data_Inspector.pbi index a9905e2..9e73157 100644 --- a/Includes/Object/Data_Inspector/Object_Data_Inspector.pbi +++ b/Includes/Object/Data_Inspector/Object_Data_Inspector.pbi @@ -869,6 +869,8 @@ Procedure Object_Data_Inspector_Window_Open(*Object.Object) BindEvent(#PB_Event_Menu, @Object_Data_Inspector_Window_Event_Menu(), *Object_Data_Inspector\Window\ID) BindEvent(#PB_Event_CloseWindow, @Object_Data_Inspector_Window_Event_CloseWindow(), *Object_Data_Inspector\Window\ID) + Window_Bounds(*Object_Data_Inspector\Window, 300, 460, #PB_Default, #PB_Default) + *Object_Data_Inspector\Update_ListIcon = #True Else @@ -947,7 +949,8 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 826 +; FirstLine = 834 ; Folding = --- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Editor/Object_Editor.pbi b/Includes/Object/Editor/Object_Editor.pbi index 595db76..384d46c 100644 --- a/Includes/Object/Editor/Object_Editor.pbi +++ b/Includes/Object/Editor/Object_Editor.pbi @@ -1196,7 +1196,7 @@ Procedure Object_Editor_Statusbar_Update(*Object.Object) ProcedureReturn #False EndIf - If *Object_Editor\Window\ID = GetGadgetState(Main_Window\MDI) + If *Object_Editor\Window\ID = Window_Get_Active() If *Object_Editor\Select_Start < *Object_Editor\Select_End StatusBarText(Main_Window\StatusBar_ID, 0, "Offset: "+Hex(*Object_Editor\Select_Start)) Else @@ -2177,7 +2177,10 @@ Procedure Object_Editor_Window_Event_SizeWindow() ResizeGadget(*Object_Editor\Canvas, #PB_Ignore, #PB_Ignore, WindowWidth(Event_Window)-17, WindowHeight(Event_Window)-ToolBarHeight) ResizeGadget(*Object_Editor\ScrollBar, WindowWidth(Event_Window)-17, #PB_Ignore, 17, WindowHeight(Event_Window)-ToolBarHeight) - *Object_Editor\Redraw = #True + Object_Editor_Organize(*Object) + Object_Editor_Get_Data(*Object) + Object_Editor_Canvas_Redraw(*Object) + Object_Editor_Statusbar_Update(*Object) EndProcedure Procedure Object_Editor_Window_Event_ActivateWindow() @@ -2296,7 +2299,7 @@ Procedure Object_Editor_Window_Open(*Object.Object) EndIf If *Object_Editor\Window = #Null - *Object_Editor\Window = Window_Create(*Object, "Editor", "Editor", #True, #PB_Ignore, #PB_Ignore, 500, 500) + *Object_Editor\Window = Window_Create(*Object, "Editor", "Editor", #True, #PB_Ignore, #PB_Ignore, 630, 650, #True, -10, Object_Editor_Main\Object_Type\UID) ; #### Toolbar *Object_Editor\ToolBar = CreateToolBar(#PB_Any, WindowID(*Object_Editor\Window\ID)) @@ -2324,7 +2327,7 @@ Procedure Object_Editor_Window_Open(*Object.Object) BindEvent(#PB_Event_CloseWindow, @Object_Editor_Window_Event_CloseWindow(), *Object_Editor\Window\ID) BindGadgetEvent(*Object_Editor\Canvas, @Object_Editor_Window_Event_Canvas()) - SetWindowCallback(@Object_Editor_Window_Callback(), *Object_Editor\Window\ID) + D3docker::Window_Set_Callback(*Object_Editor\Window\ID, @Object_Editor_Window_Callback()) *Object_Editor\Redraw = #True @@ -2351,7 +2354,7 @@ Procedure Object_Editor_Window_Close(*Object.Object) UnbindEvent(#PB_Event_CloseWindow, @Object_Editor_Window_Event_CloseWindow(), *Object_Editor\Window\ID) UnbindGadgetEvent(*Object_Editor\Canvas, @Object_Editor_Window_Event_Canvas()) - SetWindowCallback(#Null, *Object_Editor\Window\ID) + D3docker::Window_Set_Callback(*Object_Editor\Window\ID, #Null) Window_Delete(*Object_Editor\Window) *Object_Editor\Window = #Null @@ -2418,8 +2421,8 @@ MenuItem(#Object_Editor_PopupMenu_Select_All, "Select All", ImageID(Icon_Select_ ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 1493 -; FirstLine = 1481 +; CursorPosition = 2301 +; FirstLine = 2289 ; Folding = ------- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Editor/Object_Editor_Goto.pbi b/Includes/Object/Editor/Object_Editor_Goto.pbi index bf08664..a41e96d 100644 --- a/Includes/Object/Editor/Object_Editor_Goto.pbi +++ b/Includes/Object/Editor/Object_Editor_Goto.pbi @@ -160,7 +160,7 @@ Procedure Object_Editor_Goto_Window_Open(*Object.Object) Width = 270 Height = 130 - *Object_Editor_Goto\Window = Window_Create(*Object, "Editor_Goto", "Editor_Goto", #False, 0, 0, Width, Height) + *Object_Editor_Goto\Window = Window_Create(*Object, "Editor_Goto", "Editor_Goto", #False, 0, 0, Width, Height, #False) ; #### Gadgets *Object_Editor_Goto\Frame = FrameGadget(#PB_Any, 10, 10, Width-20, 70, "Position") @@ -236,7 +236,8 @@ EndProcedure ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 162 +; FirstLine = 134 ; Folding = - ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Editor/Object_Editor_Search.pbi b/Includes/Object/Editor/Object_Editor_Search.pbi index a4a5d0a..5cc65c0 100644 --- a/Includes/Object/Editor/Object_Editor_Search.pbi +++ b/Includes/Object/Editor/Object_Editor_Search.pbi @@ -1256,7 +1256,7 @@ Procedure Object_Editor_Search_Window_Open(*Object.Object) Width = 410 Height = 320 - *Object_Editor_Search\Window = Window_Create(*Object, "Editor_Search", "Editor_Search", #False, 0, 0, Width, Height) + *Object_Editor_Search\Window = Window_Create(*Object, "Editor_Search", "Editor_Search", #False, 0, 0, Width, Height, #False) ; #### Gadgets *Object_Editor_Search\Text[0] = TextGadget(#PB_Any, 10, 10, 100, 20, "Search for:", #PB_Text_Right) @@ -1902,7 +1902,8 @@ EndProcedure ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 1258 +; FirstLine = 1254 ; Folding = ----- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/File/Object_File.pbi b/Includes/Object/File/Object_File.pbi index f2466b6..80db9bd 100644 --- a/Includes/Object/File/Object_File.pbi +++ b/Includes/Object/File/Object_File.pbi @@ -1007,7 +1007,7 @@ Procedure Object_File_Window_Open(*Object.Object) Width = 500 Height = 130 - *Object_File\Window = Window_Create(*Object, "File", "File", #False, 0, 0, Width, Height) + *Object_File\Window = Window_Create(*Object, "File", "File", #False, 0, 0, Width, Height, #False) ; #### Toolbar @@ -1151,8 +1151,8 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 578 -; FirstLine = 567 +; CursorPosition = 1009 +; FirstLine = 987 ; Folding = ----- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/History/Object_History.pbi b/Includes/Object/History/Object_History.pbi index f5882d0..d6a801a 100644 --- a/Includes/Object/History/Object_History.pbi +++ b/Includes/Object/History/Object_History.pbi @@ -1181,7 +1181,7 @@ Procedure Object_History_Window_Open(*Object.Object) Width = 300 Height = 80 - *Object_History\Window = Window_Create(*Object, "History", "History", #False, 0, 0, Width, Height) + *Object_History\Window = Window_Create(*Object, "History", "History", #False, 0, 0, Width, Height, #False) ; #### Gadgets *Object_History\Text = TextGadget(#PB_Any, 10, 10, Width-20, Height-40, "") @@ -1268,7 +1268,7 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 982 -; FirstLine = 964 +; CursorPosition = 1183 +; FirstLine = 1161 ; Folding = ------ ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Math/Object_Math.pbi b/Includes/Object/Math/Object_Math.pbi index c4208ac..9ea0e4c 100644 --- a/Includes/Object/Math/Object_Math.pbi +++ b/Includes/Object/Math/Object_Math.pbi @@ -498,7 +498,7 @@ Procedure Object_Math_Window_Open(*Object.Object) Width = 300 Height = 460 - *Object_Math\Window = Window_Create(*Object, "Math", "Math", #False, 0, 0, Width, Height) + *Object_Math\Window = Window_Create(*Object, "Math", "Math", #False, 0, 0, Width, Height, #False) ; #### Gadgets @@ -647,6 +647,7 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 500 +; FirstLine = 478 ; Folding = ---- ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Math/Object_MathFormula.pbi b/Includes/Object/Math/Object_MathFormula.pbi index d07165d..2fbfe6b 100644 --- a/Includes/Object/Math/Object_MathFormula.pbi +++ b/Includes/Object/Math/Object_MathFormula.pbi @@ -498,7 +498,7 @@ Procedure Object_MathFormula_Window_Open(*Object.Object) Width = 300 Height = 460 - *Object_MathFormula\Window = Window_Create(*Object, "Math", "Math", #False, 0, 0, Width, Height) + *Object_MathFormula\Window = Window_Create(*Object, "Math", "Math", #False, 0, 0, Width, Height, #False) ; #### Gadgets @@ -647,6 +647,7 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 500 +; FirstLine = 472 ; Folding = ---- ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Network_Terminal/Object_Network_Terminal.pbi b/Includes/Object/Network_Terminal/Object_Network_Terminal.pbi index fbc328e..0915fde 100644 --- a/Includes/Object/Network_Terminal/Object_Network_Terminal.pbi +++ b/Includes/Object/Network_Terminal/Object_Network_Terminal.pbi @@ -973,7 +973,7 @@ Procedure Object_Network_Terminal_Window_Open(*Object.Object) Width = 430 Height = 150 - *Object_Network_Terminal\Window = Window_Create(*Object, "Network Terminal", "Network Terminal", #False, 0, 0, Width, Height) + *Object_Network_Terminal\Window = Window_Create(*Object, "Network Terminal", "Network Terminal", #False, 0, 0, Width, Height, #False) ; #### Toolbar @@ -1206,8 +1206,8 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 992 -; FirstLine = 988 +; CursorPosition = 975 +; FirstLine = 953 ; Folding = ------ ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Process/Object_Process.pbi b/Includes/Object/Process/Object_Process.pbi index d5a053c..fffe7d1 100644 --- a/Includes/Object/Process/Object_Process.pbi +++ b/Includes/Object/Process/Object_Process.pbi @@ -855,7 +855,7 @@ Procedure Object_Process_Window_Open(*Object.Object) Width = 400 Height = 400 - *Object_Process\Window = Window_Create(*Object, "Process", "Process", #False, 0, 0, Width, Height) + *Object_Process\Window = Window_Create(*Object, "Process", "Process", #False, 0, 0, Width, Height, #False) ; #### Toolbar @@ -964,7 +964,8 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 859 +; FirstLine = 841 ; Folding = ----- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Includes/Object/Random/Object_Random.pbi b/Includes/Object/Random/Object_Random.pbi index 56563e3..c2f0ead 100644 --- a/Includes/Object/Random/Object_Random.pbi +++ b/Includes/Object/Random/Object_Random.pbi @@ -485,7 +485,7 @@ Procedure Object_Random_Window_Open(*Object.Object) Width = 200 Height = 60 - *Object_Random\Window = Window_Create(*Object, "Random", "Random", #False, 0, 0, Width, Height) + *Object_Random\Window = Window_Create(*Object, "Random", "Random", #False, 0, 0, Width, Height, #False) ; #### Toolbar @@ -571,7 +571,7 @@ EndIf ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 271 -; FirstLine = 244 +; CursorPosition = 487 +; FirstLine = 468 ; Folding = ---- ; EnableXP \ No newline at end of file diff --git a/Includes/Object/View1D/Object_View1D.pbi b/Includes/Object/View1D/Object_View1D.pbi index 41a85c4..bbbebfa 100644 --- a/Includes/Object/View1D/Object_View1D.pbi +++ b/Includes/Object/View1D/Object_View1D.pbi @@ -984,7 +984,9 @@ Procedure Object_View1D_Window_Event_SizeWindow() ResizeGadget(*Object_View1D\Canvas_Y, 0, ToolBarHeight, Canvas_Y_Width, Data_Height) ResizeGadget(*Object_View1D\Canvas_Data, Canvas_Y_Width, ToolBarHeight, Data_Width, Data_Height) - *Object_View1D\Redraw = #True + Object_View1D_Organize(*Object) + Object_View1D_Get_Data(*Object) + Object_View1D_Canvas_Redraw(*Object) EndProcedure Procedure Object_View1D_Window_Event_ActivateWindow() @@ -1108,9 +1110,9 @@ Procedure Object_View1D_Window_Open(*Object.Object) If *Object_View1D\Window = #Null Width = 500 - Height = 500 + Height = 300 - *Object_View1D\Window = Window_Create(*Object, "View1D", "View1D", #True, #PB_Ignore, #PB_Ignore, Width, Height) + *Object_View1D\Window = Window_Create(*Object, "View1D", "View1D", #True, #PB_Ignore, #PB_Ignore, Width, Height, #True, 10, Object_View1D_Main\Object_Type\UID) ; #### Toolbar *Object_View1D\ToolBar = CreateToolBar(#PB_Any, WindowID(*Object_View1D\Window\ID)) @@ -1148,7 +1150,7 @@ Procedure Object_View1D_Window_Open(*Object.Object) BindGadgetEvent(*Object_View1D\Canvas_X, @Object_View1D_Window_Event_Canvas_X()) BindGadgetEvent(*Object_View1D\Canvas_Y, @Object_View1D_Window_Event_Canvas_Y()) - SetWindowCallback(@Object_View1D_Window_Callback(), *Object_View1D\Window\ID) + D3docker::Window_Set_Callback(*Object_View1D\Window\ID, @Object_View1D_Window_Callback()) *Object_View1D\Redraw = #True @@ -1177,7 +1179,7 @@ Procedure Object_View1D_Window_Close(*Object.Object) UnbindGadgetEvent(*Object_View1D\Canvas_X, @Object_View1D_Window_Event_Canvas_X()) UnbindGadgetEvent(*Object_View1D\Canvas_Y, @Object_View1D_Window_Event_Canvas_Y()) - SetWindowCallback(#Null, *Object_View1D\Window\ID) + D3docker::Window_Set_Callback(*Object_View1D\Window\ID, #Null) Window_Delete(*Object_View1D\Window) *Object_View1D\Window = #Null @@ -1250,6 +1252,7 @@ DataSection Object_View1D_Icon_Normalize_Y: : IncludeBinary "../../../Data/Icons/Graph_Normalize_Y.png" EndDataSection ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 1112 +; FirstLine = 1098 ; Folding = ---- ; EnableXP \ No newline at end of file diff --git a/Includes/Object/View1D/Object_View1D_Settings.pbi b/Includes/Object/View1D/Object_View1D_Settings.pbi index 61e83c9..ea1ba99 100644 --- a/Includes/Object/View1D/Object_View1D_Settings.pbi +++ b/Includes/Object/View1D/Object_View1D_Settings.pbi @@ -460,7 +460,7 @@ Procedure Object_View1D_Settings_Window_Open(*Object.Object) Width = 270 Height = 410 - *Object_View1D_Settings\Window = Window_Create(*Object, "View1D_Settings", "View1D_Settings", #False, 0, 0, Width, Height) + *Object_View1D_Settings\Window = Window_Create(*Object, "View1D_Settings", "View1D_Settings", #False, 0, 0, Width, Height, #False) ; #### Gadgets @@ -575,6 +575,7 @@ EndProcedure ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 462 +; FirstLine = 440 ; Folding = --- ; EnableXP \ No newline at end of file diff --git a/Includes/Object/View2D/Object_View2D.pbi b/Includes/Object/View2D/Object_View2D.pbi index f1f859d..4714135 100644 --- a/Includes/Object/View2D/Object_View2D.pbi +++ b/Includes/Object/View2D/Object_View2D.pbi @@ -1121,6 +1121,7 @@ Procedure Object_View2D_Window_Event_SizeWindow() ResizeGadget(*Object_View2D\Canvas_Data, 0, ToolBarHeight, Data_Width, Data_Height) + Object_View2D_Canvas_Redraw(*Object) *Object_View2D\Redraw = #True EndProcedure @@ -1218,7 +1219,7 @@ Procedure Object_View2D_Window_Open(*Object.Object) Width = 500 Height = 500 - *Object_View2D\Window = Window_Create(*Object, "View2D", "View2D", #True, #PB_Ignore, #PB_Ignore, Width, Height) + *Object_View2D\Window = Window_Create(*Object, "View2D", "View2D", #True, #PB_Ignore, #PB_Ignore, Width, Height, #True, 10, Object_View2D_Main\Object_Type\UID) ; #### Toolbar *Object_View2D\ToolBar = CreateToolBar(#PB_Any, WindowID(*Object_View2D\Window\ID)) @@ -1247,7 +1248,7 @@ Procedure Object_View2D_Window_Open(*Object.Object) BindEvent(#PB_Event_CloseWindow, @Object_View2D_Window_Event_CloseWindow(), *Object_View2D\Window\ID) BindGadgetEvent(*Object_View2D\Canvas_Data, @Object_View2D_Window_Event_Canvas_Data()) - SetWindowCallback(@Object_View2D_Window_Callback(), *Object_View2D\Window\ID) + D3docker::Window_Set_Callback(*Object_View2D\Window\ID, @Object_View2D_Window_Callback()) *Object_View2D\Redraw = #True @@ -1274,7 +1275,7 @@ Procedure Object_View2D_Window_Close(*Object.Object) UnbindEvent(#PB_Event_CloseWindow, @Object_View2D_Window_Event_CloseWindow(), *Object_View2D\Window\ID) UnbindGadgetEvent(*Object_View2D\Canvas_Data, @Object_View2D_Window_Event_Canvas_Data()) - SetWindowCallback(#Null, *Object_View2D\Window\ID) + D3docker::Window_Set_Callback(*Object_View2D\Window\ID, #Null) Window_Delete(*Object_View2D\Window) *Object_View2D\Window = #Null @@ -1341,7 +1342,7 @@ DataSection Object_View2D_Icon_Normalize: : IncludeBinary "../../../Data/Icons/Graph_Normalize.png" EndDataSection ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 420 -; FirstLine = 393 +; CursorPosition = 1220 +; FirstLine = 1205 ; Folding = ---- ; EnableXP \ No newline at end of file diff --git a/Includes/Object/View2D/Object_View2D_Settings.pbi b/Includes/Object/View2D/Object_View2D_Settings.pbi index 347e575..b0c35fd 100644 --- a/Includes/Object/View2D/Object_View2D_Settings.pbi +++ b/Includes/Object/View2D/Object_View2D_Settings.pbi @@ -443,7 +443,7 @@ Procedure Object_View2D_Settings_Window_Open(*Object.Object) Width = 270 Height = 470 - *Object_View2D_Settings\Window = Window_Create(*Object, "View2D_Settings", "View2D_Settings", #False, 0, 0, Width, Height) + *Object_View2D_Settings\Window = Window_Create(*Object, "View2D_Settings", "View2D_Settings", #False, 0, 0, Width, Height, #False) ; #### Gadgets @@ -579,7 +579,7 @@ EndProcedure ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 341 -; FirstLine = 307 +; CursorPosition = 445 +; FirstLine = 426 ; Folding = -- ; EnableXP \ No newline at end of file diff --git a/Includes/Window.pbi b/Includes/Window.pbi index 0dc0f95..35d4e5e 100644 --- a/Includes/Window.pbi +++ b/Includes/Window.pbi @@ -46,7 +46,7 @@ Structure Window Name.s Name_Short.s - MDI_Window.i ; #True if the window is embedded in a MDI + Tab_ID.s ; Windows with the same Tab_ID will be grouped into tabs if possible *Object.Object EndStructure @@ -94,7 +94,7 @@ EndProcedure Procedure Window_Get_Active() Protected *Result.Window = #Null - Protected Active_Window_ID = GetGadgetState(Main_Window\MDI) + Protected Active_Window_ID = D3docker::Window_Get_Active(Main_Window\D3docker) PushListPosition(Window()) @@ -115,19 +115,23 @@ Procedure Window_Set_Active(*Window.Window) ProcedureReturn #False EndIf - If *Window\MDI_Window - SetGadgetState(Main_Window\MDI, *Window\ID) - - Main_Window_Refresh_Active() - Else - SetActiveWindow(*Window\ID) - EndIf + D3docker::Window_Set_Active(*Window\ID) StatusBarText(Main_Window\StatusBar_ID, 0, "") StatusBarText(Main_Window\StatusBar_ID, 1, "") StatusBarText(Main_Window\StatusBar_ID, 2, "") - PostEvent(#PB_Event_SizeWindow, *Window\ID, 0) + ;PostEvent(#PB_Event_SizeWindow, *Window\ID, 0) + + ProcedureReturn #True +EndProcedure + +Procedure Window_Bounds(*Window.Window, Min_Width.l, Min_Height.l, Max_Width.l, Max_Height.l) + If Not *Window + ProcedureReturn #False + EndIf + + D3docker::Window_Bounds(*Window\ID, Min_Width, Min_Height, Max_Width, Max_Height) ProcedureReturn #True EndProcedure @@ -141,10 +145,6 @@ Procedure Window_Event_ActivateWindow() ProcedureReturn EndIf - If *Window\MDI_Window - Main_Window_Refresh_Active() - EndIf - StatusBarText(Main_Window\StatusBar_ID, 0, "") StatusBarText(Main_Window\StatusBar_ID, 1, "") StatusBarText(Main_Window\StatusBar_ID, 2, "") @@ -159,10 +159,10 @@ Procedure Window_Event_MaximizeWindow() If Not *Window ProcedureReturn EndIf - - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next + ; TODO: Still needed? + ;ForEach Window() + ; PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) + ;Next EndProcedure @@ -174,10 +174,10 @@ Procedure Window_Event_MinimizeWindow() If Not *Window ProcedureReturn EndIf - - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next + ; TODO: Still needed? + ;ForEach Window() + ; PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) + ;Next EndProcedure @@ -189,14 +189,14 @@ Procedure Window_Event_RestoreWindow() If Not *Window ProcedureReturn EndIf - - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next + ; TODO: Still needed? + ;ForEach Window() + ;PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) + ;Next EndProcedure -Procedure Window_Create(*Object.Object, Name.s, Name_Short.s, MDI, X=#PB_Ignore, Y=#PB_Ignore, Width=#PB_Ignore, Height=#PB_Ignore, Resizable=#False) +Procedure Window_Create(*Object.Object, Name.s, Name_Short.s, Docked, X=#PB_Ignore, Y=#PB_Ignore, Width=#PB_Ignore, Height=#PB_Ignore, Resizable=#False, Resize_Priority.l=0, Tab_ID.s="") Protected *Window.Window If Not AddElement(Window()) @@ -205,45 +205,77 @@ Procedure Window_Create(*Object.Object, Name.s, Name_Short.s, MDI, X=#PB_Ignore, *Window = Window() - Protected Flags + Protected Flags = #PB_Window_WindowCentered + Protected *Container + Protected *Window_Temp.Window - *Window\MDI_Window = MDI + If Resizable + Flags | #PB_Window_SizeGadget + EndIf + + ;*Window\MDI_Window = MDI *Window\Name = Name *Window\Name_Short = Name_Short - If *Window\MDI_Window - *Window\ID = AddGadgetItem(Main_Window\MDI, #PB_Any, Name) - ResizeWindow(*Window\ID, X, Y, Width, Height) - Else - If Resizable - Flags = #PB_Window_SizeGadget - EndIf - *Window\ID = OpenWindow(#PB_Any, X, Y, Width, Height, Name, #PB_Window_SystemMenu | #PB_Window_WindowCentered | Flags, WindowID(Main_Window\ID)) - EndIf + ;If *Window\MDI_Window + *Window\ID = D3docker::Window_Add(Main_Window\D3docker, X, Y, Width, Height, Name, Flags, Resize_Priority) + ;EndIf *Window\Object = *Object + *Window\Tab_ID = Tab_ID - SmartWindowRefresh(*Window\ID, 1) + ;SmartWindowRefresh(*Window\ID, 1) BindEvent(#PB_Event_ActivateWindow, @Window_Event_ActivateWindow(), *Window\ID) BindEvent(#PB_Event_MaximizeWindow, @Window_Event_MaximizeWindow(), *Window\ID) BindEvent(#PB_Event_MinimizeWindow, @Window_Event_MinimizeWindow(), *Window\ID) BindEvent(#PB_Event_RestoreWindow, @Window_Event_RestoreWindow(), *Window\ID) - If *Window\MDI_Window - AddTabBarGadgetItem(Main_Window\Panel, #PB_Default, Name_Short, #Null, *Window\ID) - SetWindowState(*Window\ID, #PB_Window_Maximize) - Main_Window_Refresh_Active() + If Docked + ;*Window_Temp = Window_Get_Active() + ;If *Window_Temp + ; *Container = D3docker::Window_Get_Container(*Window_Temp\ID) + ;EndIf + + If Tab_ID + ForEach Window() + If Window()\Tab_ID = Tab_ID + *Container = D3docker::Window_Get_Container(Window()\ID) + If *Container + Break + EndIf + EndIf + Next + EndIf + + If *Container + D3docker::Docker_Add(Main_Window\D3docker, *Container, D3docker::#Direction_Inside, *Window\ID) + Else + *Container = D3docker::Root_Get(Main_Window\D3docker) + If WindowWidth(*Window\ID) > WindowHeight(*Window\ID) + D3docker::Docker_Add(Main_Window\D3docker, *Container, D3docker::#Direction_Bottom, *Window\ID) + Else + D3docker::Docker_Add(Main_Window\D3docker, *Container, D3docker::#Direction_Right, *Window\ID) + EndIf + EndIf + + EndIf + + ;If *Window\MDI_Window + ; AddTabBarGadgetItem(Main_Window\Panel, #PB_Default, Name_Short, #Null, *Window\ID) + ; SetWindowState(*Window\ID, #PB_Window_Maximize) + ; Main_Window_Refresh_Active() ;Else ; #### Test ; SetParent_(WindowID(*Window\ID ), WindowID(Main_Window\ID)) - EndIf + ;EndIf - PostEvent(#PB_Event_SizeWindow, *Window\ID, 0) + ;PostEvent(#PB_Event_SizeWindow, *Window\ID, 0) ProcedureReturn *Window EndProcedure Procedure Window_Delete(*Window.Window) Protected i + Protected Window.i If Not *Window ProcedureReturn #False @@ -254,21 +286,23 @@ Procedure Window_Delete(*Window.Window) UnbindEvent(#PB_Event_MinimizeWindow, @Window_Event_MinimizeWindow(), *Window\ID) UnbindEvent(#PB_Event_RestoreWindow, @Window_Event_RestoreWindow(), *Window\ID) - If *Window\MDI_Window - For i = 0 To CountTabBarGadgetItems(Main_Window\Panel) - 1 - If GetTabBarGadgetItemData(Main_Window\Panel, i) = *Window\ID - RemoveTabBarGadgetItem(Main_Window\Panel, i) - Break - EndIf - Next - EndIf + ;If *Window\MDI_Window + ; For i = 0 To CountTabBarGadgetItems(Main_Window\Panel) - 1 + ; If GetTabBarGadgetItemData(Main_Window\Panel, i) = *Window\ID + ; RemoveTabBarGadgetItem(Main_Window\Panel, i) + ; Break + ; EndIf + ; Next + ;EndIf - CloseWindow(*Window\ID) + Window = *Window\ID If ChangeCurrentElement(Window(), *Window) DeleteElement(Window()) EndIf + D3docker::Window_Close(Window) + ProcedureReturn #True EndProcedure @@ -280,7 +314,8 @@ EndProcedure ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 3 +; CursorPosition = 253 +; FirstLine = 221 ; Folding = -- ; EnableUnicode ; EnableXP \ No newline at end of file diff --git a/Main.pb b/Main.pb index cd03e59..1482a68 100644 --- a/Main.pb +++ b/Main.pb @@ -153,7 +153,7 @@ ; - Object_Editor: Fixed writing at the end of data ; - Object_View2D: Added standard configuration ; -; - V0.942 (INDEV) +; - V0.950 (INDEV) ; - Object_File: Ignore result of File-requesters if it is "" ; - Network_Terminal: ; - Data_Set is not triggering an update event @@ -161,6 +161,7 @@ ; - Renamed output and input to sent and received ; - Object_History: ; - Added the option to allow write operations in any case +; - Use D3docker.pbi instead of the mdi gadget ; ; ##################################################### Begin ####################################################### @@ -171,7 +172,7 @@ UsePNGImageEncoder() ; ##################################################### Includes #################################################### -XIncludeFile "Includes/TabBarGadget.pbi" +XIncludeFile "Includes/D3docker/D3docker.pbi" XIncludeFile "Includes/Memory.pbi" XIncludeFile "Includes/D3HT.pbi" XIncludeFile "Includes/D3NBT.pbi" @@ -180,7 +181,7 @@ XIncludeFile "Includes/UnitEngine.pbi" ; ##################################################### Constants ################################################### -#Version = 0941 +#Version = 0950 Enumeration #Data_Raw @@ -288,12 +289,13 @@ Structure Main_Window Menu_ID.i ToolBar_ID.i StatusBar_ID.i - MDI.i - Panel.i + ;MDI.i + ;Panel.i + D3docker.i ; #### - MDI_Height.i - MDI_Widht.i - Panel_Height.i ; Höhe des Panels + D3docker_Height.i + D3docker_Width.i + ;Panel_Height.i ; Höhe des Panels Menu_Height.i ; Höhe des Menüs ToolBar_Height.i ; Höhe der ToolBar StatusBar_Height.i ; Höhe der StatusBar @@ -333,8 +335,6 @@ Global Icon_Goto = CatchImage(#PB_Any, ?Icon_Goto) ; ##################################################### Declares #################################################### -Declare Main_Window_Refresh_Active() - ; ##################################################### Macros ###################################################### Macro Line(x, y, Width, Height, Color) @@ -394,16 +394,11 @@ Procedure.s SHGetFolderPath(CSIDL) ProcedureReturn String EndProcedure -Procedure Main_Window_Refresh_Active() - Protected i - Protected Active_Window_ID = GetGadgetState(Main_Window\MDI) - - For i = 0 To CountTabBarGadgetItems(Main_Window\Panel) - 1 - If GetTabBarGadgetItemData(Main_Window\Panel, i) = Active_Window_ID - SetTabBarGadgetState(Main_Window\Panel, i) - Break - EndIf - Next +Procedure Main_Window_Event_SizeWindow() + Protected Event_Window = EventWindow() + Main_Window\D3docker_Width = WindowWidth(Event_Window) + Main_Window\D3docker_Height = WindowHeight(Event_Window) - Main_Window\Menu_Height - Main_Window\ToolBar_Height - Main_Window\StatusBar_Height + ResizeGadget(Main_Window\D3docker, #PB_Ignore, #PB_Ignore, Main_Window\D3docker_Width, Main_Window\D3docker_Height) EndProcedure Procedure Main_Window_Open(Width, Height) @@ -414,7 +409,7 @@ Procedure Main_Window_Open(Width, Height) ProcedureReturn 0 EndIf - SmartWindowRefresh(Main_Window\ID, 1) + SmartWindowRefresh(Main_Window\ID, #True) Main_Window\Menu_ID = CreateImageMenu(#PB_Any, WindowID(Main_Window\ID), #PB_Menu_ModernLook) If Not Main_Window\Menu_ID @@ -520,22 +515,23 @@ Procedure Main_Window_Open(Width, Height) AddStatusBarField(250) AddStatusBarField(150) + ; ######################### Events + + BindEvent(#PB_Event_SizeWindow, @Main_Window_Event_SizeWindow(), Main_Window\ID) + ; ######################### Größe Main_Window\Menu_Height = MenuHeight() Main_Window\ToolBar_Height = ToolBarHeight(Main_Window\ToolBar_ID) - Main_Window\Panel_Height = 20 Main_Window\StatusBar_Height = StatusBarHeight(Main_Window\StatusBar_ID) - Main_Window\MDI_Widht = Width - Main_Window\MDI_Height = Height - Main_Window\Menu_Height - Main_Window\ToolBar_Height - Main_Window\Panel_Height - Main_Window\StatusBar_Height + Main_Window\D3docker_Width = Width + Main_Window\D3docker_Height = Height - Main_Window\Menu_Height - Main_Window\ToolBar_Height - Main_Window\StatusBar_Height ; ################# Gadgets If UseGadgetList(WindowID(Main_Window\ID)) - Main_Window\MDI = MDIGadget(#PB_Any, 0, Main_Window\ToolBar_Height + Main_Window\Panel_Height, Main_Window\MDI_Widht, Main_Window\MDI_Height, 3, #Menu_MDI_Windows_Start) - - Main_Window\Panel = TabBarGadget(#PB_Any, 0, Main_Window\ToolBar_Height, Main_Window\MDI_Widht, Main_Window\Panel_Height, #TabBarGadget_CloseButton | #TabBarGadget_NoTabMoving) + Main_Window\D3docker = D3docker::Create(#PB_Any, 0, Main_Window\ToolBar_Height, Main_Window\D3docker_Width, Main_Window\D3docker_Height, Main_Window\ID) EndIf EndProcedure @@ -558,10 +554,6 @@ Main_Window_Open(1200, 700) Node_Editor_Open() -SetWindowState(Node_Editor\Window\ID, #PB_Window_Maximize) - -;SetGadgetState(Main_Window\MDI, #PB_MDI_TileVertically) - If FileSize(SHGetFolderPath(#CSIDL_APPDATA)+"\D3\Hexeditor\Node_Configuration.D3hex") < 0 Node_Editor_Configuration_Load("Data\Default.D3hex") Else @@ -580,11 +572,6 @@ Repeat Select Event_Window Case Main_Window\ID Select Event - Case #PB_Event_SizeWindow ; ############## - Main_Window\MDI_Widht = WindowWidth(Main_Window\ID) - Main_Window\MDI_Height = WindowHeight(Main_Window\ID) - Main_Window\Menu_Height - Main_Window\ToolBar_Height - Main_Window\Panel_Height - Main_Window\StatusBar_Height - ResizeGadget(Main_Window\Panel, #PB_Ignore, #PB_Ignore, Main_Window\MDI_Widht, #PB_Ignore) : UpdateTabBarGadget(Main_Window\Panel) - ResizeGadget(Main_Window\MDI, #PB_Ignore, #PB_Ignore, Main_Window\MDI_Widht, Main_Window\MDI_Height) Case #PB_Event_Menu ; #################### Select EventMenu() @@ -762,30 +749,6 @@ Repeat *Active_Window\Object\Function_Event(*Active_Window\Object, Object_Event) EndIf - Case #Menu_TileV - SetGadgetState(Main_Window\MDI, #PB_MDI_TileVertically) - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next - - Case #Menu_TileH - SetGadgetState(Main_Window\MDI, #PB_MDI_TileHorizontally) - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next - - Case #Menu_Cascade - SetGadgetState(Main_Window\MDI, #PB_MDI_Cascade) - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next - - Case #Menu_Arrange - SetGadgetState(Main_Window\MDI, #PB_MDI_Arrange) - ForEach Window() - PostEvent(#PB_Event_SizeWindow, Window()\ID, 0) - Next - Case #Menu_About About_Open() @@ -794,34 +757,7 @@ Repeat EndSelect - Case #PB_Event_Gadget ; ################## - Select EventGadget() - Case Main_Window\Panel - Select TabBarGadgetEvent(Main_Window\Panel) - Case #TabBarGadgetEvent_CloseTab - ;RemoveTabBarGadgetItem(Main_Window\Panel, EventTab(Main_Window\Panel)) - ;ForEach Window() - ; If Window()\ID = GetTabBarGadgetItemData(Main_Window\Panel, EventTab(Main_Window\Panel)) - ; If Window()\Object And Window()\Object\Function_Event - ; Object_Event.Object_Event - ; Object_Event\Type = #Object_Event_Goto - ; Window()\Object\Function_Event(Window()\Object, Object_Event) - ; EndIf - ; Break - ; EndIf - ;Next - Define *Window.Window = Window_Get(GetTabBarGadgetItemData(Main_Window\Panel, EventTab(Main_Window\Panel))) - If *Window - PostEvent(#PB_Event_CloseWindow, *Window\ID, 0) - EndIf - - Case #TabBarGadgetEvent_Change - Window_Set_Active(Window_Get(GetTabBarGadgetItemData(Main_Window\Panel, EventTab(Main_Window\Panel)))) - - ;SetGadgetState(Main_Window\MDI, ) - EndSelect - - EndSelect + Case #PB_Event_Gadget Case #PB_Event_CloseWindow Main\Quit = 1 @@ -898,8 +834,8 @@ DataSection EndDataSection ; IDE Options = PureBasic 5.31 (Windows - x64) -; CursorPosition = 169 -; FirstLine = 135 +; CursorPosition = 183 +; FirstLine = 155 ; Folding = -- ; EnableUnicode ; EnableXP \ No newline at end of file