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;
53 // ////////////////////////////////////////////////////////////////////////// //
54 //__gshared int lastWinWidth, lastWinHeight;
57 // ////////////////////////////////////////////////////////////////////////// //
58 public class TitlerWindow
: SubWindow
{
60 LineEditWidget edtTitle
;
61 LineEditWidget fromName
;
62 LineEditWidget fromMail
;
70 bool delegate (dynstring name
, dynstring mail
, dynstring folder
, dynstring title
) onSelected
;
72 override void createWidgets () {
76 fromName
= new LineEditWidget("Name:");
80 fromMail
= new LineEditWidget("Mail:");
84 edtTitle
= new LineEditWidget("Title:");
87 (new HBoxWidget
).enter{
88 with (new HotLabelWidget("&Name:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; hsizeId
= "editors"; }
90 fromName
= new LineEditWidget();
95 (new HBoxWidget
).enter{
96 with (new HotLabelWidget("&Mail:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; hsizeId
= "editors"; }
98 fromMail
= new LineEditWidget();
103 (new HBoxWidget
).enter{
104 with (new HotLabelWidget("&Title:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; hsizeId
= "editors"; }
106 edtTitle
= new LineEditWidget();
112 (new HBoxWidget
).enter{
115 with (new ButtonWidget(" O&k ")) {
116 hsizeId
= "okcancel";
117 deftype
= Default
.Accept
;
118 onAction
= delegate (self
) {
119 if (onSelected
!is null) {
120 if (!onSelected(fromName
.str, fromMail
.str, folder
, edtTitle
.str)) return;
126 with (new ButtonWidget(" Cancel ")) {
127 hsizeId
= "okcancel";
128 deftype
= Default
.Cancel
;
129 onAction
= delegate (self
) {
140 edtTitle
.str = title
;
148 this (const(char)[] aname
, const(char)[] amail
, const(char)[] afolder
, const(char)[] atitle
) {
149 dynstring caption
= "Title for "~aname
~" <"~amail
~">";
159 // ////////////////////////////////////////////////////////////////////////// //
160 public class TagOptionsWindow
: SubWindow
{
161 LabelWidget optPath
; // real path
162 LineEditWidget optMonthes
;
163 CheckboxWidget optThreaded
;
164 CheckboxWidget optAttaches
;
167 void delegate (const(char)[] tagname
) onUpdated
;
169 this (const(char)[] atagname
) {
171 dynstring caption
= "options for '"~atagname
~"'";
175 override void createWidgets () {
176 optPath
= new LabelWidget("", LabelWidget
.HAlign
.Center
);
180 optMonthes
= new LineEditWidget("Monthes:");
182 optMonthes
.width
= optMonthes
.titwdt
+64;
184 (new HBoxWidget
).enter{
185 with (new HotLabelWidget("&Monthes:", LabelWidget
.HAlign
.Right
)) { width
= width
+2; /*hsizeId = "editors";*/ }
187 optMonthes
= new LineEditWidget();
188 //optMonthes.flex = 1;
189 optMonthes
.width
= gxTextWidthUtf("96669");
190 conwriteln("ISMYSEL: ", optMonthes
.isMySelector(" Widget#. "));
191 conwriteln("ISMYSEL: ", optMonthes
.isMySelector(" HBoxWidget LineEditWidget#. "));
192 conwriteln("ISMYSEL: ", optMonthes
.isMySelector(" HBoxWidget> #. "));
193 conwriteln("ISMYSEL: ", optMonthes
.isMySelector(" SubWindow HBoxWidget LineEditWidget#. "));
194 //new SpringWidget(1);
198 optThreaded
= new CheckboxWidget("&Threaded");
199 optThreaded
.flex
= 1;
201 optAttaches
= new CheckboxWidget("&Attaches");
202 optAttaches
.flex
= 1;
205 (new HBoxWidget
).enter{
208 with (new ButtonWidget(" O&k ")) {
209 hsizeId
= "okcancel";
210 deftype
= Default
.Accept
;
211 onAction
= delegate (self
) {
212 if (onUpdated
!is null) onUpdated(tagname
);
217 with (new ButtonWidget(" Cancel ")) {
218 hsizeId
= "okcancel";
219 deftype
= Default
.Cancel
;
220 onAction
= delegate (self
) {
231 optPath
.text
= "booPath";
232 optMonthes
.str = "666";
234 optThreaded
.enabled
= false;
235 optAttaches
.enabled
= true;
237 optMonthes
.killTextOnChar
= true;
241 //add(); // for "focused"
243 forEachSelector("SubWindow > RootWidget CheckboxWidget", (EgraStyledClass w
) {
244 import iv
.vfs
.io
; writeln("LEW=", typeid(w
).name
, "; text=", (cast(CheckboxWidget
)w
).title
.getData
);
248 forEachSelector("SubWindow > RootWidget :focused", (EgraStyledClass w
) {
249 import iv
.vfs
.io
; writeln("FOCUSED=", typeid(w
).name
);
253 foreach (EgraStyledClass c
; querySelectorAll("SubWindow > RootWidget HotLabelWidget")) {
255 writeln("LBL: <", (cast(HotLabelWidget
)c
).text
.getData
, ">");
259 auto qf
= querySelector(":focused");
260 if (qf
!is null) writeln("QFOCUSED=", typeid(qf
).name
); else writeln("FUCK!");
265 // ////////////////////////////////////////////////////////////////////////// //
266 void initConsole () {
267 // //////////////////////////////////////////////////////////////////// //
269 import core
.memory
: GC
;
270 conwriteln("starting GC collection...");
273 conwriteln("GC collection complete.");
274 })("gc_collect", "force GC collection cycle");
277 // //////////////////////////////////////////////////////////////////// //
279 auto qww
= new YesNoWindow("Quit?", "Do you really want to quit?", true);
280 qww
.onYes
= () { concmd("quit"); };
282 })("quit_prompt", "quit with prompt");
285 new TitlerWindow("name", "mail", "folder", "title");
286 })("window_titler", "titler window test");
289 new TagOptionsWindow("xtag");
290 })("window_tagoptions", "tag options window test");
294 // ////////////////////////////////////////////////////////////////////////// //
295 __gshared MainPaneWindow mainPane
;
298 final class MainPaneWindow
: SubWindow
{
299 ProgressBarWidget pbar
;
302 super(null, GxPoint(0, 0), GxSize(screenWidth
, screenHeight
));
303 mType
= Type
.OnBottom
;
305 pbar
= new ProgressBarWidget(rootWidget
, "progress bar");
306 pbar
.setMinMax(0, 100);
307 pbar
.width
= clientWidth
-64;
309 pbar
.posy
= clientHeight
-pbar
.height
-8;
310 pbar
.posx
= (clientWidth
-pbar
.width
)/2;
315 // //////////////////////////////////////////////////////////////////// //
316 override void onPaint () {
319 enum guiGroupListWidth
= 128;
320 enum guiThreadListHeight
= 520;
322 gxFillRect(0, 0, guiGroupListWidth
, screenHeight
, getColor("grouplist-back"));
323 gxVLine(guiGroupListWidth
, 0, screenHeight
, getColor("grouplist-divline"));
325 gxFillRect(guiGroupListWidth
+1, 0, screenWidth
, guiThreadListHeight
, getColor("threadlist-back"));
326 gxHLine(guiGroupListWidth
+1, guiThreadListHeight
, screenWidth
, getColor("threadlist-divline"));
328 version(test_round_rect
) {
330 gxFillRoundedRect(lastMouseX
-16, lastMouseY
-16, 128, 96, rrad
, /*gxSolidWhite*/gxRGBA
!(0, 255, 0, 127));
331 //gxDrawRoundedRect(lastMouseX-16, lastMouseY-16, 128, 96, rrad, gxRGBA!(0, 255, 0, 127));
337 version(test_round_rect
) {
341 override bool onKeyBubble (KeyEvent event
) {
343 version(test_round_rect
) {
344 if (event
== "Plus") { ++rrad
; return true; }
345 if (event
== "Minus") { --rrad
; return true; }
347 if (event
== "C-Q") { concmd("quit_prompt"); return true; }
348 if (event
== "1") { concmd("window_titler"); return true; }
349 if (event
== "2") { concmd("window_tagoptions"); return true; }
350 if (event
== "Minus") { pbar
.current
= pbar
.current
-1; return true; }
351 if (event
== "Plus") { pbar
.current
= pbar
.current
+1; return true; }
352 //if (dbg_dump_keynames) conwriteln("key: ", event.toStr, ": ", event.modifierState&ModifierState.windows);
353 //foreach (const ref kv; mainAppKeyBindings.byKeyValue) if (event == kv.key) concmd(kv.value);
358 // returning `false` to avoid screen rebuilding by dispatcher
359 override bool onMouseBubble (MouseEvent event
) {
360 if (event
.type
== MouseEventType
.buttonPressed || event
.type
== MouseEventType
.buttonReleased
) {
363 // for OpenGL, this rebuilds the whole screen anyway
371 // ////////////////////////////////////////////////////////////////////////// //
372 void main (string
[] args
) {
373 defaultColorStyle
.parseStyle(TestStyle
);
374 //egraDefaultFontSize = 48;
376 glconAllowOpenGLRender
= false;
378 sdpyWindowClass
= "EGUITest";
379 //glconShowKey = "M-Grave";
384 conProcessArgs
!true(args
);
386 egraCreateSystemWindow("EGRA Test", allowResize
:false);
388 vbwin
.addEventListener((QuitEvent evt
) {
389 if (vbwin
.closed
) return;
390 if (isQuitRequested
) { vbwin
.close(); return; }
394 static if (is(typeof(&vbwin
.closeQuery
))) {
395 vbwin
.closeQuery
= delegate () { concmd("quit"); egraPostDoConCommands(); };
398 mainPane
= new MainPaneWindow();
399 //egraSkipScreenClear = true; // main pane is fullscreen
404 vbwin
.eventLoop(1000*10,
406 egraProcessConsole();
408 delegate (KeyEvent event
) {
409 if (egraOnKey(event
)) return;
411 delegate (MouseEvent event
) {
412 if (egraOnMouse(event
)) return;
414 delegate (dchar ch
) {
415 if (egraOnChar(ch
)) return;
420 conProcessQueue(int.max
/4);