root/trunk/gtk/old/base.d

Revision 8, 18.9 kB (checked in by Chris Miller, 5 years ago)

First steps of DFL GTK.

Line 
1 // See the included license.txt for copyright and license details.
2
3
4 ///
5 module dfl.base;
6
7 import dfl.internal.dlib, dfl.internal.clib, dfl.internal.gtk;
8
9 import dfl.event, dfl.drawing;
10
11
12 alias GtkWidget* HWindow;
13
14
15 ///
16 interface IWindow // docmain
17 {
18     ///
19     HWindow handle(); // getter
20 }
21
22 deprecated alias IWindow IWin32Window; // deprecated
23
24
25 ///
26 class DflException: Exception // docmain
27 {
28     ///
29     this(char[] msg)
30     {
31         super(msg);
32     }
33 }
34
35
36 ///
37 class StringObject: DObject
38 {
39     ///
40     char[] value;
41    
42    
43     ///
44     this(char[] str)
45     {
46         this.value = str;
47     }
48    
49    
50     override char[] toString()
51     {
52         return value;
53     }
54    
55    
56     override int opEquals(Object o)
57     {
58         return value == getObjectString(o); // ?
59     }
60    
61    
62     int opEquals(StringObject s)
63     {
64         return value == s.value;
65     }
66    
67    
68     override int opCmp(Object o)
69     {
70         return stringICmp(value, getObjectString(o)); // ?
71     }
72    
73    
74     int opCmp(StringObject s)
75     {
76         return stringICmp(value, s.value);
77     }
78 }
79
80
81 ///
82 enum Keys: uint // docmain
83 {
84     NONE =     0, /// No keys specified.
85    
86     ///
87     SHIFT =    0x10000, /// Modifier keys.
88     CONTROL =  0x20000, /// ditto
89     ALT =      0x40000, /// ditto
90    
91     // GDK_a ...
92     A = 'a', /// Letters.
93     B, /// ditto
94     C, /// ditto
95     D, /// ditto
96     E, /// ditto
97     F, /// ditto
98     G, /// ditto
99     H, /// ditto
100     I, /// ditto
101     J, /// ditto
102     K, /// ditto
103     L, /// ditto
104     M, /// ditto
105     N, /// ditto
106     O, /// ditto
107     P, /// ditto
108     Q, /// ditto
109     R, /// ditto
110     S, /// ditto
111     T, /// ditto
112     U, /// ditto
113     V, /// ditto
114     W, /// ditto
115     X, /// ditto
116     Y, /// ditto
117     Z, /// ditto
118    
119     D0 = '0', /// Digits.
120     D1 = '1', /// ditto
121     D2 = '2', /// ditto
122     D3 = '3', /// ditto
123     D4 = '4', /// ditto
124     D5 = '5', /// ditto
125     D6 = '6', /// ditto
126     D7 = '7', /// ditto
127     D8 = '8', /// ditto
128     D9 = '9', /// ditto
129    
130     // GDK_F1 ...
131     F1 = 0xFFBE, /// F - function keys.
132     F2, /// ditto
133     F3, /// ditto
134     F4, /// ditto
135     F5, /// ditto
136     F6, /// ditto
137     F7, /// ditto
138     F8, /// ditto
139     F9, /// ditto
140     F10, /// ditto
141     F11, /// ditto
142     F12, /// ditto
143     F13, /// ditto
144     F14, /// ditto
145     F15, /// ditto
146     F16, /// ditto
147     F17, /// ditto
148     F18, /// ditto
149     F19, /// ditto
150     F20, /// ditto
151     F21, /// ditto
152     F22, /// ditto
153     F23, /// ditto
154     F24, /// ditto
155    
156     // GDK_KP_0 ...
157     NUM_PAD0 = 0xFFB0, /// Numbers on keypad.
158     NUM_PAD1, /// ditto
159     NUM_PAD2, /// ditto
160     NUM_PAD3, /// ditto
161     NUM_PAD4, /// ditto
162     NUM_PAD5, /// ditto
163     NUM_PAD6, /// ditto
164     NUM_PAD7, /// ditto
165     NUM_PAD8, /// ditto
166     NUM_PAD9, /// ditto
167    
168     //ADD = , ///
169     //APPS = , /// Application.
170     //ATTN = , ///
171     BACK = 0xFF08, /// Backspace.
172     CANCEL = 0xFF69, ///
173     CAPITAL = 0xFFE5, ///
174     CAPS_LOCK = 0xFFE5, /// ditto
175     CLEAR = 0xFF0B, ///
176    
177     // GDK_Control_L (Note: skipping GDK_Control_R)
178     CONTROL_KEY = 0xFFE3, ///
179    
180     // GDK_3270_CursorSelect ?
181     CRSEL = 0xFD1C, ///
182    
183     // GDK_KP_Decimal
184     DECIMAL = 0xFFAE, ///
185    
186     // GDK_Delete
187     DEL = 0xFFFF, ///
188     DELETE = DEL, ///
189    
190     // GDK_period
191     PERIOD = 0x02E, ///
192     DOT = PERIOD, /// ditto
193    
194     /+ // Not converted yet...
195     DIVIDE = 111, ///
196     DOWN = 40, /// Down arrow.
197     END = 35, ///
198     ENTER = 13, ///
199     ERASE_EOF = 249, ///
200     ESCAPE = 27, ///
201     EXECUTE = 43, ///
202     EXSEL = 248, ///
203     FINAL_MODE = 4, /// IME final mode.
204     HANGUL_MODE = 21, /// IME Hangul mode.
205     HANGUEL_MODE = 21, /// ditto
206     HANJA_MODE = 25, /// IME Hanja mode.
207     HELP = 47, ///
208     HOME = 36, ///
209     IME_ACCEPT = 30, ///
210     IME_CONVERT = 28, ///
211     IME_MODE_CHANGE = 31, ///
212     IME_NONCONVERT = 29, ///
213     INSERT = 45, ///
214     JUNJA_MODE = 23, ///
215     KANA_MODE = 21, ///
216     KANJI_MODE = 25, ///
217     LEFT_CONTROL = 162, /// Left Ctrl.
218     LEFT = 37, /// Left arrow.
219     LINE_FEED = 10, ///
220     LEFT_MENU = 164, /// Left Alt.
221     LEFT_SHIFT = 160, ///
222     LEFT_WIN = 91, /// Left Windows logo.
223     MENU = 18, /// Alt.
224     MULTIPLY = 106, ///
225     NEXT = 34, /// Page down.
226     NO_NAME = 252, // Reserved for future use.
227     NUM_LOCK = 144, ///
228     OEM8 = 223, // OEM specific.
229     OEM_CLEAR = 254,
230     PA1 = 253,
231     PAGE_DOWN = 34, ///
232     PAGE_UP = 33, ///
233     PAUSE = 19, ///
234     PLAY = 250, ///
235     PRINT = 42, ///
236     PRINT_SCREEN = 44, ///
237     PROCESS_KEY = 229, ///
238     RIGHT_CONTROL = 163, /// Right Ctrl.
239     RETURN = 13, ///
240     RIGHT = 39, /// Right arrow.
241     RIGHT_MENU = 165, /// Right Alt.
242     RIGHT_SHIFT = 161, ///
243     RIGHT_WIN = 92, /// Right Windows logo.
244     SCROLL = 145, /// Scroll lock.
245     SELECT = 41, ///
246     SEPARATOR = 108, ///
247     SHIFT_KEY = 16, ///
248     SNAPSHOT = 44, /// Print screen.
249     SPACE = 32, ///
250     SPACEBAR = SPACE, // Extra.
251     SUBTRACT = 109, ///
252     TAB = 9, ///
253     UP = 38, /// Up arrow.
254     ZOOM = 251, ///
255     
256     BROWSER_BACK = 166, ///
257     BROWSER_FAVORITES = 171, /// ditto
258     BROWSER_FORWARD = 167, /// ditto
259     BROWSER_HOME = 172, /// ditto
260     BROWSER_REFRESH = 168, /// ditto
261     BROWSER_SEARCH = 170, /// ditto
262     BROWSER_STOP = 169, /// ditto
263     LAUNCH_APPLICATION1 = 182, ///
264     LAUNCH_APPLICATION2 = 183, /// ditto
265     LAUNCH_MAIL = 180, /// ditto
266     MEDIA_NEXT_TRACK = 176, ///
267     MEDIA_PLAY_PAUSE = 179, /// ditto
268     MEDIA_PREVIOUS_TRACK = 177, /// ditto
269     MEDIA_STOP = 178, /// ditto
270     OEM_BACKSLASH = 226, // OEM angle bracket or backslash.
271     OEM_CLOSE_BRACKETS = 221,
272     OEM_COMMA = 188,
273     OEM_MINUS = 189,
274     OEM_OPEN_BRACKETS = 219,
275     OEM_PERIOD = 190,
276     OEM_PIPE = 220,
277     OEM_PLUS = 187,
278     OEM_QUESTION = 191,
279     OEM_QUOTES = 222,
280     OEM_SEMICOLON = 186,
281     OEM_TILDE = 192,
282     SELECT_MEDIA = 181, ///
283     VOLUME_DOWN = 174, ///
284     VOLUME_MUTE = 173, /// ditto
285     VOLUME_UP = 175, /// ditto
286     +/
287    
288     /// Bit mask to extract key code from key value.
289     KEY_CODE = 0xFFFF,
290    
291     /// Bit mask to extract modifiers from key value.
292     MODIFIERS = 0xFFFF0000,
293 }
294
295
296 ///
297 enum MouseButtons: uint // docmain
298 {
299     /// No mouse buttons specified.
300     NONE =      0,
301    
302     LEFT = GdkModifierType.GDK_BUTTON1_MASK, ///
303     RIGHT = GdkModifierType.GDK_BUTTON3_MASK, /// ditto
304     MIDDLE = GdkModifierType.GDK_BUTTON2_MASK, /// ditto
305 }
306
307
308 ///
309 interface IButtonControl // docmain
310 {
311     ///
312     DialogResult dialogResult(); // getter
313     /// ditto
314     void dialogResult(DialogResult); // setter
315    
316     ///
317     void notifyDefault(bool); // True if default button.
318    
319     ///
320     void performClick(); // Raise click event.
321 }
322
323
324 ///
325 enum DialogResult: ubyte // docmain
326 {
327     NONE, ///
328    
329     ABORT, ///
330     CANCEL, ///
331     IGNORE, ///
332     NO, ///
333     OK, ///
334     RETRY, ///
335     YES, ///
336    
337     // Extra.
338     CLOSE,
339     HELP,
340 }
341
342
343 ///
344 enum SortOrder: ubyte
345 {
346     NONE, ///
347    
348     ASCENDING, ///
349     DESCENDING, /// ditto
350 }
351
352
353 ///
354 enum View: ubyte
355 {
356     LARGE_ICON, ///
357     SMALL_ICON, ///
358     LIST, ///
359     DETAILS, ///
360 }
361
362
363 ///
364 enum ItemBoundsPortion: ubyte
365 {
366     ENTIRE, ///
367     ICON, ///
368     ITEM_ONLY, /// Excludes other stuff like check boxes.
369     LABEL, /// Item's text.
370 }
371
372
373 ///
374 enum ItemActivation: ubyte
375 {
376     STANDARD, ///
377     ONE_CLICK, ///
378     TWO_CLICK, ///
379 }
380
381
382 ///
383 enum ColumnHeaderStyle: ubyte
384 {
385     CLICKABLE, ///
386     NONCLICKABLE, ///
387     NONE, /// No column header.
388 }
389
390
391 ///
392 enum BorderStyle: ubyte
393 {
394     NONE, ///
395    
396     FIXED_3D, ///
397     FIXED_SINGLE, /// ditto
398 }
399
400
401 ///
402 enum FlatStyle: ubyte
403 {
404     STANDARD, ///
405     FLAT, /// ditto
406     POPUP, /// ditto
407     SYSTEM, /// ditto
408 }
409
410
411 ///
412 enum Appearance: ubyte
413 {
414     NORMAL, ///
415     BUTTON, ///
416 }
417
418
419 ///
420 enum ContentAlignment: ubyte
421 {
422     TOP_LEFT, ///
423     BOTTOM_CENTER, ///
424     BOTTOM_LEFT, ///
425     BOTTOM_RIGHT, ///
426     MIDDLE_CENTER, ///
427     MIDDLE_LEFT, ///
428     MIDDLE_RIGHT, ///
429     TOP_CENTER, ///
430     TOP_RIGHT, ///
431 }
432
433
434 ///
435 enum CharacterCasing: ubyte
436 {
437     NORMAL, ///
438     LOWER, ///
439     UPPER, ///
440 }
441
442
443 ///
444 // Not flags.
445 enum ScrollBars: ubyte
446 {
447     NONE, ///
448    
449     HORIZONTAL, ///
450     VERTICAL, /// ditto
451     BOTH, /// ditto
452 }
453
454
455 ///
456 enum HorizontalAlignment: ubyte
457 {
458     LEFT, ///
459     RIGHT, /// ditto
460     CENTER, /// ditto
461 }
462
463
464 ///
465 enum DrawMode: ubyte
466 {
467     NORMAL, ///
468     OWNER_DRAW_FIXED, ///
469     OWNER_DRAW_VARIABLE, /// ditto
470 }
471
472
473 ///
474 enum DrawItemState: uint
475 {
476     NONE = 0, ///
477     SELECTED = 1, /// ditto
478     DISABLED = 2, /// ditto
479     CHECKED = 8, /// ditto
480     FOCUS = 0x10, /// ditto
481     DEFAULT = 0x20, /// ditto
482     HOT_LIGHT = 0x40, /// ditto
483     NO_ACCELERATOR = 0x80, /// ditto
484     INACTIVE = 0x100, /// ditto
485     NO_FOCUS_RECT = 0x200, /// ditto
486     COMBO_BOX_EDIT = 0x1000, /// ditto
487 }
488
489
490 ///
491 enum RightToLeft: ubyte
492 {
493     INHERIT = 2, ///
494     YES = 1, /// ditto
495     NO = 0, /// ditto
496 }
497
498
499 ///
500 class PaintEventArgs: EventArgs
501 {
502     ///
503     this(Graphics graphics, Rect clipRect)
504     {
505         g = graphics;
506         cr = clipRect;
507     }
508    
509    
510     ///
511     final Graphics graphics() // getter
512     {
513         return g;
514     }
515    
516    
517     ///
518     final Rect clipRectangle() // getter
519     {
520         return cr;
521     }
522    
523    
524     private:
525     Graphics g;
526     Rect cr;
527 }
528
529
530 ///
531 class CancelEventArgs: EventArgs
532 {
533     ///
534     // Initialize cancel to false.
535     this()
536     {
537         cncl = false;
538     }
539    
540     /// ditto
541     this(bool cancel)
542     {
543         cncl = cancel;
544     }
545    
546    
547     ///
548     final void cancel(bool byes) // setter
549     {
550         cncl = byes;
551     }
552    
553     /// ditto
554     final bool cancel() // getter
555     {
556         return cncl;
557     }
558    
559    
560     private:
561     bool cncl;
562 }
563
564
565 ///
566 class KeyEventArgs: EventArgs
567 {
568     ///
569     this(Keys keys)
570     {
571         ks = keys;
572     }
573    
574    
575     ///
576     final bool alt() // getter
577     {
578         return (ks & Keys.ALT) != 0;
579     }
580    
581    
582     ///
583     final bool control() // getter
584     {
585         return (ks & Keys.CONTROL) != 0;
586     }
587    
588    
589     ///
590     final void handled(bool byes) // setter
591     {
592         hand = byes;
593     }
594    
595     ///
596     final bool handled() // getter
597     {
598         return hand;
599     }
600    
601    
602     ///
603     final Keys keyCode() // getter
604     {
605         return ks & Keys.KEY_CODE;
606     }
607    
608    
609     ///
610     final Keys keyData() // getter
611     {
612         return ks;
613     }
614    
615    
616     ///
617     // -keyData- as an int.
618     final int keyValue() // getter
619     {
620         return cast(int)ks;
621     }
622    
623    
624     ///
625     final Keys modifiers() // getter
626     {
627         return ks & Keys.MODIFIERS;
628     }
629    
630    
631     ///
632     final bool shift() // getter
633     {
634         return (ks & Keys.SHIFT) != 0;
635     }
636    
637    
638     private:
639     Keys ks;
640     bool hand = false;
641 }
642
643
644 ///
645 class MouseEventArgs: EventArgs
646 {
647     ///
648     // -delta- is mouse wheel rotations.
649     this(MouseButtons button, int clicks, int x, int y, int delta)
650     {
651         btn = button;
652         clks = clicks;
653         _x = x;
654         _y = y;
655         dlt = delta;
656     }
657    
658    
659     ///
660     final MouseButtons button() // getter
661     {
662         return btn;
663     }
664    
665    
666     ///
667     final int clicks() // getter
668     {
669         return clks;
670     }
671    
672    
673     ///
674     final int delta() // getter
675     {
676         return dlt;
677     }
678    
679    
680     ///
681     final int x() // getter
682     {
683         return _x;
684     }
685    
686    
687     ///
688     final int y() // getter
689     {
690         return _y;
691     }
692    
693    
694     private:
695     MouseButtons btn;
696     int clks;
697     int _x, _y;
698     int dlt;
699 }
700
701
702 ///
703 class LabelEditEventArgs: EventArgs
704 {
705     ///
706     this(int index)
707     {
708        
709     }
710    
711     /// ditto
712     this(int index, char[] labelText)
713     {
714         this.idx = index;
715         this.ltxt = labelText;
716     }
717    
718    
719     ///
720     final void cancelEdit(bool byes) // setter
721     {
722         cancl = byes;
723     }
724    
725     /// ditto
726     final bool cancelEdit() // getter
727     {
728         return cancl;
729     }
730    
731    
732     ///
733     // The text of the label's edit.
734     final char[] label() // getter
735     {
736         return ltxt;
737     }
738    
739    
740     ///
741     // Gets the item's index.
742     final int item() // getter
743     {
744         return idx;
745     }
746    
747    
748     private:
749     int idx;
750     char[] ltxt;
751     bool cancl = false;
752 }
753
754
755 ///
756 class ColumnClickEventArgs: EventArgs
757 {
758     ///
759     this(int col)
760     {
761         this.col = col;
762     }
763    
764    
765     ///
766     final int column() // getter
767     {
768         return col;
769     }
770    
771    
772     private:
773     int col;
774 }
775
776
777 ///
778 class DrawItemEventArgs: EventArgs
779 {
780     ///
781     this(Graphics g, Font f, Rect r, int i, DrawItemState dis)
782     {
783         this(g, f, r, i , dis, Color.empty, Color.empty);
784     }
785    
786     /// ditto
787     this(Graphics g, Font f, Rect r, int i, DrawItemState dis, Color fc, Color bc)
788     {
789         gpx = g;
790         fnt = f;
791         rect = r;
792         idx = i;
793         distate = dis;
794         fcolor = fc;
795         bcolor = bc;
796     }
797    
798    
799     ///
800     final Color backColor() // getter
801     {
802         return bcolor;
803     }
804    
805    
806     ///
807     final Rect bounds() // getter
808     {
809         return rect;
810     }
811    
812    
813     ///
814     final Font font() // getter
815     {
816         return fnt;
817     }
818    
819    
820     ///
821     final Color foreColor() // getter
822     {
823         return fcolor;
824     }
825    
826    
827     ///
828     final Graphics graphics() // getter
829     {
830         return gpx;
831     }
832    
833    
834     ///
835     final int index() // getter
836     {
837         return idx;
838     }
839    
840    
841     ///
842     final DrawItemState state() // getter
843     {
844         return distate;
845     }
846    
847    
848     ///
849     void drawBackground()
850     {
851         gpx.fillRectangle(bcolor, rect);
852     }
853    
854    
855     ///
856     void drawFocusRectangle()
857     {
858         if(distate & DrawItemState.FOCUS)
859         {
860             /+ // To-do: ...
861             RECT _rect;
862             rect.getRect(&_rect);
863             DrawFocusRect(gpx.handle, &_rect);
864             +/
865         }
866     }
867    
868    
869     private:
870     Graphics gpx;
871     Font fnt; // Suggestion; the parent's font.
872     Rect rect;
873     int idx;
874     DrawItemState distate;
875     Color fcolor, bcolor; // Suggestion; depends on item state.
876 }
877
878
879 ///
880 class MeasureItemEventArgs: EventArgs
881 {
882     ///
883     this(Graphics g, int index, int itemHeight)
884     {
885         gpx = g;
886         idx = index;
887         iheight = itemHeight;
888     }
889    
890     /// ditto
891     this(Graphics g, int index)
892     {
893         this(g, index, 0);
894     }
895    
896    
897     ///
898     final Graphics graphics() // getter
899     {
900         return gpx;
901     }
902    
903    
904     ///
905     final int index() // getter
906     {
907         return idx;
908     }
909    
910    
911     ///
912     final void itemHeight(int height) // setter
913     {
914         iheight = height;
915     }
916    
917     /// ditto
918     final int itemHeight() // getter
919     {
920         return iheight;
921     }
922    
923    
924     ///
925     final void itemWidth(int width) // setter
926     {
927         iwidth = width;
928     }
929    
930     /// ditto
931     final int itemWidth() // getter
932     {
933         return iwidth;
934     }
935    
936    
937     private:
938     Graphics gpx;
939     int idx, iheight, iwidth = 0;
940 }
941
942
943 /+
944 ///
945 class Cursor // docmain
946 {
947     private static Cursor _cur;
948     
949     
950     /+
951     // Used internally.
952     this(HCURSOR hcur, bool owned = true)
953     {
954         this.hcur = hcur;
955         this.owned = owned;
956     }
957     +/
958     
959     
960     ~this()
961     {
962         if(owned)
963             dispose();
964     }
965     
966     
967     ///
968     void dispose()
969     {
970         //DestroyCursor(hcur);
971         // To-do: ...
972         hcur = HCURSOR.init;
973     }
974     
975     
976     ///
977     static void current(Cursor cur) // setter
978     {
979         // Keep a reference so that it doesn't get garbage collected until set again.
980         _cur = cur;
981         
982         //SetCursor(cur ? cur.hcur : HCURSOR.init);
983         // To-do: ...
984     }
985     
986     /// ditto
987     static Cursor current() // getter
988     {
989         /+
990         HCURSOR hcur = GetCursor();
991         return hcur ? new Cursor(hcur, false) : null;
992         +/
993         // To-do: ...
994     }
995     
996     
997     ///
998     static void clip(Rect r) // setter
999     {
1000         RECT rect;
1001         r.getRect(&rect);
1002         //ClipCursor(&rect);
1003         // To-do: ...
1004     }
1005     
1006     /// ditto
1007     static Rect clip() // getter
1008     {
1009         RECT rect;
1010         //GetClipCursor(&rect);
1011         // To-do: ...
1012         return Rect(&rect);
1013     }
1014     
1015     
1016     ///
1017     final HCURSOR handle() // getter
1018     {
1019         return hcur;
1020     }
1021     
1022     
1023     ///
1024     // Uses the actual size.
1025     final void draw(Graphics g, Point pt)
1026     {
1027         //DrawIconEx(g.handle, pt.x, pt.y, hcur, 0, 0, 0, HBRUSH.init, DI_NORMAL);
1028         // To-do: ...
1029     }
1030     
1031     
1032     ///
1033     final void drawStretched(Graphics g, Rect r)
1034     {
1035         /+
1036         // DrawIconEx operates differently if the width or height is zero
1037         // so bail out if zero and pretend the zero size cursor was drawn.
1038         int width = r.width;
1039         if(!width)
1040             return;
1041         int height = r.height;
1042         if(!height)
1043             return;
1044         
1045         DrawIconEx(g.handle, r.x, r.y, hcur, width, height, 0, HBRUSH.init, DI_NORMAL);
1046         +/
1047         // To-do: ...
1048     }
1049     
1050     
1051     override int opEquals(Object o)
1052     {
1053         Cursor cur = cast(Cursor)o;
1054         if(!cur)
1055             return 0; // Not equal.
1056         return opEquals(cur);
1057     }
1058     
1059     
1060     int opEquals(Cursor cur)
1061     {
1062         return hcur == cur.hcur;
1063     }
1064     
1065     
1066     /// Show/hide the current mouse cursor; reference counted.
1067     // show/hide are ref counted.
1068     static void hide()
1069     {
1070         //ShowCursor(false);
1071         // To-do: ...
1072     }
1073     
1074     /// ditto
1075     // show/hide are ref counted.
1076     static void show()
1077     {
1078         //ShowCursor(true);
1079         // To-do: ...
1080     }
1081     
1082     
1083     /// The position of the current mouse cursor.
1084     static void position(Point pt) // setter
1085     {
1086         //SetCursorPos(pt.x, pt.y);
1087         // To-do: ...
1088     }
1089     
1090     /// ditto
1091     static Point position() // getter
1092     {
1093         Point pt;
1094         //GetCursorPos(&pt.point);
1095         // To-do: ...
1096         return pt;
1097     }
1098     
1099     
1100     private:
1101     //HCURSOR hcur;
1102     bool owned = true;
1103 }
1104 +/
1105
1106
1107 /+
1108 ///
1109 class Cursors // docmain
1110 {
1111     private this() {}
1112     
1113     
1114     static:
1115     
1116     /+ // To-do: ...
1117     ///
1118     Cursor appStarting() // getter
1119     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_APPSTARTING), false); }
1120     
1121     ///
1122     Cursor arrow() // getter
1123     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_ARROW), false); }
1124     
1125     ///
1126     Cursor cross() // getter
1127     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_CROSS), false); }
1128     
1129     ///
1130     //Cursor default() // getter
1131     Cursor defaultCursor() // getter
1132     { return arrow; }
1133     
1134     ///
1135     Cursor hand() // getter
1136     {
1137         version(SUPPORTS_HAND_CURSOR) // Windows 98+
1138         {
1139             return new Cursor(LoadCursorA(HINSTANCE.init, IDC_HAND), false);
1140         }
1141         else
1142         {
1143             static HCURSOR hcurHand;
1144             
1145             if(!hcurHand)
1146             {
1147                 hcurHand = LoadCursorA(HINSTANCE.init, IDC_HAND);
1148                 if(!hcurHand) // Must be Windows 95, so load the cursor from winhlp32.exe.
1149                 {
1150                     UINT len;
1151                     char[MAX_PATH] winhlppath = void;
1152                     
1153                     len = GetWindowsDirectoryA(winhlppath.ptr, winhlppath.length - 16);
1154                     if(!len || len > winhlppath.length - 16)
1155                     {
1156                         load_failed:
1157                         return arrow; // Just fall back to a normal arrow.
1158                     }
1159                     strcpy(winhlppath.ptr + len, "\\winhlp32.exe");
1160                     
1161                     HINSTANCE hinstWinhlp;
1162                     hinstWinhlp = LoadLibraryExA(winhlppath.ptr, HANDLE.init, LOAD_LIBRARY_AS_DATAFILE);
1163                     if(!hinstWinhlp)
1164                         goto load_failed;
1165                     
1166                     HCURSOR hcur;
1167                     hcur = LoadCursorA(hinstWinhlp, cast(char*)106);
1168                     if(!hcur) // No such cursor resource.
1169                     {
1170                         FreeLibrary(hinstWinhlp);
1171                         goto load_failed;
1172                     }
1173                     hcurHand = CopyCursor(hcur);
1174                     if(!hcurHand)
1175                     {
1176                         FreeLibrary(hinstWinhlp);
1177                         //throw new DflException("Unable to copy cursor resource");
1178                         goto load_failed;
1179                     }
1180                     
1181                     FreeLibrary(hinstWinhlp);
1182                 }
1183             }
1184             
1185             assert(hcurHand);
1186             // Copy the cursor and own it here so that it's safe to dispose it.
1187             return new Cursor(CopyCursor(hcurHand));
1188         }
1189     }
1190     
1191     ///
1192     Cursor help() // getter
1193     {
1194         HCURSOR hcur;
1195         hcur = LoadCursorA(HINSTANCE.init, IDC_HELP);
1196         if(!hcur) // IDC_HELP might not be supported on Windows 95, so fall back to a normal arrow.
1197             return arrow;
1198         return new Cursor(hcur);
1199     }
1200     
1201     ///
1202     Cursor hSplit() // getter
1203     {
1204         // ...
1205         return sizeNS;
1206     }
1207     
1208     /// ditto
1209     Cursor vSplit() // getter
1210     {
1211         // ...
1212         return sizeWE;
1213     }
1214     
1215     
1216     ///
1217     Cursor iBeam() // getter
1218     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_IBEAM), false); }
1219     
1220     ///
1221     Cursor no() // getter
1222     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_NO), false); }
1223     
1224     
1225     ///
1226     Cursor sizeAll() // getter
1227     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_SIZEALL), false); }
1228     
1229     /// ditto
1230     Cursor sizeNESW() // getter
1231     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_SIZENESW), false); }
1232     
1233     /// ditto
1234     Cursor sizeNS() // getter
1235     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_SIZENS), false); }
1236     
1237     /// ditto
1238     Cursor sizeNWSE() // getter
1239     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_SIZENWSE), false); }
1240     
1241     /// ditto
1242     Cursor sizeWE() // getter
1243     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_SIZEWE), false); }
1244     
1245     
1246     /+
1247     ///
1248     // Insertion point.
1249     Cursor upArrow() // getter
1250     {
1251         // ...
1252     }
1253     +/
1254     
1255     ///
1256     Cursor waitCursor() // getter
1257     { return new Cursor(LoadCursorA(HINSTANCE.init, IDC_WAIT), false); }
1258     +/
1259 }
1260 +/
Note: See TracBrowser for help on using the browser.