|
| 1 | +;-------------------------------------------------------------------------------------------- |
| 2 | +; Copyright (c) Fantaise Software. All rights reserved. |
| 3 | +; Dual licensed under the GPL and Fantaisie Software licenses. |
| 4 | +; See LICENSE and LICENSE-FANTAISIE in the project root for license information. |
| 5 | +;-------------------------------------------------------------------------------------------- |
| 6 | + |
| 7 | + |
| 8 | +; Define these for easier crossplatform development, also without the IDE |
| 9 | +; |
| 10 | +CompilerIf Defined(CompileWindows, #PB_Constant) = 0 |
| 11 | + CompilerSelect #PB_Compiler_OS |
| 12 | + CompilerCase #PB_OS_Windows |
| 13 | + #CompileWindows = 1 |
| 14 | + #CompileLinux = 0 |
| 15 | + #CompileLinuxGtk1 = 0 |
| 16 | + #CompileLinuxGtk2 = 0 |
| 17 | + #CompileMac = 0 |
| 18 | + #CompileMacCarbon = 0 |
| 19 | + #CompileMacCocoa = 0 |
| 20 | + |
| 21 | + CompilerCase #PB_OS_Linux |
| 22 | + #CompileWindows = 0 |
| 23 | + #CompileLinux = 1 |
| 24 | + CompilerIf Subsystem("Gtk1") |
| 25 | + #CompileLinuxGtk1 = 1 |
| 26 | + #CompileLinuxGtk2 = 0 |
| 27 | + CompilerElse |
| 28 | + #CompileLinuxGtk1 = 0 |
| 29 | + #CompileLinuxGtk2 = 1 |
| 30 | + CompilerEndIf |
| 31 | + #CompileMac = 0 |
| 32 | + #CompileMacCarbon = 0 |
| 33 | + #CompileMacCocoa = 0 |
| 34 | + |
| 35 | + CompilerCase #PB_OS_MacOS |
| 36 | + #CompileWindows = 0 |
| 37 | + #CompileLinux = 0 |
| 38 | + #CompileLinuxGtk1 = 0 |
| 39 | + #CompileLinuxGtk2 = 0 |
| 40 | + #CompileMac = 1 |
| 41 | + CompilerIf Subsystem("carbon") |
| 42 | + #CompileMacCocoa = 0 |
| 43 | + #CompileMacCarbon = 1 |
| 44 | + CompilerElse |
| 45 | + #CompileMacCocoa = 1 |
| 46 | + #CompileMacCarbon = 0 |
| 47 | + CompilerEndIf |
| 48 | + |
| 49 | + CompilerEndSelect |
| 50 | +CompilerEndIf |
| 51 | + |
| 52 | + |
| 53 | +; Max number of childs that any container can have. |
| 54 | +; |
| 55 | +#MAX_CHILDLIST = 100 |
| 56 | + |
| 57 | +Enumeration 1 |
| 58 | + #DIALOG_Window |
| 59 | + #DIALOG_Shortcut ; not a real object, only used during dialog creation |
| 60 | + |
| 61 | + #DIALOG_Button |
| 62 | + #DIALOG_Checkbox |
| 63 | + #DIALOG_Image |
| 64 | + #DIALOG_Option |
| 65 | + #DIALOG_ListView |
| 66 | + #DIALOG_ListIcon |
| 67 | + #DIALOG_Tree |
| 68 | + #DIALOG_Container |
| 69 | + #DIALOG_ComboBox |
| 70 | + #DIALOG_Text |
| 71 | + #DIALOG_String |
| 72 | + #DIALOG_Panel |
| 73 | + #DIALOG_Tab |
| 74 | + #DIALOG_Scroll |
| 75 | + #DIALOG_Frame |
| 76 | + #DIALOG_Item |
| 77 | + #DIALOG_Column |
| 78 | + #DIALOG_Editor |
| 79 | + #DIALOG_Scintilla |
| 80 | + #DIALOG_ScrollBar |
| 81 | + #DIALOG_ProgressBar |
| 82 | + #DIALOG_ExplorerList |
| 83 | + #DIALOG_ExplorerTree |
| 84 | + #DIALOG_ExplorerCombo |
| 85 | + #DIALOG_Splitter |
| 86 | + #DIALOG_ShortcutGadget |
| 87 | + #DIALOG_ButtonImage |
| 88 | + #DIALOG_TrackBar |
| 89 | + #DIALOG_HyperLink |
| 90 | + |
| 91 | + ; virtual packing objects |
| 92 | + #DIALOG_VBox |
| 93 | + #DIALOG_HBox |
| 94 | + #DIALOG_Multibox |
| 95 | + #DIALOG_Singlebox |
| 96 | + #DIALOG_Gridbox |
| 97 | + #DIALOG_Empty |
| 98 | +EndEnumeration |
| 99 | + |
| 100 | +; Alignment Properties |
| 101 | +; |
| 102 | +Enumeration ; also used for left, center, right |
| 103 | + #Dlg_Align_Top = 1 ; do not include 0 for better testing |
| 104 | + #Dlg_Align_Center |
| 105 | + #Dlg_Align_Bottom |
| 106 | +EndEnumeration |
| 107 | + |
| 108 | +; Expansion Properties |
| 109 | +; |
| 110 | +Enumeration |
| 111 | + #Dlg_Expand_Yes = 1 |
| 112 | + #Dlg_Expand_No |
| 113 | + #Dlg_Expand_Equal |
| 114 | + #Dlg_Expand_Item |
| 115 | +EndEnumeration |
| 116 | + |
| 117 | +; Represents the size/position info for a dialog |
| 118 | +; |
| 119 | +Structure DialogPosition |
| 120 | + x.l |
| 121 | + y.l |
| 122 | + Width.l |
| 123 | + Height.l |
| 124 | + IsMaximized.l |
| 125 | +EndStructure |
| 126 | + |
| 127 | + |
| 128 | +; Representation of the fixed values in the datasection |
| 129 | +; |
| 130 | +Structure DialogObjectData |
| 131 | + Type.l |
| 132 | + Gadget.l ; remains .l as here are no PB_Any objects |
| 133 | + Flags.l |
| 134 | + MinWidth.l |
| 135 | + MinHeight.l |
| 136 | + HasText.l |
| 137 | + KeyCount.l |
| 138 | +EndStructure |
| 139 | + |
| 140 | +; Representation of a shortcut in the datasection |
| 141 | +; |
| 142 | +Structure DialogShortcutData |
| 143 | + Type.l ; = #DIALOG_Shortcut |
| 144 | + Key.l |
| 145 | + MenuItem.l |
| 146 | +EndStructure |
| 147 | + |
| 148 | + |
| 149 | +; Functions implemented for each dialog object |
| 150 | +; |
| 151 | +; Note: |
| 152 | +; SizeRequestReal() should be the real function. |
| 153 | +; SizeRequest() should always be the DlgBase_SizeRequestWrapper() |
| 154 | +; function for all Objects. This wrapper properly checks for the |
| 155 | +; width="ignore" setting and applies it so it does not have to be done |
| 156 | +; in all code separately |
| 157 | +; |
| 158 | +; Do not call SizeRequestReal() directly, but always call through |
| 159 | +; SizeRequest() |
| 160 | +; |
| 161 | +Interface DialogObject |
| 162 | + SizeRequest(*Width.LONG, *Height.LONG) |
| 163 | + SizeRequestReal(*Width.LONG, *Height.LONG) |
| 164 | + SizeApply(x, y, Width, Height) |
| 165 | + AddChild(Child.DialogObject) |
| 166 | + FoldApply(State) |
| 167 | + Find(Name$) |
| 168 | + Finish() |
| 169 | + Update() |
| 170 | + Destroy() |
| 171 | +EndInterface |
| 172 | + |
| 173 | + |
| 174 | +; The Window object (the main object of a dialog) implements more methods for public access |
| 175 | +; by the user. Note that the DialogObject functions are designed to be called inside the |
| 176 | +; Dialog files only. |
| 177 | +; |
| 178 | +Interface DialogWindow Extends DialogObject |
| 179 | + Window() ; Get the #Window number of the dialog window |
| 180 | + Gadget(Name$) ; Get the #Gadget number of the gadget where the 'name' tag is set to Name$ (case insensitive) |
| 181 | + Fold(Name$, State); Fold/Unfold an object based on its 'name' tag |
| 182 | + LanguageUpdate() ; Update all language strings |
| 183 | + GuiUpdate() ; Re-calculate and resize gui (call this when for example font sizes have changed, or after language updates) |
| 184 | + SizeUpdate() ; call this after a #PB_Event_SizeWindow for a resizable dialog. (updates all sizes to fit the current window size) |
| 185 | + Close(*Sizing.DialogPosition = 0) ; close the window and free all data. fill the *Sizing structrue with data if present |
| 186 | +EndInterface |
| 187 | + |
| 188 | + |
| 189 | +Declare OpenDialog(*DataOffset.DialogObjectData, ParentID = 0, *Sizing.DialogPosition = 0) |
| 190 | + |
0 commit comments