2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module test /*is aliced*/;
19 import arsd
.simpledisplay
;
31 // ////////////////////////////////////////////////////////////////////////// //
32 static immutable string TestStyle
= `
34 grouplist-divline: white;
37 threadlist-divline: white;
38 threadlist-back: #222;
52 // ////////////////////////////////////////////////////////////////////////// //
53 //__gshared int lastWinWidth, lastWinHeight;
56 // ////////////////////////////////////////////////////////////////////////// //
57 public class TitlerWindow
: SubWindow
{
59 LineEditWidget edtTitle
;
60 LineEditWidget fromName
;
61 LineEditWidget fromMail
;
69 bool delegate (const(char)[] name
, const(char)[] mail
, const(char)[] folder
, const(char)[] title
) onSelected
;
71 override void createWidgets () {
75 fromName
= new LineEditWidget("Name:");
79 fromMail
= new LineEditWidget("Mail:");
83 edtTitle
= new LineEditWidget("Title:");
86 (new HBoxWidget
).enter{
87 with (new HotLabelWidget("&Name:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; hsizeId
= "editors"; }
89 fromName
= new LineEditWidget();
94 (new HBoxWidget
).enter{
95 with (new HotLabelWidget("&Mail:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; hsizeId
= "editors"; }
97 fromMail
= new LineEditWidget();
102 (new HBoxWidget
).enter{
103 with (new HotLabelWidget("&Title:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; hsizeId
= "editors"; }
105 edtTitle
= new LineEditWidget();
111 (new HBoxWidget
).enter{
114 with (new ButtonWidget(" O&k ")) {
115 hsizeId
= "okcancel";
116 deftype
= Default
.Accept
;
117 onAction
= delegate (self
) {
118 if (onSelected
!is null) {
119 if (!onSelected(fromName
.str, fromMail
.str, folder
, edtTitle
.str)) return;
125 with (new ButtonWidget(" Cancel ")) {
126 hsizeId
= "okcancel";
127 deftype
= Default
.Cancel
;
128 onAction
= delegate (self
) {
139 edtTitle
.str = title
;
147 this (string aname
, string amail
, string afolder
, string atitle
) {
148 string caption
= "Title for "~aname
~" <"~amail
~">";
158 // ////////////////////////////////////////////////////////////////////////// //
159 public class TagOptionsWindow
: SubWindow
{
160 LabelWidget optPath
; // real path
161 LineEditWidget optMonthes
;
162 CheckboxWidget optThreaded
;
163 CheckboxWidget optAttaches
;
166 void delegate (const(char)[] tagname
) onUpdated
;
168 this (string atagname
) {
170 string caption
= "options for '"~atagname
~"'";
174 override void createWidgets () {
175 optPath
= new LabelWidget("", LabelWidget
.HAlign
.Center
);
179 optMonthes
= new LineEditWidget("Monthes:");
181 optMonthes
.width
= optMonthes
.titwdt
+64;
183 (new HBoxWidget
).enter{
184 with (new HotLabelWidget("&Monthes:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; /*hsizeId = "editors";*/ }
186 optMonthes
= new LineEditWidget();
187 //optMonthes.flex = 1;
188 optMonthes
.width
= gxTextWidthUtf("96669");
189 //new SpringWidget(1);
193 optThreaded
= new CheckboxWidget("&Threaded");
194 optThreaded
.flex
= 1;
196 optAttaches
= new CheckboxWidget("&Attaches");
197 optAttaches
.flex
= 1;
200 (new HBoxWidget
).enter{
203 with (new ButtonWidget(" O&k ")) {
204 hsizeId
= "okcancel";
205 deftype
= Default
.Accept
;
206 onAction
= delegate (self
) {
207 if (onUpdated
!is null) onUpdated(tagname
);
212 with (new ButtonWidget(" Cancel ")) {
213 hsizeId
= "okcancel";
214 deftype
= Default
.Cancel
;
215 onAction
= delegate (self
) {
226 optPath
.text
= "booPath";
227 optMonthes
.str = "666";
229 optThreaded
.enabled
= false;
230 optAttaches
.enabled
= true;
232 optMonthes
.killTextOnChar
= true;
239 // ////////////////////////////////////////////////////////////////////////// //
240 void initConsole () {
241 // //////////////////////////////////////////////////////////////////// //
243 import core
.memory
: GC
;
244 conwriteln("starting GC collection...");
247 conwriteln("GC collection complete.");
248 })("gc_collect", "force GC collection cycle");
251 // //////////////////////////////////////////////////////////////////// //
253 auto qww
= new YesNoWindow("Quit?", "Do you really want to quit?", true);
254 qww
.onYes
= () { concmd("quit"); };
256 })("quit_prompt", "quit with prompt");
259 new TitlerWindow("name", "mail", "folder", "title");
260 })("window_titler", "titler window test");
263 new TagOptionsWindow("xtag");
264 })("window_tagoptions", "tag options window test");
268 // ////////////////////////////////////////////////////////////////////////// //
269 __gshared MainPaneWindow mainPane
;
272 final class MainPaneWindow
: SubWindow
{
273 ProgressBarWidget pbar
;
276 super(null, GxPoint(0, 0), GxSize(screenWidth
, screenHeight
));
277 mType
= Type
.OnBottom
;
279 pbar
= new ProgressBarWidget(rootWidget
, "progress bar");
280 pbar
.setMinMax(0, 100);
281 pbar
.width
= clientWidth
-64;
283 pbar
.posy
= clientHeight
-pbar
.height
-8;
284 pbar
.posx
= (clientWidth
-pbar
.width
)/2;
289 // //////////////////////////////////////////////////////////////////// //
290 override void onPaint () {
293 enum guiGroupListWidth
= 128;
294 enum guiThreadListHeight
= 520;
296 gxFillRect(0, 0, guiGroupListWidth
, screenHeight
, getColor("grouplist-back"));
297 gxVLine(guiGroupListWidth
, 0, screenHeight
, getColor("grouplist-divline"));
299 gxFillRect(guiGroupListWidth
+1, 0, screenWidth
, guiThreadListHeight
, getColor("threadlist-back"));
300 gxHLine(guiGroupListWidth
+1, guiThreadListHeight
, screenWidth
, getColor("threadlist-divline"));
302 version(test_round_rect
) {
304 gxFillRoundedRect(lastMouseX
-16, lastMouseY
-16, 128, 96, rrad
, /*gxSolidWhite*/gxRGBA
!(0, 255, 0, 127));
305 //gxDrawRoundedRect(lastMouseX-16, lastMouseY-16, 128, 96, rrad, gxRGBA!(0, 255, 0, 127));
311 version(test_round_rect
) {
315 override bool onKeyBubble (KeyEvent event
) {
317 version(test_round_rect
) {
318 if (event
== "Plus") { ++rrad
; return true; }
319 if (event
== "Minus") { --rrad
; return true; }
321 if (event
== "C-Q") { concmd("quit_prompt"); return true; }
322 if (event
== "1") { concmd("window_titler"); return true; }
323 if (event
== "2") { concmd("window_tagoptions"); return true; }
324 if (event
== "Minus") { pbar
.current
= pbar
.current
-1; return true; }
325 if (event
== "Plus") { pbar
.current
= pbar
.current
+1; return true; }
326 //if (dbg_dump_keynames) conwriteln("key: ", event.toStr, ": ", event.modifierState&ModifierState.windows);
327 //foreach (const ref kv; mainAppKeyBindings.byKeyValue) if (event == kv.key) concmd(kv.value);
332 // returning `false` to avoid screen rebuilding by dispatcher
333 override bool onMouseBubble (MouseEvent event
) {
334 if (event
.type
== MouseEventType
.buttonPressed || event
.type
== MouseEventType
.buttonReleased
) {
337 // for OpenGL, this rebuilds the whole screen anyway
345 // ////////////////////////////////////////////////////////////////////////// //
346 void main (string
[] args
) {
347 defaultColorStyle
.parseStyle(TestStyle
);
348 //egraDefaultFontSize = 48;
350 glconAllowOpenGLRender
= false;
352 sdpyWindowClass
= "EGUITest";
353 //glconShowKey = "M-Grave";
358 conProcessArgs
!true(args
);
360 egraCreateSystemWindow("EGRA Test", allowResize
:false);
362 vbwin
.addEventListener((QuitEvent evt
) {
363 if (vbwin
.closed
) return;
364 if (isQuitRequested
) { vbwin
.close(); return; }
368 static if (is(typeof(&vbwin
.closeQuery
))) {
369 vbwin
.closeQuery
= delegate () { concmd("quit"); egraPostDoConCommands(); };
372 mainPane
= new MainPaneWindow();
373 //egraSkipScreenClear = true; // main pane is fullscreen
378 vbwin
.eventLoop(1000*10,
380 egraProcessConsole();
382 delegate (KeyEvent event
) {
383 if (egraOnKey(event
)) return;
385 delegate (MouseEvent event
) {
386 if (egraOnMouse(event
)) return;
388 delegate (dchar ch
) {
389 if (egraOnChar(ch
)) return;
394 conProcessQueue(int.max
/4);