annotate mde/gui/widget/Ifaces.d @ 72:159775502bb4

The first dynamically generated widget lists, based on Options, are here!
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 05 Jul 2008 18:27:46 +0100
parents f54ae4fc2b2f
children 25cb7420dc91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify it under the terms
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /** Window and widget interfaces. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 module mde.gui.widget.Ifaces;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 public import mde.gui.renderer.IRenderer;
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
20 public import mde.gui.IGui;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
22 /** Interface for Window, allowing widgets to call some of Window's methods.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
23 *
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
24 * Contains the methods in Window available for widgets to call on their root.
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
25 *
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
26 * Notation:
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
27 * Positive/negative direction: along the x/y axis in this direction.
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
28 * Layout widget: a widget containing multiple sub-widges (which hence controls how they are laid
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
29 * out). */
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
30 interface IWindow : IWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
31 {
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
32 /** Widget ID type. Each ID is unique under this window.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
33 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
34 * Type is int since this is the widget data type. */
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35 alias int widgetID;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
36
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
37 /** Get a widget by ID.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
38 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
39 * Returns the widget with the given ID from the Window's widget list. If the widget hasn't yet
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
40 * been created, creates it using the Window's widget creation data. */
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
41 IWidget makeWidget (widgetID i);
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
42
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
43 /** Get a string from the widgetString associative array. */
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
44 char[] getWidgetString (int i);
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
45
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
46 /** Add widget's saveData to the data to be saved, returning it's widgetID. */
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
47 widgetID addCreationData (IWidget widget);
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
48
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
49 /** Add a string to the widgetString associative array, returning it's index. */
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
50 int addWidgetString (char[] str);
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
51
41
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
52 /** Returns the window's gui. */
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
53 IGui gui ();
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
54
41
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
55 /** The widget/window needs redrawing. */
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
56 void requestRedraw ();
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
57
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
58 /** Get the window's renderer.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
59 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
60 * Normally specific to the GUI, but widgets have no direct contact with the GUI and this
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
61 * provides the possibility of per-window renderers (if desired). */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
62 IRenderer renderer ();
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
63 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
64
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
65 /** Interface for widgets.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
66 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
67 * Note that Window also implements this interface so that widgets can interact with their parent
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
68 * in a uniform way.
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
69 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
70 * A widget is a region of a GUI window which handles rendering and user-interaction for itself
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
71 * and is able to communicate with it's window and parent/child widgets as necessary.
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
72 *
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
73 * If a widget is to be creatable by Window.makeWidget, it must be listed in the createWidget
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
74 * module, have a constructor of the following form, and should implement getCreationData().
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
75 * Use Ddoc to explain what initialization data is used.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
76 * ----------------------------------
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
77 * /++ Constructor for a ... widget.
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
78 * +
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
79 * + Widget uses the initialisation data:
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
80 * + [widgetID, x, y]
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
81 * + where x is ... and y is ... +/
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
82 * this (IWindow window, int[] data);
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
83 * ----------------------------------
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
84 * Where window is the root window (the window to which the widget belongs) and data is an array of
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
85 * initialisation data. The method should throw a WidgetDataException (created without parameters)
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
86 * if the data has wrong length or is otherwise invalid.
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
87 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
88 * The widget's size should be set either by it's this() method or by the first call to
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
89 * setSize(). setSize() is called on all widgets immediately after their creation, and throwing an
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
90 * exception at this point (but not on later calls to setSize) is an acceptible method of failure.
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
91 */
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
92 //NOTE: add another this() without the data for default initialization, for the GUI editor?
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
93 interface IWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
94 {
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
95 //BEGIN Load and save
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
96 /** Called after creating widgets to adjust size & other mutable attributes from saved data.
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
97 *
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
98 * As for setSize, setPosition should be called afterwards.
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
99 *
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
100 * Each widget should call adjust on each of its sub-widgets in turn with data, each time
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
101 * replacing data by the return value of the call. It should then take its own mutable data
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
102 * from the beginning of the array and return the remainder of the array.
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
103 *
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
104 * Adjust should handle errors gracefully by reverting to default values and not throwing.
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
105 * This is because the creation data and the user's mutable data may be stored separately and
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
106 * become out-of-sync during an update. */
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
107 int[] adjust (int[] data);
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
108
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
109 /** Output data suitible for recreating the widget (data to be passed to this()).
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
110 *
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
111 * Function may need to call Window's addCreationData() and addWidgetString() methods to save
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
112 * other data.
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
113 *
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
114 * Creation data is data only changed when the gui is edited. */
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
115 int[] getCreationData ();
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
116
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
117 /** Output data containing the widget's current adjustments (data to be passed to adjust()).
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
118 *
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
119 * Mutable data is data which can be changed during normal gui use, such as the size of
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
120 * resizible widgets or current tab of a tab widget.
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
121 *
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
122 * Should be a concatenation of each sub-widget's mutable data and the widget's own. */
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
123 int[] getMutableData ();
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
124 //END Load and save
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
125
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
126 //BEGIN Size and position
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
127 /** is the width / height resizable?
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
128 *
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
129 * If not, the widget has fixed dimensions equal the output of getMinimalSize. */
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
130 bool isWSizable ();
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
131 bool isHSizable (); /// ditto
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
132
66
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
133 /** The minimal size the widget could be shrunk to (or its fixed size).
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
134 *
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
135 * Takes into account child-widgets and any other contents. */
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
136 wdim minWidth ();
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
137 wdim minHeight (); /// ditto
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
138
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
139 /** Get the current size of the widget. */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
140 void getCurrentSize (out wdim w, out wdim h);
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
141
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
142 /** Used to adjust the size.
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
143 *
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
144 * Params:
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
145 * nw/nh = The new width/height
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
146 * dir = Direction to resize from. This is only really applicable to layout widgets.
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
147 * It must be either -1 (start resizing from highest row/col index, decreasing the
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
148 * index as necessary), or +1 (resize from the lowest index, i.e. 0).
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
149 * Most widgets can simply ignore it.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
150 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
151 * Implementation:
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
152 * The size should be clamped to the widget's minimal size, i.e. the size set may be larger
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
153 * than that given by the parameters. Conversely, the size should not be reduced to the
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
154 * widget's maximal size (if any) but expanded as necessary (alignment to be implemented).
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
155 * This should be true for both resizable and fixed widgets; fixed widgets may still be scaled
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
156 * to fill a whole row/column in a layout widget.
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
157 *
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
158 * If the actual size is needed, call getCurrentSize afterwards. setPosition must be called
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
159 * afterwards if the widget might be a layout widget. */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
160 void setWidth (wdim nw, int dir);
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
161 void setHeight (wdim nh, int dir); /// ditto
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
162
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
163 /** Set the current position (i.e. called on init and move). */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
164 void setPosition (wdim x, wdim y);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
165 //END Size and position
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
166
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
167 //BEGIN Events
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
168 /** Recursively scan the widget tree to find the widget under (x,y).
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
169 *
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
170 * If called on a widget, that widget should assume the location is over itself, and so should
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
171 * either return itself or the result of calling getWidget on the appropriate child widget.
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
172 *
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
173 * In the case of Window this may not be the case; it should check and return null if not under
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
174 * (x,y).
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
175 *
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
176 * Note: use global coordinates (x,y) not coordinates relative to the widget. */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
177 IWidget getWidget (wdim x, wdim y);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
178
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
179 /** Receive a mouse click event.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
180 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
181 * See mde.input.input.Input.MouseClickCallback for parameters. However, cx and cy are adjusted
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
182 * to the Widget's local coordinates.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
183 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
184 * Widget may assume coordinates are on the widget (caller must check). */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
185 void clickEvent (wdabs cx, wdabs cy, ubyte b, bool state);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
186 //END Events
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
187
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
188 /** Draw, using the stored values of x and y.
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
189 *
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
190 * Maybe later enforce clipping of all sub-widget drawing, particularly for cases where only
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
191 * part of the widget is visible: scroll bars or a hidden window. */
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
192 void draw ();
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
193 }