Mercurial > dwindows
annotate dw.hpp @ 2882:99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
use traditional function pointers instead. Also added inital menu support
although it is incomplete as of this commit.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 22 Dec 2022 13:59:46 +0000 |
parents | 2ba0959eb3cf |
children | 06e475feaac0 |
rev | line source |
---|---|
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1 /* Dynamic Windows C++ Language Bindings |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2 * Copyright 2022 Brian Smith |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
3 * Recommends a C++11 compatible compiler. |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
4 */ |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6 #ifndef _HPP_DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 #define _HPP_DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8 #include <dw.h> |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
9 |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
10 // Attempt to support compilers without nullptr type literal |
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
11 #if __cplusplus >= 201103L |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
12 #define DW_CPP11 |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
13 #define DW_NULL nullptr |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
14 #include <functional> |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
15 #else |
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
16 #define DW_NULL NULL |
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
17 #endif |
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
18 |
2873
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
19 // Attempt to allow compilation on GCC older than 4.7 |
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
20 #if defined(__GNUC__) && (__GNuC__ < 5 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)) |
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
21 #define override |
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
22 #endif |
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
23 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
24 namespace DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
25 { |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
26 |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
27 // Forward declare these so they can be referenced |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
28 class Render; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
29 class Pixmap; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
30 class MenuItem; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
31 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
32 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
33 // Base handle class which allows opaque access to |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
34 // The base system handles |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
35 class Handle |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
36 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
37 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
38 void *handle; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
39 void SetHandle(void *newhandle) { handle = newhandle; } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
40 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
41 void *GetHandle() { return handle; } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
42 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
43 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
44 // Widget class allows packing and style |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
45 class Widget : public Handle |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
46 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
47 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
48 void SetHWND(HWND newhwnd) { |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
49 hwnd = newhwnd; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
50 SetHandle(reinterpret_cast<void *>(newhwnd)); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
51 // Save the C++ class pointer in the window data for later |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
52 dw_window_set_data(hwnd, "_dw_classptr", this); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
53 } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
54 HWND hwnd; |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
55 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
56 HWND GetHWND() { return hwnd; } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
57 int Unpack() { return dw_box_unpack(hwnd); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
58 void SetStyle(unsigned long style, unsigned long mask) { dw_window_set_style(hwnd, style, mask); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
59 void SetTooltip(char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
60 int SetColor(unsigned long fore, unsigned long back) { return dw_window_set_color(hwnd, fore, back); } |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
61 void SetData(const char *dataname, void *data) { dw_window_set_data(hwnd, dataname, data); } |
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
62 void *GetData(const char *dataname) { return dw_window_get_data(hwnd, dataname); } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
63 void SetPointer(int cursortype) { dw_window_set_pointer(hwnd, cursortype); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
64 Widget *FromID(int id) { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
65 HWND child = dw_window_from_id(hwnd, id); |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
66 if(child) { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
67 return reinterpret_cast<Widget *>(dw_window_get_data(child, "_dw_classptr")); |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
68 } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
69 return DW_NULL; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
70 } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
71 void GetPreferredSize(int *width, int *height) { dw_window_get_preferred_size(hwnd, width, height); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
72 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
73 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
74 // Box class is a packable object |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
75 class Boxes : virtual public Widget |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
76 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
77 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
78 // User functions |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
79 void PackStart(Widget *item, int width, int height, int hsize, int vsize, int pad) { |
2871
4b7c4cd7a11d
OS2: Fix building the C++ bindings on OS/2 with GCC.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2870
diff
changeset
|
80 dw_box_pack_start(hwnd, item ? item->GetHWND() : DW_NOHWND, width, height, hsize, vsize, pad); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
81 void PackEnd(Widget *item, int width, int height, int hsize, int vsize, int pad) { |
2871
4b7c4cd7a11d
OS2: Fix building the C++ bindings on OS/2 with GCC.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2870
diff
changeset
|
82 dw_box_pack_end(hwnd, item ? item->GetHWND() : DW_NOHWND, width, height, hsize, vsize, pad); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
83 void PackAtIndex(Widget *item, int index, int width, int height, int hsize, int vsize, int pad) { |
2871
4b7c4cd7a11d
OS2: Fix building the C++ bindings on OS/2 with GCC.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2870
diff
changeset
|
84 dw_box_pack_at_index(hwnd, item ? item->GetHWND() : DW_NOHWND, index, width, height, hsize, vsize, pad); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
85 Widget *UnpackAtIndex(int index) { HWND widget = dw_box_unpack_at_index(hwnd, index); |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
86 void *classptr = widget ? dw_window_get_data(widget, "_dw_classptr") : DW_NULL; |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
87 return reinterpret_cast<Widget *>(classptr); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
88 } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
89 }; |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
90 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
91 class Box : public Boxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
92 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
93 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
94 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
95 Box(int type, int pad) { SetHWND(dw_box_new(type, pad)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
96 Box(int type) { SetHWND(dw_box_new(type, 0)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
97 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
98 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
99 // Special scrollable box |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
100 class ScrollBox : public Boxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
101 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
102 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
103 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
104 ScrollBox(int type, int pad) { SetHWND(dw_scrollbox_new(type, pad)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
105 ScrollBox(int type) { SetHWND(dw_scrollbox_new(type, 0)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
106 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
107 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
108 int GetRange(int orient) { return dw_scrollbox_get_range(hwnd, orient); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
109 int GetPos(int orient) { return dw_scrollbox_get_pos(hwnd, orient); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
110 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
111 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
112 // TODO: Find a way to implement this cross platform... |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
113 // That way we can skip adding unused signal handlers |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
114 #define IsOverridden(a, b) true |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
115 |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
116 // Base class for several types of widgets including buttons and menu items |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
117 class Clickable : virtual public Widget |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
118 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
119 private: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
120 bool ClickedConnected; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
121 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
122 std::function<int()> _ConnectClicked; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
123 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
124 int (*_ConnectClicked)(); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
125 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
126 static int _OnClicked(HWND window, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
127 if(reinterpret_cast<Clickable *>(data)->_ConnectClicked) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
128 return reinterpret_cast<Clickable *>(data)->_ConnectClicked(); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
129 return reinterpret_cast<Clickable *>(data)->OnClicked(); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
130 protected: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
131 void Setup() { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
132 if(IsOverridden(Clickable::OnClicked, this)) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
133 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
134 ClickedConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
135 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
136 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
137 // Our signal handler functions to be overriden... |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
138 // If they are not overridden and an event is generated, remove the unused handler |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
139 virtual int OnClicked() { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
140 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_CLICKED); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
141 ClickedConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
142 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
143 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
144 public: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
145 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
146 void ConnectClicked(std::function<int()> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
147 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
148 void ConnectClicked(int (*userfunc)()) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
149 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
150 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
151 _ConnectClicked = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
152 if(!ClickedConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
153 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
154 ClickedConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
155 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
156 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
157 }; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
158 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
159 class Menus : public Handle |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
160 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
161 protected: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
162 void SetHMENUI(HMENUI newmenu) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
163 menu = newmenu; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
164 SetHandle(reinterpret_cast<void *>(newmenu)); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
165 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
166 HMENUI menu; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
167 public: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
168 // User functions |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
169 HMENUI GetHMENUI() { return menu; } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
170 }; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
171 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
172 class Menu : public Menus |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
173 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
174 public: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
175 // Constructors |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
176 Menu(HWND location) { SetHMENUI(dw_menubar_new(location)); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
177 Menu(unsigned long id) { SetHMENUI(dw_menu_new(id)); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
178 Menu() { SetHMENUI(dw_menu_new(0)); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
179 }; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
180 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
181 class MenuItem : public Clickable |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
182 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
183 public: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
184 // Constructors |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
185 MenuItem(Menus *menu, const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
186 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, id, flags, end, check, submenu ? submenu->GetHMENUI() : DW_NULL)); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
187 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
188 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
189 // User functions |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
190 void SetState(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
191 void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
192 }; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
193 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
194 // Top-level window class is packable |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
195 class Window : public Boxes |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
196 { |
2865
fd32dce7fecd
Initial signal handler support for the C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2861
diff
changeset
|
197 private: |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
198 bool DeleteConnected, ConfigureConnected; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
199 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
200 std::function<int()> _ConnectDelete; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
201 std::function<int(int, int)> _ConnectConfigure; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
202 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
203 int (*_ConnectDelete)(); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
204 int (*_ConnectConfigure)(int width, int height); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
205 #endif |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
206 void Setup() { |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
207 if(IsOverridden(Window::OnDelete, this)) { |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
208 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
209 DeleteConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
210 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
211 if(IsOverridden(Window::OnConfigure, this)) { |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
212 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
213 ConfigureConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
214 } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
215 } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
216 static int _OnDelete(HWND window, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
217 if(reinterpret_cast<Window *>(data)->_ConnectDelete) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
218 return reinterpret_cast<Window *>(data)->_ConnectDelete(); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
219 return reinterpret_cast<Window *>(data)->OnDelete(); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
220 static int _OnConfigure(HWND window, int width, int height, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
221 if(reinterpret_cast<Window *>(data)->_ConnectConfigure) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
222 return reinterpret_cast<Window *>(data)->_ConnectConfigure(width, height); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
223 return reinterpret_cast<Window *>(data)->OnConfigure(width, height); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
224 Menu *menu; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
225 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
226 // Constructors |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
227 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
228 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
229 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); Setup(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
230 Window(const char *title) { SetHWND(dw_window_new(HWND_DESKTOP, title, DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
2865
fd32dce7fecd
Initial signal handler support for the C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2861
diff
changeset
|
231 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
232 Window() { SetHWND(dw_window_new(HWND_DESKTOP, "", DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
2865
fd32dce7fecd
Initial signal handler support for the C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2861
diff
changeset
|
233 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
234 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
235 // User functions |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
236 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
237 char *GetText() { return dw_window_get_text(hwnd); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
238 void SetSize(unsigned long width, unsigned long height) { dw_window_set_size(hwnd, width, height); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
239 int Show() { return dw_window_show(hwnd); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
240 int Hide() { return dw_window_hide(hwnd); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
241 void SetGravity(int horz, int vert) { dw_window_set_gravity(hwnd, horz, vert); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
242 int Minimize() { return dw_window_minimize(hwnd); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
243 int Raise() { return dw_window_raise(hwnd); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
244 int Lower() { return dw_window_lower(hwnd); } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
245 void Redraw() { dw_window_redraw(hwnd); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
246 void Default(Widget *defaultitem) { if(defaultitem) dw_window_default(hwnd, defaultitem->GetHWND()); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
247 void SetIcon(HICN icon) { dw_window_set_icon(hwnd, icon); } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
248 Menu *MenuBar() { if(menu == DW_NULL) menu = new Menu(hwnd); return menu; } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
249 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
250 void ConnectDelete(std::function<int()> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
251 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
252 void ConnectDelete(int (*userfunc)()) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
253 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
254 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
255 _ConnectDelete = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
256 if(!DeleteConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
257 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
258 DeleteConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
259 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
260 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
261 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
262 void ConnectConfigure(std::function<int(int, int)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
263 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
264 void ConnectConfigure(int (*userfunc)(int, int)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
265 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
266 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
267 _ConnectConfigure = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
268 if(!ConfigureConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
269 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
270 ConfigureConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
271 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
272 } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
273 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
274 // Our signal handler functions to be overriden... |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
275 // If they are not overridden and an event is generated, remove the unused handler |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
276 virtual int OnDelete() { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
277 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_DELETE); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
278 DeleteConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
279 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
280 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
281 virtual int OnConfigure(int width, int height) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
282 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_CONFIGURE); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
283 ConfigureConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
284 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
285 }; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
286 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
287 |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
288 // Class for focusable widgets |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
289 class Focusable : virtual public Widget |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
290 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
291 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
292 void Enable() { dw_window_enable(hwnd); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
293 void Disable() { dw_window_disable(hwnd); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
294 void SetFocus() { dw_window_set_focus(hwnd); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
295 }; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
296 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
297 // Text based button |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
298 class TextButton : public Clickable, public Focusable |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
299 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
300 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
301 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
302 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
303 char *GetText() { return dw_window_get_text(hwnd); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
304 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
305 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
306 class Button : public TextButton |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
307 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
308 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
309 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
310 Button(const char *text, unsigned long id) { SetHWND(dw_button_new(text, id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
311 Button(unsigned long id) { SetHWND(dw_button_new("", id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
312 Button(const char *text) { SetHWND(dw_button_new(text, 0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
313 Button() { SetHWND(dw_button_new("", 0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
314 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
315 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
316 // Image based button |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
317 class BitmapButton : public Clickable, public Focusable |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
318 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
319 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
320 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
321 BitmapButton(const char *text, unsigned long id) { SetHWND(dw_bitmapbutton_new(text, id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
322 BitmapButton(unsigned long id) { SetHWND(dw_bitmapbutton_new("", id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
323 BitmapButton(const char *text, unsigned long id, const char *file) { SetHWND(dw_bitmapbutton_new_from_file(text, id, file)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
324 BitmapButton(const char *text, const char *file) { SetHWND(dw_bitmapbutton_new_from_file(text, 0, file)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
325 BitmapButton(const char *text, unsigned long id, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, id, data, len)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
326 BitmapButton(const char *text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, 0, data, len)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
327 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
328 |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
329 class CheckBoxes : virtual public TextButton |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
330 { |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
331 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
332 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
333 void Set(int value) { dw_checkbox_set(hwnd, value); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
334 int Get() { return dw_checkbox_get(hwnd); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
335 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
336 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
337 class CheckBox : public CheckBoxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
338 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
339 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
340 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
341 CheckBox(const char *text, unsigned long id) { SetHWND(dw_checkbox_new(text, id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
342 CheckBox(unsigned long id) { SetHWND(dw_checkbox_new("", id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
343 CheckBox(const char *text) { SetHWND(dw_checkbox_new(text, 0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
344 CheckBox() { SetHWND(dw_checkbox_new("", 0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
345 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
346 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
347 class RadioButton : public CheckBoxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
348 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
349 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
350 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
351 RadioButton(const char *text, unsigned long id) { SetHWND(dw_radiobutton_new(text, id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
352 RadioButton(unsigned long id) { SetHWND(dw_radiobutton_new("", id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
353 RadioButton(const char *text) { SetHWND(dw_radiobutton_new(text, 0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
354 RadioButton() { SetHWND(dw_radiobutton_new("", 0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
355 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
356 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
357 // Class for handling static text widget |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
358 class TextWidget : virtual public Widget |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
359 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
360 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
361 // User functions |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
362 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
363 char *GetText() { return dw_window_get_text(hwnd); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
364 int SetFont(const char *font) { return dw_window_set_font(hwnd, font); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
365 char *GetFont() { return dw_window_get_font(hwnd); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
366 }; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
367 |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
368 // Class for handling static text widget |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
369 class Text : public TextWidget |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
370 { |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
371 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
372 // Constructors |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
373 Text(const char *text, unsigned long id) { SetHWND(dw_text_new(text, id)); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
374 Text(const char *text) { SetHWND(dw_text_new(text, 0)); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
375 Text(unsigned long id) { SetHWND(dw_text_new("", id)); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
376 Text() { SetHWND(dw_text_new("", 0)); } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
377 }; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
378 |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
379 class StatusText : public TextWidget |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
380 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
381 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
382 // Constructors |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
383 StatusText(const char *text, unsigned long id) { SetHWND(dw_status_text_new(text, id)); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
384 StatusText(const char *text) { SetHWND(dw_status_text_new(text, 0)); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
385 StatusText(unsigned long id) { SetHWND(dw_status_text_new("", id)); } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
386 StatusText() { SetHWND(dw_status_text_new("", 0)); } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
387 }; |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
388 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
389 // Class for handing static image widget |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
390 class Bitmap : public Widget |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
391 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
392 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
393 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
394 Bitmap(const char *data, int len) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap_from_data(hwnd, 0, data, len); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
395 Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
396 Bitmap(unsigned long id) { SetHWND(dw_bitmap_new(id)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
397 Bitmap() { SetHWND(dw_bitmap_new(0)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
398 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
399 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
400 void Set(unsigned long id) { dw_window_set_bitmap(hwnd, id, DW_NULL); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
401 void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
402 void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
403 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
404 |
2879
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
405 // Class for handing calendar widget |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
406 class Calendar : public Widget |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
407 { |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
408 public: |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
409 // Constructors |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
410 Calendar(unsigned long id) { SetHWND(dw_calendar_new(id)); } |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
411 Calendar() { SetHWND(dw_calendar_new(0)); } |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
412 |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
413 // User functions |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
414 void GetData(unsigned int *year, unsigned int *month, unsigned int *day) { dw_calendar_get_date(hwnd, year, month, day); } |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
415 void SetData(unsigned int year, unsigned int month, unsigned int day) { dw_calendar_set_date(hwnd, year, month, day); } |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
416 }; |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
417 |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
418 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
419 // Abstract class that defines drawing, either to screen or picture (pixmap) |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
420 class Drawable |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
421 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
422 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
423 virtual void DrawPoint(int x, int y) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
424 virtual void DrawLine(int x1, int y1, int x2, int y2) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
425 virtual void DrawPolygon(int flags, int npoints, int x[], int y[]) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
426 virtual void DrawRect(int fill, int x, int y, int width, int height) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
427 virtual void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
428 virtual void DrawText(int x, int y, const char *text) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
429 virtual int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
430 virtual int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
431 virtual void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
432 virtual void BitBlt(int xdest, int ydest, int width, int height, Pixmap *srcp, int xsrc, int ysrc) = 0; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
433 void SetColor(unsigned long fore, unsigned long back) { dw_color_foreground_set(fore); dw_color_background_set(back); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
434 void SetBackgroundColor(unsigned long back) { dw_color_background_set(back); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
435 void SetForegroundColor(unsigned long fore) { dw_color_foreground_set(fore); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
436 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
437 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
438 class Render : public Drawable, public Widget |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
439 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
440 private: |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
441 bool ExposeConnected, ConfigureConnected; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
442 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
443 std::function<int(DWExpose *)> _ConnectExpose; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
444 std::function<int(int, int)> _ConnectConfigure; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
445 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
446 int (*_ConnectExpose)(DWExpose *); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
447 int (*_ConnectConfigure)(int width, int height); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
448 #endif |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
449 void Setup() { |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
450 if(IsOverridden(Render::OnExpose, this)) { |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
451 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
452 ExposeConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
453 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
454 if(IsOverridden(Render::OnConfigure, this)) { |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
455 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
456 ConfigureConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
457 } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
458 } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
459 static int _OnExpose(HWND window, DWExpose *exp, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
460 if(reinterpret_cast<Render *>(data)->_ConnectExpose) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
461 return reinterpret_cast<Render *>(data)->_ConnectExpose(exp); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
462 return reinterpret_cast<Render *>(data)->OnExpose(exp); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
463 static int _OnConfigure(HWND window, int width, int height, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
464 if(reinterpret_cast<Render *>(data)->_ConnectConfigure) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
465 return reinterpret_cast<Render *>(data)->_ConnectConfigure(width, height); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
466 return reinterpret_cast<Render *>(data)->OnConfigure(width, height); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
467 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
468 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
469 Render(unsigned long id) { SetHWND(dw_render_new(id)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
470 Render() { SetHWND(dw_render_new(0)); Setup(); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
471 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
472 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
473 void DrawPoint(int x, int y) { dw_draw_point(hwnd, DW_NULL, x, y); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
474 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(hwnd, DW_NULL, x1, y1, x2, y2); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
475 void DrawPolygon(int flags, int npoints, int x[], int y[]) { dw_draw_polygon(hwnd, DW_NULL, flags, npoints, x, y); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
476 void DrawRect(int fill, int x, int y, int width, int height) { dw_draw_rect(hwnd, DW_NULL, fill, x, y, width, height); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
477 void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) { dw_draw_arc(hwnd, DW_NULL, flags, xorigin, yorigin, x1, y1, x2, y2); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
478 void DrawText(int x, int y, const char *text) { dw_draw_text(hwnd, DW_NULL, x, y, text); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
479 int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
480 return dw_pixmap_stretch_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc, srcwidth, srcheight); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
481 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
482 int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
483 void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
484 return dw_pixmap_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
485 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
486 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
487 int SetFont(const char *fontname) { return dw_window_set_font(hwnd, fontname); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
488 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(hwnd, DW_NULL, text, width, height); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
489 char *GetFont() { return dw_window_get_font(hwnd); } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
490 void Redraw() { dw_render_redraw(hwnd); } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
491 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
492 void ConnectExpose(std::function<int(DWExpose *)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
493 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
494 void ConnectExpose(int (*userfunc)(DWExpose *)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
495 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
496 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
497 _ConnectExpose = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
498 if(!ExposeConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
499 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
500 ExposeConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
501 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
502 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
503 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
504 void ConnectConfigure(std::function<int(int, int)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
505 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
506 void ConnectConfigure(int (*userfunc)(int, int)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
507 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
508 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
509 _ConnectConfigure = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
510 if(!ConfigureConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
511 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
512 ConfigureConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
513 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
514 } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
515 protected: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
516 // Our signal handler functions to be overriden... |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
517 // If they are not overridden and an event is generated, remove the unused handler |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
518 virtual int OnExpose(DWExpose *exp) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
519 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_EXPOSE); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
520 ExposeConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
521 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
522 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
523 virtual int OnConfigure(int width, int height) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
524 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_CONFIGURE); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
525 ConfigureConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
526 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
527 }; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
528 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
529 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
530 class Pixmap : public Drawable, public Handle |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
531 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
532 private: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
533 void SetHPIXMAP(HPIXMAP newpixmap) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
534 hpixmap = newpixmap; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
535 SetHandle(reinterpret_cast<void *>(newpixmap)); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
536 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
537 HPIXMAP hpixmap; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
538 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
539 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
540 Pixmap(HWND window, unsigned long width, unsigned long height, int depth) { SetHPIXMAP(dw_pixmap_new(window, width, height, depth)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
541 Pixmap(HWND window, unsigned long width, unsigned long height) { SetHPIXMAP(dw_pixmap_new(window, width, height, 32)); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
542 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
543 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
544 HPIXMAP GetHPIXMAP() { return hpixmap; } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
545 void DrawPoint(int x, int y) { dw_draw_point(DW_NOHWND, hpixmap, x, y); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
546 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(DW_NOHWND, hpixmap, x1, y1, x2, y2); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
547 void DrawPolygon(int flags, int npoints, int x[], int y[]) { dw_draw_polygon(DW_NOHWND, hpixmap, flags, npoints, x, y); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
548 void DrawRect(int fill, int x, int y, int width, int height) { dw_draw_rect(DW_NOHWND, hpixmap, fill, x, y, width, height); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
549 void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) { dw_draw_arc(DW_NOHWND, hpixmap, flags, xorigin, yorigin, x1, y1, x2, y2); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
550 void DrawText(int x, int y, const char *text) { dw_draw_text(DW_NOHWND, hpixmap, x, y, text); } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
551 int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
552 return dw_pixmap_stretch_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc, srcwidth, srcheight); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
553 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
554 int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
555 return dw_pixmap_stretch_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc, srcwidth, srcheight); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
556 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
557 void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
558 dw_pixmap_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
559 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
560 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
561 dw_pixmap_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
562 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
563 int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
564 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
565 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
566 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
567 // Need to declare these here after Pixmap is defined |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
568 int Render::BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
569 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
570 return dw_pixmap_stretch_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc, srcwidth, srcheight); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
571 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
572 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
573 void Render::BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc) |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
574 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
575 dw_pixmap_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
576 } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
577 |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
578 // Class for the HTML rendering widget |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
579 class HTML : public Widget |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
580 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
581 private: |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
582 bool ChangedConnected, ResultConnected; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
583 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
584 std::function<int(int, char *)> _ConnectChanged; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
585 std::function<int(int, char *, void *)> _ConnectResult; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
586 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
587 int (*_ConnectChanged)(int status, char *url); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
588 int (*_ConnectResult)(int status, char *result, void *scriptdata); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
589 #endif |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
590 void Setup() { |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
591 if(IsOverridden(HTML::OnChanged, this)) { |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
592 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
593 ChangedConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
594 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
595 if(IsOverridden(HTML::OnResult, this)) { |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
596 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnResult), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
597 ResultConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
598 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
599 } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
600 static int _OnChanged(HWND window, int status, char *url, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
601 if(reinterpret_cast<HTML *>(data)->_ConnectChanged) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
602 return reinterpret_cast<HTML *>(data)->_ConnectChanged(status, url); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
603 return reinterpret_cast<HTML *>(data)->OnChanged(status, url); } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
604 static int _OnResult(HWND window, int status, char *result, void *scriptdata, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
605 if(reinterpret_cast<HTML *>(data)->_ConnectResult) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
606 return reinterpret_cast<HTML *>(data)->_ConnectResult(status, result, scriptdata); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
607 return reinterpret_cast<HTML *>(data)->OnResult(status, result, scriptdata); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
608 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
609 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
610 HTML(unsigned long id) { SetHWND(dw_html_new(id)); Setup(); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
611 HTML() { SetHWND(dw_html_new(0)); Setup(); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
612 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
613 // User functions |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
614 void Action(int action) { dw_html_action(hwnd, action); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
615 int JavascriptRun(const char *script, void *scriptdata) { return dw_html_javascript_run(hwnd, script, scriptdata); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
616 int Raw(const char *buffer) { return dw_html_raw(hwnd, buffer); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
617 int URL(const char *url) { return dw_html_url(hwnd, url); } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
618 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
619 void ConnectChanged(std::function<int(int, char *)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
620 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
621 void ConnectChanged(int (*userfunc)(int, char *)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
622 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
623 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
624 _ConnectChanged = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
625 if(!ChangedConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
626 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
627 ChangedConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
628 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
629 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
630 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
631 void ConnectResult(std::function<int(int, char *, void *)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
632 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
633 void ConnectResult(int (*userfunc)(int, char *, void *)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
634 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
635 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
636 _ConnectResult = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
637 if(!ResultConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
638 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnResult), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
639 ResultConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
640 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
641 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
642 protected: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
643 // Our signal handler functions to be overriden... |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
644 // If they are not overridden and an event is generated, remove the unused handler |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
645 virtual int OnChanged(int status, char *url) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
646 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_HTML_CHANGED); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
647 ChangedConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
648 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
649 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
650 virtual int OnResult(int status, char *result, void *scriptdata) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
651 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_HTML_RESULT); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
652 ResultConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
653 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
654 }; |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
655 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
656 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
657 // Base class for several widgets that allow text entry |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
658 class TextEntry : virtual public Focusable, virtual public TextWidget |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
659 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
660 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
661 // User functions |
2879
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
662 void ClickDefault(Focusable *next) { if(next) dw_window_click_default(hwnd, next->GetHWND()); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
663 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
664 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
665 class Entryfield : public TextEntry |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
666 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
667 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
668 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
669 Entryfield(const char *text, unsigned long id) { SetHWND(dw_entryfield_new(text, id)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
670 Entryfield(unsigned long id) { SetHWND(dw_entryfield_new("", id)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
671 Entryfield(const char *text) { SetHWND(dw_entryfield_new(text, 0)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
672 Entryfield() { SetHWND(dw_entryfield_new("", 0)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
673 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
674 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
675 class EntryfieldPassword : public TextEntry |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
676 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
677 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
678 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
679 EntryfieldPassword(const char *text, unsigned long id) { SetHWND(dw_entryfield_password_new(text, id)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
680 EntryfieldPassword(unsigned long id) { SetHWND(dw_entryfield_password_new("", id)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
681 EntryfieldPassword(const char *text) { SetHWND(dw_entryfield_password_new(text, 0)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
682 EntryfieldPassword() { SetHWND(dw_entryfield_password_new("", 0)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
683 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
684 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
685 // Base class for several widgets that have a list of elements |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
686 class ListBoxes : virtual public Focusable |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
687 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
688 private: |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
689 bool ListSelectConnected; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
690 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
691 std::function<int(int)> _ConnectListSelect; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
692 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
693 int (*_ConnectListSelect)(int index); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
694 #endif |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
695 void Setup() { |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
696 if(IsOverridden(ListBoxes::OnListSelect, this)) { |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
697 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
698 ListSelectConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
699 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
700 } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
701 static int _OnListSelect(HWND window, int index, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
702 if(reinterpret_cast<ListBoxes *>(data)->_ConnectListSelect) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
703 return reinterpret_cast<ListBoxes *>(data)->_ConnectListSelect(index); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
704 return reinterpret_cast<ListBoxes *>(data)->OnListSelect(index); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
705 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
706 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
707 // User functions |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
708 void Append(const char *text) { dw_listbox_append(hwnd, text); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
709 void Clear() { dw_listbox_clear(hwnd); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
710 int Count() { return dw_listbox_count(hwnd); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
711 void Delete(int index) { dw_listbox_delete(hwnd, index); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
712 void GetText(unsigned int index, char *buffer, unsigned int length) { dw_listbox_get_text(hwnd, index, buffer, length); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
713 void SetText(unsigned int index, char *buffer) { dw_listbox_set_text(hwnd, index, buffer); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
714 void Insert(const char *text, int pos) { dw_listbox_insert(hwnd, text, pos); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
715 void ListAppend(char **text, int count) { dw_listbox_list_append(hwnd, text, count); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
716 void Select(int index, int state) { dw_listbox_select(hwnd, index, state); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
717 int Selected() { return dw_listbox_selected(hwnd); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
718 int Selected(int where) { return dw_listbox_selected_multi(hwnd, where); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
719 void SetTop(int top) { dw_listbox_set_top(hwnd, top); } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
720 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
721 void ConnectListSelect(std::function<int(int)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
722 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
723 void ConnectListSelect(int (*userfunc)(int)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
724 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
725 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
726 _ConnectListSelect = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
727 if(!ListSelectConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
728 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
729 ListSelectConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
730 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
731 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
732 protected: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
733 // Our signal handler functions to be overriden... |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
734 // If they are not overridden and an event is generated, remove the unused handler |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
735 virtual int OnListSelect(int index) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
736 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_LIST_SELECT); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
737 ListSelectConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
738 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
739 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
740 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
741 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
742 class Combobox : public TextEntry, public ListBoxes |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
743 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
744 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
745 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
746 Combobox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
747 Combobox(unsigned long id) { SetHWND(dw_combobox_new("", id)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
748 Combobox(const char *text) { SetHWND(dw_combobox_new(text, 0)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
749 Combobox() { SetHWND(dw_combobox_new("", 0)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
750 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
751 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
752 class Listbox : public ListBoxes |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
753 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
754 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
755 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
756 Listbox(unsigned long id, int multi) { SetHWND(dw_listbox_new(id, multi)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
757 Listbox(unsigned long id) { SetHWND(dw_listbox_new(id, FALSE)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
758 Listbox(int multi) { SetHWND(dw_listbox_new(0, multi)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
759 Listbox() { SetHWND(dw_listbox_new(0, FALSE)); } |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
760 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
761 |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
762 // Base class for several ranged type widgets |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
763 class Ranged : virtual public Widget |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
764 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
765 private: |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
766 bool ValueChangedConnected; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
767 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
768 std::function<int(int)> _ConnectValueChanged; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
769 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
770 int (*_ConnectValueChanged)(int value); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
771 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
772 static int _OnValueChanged(HWND window, int value, void *data) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
773 if(reinterpret_cast<Ranged *>(data)->_ConnectValueChanged) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
774 return reinterpret_cast<Ranged *>(data)->_ConnectValueChanged(value); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
775 return reinterpret_cast<Ranged *>(data)->OnValueChanged(value); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
776 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
777 protected: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
778 void Setup() { |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
779 if(IsOverridden(Ranged::OnValueChanged, this)) { |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
780 dw_signal_connect(hwnd, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(_OnValueChanged), this); |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
781 ValueChangedConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
782 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
783 } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
784 // Our signal handler functions to be overriden... |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
785 // If they are not overridden and an event is generated, remove the unused handler |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
786 virtual int OnValueChanged(int value) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
787 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_VALUE_CHANGED); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
788 ValueChangedConnected = false; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
789 return FALSE; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
790 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
791 public: |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
792 #ifdef DW_CPP11 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
793 void ConnectValueChanged(std::function<int(int)> userfunc) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
794 #else |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
795 void ConnectValueChanged(int (*userfunc)(int)) |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
796 #endif |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
797 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
798 _ConnectValueChanged = userfunc; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
799 if(!ValueChangedConnected) { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
800 dw_signal_connect(hwnd, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(_OnValueChanged), this); |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
801 ValueChangedConnected = true; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
802 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
803 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
804 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
805 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
806 class Slider : public Ranged |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
807 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
808 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
809 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
810 Slider(int orient, int increments, unsigned long id) { SetHWND(dw_slider_new(orient, increments, id)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
811 Slider(int orient, int increments) { SetHWND(dw_slider_new(orient, increments, 0)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
812 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
813 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
814 unsigned int GetPos() { return dw_slider_get_pos(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
815 void SetPos(unsigned int position) { dw_slider_set_pos(hwnd, position); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
816 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
817 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
818 class Scrollbar : public Ranged |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
819 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
820 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
821 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
822 Scrollbar(int orient, unsigned long id) { SetHWND(dw_scrollbar_new(orient, id)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
823 Scrollbar(int orient) { SetHWND(dw_scrollbar_new(orient, 0)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
824 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
825 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
826 unsigned int GetPos() { return dw_scrollbar_get_pos(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
827 void SetPos(unsigned int position) { dw_scrollbar_set_pos(hwnd, position); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
828 void SetRange(unsigned int range, unsigned int visible) { dw_scrollbar_set_range(hwnd, range, visible); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
829 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
830 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
831 class SpinButton : public Ranged, public TextEntry |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
832 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
833 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
834 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
835 SpinButton(const char *text, unsigned long id) { SetHWND(dw_spinbutton_new(text, id)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
836 SpinButton(unsigned long id) { SetHWND(dw_spinbutton_new("", id)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
837 SpinButton(const char *text) { SetHWND(dw_spinbutton_new(text, 0)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
838 SpinButton() { SetHWND(dw_spinbutton_new("", 0)); Setup(); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
839 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
840 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
841 long GetPos() { return dw_spinbutton_get_pos(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
842 void SetPos(long position) { dw_spinbutton_set_pos(hwnd, position); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
843 void SetLimits(long upper, long lower) { dw_spinbutton_set_limits(hwnd, upper, lower); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
844 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
845 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
846 // Multi-line Edit widget |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
847 class MLE : public Focusable |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
848 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
849 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
850 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
851 MLE(unsigned long id) { SetHWND(dw_mle_new(id)); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
852 MLE() { SetHWND(dw_mle_new(0)); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
853 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
854 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
855 void Freeze() { dw_mle_freeze(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
856 void Thaw() { dw_mle_thaw(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
857 void Clear() { dw_mle_clear(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
858 void Delete(int startpoint, int length) { dw_mle_delete(hwnd, startpoint, length); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
859 void Export(char *buffer, int startpoint, int length) { dw_mle_export(hwnd, buffer, startpoint, length); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
860 void Import(const char *buffer, int startpoint) { dw_mle_import(hwnd, buffer, startpoint); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
861 void GetSize(unsigned long *bytes, unsigned long *lines) { dw_mle_get_size(hwnd, bytes, lines); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
862 void Search(const char *text, int point, unsigned long flags) { dw_mle_search(hwnd, text, point, flags); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
863 void SetAutoComplete(int state) { dw_mle_set_auto_complete(hwnd, state); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
864 void SetCursor(int point) { dw_mle_set_cursor(hwnd, point); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
865 void SetEditable(int state) { dw_mle_set_editable(hwnd, state); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
866 void SetVisible(int line) { dw_mle_set_visible(hwnd, line); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
867 void SetWordWrap(int state) { dw_mle_set_word_wrap(hwnd, state); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
868 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
869 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
870 class App |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
871 { |
2866
6ea67d0809eb
Convert DW::App class into a singleton so subsequent DW::App::Init() calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2865
diff
changeset
|
872 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
873 App() { } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
874 static App *_app; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
875 public: |
2870
7b4e30c19757
C++: Disable singleton safety code for non C++11 compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2869
diff
changeset
|
876 // Allow the code to compile if handicapped on older compilers |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
877 #ifdef DW_CPP11 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
878 // Singletons should not be cloneable. |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
879 App(App &other) = delete; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
880 // Singletons should not be assignable. |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
881 void operator=(const App &) = delete; |
2870
7b4e30c19757
C++: Disable singleton safety code for non C++11 compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2869
diff
changeset
|
882 #endif |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
883 // Initialization functions for creating App |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
884 static App *Init() { if(!_app) { _app = new App; dw_init(TRUE, 0, DW_NULL); } return _app; } |
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
885 static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, 0, DW_NULL); } return _app; } |
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
886 static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, DW_NULL); } return _app; } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
887 static App *Init(int argc, char *argv[]) { if(!_app) { _app = new App(); dw_init(TRUE, argc, argv); } return _app; } |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
888 static App *Init(int argc, char *argv[], const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, argc, argv); } return _app; } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
889 static App *Init(int argc, char *argv[], const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, argc, argv); } return _app; } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
890 |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
891 // User functions |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
892 void Main() { dw_main(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
893 void MainIteration() { dw_main_iteration(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
894 void MainQuit() { dw_main_quit(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
895 void Exit(int exitcode) { dw_exit(exitcode); } |
2882
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
896 int MessageBox(const char *title, int flags, const char *format) { return dw_messagebox(title, flags, format); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
897 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
898 |
2866
6ea67d0809eb
Convert DW::App class into a singleton so subsequent DW::App::Init() calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2865
diff
changeset
|
899 // Static singleton reference declared outside of the class |
2872
e62fc9b3b09c
C++: Add DW_NULL which is nullptr on C++11 and NULL on older versions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2871
diff
changeset
|
900 App* App::_app = DW_NULL; |
2866
6ea67d0809eb
Convert DW::App class into a singleton so subsequent DW::App::Init() calls
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2865
diff
changeset
|
901 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
902 } /* namespace DW */ |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
903 #endif |