1 // Note: this class is called Dialog, but it can also handle a tab under the following conditions:
3 // - backgroundImage is the tab's background
8 // - intendedHeight ends up to be the tab's actual height, or at least close
9 // - titleFontSize is 0
10 // - marginTop cancels out as much of titleHeight as needed (that is, it should be actualMarginTop - titleHeight)
11 // To ensure the latter, you best create all tabs FIRST and insert the tabbed
12 // control to your dialog THEN - with the right height
14 // a subclass may help with using this as a tab
17 CLASS(Dialog) EXTENDS(InputContainer)
18 METHOD(Dialog, configureDialog, void(entity)) // no runtime configuration, all parameters are given in the code!
19 METHOD(Dialog, fill, void(entity)) // to be overridden by user to fill the dialog with controls
20 METHOD(Dialog, keyDown, float(entity, float, float, float))
21 METHOD(Dialog, close, void(entity))
22 METHOD(Dialog, addItemSimple, void(entity, float, float, float, float, entity))
24 METHOD(Dialog, TD, void(entity, float, float, entity))
25 METHOD(Dialog, TDempty, void(entity, float))
26 METHOD(Dialog, setFirstColumn, void(entity, float))
27 METHOD(Dialog, TR, void(entity))
28 METHOD(Dialog, gotoXY, void(entity, float, float))
30 ATTRIB(Dialog, isTabRoot, float, 1)
31 ATTRIB(Dialog, closeButton, entity, NULL)
32 ATTRIB(Dialog, intendedHeight, float, 0)
33 ATTRIB(Dialog, itemOrigin, vector, '0 0 0')
34 ATTRIB(Dialog, itemSize, vector, '0 0 0')
35 ATTRIB(Dialog, itemSpacing, vector, '0 0 0')
36 ATTRIB(Dialog, currentRow, float, 0)
37 ATTRIB(Dialog, currentColumn, float, 0)
38 ATTRIB(Dialog, firstColumn, float, 0)
41 ATTRIB(Dialog, closable, float, 1)
42 ATTRIB(Dialog, rootDialog, float, 1)
43 ATTRIB(Dialog, title, string, "Form1") // ;)
44 ATTRIB(Dialog, color, vector, '1 0.5 1')
45 ATTRIB(Dialog, intendedWidth, float, 0)
46 ATTRIB(Dialog, rows, float, 3)
47 ATTRIB(Dialog, columns, float, 2)
49 ATTRIB(Dialog, marginTop, float, 0) // pixels
50 ATTRIB(Dialog, marginBottom, float, 0) // pixels
51 ATTRIB(Dialog, marginLeft, float, 0) // pixels
52 ATTRIB(Dialog, marginRight, float, 0) // pixels
53 ATTRIB(Dialog, columnSpacing, float, 0) // pixels
54 ATTRIB(Dialog, rowSpacing, float, 0) // pixels
55 ATTRIB(Dialog, rowHeight, float, 0) // pixels
56 ATTRIB(Dialog, titleHeight, float, 0) // pixels
57 ATTRIB(Dialog, titleFontSize, float, 0) // pixels; if 0, title causes no margin
59 ATTRIB(Dialog, backgroundImage, string, "")
60 ATTRIB(Dialog, closeButtonImage, string, "")
65 void Dialog_Close(entity button, entity me)
70 void fillDialog(entity me)
74 void addItemSimpleDialog(entity me, float row, float col, float rowspan, float colspan, entity e)
76 //print(vtos(me.itemSpacing), " ", vtos(me.itemSize), "\n");
78 me.itemOrigin + eX * ( col * me.itemSpacing_x) + eY * ( row * me.itemSpacing_y),
79 me.itemSize + eX * ((colspan - 1) * me.itemSpacing_x) + eY * ((rowspan - 1) * me.itemSpacing_y),
83 void gotoXYDialog(entity me, float row, float col)
86 me.currentColumn = col;
89 void TRDialog(entity me)
92 me.currentColumn = me.firstColumn;
95 void TDDialog(entity me, float rowspan, float colspan, entity e)
97 me.addItemSimple(me, me.currentRow, me.currentColumn, rowspan, colspan, e);
98 me.currentColumn += colspan;
101 void setFirstColumnDialog(entity me, float col)
103 me.firstColumn = col;
106 void TDemptyDialog(entity me, float colspan)
108 me.currentColumn += colspan;
111 void configureDialogDialog(entity me)
113 entity frame, closebutton;
114 float absWidth, absHeight;
116 frame = spawnBorderImage();
117 frame.configureBorderImage(frame, me.title, me.titleFontSize, me.color, me.backgroundImage, me.titleHeight);
118 me.addItem(me, frame, '0 0 0', '1 1 0', 1);
120 if(!me.titleFontSize)
121 me.titleHeight = 0; // no title bar
123 absWidth = me.intendedWidth * cvar("vid_conwidth");
124 absHeight = me.titleHeight + me.marginTop + me.rows * me.rowHeight + (me.rows - 1) * me.rowSpacing + me.marginBottom;
125 me.itemOrigin = eX * (me.marginLeft / absWidth)
126 + eY * ((me.titleHeight + me.marginTop) / absHeight);
127 me.itemSize = eX * ((1 - (me.marginLeft + me.marginRight + me.columnSpacing * (me.columns - 1)) / absWidth) / me.columns)
128 + eY * (me.rowHeight / absHeight);
129 me.itemSpacing = me.itemSize
130 + eX * (me.columnSpacing / absWidth)
131 + eY * (me.rowSpacing / absHeight);
132 me.intendedHeight = absHeight / cvar("vid_conheight");
134 me.currentColumn = -1;
140 closebutton = me.closeButton = spawnButton();
141 closebutton.configureButton(closebutton, "Close", 0, me.closeButtonImage);
142 closebutton.onClick = Dialog_Close; closebutton.onClickEntity = me;
143 closebutton.srcMulti = 0;
144 me.addItem(me, closebutton, '0 0 0', '1 1 0', 1); // put it as LAST
147 frame.closeButton = closebutton;
150 void closeDialog(entity me)
152 if(me.parent.instanceOfNexposee)
154 ExposeeCloseButton_Click(me, me.parent);
156 else if(me.parent.instanceOfModalController)
158 DialogCloseButton_Click(me, me);
166 float keyDownDialog(entity me, float key, float ascii, float shift)
176 return keyDownInputContainer(me, key, ascii, shift);