Mercurial > dwindows
annotate dw.hpp @ 2939:ebbc5b16899e
C++: Another couple fixes, context menus and PackAtIndex that got lost during porting.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 01 Jan 2023 00:23:39 +0000 |
parents | 1184f58135ba |
children | 60e90b783cb1 |
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> |
2907
afd2d900d1e9
C++: Need to include string.h for strlen() on some platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2906
diff
changeset
|
9 #include <string.h> |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
10 |
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
|
11 // Attempt to support compilers without nullptr type literal |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
12 #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
|
13 #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
|
14 #define DW_NULL nullptr |
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 |
2928
102b96d77f89
C++: Visual Studio 2013 lambda support also did not work, bump to 2015.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2927
diff
changeset
|
19 // Support Lambdas on C++11, Visual C 2015 or GCC 4.5 |
102b96d77f89
C++: Visual Studio 2013 lambda support also did not work, bump to 2015.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2927
diff
changeset
|
20 #if defined(DW_CPP11) || (defined(_MSC_VER) && _MSC_VER >= 1900) || \ |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
21 (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))) |
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
22 #define DW_LAMBDA |
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
23 #include <functional> |
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
24 #endif |
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
25 |
2873
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
26 // 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
|
27 #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
|
28 #define override |
2926
5b584c5ddc96
C++: GCC before 4.7 also doesn't support final.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2925
diff
changeset
|
29 #define final |
2873
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
30 #endif |
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
31 |
2925
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
32 // Attempt to allow compilation on MSVC older than 2012 |
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
33 #if defined(_MSC_VER) && _MSC_VER < 1700 |
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
34 #define final |
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
35 #endif |
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
36 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
37 namespace DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
38 { |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
39 |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
40 #define THREAD_STACK 10000 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
41 |
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
|
42 // 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
|
43 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
|
44 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
|
45 class MenuItem; |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
46 class Window; |
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
|
47 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
48 // 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
|
49 // The base system handles |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
50 class Handle |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
51 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
52 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
53 void *handle; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
54 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
|
55 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
56 void *GetHandle() { return handle; } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
57 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
58 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
59 // Widget class allows packing and style |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
60 class Widget : public Handle |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
61 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
62 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
63 void SetHWND(HWND newhwnd) { |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
64 hwnd = newhwnd; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
65 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
|
66 // 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
|
67 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
|
68 } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
69 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
|
70 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
71 HWND GetHWND() { return hwnd; } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
72 int Destroy() { int retval = dw_window_destroy(hwnd); delete this; return retval; } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
73 Widget *FromID(int id) { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
74 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
|
75 if(child) { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
76 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
|
77 } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
78 return DW_NULL; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
79 } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
80 void GetPreferredSize(int *width, int *height) { dw_window_get_preferred_size(hwnd, width, height); } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
81 int SetColor(unsigned long fore, unsigned long back) { return dw_window_set_color(hwnd, fore, back); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
82 void SetData(const char *dataname, void *data) { dw_window_set_data(hwnd, dataname, data); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
83 void *GetData(const char *dataname) { return dw_window_get_data(hwnd, dataname); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
84 void SetPointer(int cursortype) { dw_window_set_pointer(hwnd, cursortype); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
85 void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
86 void SetStyle(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); } |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
87 void SetTooltip(const char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
88 int Unpack() { return dw_box_unpack(hwnd); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
89 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
90 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
91 // 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
|
92 class Boxes : virtual public Widget |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
93 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
94 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
95 // User functions |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
96 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
|
97 dw_box_pack_start(hwnd, item ? item->GetHWND() : DW_NOHWND, width, height, hsize, vsize, pad); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
98 void PackStart(Widget *item, int hsize, int vsize, int pad) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
99 dw_box_pack_start(hwnd, item ? item->GetHWND() : DW_NOHWND, DW_SIZE_AUTO, DW_SIZE_AUTO, hsize, vsize, pad); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
100 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
|
101 dw_box_pack_end(hwnd, item ? item->GetHWND() : DW_NOHWND, width, height, hsize, vsize, pad); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
102 void PackEnd(Widget *item, int hsize, int vsize, int pad) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
103 dw_box_pack_end(hwnd, item ? item->GetHWND() : DW_NOHWND, DW_SIZE_AUTO, DW_SIZE_AUTO, hsize, vsize, pad); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
104 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
|
105 dw_box_pack_at_index(hwnd, item ? item->GetHWND() : DW_NOHWND, index, width, height, hsize, vsize, pad); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
106 void PackAtIndex(Widget *item, int index, int hsize, int vsize, int pad) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
107 dw_box_pack_at_index(hwnd, item ? item->GetHWND() : DW_NOHWND, index, DW_SIZE_AUTO, DW_SIZE_AUTO, hsize, vsize, pad); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
112 }; |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
113 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
114 class Box : public Boxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
115 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
116 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
117 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
118 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
|
119 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
|
120 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
121 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
122 // Special scrollable box |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
123 class ScrollBox : public Boxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
124 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
125 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
126 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
127 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
|
128 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
|
129 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
130 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
131 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
|
132 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
|
133 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
134 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
135 // 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
|
136 // 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
|
137 #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
|
138 |
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
|
139 // 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
|
140 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
|
141 { |
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 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
|
143 bool ClickedConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
144 #ifdef DW_LAMBDA |
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
|
145 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
|
146 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
147 int (*_ConnectClickedOld)(Clickable *); |
2911
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
148 static int _OnClicked(HWND window, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
149 Clickable *classptr = reinterpret_cast<Clickable *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
150 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
151 if(classptr->_ConnectClicked) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
152 return classptr->_ConnectClicked(); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
153 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
154 if(classptr->_ConnectClickedOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
155 return classptr->_ConnectClickedOld(classptr); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
156 return classptr->OnClicked(); } |
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
|
157 protected: |
2929
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
158 virtual ~Clickable() {} |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
159 void Setup() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
160 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
161 _ConnectClicked = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
162 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
163 _ConnectClickedOld = 0; |
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
|
164 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
|
165 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
|
166 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
|
167 } |
2911
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
168 else { |
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
169 ClickedConnected = false; |
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
170 } |
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
|
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 // 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
|
173 // 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 } |
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 public: |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
180 #ifdef DW_LAMBDA |
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
|
181 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
|
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 _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
|
184 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
|
185 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
|
186 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
|
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 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
189 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
190 void ConnectClicked(int (*userfunc)(Clickable *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
191 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
192 _ConnectClickedOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
193 if(!ClickedConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
194 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
195 ClickedConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
196 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
197 } |
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 }; |
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 |
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 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
|
201 { |
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 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
|
203 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
|
204 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
|
205 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
|
206 } |
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 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
|
208 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
|
209 // 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
|
210 HMENUI GetHMENUI() { return menu; } |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
211 MenuItem *AppendItem(const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu); |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
212 MenuItem *AppendItem(const char *title, unsigned long flags, int check, Menus *submenu); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
213 MenuItem *AppendItem(const char *title, unsigned long flags, int check); |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
214 MenuItem *AppendItem(const char *title, Menus *submenu); |
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
215 MenuItem *AppendItem(const char *title); |
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 }; |
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 |
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 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
|
219 { |
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 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
|
221 // 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
|
222 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
|
223 Menu() { SetHMENUI(dw_menu_new(0)); } |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
224 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
225 // User functions |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
226 void Popup(Window *window, int x, int y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
227 void Popup(Window *window); |
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
|
228 }; |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
229 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
230 class MenuBar : public Menus |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
231 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
232 public: |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
233 // Constructors |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
234 MenuBar(HWND location) { SetHMENUI(dw_menubar_new(location)); } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
235 }; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
236 |
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
|
237 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
|
238 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
239 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
|
240 // 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
|
241 MenuItem(Menus *menu, const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { |
2911
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
242 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, id, flags, end, check, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
243 } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
244 MenuItem(Menus *menu, const char *title, unsigned long flags, int check, Menus *submenu) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
245 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, flags, TRUE, check, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
246 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
247 MenuItem(Menus *menu, const char *title, unsigned long flags, int check) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
248 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, flags, TRUE, check, DW_NOMENU)); Setup(); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
249 } |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
250 MenuItem(Menus *menu, const char *title, Menus *submenu) { |
2911
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
251 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, 0, TRUE, FALSE, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
252 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
253 MenuItem(Menus *menu, const char *title) { |
2911
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
254 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, 0, TRUE, FALSE, DW_NOMENU)); 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
|
255 } |
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 |
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 // 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
|
258 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
|
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 |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
261 MenuItem *Menus::AppendItem(const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { |
2891
185c1e9674a1
C++: Fix a crash caused by passing the wrong variable to the constructor.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2890
diff
changeset
|
262 return new MenuItem(this, title, id, flags, end, check, submenu); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
263 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
264 |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
265 MenuItem *Menus::AppendItem(const char *title, unsigned long flags, int check, Menus *submenu) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
266 return new MenuItem(this, title, flags, check, submenu); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
267 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
268 |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
269 MenuItem *Menus::AppendItem(const char *title, unsigned long flags, int check) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
270 return new MenuItem(this, title, flags, check); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
271 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
272 |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
273 MenuItem *Menus::AppendItem(const char *title, Menus *submenu) { |
2891
185c1e9674a1
C++: Fix a crash caused by passing the wrong variable to the constructor.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2890
diff
changeset
|
274 return new MenuItem(this, title, submenu); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
275 } |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
276 MenuItem *Menus::AppendItem(const char *title) { |
2891
185c1e9674a1
C++: Fix a crash caused by passing the wrong variable to the constructor.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2890
diff
changeset
|
277 return new MenuItem(this, title); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
278 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
279 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
280 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
281 // 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
|
282 class Window : public Boxes |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
283 { |
2865
fd32dce7fecd
Initial signal handler support for the C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2861
diff
changeset
|
284 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
|
285 bool DeleteConnected, ConfigureConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
286 #ifdef DW_LAMBDA |
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
|
287 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
|
288 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
|
289 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
290 int (*_ConnectDeleteOld)(Window *); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
291 int (*_ConnectConfigureOld)(Window *, int width, int height); |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
292 void Setup() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
293 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
294 _ConnectDelete = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
295 _ConnectConfigure = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
296 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
297 _ConnectDeleteOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
298 _ConnectConfigureOld = 0; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
299 menu = DW_NULL; |
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
|
300 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
|
301 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
|
302 DeleteConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
303 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
304 DeleteConnected = false; |
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
|
305 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
306 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
|
307 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
|
308 ConfigureConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
309 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
310 ConfigureConnected = false; |
2906
9d6280f206bd
Minor code cleanups in the template and C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2905
diff
changeset
|
311 } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
312 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
313 static int _OnDelete(HWND window, void *data) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
314 Window *classptr = reinterpret_cast<Window *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
315 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
316 if(classptr->_ConnectDelete) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
317 return classptr->_ConnectDelete(); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
318 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
319 if(classptr->_ConnectDeleteOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
320 return classptr->_ConnectDeleteOld(classptr); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
321 return classptr->OnDelete(); } |
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
|
322 static int _OnConfigure(HWND window, int width, int height, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
323 Window *classptr = reinterpret_cast<Window *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
324 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
325 if(classptr->_ConnectConfigure) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
326 return classptr->_ConnectConfigure(width, height); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
327 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
328 if(classptr->_ConnectConfigureOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
329 return classptr->_ConnectConfigureOld(classptr, width, height); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
330 return classptr->OnConfigure(width, height); } |
2884
06e475feaac0
C++: Split Menu and MenuBar to prevent type conflicts.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2882
diff
changeset
|
331 MenuBar *menu; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
332 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
333 // Constructors |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 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
|
341 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
342 // User functions |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 void Default(Widget *defaultitem) { if(defaultitem) dw_window_default(hwnd, defaultitem->GetHWND()); } |
2939
ebbc5b16899e
C++: Another couple fixes, context menus and PackAtIndex that got lost during porting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2938
diff
changeset
|
354 void ClickDefault(Widget *defaultitem) { if(defaultitem) dw_window_click_default(hwnd, defaultitem->GetHWND()); } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
355 void SetIcon(HICN icon) { dw_window_set_icon(hwnd, icon); } |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
356 MenuBar *MenuBarNew() { if(!menu) menu = new MenuBar(hwnd); return menu; } |
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
357 void Popup(Menu *menu, int x, int y) { |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
358 if(menu) { |
2890
ab4c86ddc63a
C++: Fix a logic error reported by MSVC 2022.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2889
diff
changeset
|
359 HMENUI pmenu = menu->GetHMENUI(); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
360 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
361 dw_menu_popup(&pmenu, hwnd, x, y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
362 delete menu; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
363 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
364 } |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
365 void Popup(Menu *menu) { |
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
366 if(menu) { |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
367 long x, y; |
2890
ab4c86ddc63a
C++: Fix a logic error reported by MSVC 2022.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2889
diff
changeset
|
368 HMENUI pmenu = menu->GetHMENUI(); |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
369 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
370 dw_pointer_query_pos(&x, &y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
371 dw_menu_popup(&pmenu, hwnd, (int)x, (int)y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
372 delete menu; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
373 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
374 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
375 #ifdef DW_LAMBDA |
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
|
376 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
|
377 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
378 _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
|
379 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
|
380 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
|
381 DeleteConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
382 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
383 DeleteConnected = false; |
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
|
384 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
385 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
386 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
387 void ConnectDelete(int (*userfunc)(Window *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
388 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
389 _ConnectDeleteOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
390 if(!DeleteConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
391 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
392 DeleteConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
393 } else { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
394 DeleteConnected = false; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
395 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
396 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
397 #ifdef DW_LAMBDA |
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
|
398 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
|
399 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
400 _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
|
401 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
|
402 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
|
403 ConfigureConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
404 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
405 ConfigureConnected = false; |
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
|
406 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
407 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
408 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
409 void ConnectConfigure(int (*userfunc)(Window *, int, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
410 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
411 _ConnectConfigureOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
412 if(!ConfigureConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
413 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
414 ConfigureConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
415 } else { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
416 ConfigureConnected = false; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
417 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
418 } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
419 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
420 // 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
|
421 // 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
427 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
|
428 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
|
429 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
|
430 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
|
431 }; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
432 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
433 |
2885
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
434 void Menu::Popup(Window *window, int x, int y) |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
435 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
436 if(window) |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
437 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
438 HMENUI pmenu = menu; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
439 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
440 dw_menu_popup(&pmenu, window->GetHWND(), x, y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
441 delete this; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
442 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
443 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
444 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
445 void Menu::Popup(Window *window) |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
446 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
447 if(window) { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
448 long x, y; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
449 HMENUI pmenu = menu; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
450 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
451 dw_pointer_query_pos(&x, &y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
452 dw_menu_popup(&pmenu, window->GetHWND(), (int)x, (int)y); |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
453 delete this; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
454 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
455 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
456 |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
457 // Class for focusable widgets |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
458 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
|
459 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
460 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
461 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
|
462 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
|
463 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
|
464 }; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
465 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
466 // 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
|
467 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
|
468 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
469 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
470 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
471 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
|
472 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
|
473 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
474 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
475 class Button : public TextButton |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
476 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
477 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
478 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
479 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
|
480 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
|
481 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
|
482 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
|
483 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
484 |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
485 class BitmapWidget : virtual public Widget |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
486 { |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
487 public: |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
488 // User functions |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
489 void Set(unsigned long id) { dw_window_set_bitmap(hwnd, id, DW_NULL); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
490 void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
491 void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
492 }; |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
493 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
494 // Image based button |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
495 class BitmapButton : public Clickable, public Focusable, public BitmapWidget |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
496 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
497 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
498 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
506 |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
507 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
|
508 { |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
509 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
510 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
511 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
|
512 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
|
513 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
514 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
515 class CheckBox : public CheckBoxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
516 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
517 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
518 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
519 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
|
520 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
|
521 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
|
522 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
|
523 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
524 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
525 class RadioButton : public CheckBoxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
526 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
527 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
528 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
529 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
|
530 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
|
531 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
|
532 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
|
533 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
534 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
535 // 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
|
536 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
|
537 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
538 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
539 // User functions |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
540 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
|
541 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
|
542 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
|
543 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
|
544 }; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
545 |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
546 // 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
|
547 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
|
548 { |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
549 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
550 // Constructors |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
551 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
|
552 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
|
553 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
|
554 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
|
555 }; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
556 |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
557 class StatusText : public TextWidget |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
558 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
559 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
560 // Constructors |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
561 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
|
562 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
|
563 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
|
564 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
|
565 }; |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
566 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
567 // Class for handing static image widget |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
568 class Bitmap : public BitmapWidget |
2874
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 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
571 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
572 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
|
573 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
|
574 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
|
575 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
|
576 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
577 |
2879
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
578 // 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
|
579 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
|
580 { |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
581 public: |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
582 // Constructors |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
583 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
|
584 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
|
585 |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
586 // User functions |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
587 void GetDate(unsigned int *year, unsigned int *month, unsigned int *day) { dw_calendar_get_date(hwnd, year, month, day); } |
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
588 void SetDate(unsigned int year, unsigned int month, unsigned int day) { dw_calendar_set_date(hwnd, year, month, day); } |
2879
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
589 }; |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
590 |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
591 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
592 // 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
|
593 class Drawable |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
594 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
595 public: |
2929
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
596 virtual ~Drawable() { } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 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
|
605 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
|
606 virtual void BitBlt(int xdest, int ydest, int width, int height, Pixmap *srcp, int xsrc, int ysrc) = 0; |
2929
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
607 void SetColor(unsigned long fore, unsigned long back) { dw_color_foreground_set(fore); dw_color_background_set(back); } |
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
608 void SetBackgroundColor(unsigned long back) { dw_color_background_set(back); } |
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
609 void SetForegroundColor(unsigned long fore) { dw_color_foreground_set(fore); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
610 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
611 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
612 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
|
613 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
614 private: |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
615 bool ExposeConnected, ConfigureConnected, KeyPressConnected, ButtonPressConnected, ButtonReleaseConnected, MotionNotifyConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
616 #ifdef DW_LAMBDA |
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
|
617 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
|
618 std::function<int(int, int)> _ConnectConfigure; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
619 std::function<int(char c, int, int, char *)> _ConnectKeyPress; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
620 std::function<int(int, int, int)> _ConnectButtonPress; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
621 std::function<int(int, int, int)> _ConnectButtonRelease; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
622 std::function<int(int, int, int)> _ConnectMotionNotify; |
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
|
623 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
624 int (*_ConnectExposeOld)(Render *, DWExpose *); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
625 int (*_ConnectConfigureOld)(Render *, int width, int height); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
626 int (*_ConnectKeyPressOld)(Render *, char c, int vk, int state, char *utf8); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
627 int (*_ConnectButtonPressOld)(Render *, int x, int y, int buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
628 int (*_ConnectButtonReleaseOld)(Render *, int x, int y, int buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
629 int (*_ConnectMotionNotifyOld)(Render *, int x, int y, int buttonmask); |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
630 void Setup() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
631 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
632 _ConnectExpose = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
633 _ConnectConfigure = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
634 _ConnectKeyPress = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
635 _ConnectButtonPress = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
636 _ConnectButtonRelease = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
637 _ConnectMotionNotify = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
638 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
639 _ConnectExposeOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
640 _ConnectConfigureOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
641 _ConnectKeyPressOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
642 _ConnectButtonPressOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
643 _ConnectButtonReleaseOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
644 _ConnectMotionNotifyOld = 0; |
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 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
|
646 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
|
647 ExposeConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
648 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
649 ExposeConnected = false; |
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
|
650 } |
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 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
|
652 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
|
653 ConfigureConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
654 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
655 ConfigureConnected = false; |
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
|
656 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
657 if(IsOverridden(Render::OnKeyPress, this)) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
658 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
659 KeyPressConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
660 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
661 KeyPressConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
662 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
663 if(IsOverridden(Render::OnButtonPress, this)) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
664 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_OnButtonPress), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
665 ButtonPressConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
666 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
667 ButtonPressConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
668 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
669 if(IsOverridden(Render::OnButtonRelease, this)) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
670 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_RELEASE, DW_SIGNAL_FUNC(_OnButtonRelease), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
671 ButtonReleaseConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
672 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
673 ButtonReleaseConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
674 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
675 if(IsOverridden(Render::OnMotionNotify, this)) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
676 dw_signal_connect(hwnd, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(_OnMotionNotify), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
677 MotionNotifyConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
678 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
679 MotionNotifyConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
680 } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
681 } |
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
|
682 static int _OnExpose(HWND window, DWExpose *exp, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
683 Render *classptr = reinterpret_cast<Render *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
684 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
685 if(classptr->_ConnectExpose) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
686 return classptr->_ConnectExpose(exp); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
687 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
688 if(classptr->_ConnectExposeOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
689 return classptr->_ConnectExposeOld(classptr, exp); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
690 return classptr->OnExpose(exp); } |
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
|
691 static int _OnConfigure(HWND window, int width, int height, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
692 Render *classptr = reinterpret_cast<Render *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
693 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
694 if(classptr->_ConnectConfigure) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
695 return classptr->_ConnectConfigure(width, height); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
696 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
697 if(classptr->_ConnectConfigureOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
698 return classptr->_ConnectConfigureOld(classptr, width, height); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
699 return classptr->OnConfigure(width, height); } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
700 static int _OnKeyPress(HWND window, char c, int vk, int state, void *data, char *utf8) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
701 Render *classptr = reinterpret_cast<Render *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
702 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
703 if(classptr->_ConnectKeyPress) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
704 return classptr->_ConnectKeyPress(c, vk, state, utf8); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
705 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
706 if(classptr->_ConnectKeyPressOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
707 return classptr->_ConnectKeyPressOld(classptr, c, vk, state, utf8); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
708 return classptr->OnKeyPress(c, vk, state, utf8); } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
709 static int _OnButtonPress(HWND window, int x, int y, int buttonmask, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
710 Render *classptr = reinterpret_cast<Render *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
711 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
712 if(classptr->_ConnectButtonPress) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
713 return classptr->_ConnectButtonPress(x, y, buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
714 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
715 if(classptr->_ConnectButtonPressOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
716 return classptr->_ConnectButtonPressOld(classptr, x, y, buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
717 return classptr->OnButtonPress(x, y, buttonmask); } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
718 static int _OnButtonRelease(HWND window, int x, int y, int buttonmask, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
719 Render *classptr = reinterpret_cast<Render *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
720 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
721 if(classptr->_ConnectButtonRelease) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
722 return classptr->_ConnectButtonRelease(x, y, buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
723 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
724 if(classptr->_ConnectButtonReleaseOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
725 return classptr->_ConnectButtonReleaseOld(classptr, x, y, buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
726 return classptr->OnButtonRelease(x, y, buttonmask); } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
727 static int _OnMotionNotify(HWND window, int x, int y, int buttonmask, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
728 Render *classptr = reinterpret_cast<Render *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
729 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
730 if(classptr->_ConnectMotionNotify) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
731 return classptr->_ConnectMotionNotify(x, y, buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
732 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
733 if(classptr->_ConnectMotionNotifyOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
734 return classptr->_ConnectMotionNotifyOld(classptr, x, y, buttonmask); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
735 return classptr->OnMotionNotify(x, y, buttonmask); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
736 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
737 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
738 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
|
739 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
|
740 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
741 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
742 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
|
743 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
|
744 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
|
745 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
|
746 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
|
747 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
|
748 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
|
749 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
|
750 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
751 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
|
752 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
|
753 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
|
754 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
755 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
|
756 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
|
757 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
|
758 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
|
759 void Redraw() { dw_render_redraw(hwnd); } |
2919
e609aa6a5b93
C++: Attempt to implement page 2 rendering...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2917
diff
changeset
|
760 void Flush() { dw_flush(); } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
761 #ifdef DW_LAMBDA |
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
|
762 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
|
763 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
764 _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
|
765 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
|
766 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
|
767 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
|
768 } |
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 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
770 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
771 void ConnectExpose(int (*userfunc)(Render *, DWExpose *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
772 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
773 _ConnectExposeOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
774 if(!ExposeConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
775 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
776 ExposeConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
777 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
778 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
779 #ifdef DW_LAMBDA |
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
|
780 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
|
781 { |
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 _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
|
783 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
|
784 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
|
785 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
|
786 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
787 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
788 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
789 void ConnectConfigure(int (*userfunc)(Render *, int, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
790 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
791 _ConnectConfigureOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
792 if(!ConfigureConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
793 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
794 ConfigureConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
795 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
796 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
797 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
798 void ConnectKeyPress(std::function<int(char, int, int, char *)> userfunc) |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
799 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
800 _ConnectKeyPress = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
801 if(!KeyPressConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
802 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
803 KeyPressConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
804 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
805 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
806 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
807 void ConnectKeyPress(int (*userfunc)(Render *, char, int, int, char *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
808 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
809 _ConnectKeyPressOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
810 if(!KeyPressConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
811 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
812 KeyPressConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
813 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
814 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
815 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
816 void ConnectButtonPress(std::function<int(int, int, int)> userfunc) |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
817 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
818 _ConnectButtonPress = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
819 if(!KeyPressConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
820 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_OnButtonPress), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
821 ButtonPressConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
822 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
823 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
824 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
825 void ConnectButtonPress(int (*userfunc)(Render *, int, int, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
826 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
827 _ConnectButtonPressOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
828 if(!KeyPressConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
829 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_OnButtonPress), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
830 ButtonPressConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
831 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
832 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
833 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
834 void ConnectButtonRelease(std::function<int(int, int, int)> userfunc) |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
835 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
836 _ConnectButtonRelease = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
837 if(!KeyPressConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
838 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_RELEASE, DW_SIGNAL_FUNC(_OnButtonRelease), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
839 ButtonReleaseConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
840 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
841 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
842 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
843 void ConnectButtonRelease(int (*userfunc)(Render *, int, int, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
844 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
845 _ConnectButtonReleaseOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
846 if(!KeyPressConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
847 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_RELEASE, DW_SIGNAL_FUNC(_OnButtonRelease), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
848 ButtonReleaseConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
849 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
850 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
851 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
852 void ConnectMotionNotify(std::function<int(int, int, int)> userfunc) |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
853 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
854 _ConnectMotionNotify = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
855 if(!MotionNotifyConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
856 dw_signal_connect(hwnd, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(_OnMotionNotify), this); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
857 MotionNotifyConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
858 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
859 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
860 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
861 void ConnectMotionNotify(int (*userfunc)(Render *, int, int, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
862 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
863 _ConnectMotionNotifyOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
864 if(!MotionNotifyConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
865 dw_signal_connect(hwnd, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(_OnMotionNotify), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
866 MotionNotifyConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
867 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
868 } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
869 protected: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
870 // 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
|
871 // 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
|
872 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
|
873 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
|
874 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
|
875 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
|
876 } |
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 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
|
878 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
|
879 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
|
880 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
|
881 }; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
882 virtual int OnKeyPress(char c, int vk, int state, char *utf8) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
883 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_KEY_PRESS); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
884 KeyPressConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
885 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
886 }; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
887 virtual int OnButtonPress(char x, int y, int buttonmask) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
888 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_BUTTON_PRESS); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
889 ButtonPressConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
890 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
891 }; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
892 virtual int OnButtonRelease(char x, int y, int buttonmask) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
893 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_BUTTON_RELEASE); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
894 ButtonReleaseConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
895 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
896 }; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
897 virtual int OnMotionNotify(char x, int y, int buttonmask) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
898 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_MOTION_NOTIFY); |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
899 MotionNotifyConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
900 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
901 }; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
902 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
903 |
2919
e609aa6a5b93
C++: Attempt to implement page 2 rendering...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2917
diff
changeset
|
904 class Pixmap final : public Drawable, public Handle |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
905 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
906 private: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
907 void SetHPIXMAP(HPIXMAP newpixmap) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
908 hpixmap = newpixmap; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
909 SetHandle(reinterpret_cast<void *>(newpixmap)); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
910 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
911 HPIXMAP hpixmap; |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
912 unsigned long pwidth, pheight; |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
913 bool hpmprot; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
914 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
915 // Constructors |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
916 Pixmap(Render *window, unsigned long width, unsigned long height, int depth) { |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
917 SetHPIXMAP(dw_pixmap_new(window ? window->GetHWND() : DW_NOHWND, width, height, depth)); |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
918 pwidth = width; pheight = height; |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
919 hpmprot = false; |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
920 } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
921 Pixmap(Render *window, unsigned long width, unsigned long height) { |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
922 SetHPIXMAP(dw_pixmap_new(window ? window->GetHWND() : DW_NOHWND, width, height, 32)); |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
923 pwidth = width; pheight = height; |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
924 hpmprot = false; |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
925 } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
926 Pixmap(Render *window, const char *filename) { |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
927 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename)); |
2922
0919c2b82109
C++: Accidentally clobbered some required code in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2921
diff
changeset
|
928 pwidth = hpixmap ? DW_PIXMAP_WIDTH(hpixmap) : 0; |
0919c2b82109
C++: Accidentally clobbered some required code in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2921
diff
changeset
|
929 pheight = hpixmap ? DW_PIXMAP_HEIGHT(hpixmap) : 0; |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
930 hpmprot = false; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
931 } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
932 Pixmap(HPIXMAP hpm) { |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
933 SetHPIXMAP(hpm); |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
934 pwidth = hpixmap ? DW_PIXMAP_WIDTH(hpixmap) : 0; |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
935 pheight = hpixmap ? DW_PIXMAP_HEIGHT(hpixmap) : 0; |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
936 hpmprot = true; |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
937 } |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
938 // Destructor |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
939 ~Pixmap() { if(hpmprot == false) dw_pixmap_destroy(hpixmap); hpixmap = 0; } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
940 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
941 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
942 HPIXMAP GetHPIXMAP() { return hpixmap; } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
943 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
|
944 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
|
945 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
|
946 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
|
947 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
|
948 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
|
949 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
|
950 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
|
951 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
952 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
|
953 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
|
954 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
955 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
|
956 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
|
957 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
958 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
|
959 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
|
960 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
961 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
|
962 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); } |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
963 void SetTransparentColor(unsigned long color) { dw_pixmap_set_transparent_color(hpixmap, color); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
964 unsigned long GetWidth() { return pwidth; } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
965 unsigned long GetHeight() { return pheight; } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
966 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
967 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
968 // 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
|
969 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
|
970 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
971 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
|
972 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
973 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
974 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
|
975 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
976 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
|
977 } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
978 |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
979 // 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
|
980 class HTML : public Widget |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
981 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
982 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
|
983 bool ChangedConnected, ResultConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
984 #ifdef DW_LAMBDA |
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
|
985 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
|
986 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
|
987 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
988 int (*_ConnectChangedOld)(HTML *, int status, char *url); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
989 int (*_ConnectResultOld)(HTML *, int status, char *result, void *scriptdata); |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
990 void Setup() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
991 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
992 _ConnectChanged = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
993 _ConnectResult = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
994 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
995 _ConnectChangedOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
996 _ConnectResultOld = 0; |
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
|
997 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
|
998 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
|
999 ChangedConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1000 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1001 ChangedConnected = false; |
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
|
1002 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1003 if(IsOverridden(HTML::OnResult, this)) { |
2936
75f6e21f5a02
C++: Connected the wrong signal for the HTML result, causing crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2933
diff
changeset
|
1004 dw_signal_connect(hwnd, DW_SIGNAL_HTML_RESULT, 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
|
1005 ResultConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1006 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1007 ResultConnected = false; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1008 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1009 } |
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
|
1010 static int _OnChanged(HWND window, int status, char *url, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1011 HTML *classptr = reinterpret_cast<HTML *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1012 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1013 if(classptr->_ConnectChanged) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1014 return classptr->_ConnectChanged(status, url); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1015 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1016 if(classptr->_ConnectChangedOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1017 return classptr->_ConnectChangedOld(classptr, status, url); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1018 return classptr->OnChanged(status, 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
|
1019 static int _OnResult(HWND window, int status, char *result, void *scriptdata, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1020 HTML *classptr = reinterpret_cast<HTML *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1021 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1022 if(classptr->_ConnectResult) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1023 return classptr->_ConnectResult(status, result, scriptdata); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1024 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1025 if(classptr->_ConnectResultOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1026 return classptr->_ConnectResultOld(classptr, status, result, scriptdata); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1027 return classptr->OnResult(status, result, scriptdata); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1028 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1029 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1030 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
|
1031 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
|
1032 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1033 // User functions |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1034 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
|
1035 int JavascriptRun(const char *script, void *scriptdata) { return dw_html_javascript_run(hwnd, script, scriptdata); } |
2932
3f660f47a45f
C++: Add HTML and ScrollBox pages to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2931
diff
changeset
|
1036 int JavascriptRun(const char *script) { return dw_html_javascript_run(hwnd, script, NULL); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1037 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
|
1038 int URL(const char *url) { return dw_html_url(hwnd, url); } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1039 #ifdef DW_LAMBDA |
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
|
1040 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
|
1041 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1042 _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
|
1043 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
|
1044 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
|
1045 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
|
1046 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1047 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1048 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1049 void ConnectChanged(int (*userfunc)(HTML *, int, char *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1050 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1051 _ConnectChangedOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1052 if(!ChangedConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1053 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1054 ChangedConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1055 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1056 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1057 #ifdef DW_LAMBDA |
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
|
1058 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
|
1059 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1060 _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
|
1061 if(!ResultConnected) { |
2936
75f6e21f5a02
C++: Connected the wrong signal for the HTML result, causing crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2933
diff
changeset
|
1062 dw_signal_connect(hwnd, DW_SIGNAL_HTML_RESULT, 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
|
1063 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
|
1064 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1065 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1066 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1067 void ConnectResult(int (*userfunc)(HTML *, int, char *, void *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1068 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1069 _ConnectResultOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1070 if(!ResultConnected) { |
2936
75f6e21f5a02
C++: Connected the wrong signal for the HTML result, causing crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2933
diff
changeset
|
1071 dw_signal_connect(hwnd, DW_SIGNAL_HTML_RESULT, DW_SIGNAL_FUNC(_OnResult), this); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1072 ResultConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1073 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1074 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1075 protected: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1076 // 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
|
1077 // 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
|
1078 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
|
1079 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
|
1080 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
|
1081 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
|
1082 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1083 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
|
1084 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
|
1085 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
|
1086 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
|
1087 }; |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1088 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1089 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1090 // 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
|
1091 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
|
1092 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1093 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1094 // 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
|
1095 void ClickDefault(Focusable *next) { if(next) dw_window_click_default(hwnd, next->GetHWND()); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1096 void SetLimit(int limit) { dw_entryfield_set_limit(hwnd, limit);} |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1097 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1098 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1099 class Entryfield : public TextEntry |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1100 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1101 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1102 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1108 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1109 class EntryfieldPassword : public TextEntry |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1110 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1111 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1112 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1113 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
|
1114 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
|
1115 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
|
1116 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
|
1117 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1118 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1119 // 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
|
1120 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
|
1121 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1122 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
|
1123 bool ListSelectConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1124 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1125 std::function<int(unsigned int)> _ConnectListSelect; |
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
|
1126 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1127 int (*_ConnectListSelectOld)(ListBoxes *, unsigned int index); |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1128 void Setup() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1129 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1130 _ConnectListSelect = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1131 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1132 _ConnectListSelectOld = 0; |
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
|
1133 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
|
1134 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
|
1135 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
|
1136 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1137 } |
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
|
1138 static int _OnListSelect(HWND window, int index, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1139 ListBoxes *classptr = reinterpret_cast<ListBoxes *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1140 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1141 if(classptr->_ConnectListSelect) |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1142 return classptr->_ConnectListSelect((unsigned int)index); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1143 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1144 if(classptr->_ConnectListSelectOld) |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1145 return classptr->_ConnectListSelectOld(classptr, (unsigned int)index); |
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1146 return classptr->OnListSelect((unsigned int)index); |
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
|
1147 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1148 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1149 // User functions |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1150 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
|
1151 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
|
1152 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
|
1153 void Delete(int index) { dw_listbox_delete(hwnd, index); } |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1154 void GetListText(unsigned int index, char *buffer, unsigned int length) { dw_listbox_get_text(hwnd, index, buffer, length); } |
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1155 void SetListText(unsigned int index, char *buffer) { dw_listbox_set_text(hwnd, index, buffer); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1156 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
|
1157 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
|
1158 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
|
1159 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
|
1160 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
|
1161 void SetTop(int top) { dw_listbox_set_top(hwnd, top); } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1162 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1163 void ConnectListSelect(std::function<int(unsigned int)> userfunc) |
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
|
1164 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1165 _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
|
1166 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
|
1167 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
|
1168 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
|
1169 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1170 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1171 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1172 void ConnectListSelect(int (*userfunc)(ListBoxes *, unsigned int)) |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1173 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1174 _ConnectListSelectOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1175 if(!ListSelectConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1176 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1177 ListSelectConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1178 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1179 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1180 protected: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1181 // 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
|
1182 // If they are not overridden and an event is generated, remove the unused handler |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1183 virtual int OnListSelect(unsigned int index) { |
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
|
1184 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
|
1185 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
|
1186 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
|
1187 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1188 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1189 |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1190 class ComboBox : public TextEntry, public ListBoxes |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1191 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1192 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1193 // Constructors |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1194 ComboBox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1195 ComboBox(unsigned long id) { SetHWND(dw_combobox_new("", id)); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1196 ComboBox(const char *text) { SetHWND(dw_combobox_new(text, 0)); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1197 ComboBox() { SetHWND(dw_combobox_new("", 0)); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1198 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1199 |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1200 class ListBox : public ListBoxes |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1201 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1202 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1203 // Constructors |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1204 ListBox(unsigned long id, int multi) { SetHWND(dw_listbox_new(id, multi)); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1205 ListBox(unsigned long id) { SetHWND(dw_listbox_new(id, FALSE)); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1206 ListBox(int multi) { SetHWND(dw_listbox_new(0, multi)); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1207 ListBox() { SetHWND(dw_listbox_new(0, FALSE)); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1208 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1209 |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1210 // 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
|
1211 class Ranged : virtual public Widget |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1212 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1213 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
|
1214 bool ValueChangedConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1215 #ifdef DW_LAMBDA |
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
|
1216 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
|
1217 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1218 int (*_ConnectValueChangedOld)(Ranged *, int value); |
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
|
1219 static int _OnValueChanged(HWND window, int value, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1220 Ranged *classptr = reinterpret_cast<Ranged *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1221 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1222 if(classptr->_ConnectValueChanged) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1223 return classptr->_ConnectValueChanged(value); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1224 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1225 if(classptr->_ConnectValueChangedOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1226 return classptr->_ConnectValueChangedOld(classptr, value); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1227 return classptr->OnValueChanged(value); |
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
|
1228 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1229 protected: |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1230 void Setup() { |
2924
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1231 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1232 _ConnectValueChanged = 0; |
2924
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1233 #endif |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1234 _ConnectValueChangedOld = 0; |
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
|
1235 if(IsOverridden(Ranged::OnValueChanged, this)) { |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1236 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
|
1237 ValueChangedConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1238 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1239 ValueChangedConnected = false; |
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
|
1240 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1241 } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1242 // 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
|
1243 // 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
|
1244 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
|
1245 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
|
1246 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
|
1247 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
|
1248 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1249 public: |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1250 #ifdef DW_LAMBDA |
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
|
1251 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
|
1252 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1253 _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
|
1254 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
|
1255 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
|
1256 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
|
1257 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1258 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1259 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1260 void ConnectValueChanged(int (*userfunc)(Ranged *, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1261 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1262 _ConnectValueChangedOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1263 if(!ValueChangedConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1264 dw_signal_connect(hwnd, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(_OnValueChanged), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1265 ValueChangedConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1266 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1267 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1268 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1269 |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1270 class Percent : public Widget |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1271 { |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1272 public: |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1273 // Constructors |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1274 Percent(unsigned long id) { SetHWND(dw_percent_new(id)); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1275 Percent() { SetHWND(dw_percent_new(0)); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1276 |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1277 // User functions |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1278 void SetPos(unsigned int position) { dw_percent_set_pos(hwnd, position); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1279 }; |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1280 |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1281 class Slider : public Ranged |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1282 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1283 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1284 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1285 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
|
1286 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
|
1287 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1288 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1289 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
|
1290 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
|
1291 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1292 |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1293 class ScrollBar : public Ranged |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1294 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1295 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1296 // Constructors |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1297 ScrollBar(int orient, unsigned long id) { SetHWND(dw_scrollbar_new(orient, id)); Setup(); } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1298 ScrollBar(int orient) { SetHWND(dw_scrollbar_new(orient, 0)); Setup(); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1299 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1300 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1301 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
|
1302 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
|
1303 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
|
1304 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1305 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1306 class SpinButton : public Ranged, public TextEntry |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1307 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1308 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1309 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1310 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
|
1311 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
|
1312 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
|
1313 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
|
1314 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1315 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1316 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
|
1317 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
|
1318 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
|
1319 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1320 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1321 // Multi-line Edit widget |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1322 class MLE : public Focusable |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1323 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1324 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1325 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1326 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
|
1327 MLE() { SetHWND(dw_mle_new(0)); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1328 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1329 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1330 void Freeze() { dw_mle_freeze(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1331 void Thaw() { dw_mle_thaw(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1332 void Clear() { dw_mle_clear(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1333 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
|
1334 void Export(char *buffer, int startpoint, int length) { dw_mle_export(hwnd, buffer, startpoint, length); } |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1335 int Import(const char *buffer, int startpoint) { return dw_mle_import(hwnd, buffer, startpoint); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1336 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
|
1337 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
|
1338 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
|
1339 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
|
1340 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
|
1341 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
|
1342 void SetWordWrap(int state) { dw_mle_set_word_wrap(hwnd, state); } |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1343 int SetFont(const char *font) { return dw_window_set_font(hwnd, font); } |
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1344 char *GetFont() { return dw_window_get_font(hwnd); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1345 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1346 |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1347 class Notebook : public Widget |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1348 { |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1349 private: |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1350 bool SwitchPageConnected; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1351 #ifdef DW_LAMBDA |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1352 std::function<int(unsigned long)> _ConnectSwitchPage; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1353 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1354 int (*_ConnectSwitchPageOld)(Notebook *, unsigned long); |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1355 static int _OnSwitchPage(HWND window, unsigned long pageid, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1356 Notebook *classptr = reinterpret_cast<Notebook *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1357 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1358 if(classptr->_ConnectSwitchPage) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1359 return classptr->_ConnectSwitchPage(pageid); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1360 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1361 if(classptr->_ConnectSwitchPageOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1362 return classptr->_ConnectSwitchPageOld(classptr, pageid); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1363 return classptr->OnSwitchPage(pageid); |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1364 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1365 protected: |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1366 void Setup() { |
2924
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1367 #ifdef DW_LAMBDA |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1368 _ConnectSwitchPage = 0; |
2924
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1369 #endif |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1370 _ConnectSwitchPageOld = 0; |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1371 if(IsOverridden(Notebook::OnSwitchPage, this)) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1372 dw_signal_connect(hwnd, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(_OnSwitchPage), this); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1373 SwitchPageConnected = true; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1374 } else { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1375 SwitchPageConnected = false; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1376 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1377 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1378 // Our signal handler functions to be overriden... |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1379 // If they are not overridden and an event is generated, remove the unused handler |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1380 virtual int OnSwitchPage(unsigned long pageid) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1381 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_SWITCH_PAGE); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1382 SwitchPageConnected = false; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1383 return FALSE; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1384 } |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1385 public: |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1386 // Constructors |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1387 Notebook(unsigned long id, int top) { SetHWND(dw_notebook_new(id, top)); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1388 Notebook(unsigned long id) { SetHWND(dw_notebook_new(id, TRUE)); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1389 Notebook() { SetHWND(dw_notebook_new(0, TRUE)); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1390 |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1391 // User functions |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1392 void Pack(unsigned long pageid, Widget *page) { dw_notebook_pack(hwnd, pageid, page ? page->GetHWND() : DW_NOHWND); } |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1393 void PageDestroy(unsigned long pageid) { dw_notebook_page_destroy(hwnd, pageid); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1394 unsigned long PageGet() { return dw_notebook_page_get(hwnd); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1395 unsigned long PageNew(unsigned long flags, int front) { return dw_notebook_page_new(hwnd, flags, front); } |
2920
c6b699a441fe
C++: Fix a couple minor errors while attempting to fix Mac crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2919
diff
changeset
|
1396 unsigned long PageNew(unsigned long flags) { return dw_notebook_page_new(hwnd, flags, FALSE); } |
c6b699a441fe
C++: Fix a couple minor errors while attempting to fix Mac crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2919
diff
changeset
|
1397 unsigned long PageNew() { return dw_notebook_page_new(hwnd, 0, FALSE); } |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1398 void PageSet(unsigned long pageid) { dw_notebook_page_set(hwnd, pageid); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1399 void PageSetStatusText(unsigned long pageid, const char *text) { dw_notebook_page_set_status_text(hwnd, pageid, text); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1400 void PageSetText(unsigned long pageid, const char *text) { dw_notebook_page_set_text(hwnd, pageid, text); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1401 #ifdef DW_LAMBDA |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1402 void ConnectSwitchPage(std::function<int(unsigned long)> userfunc) |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1403 { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1404 _ConnectSwitchPage = userfunc; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1405 if(!SwitchPageConnected) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1406 dw_signal_connect(hwnd, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(_OnSwitchPage), this); |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1407 SwitchPageConnected = true; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1408 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1409 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1410 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1411 void ConnectSwitchPage(int (*userfunc)(Notebook *, unsigned long)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1412 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1413 _ConnectSwitchPageOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1414 if(!SwitchPageConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1415 dw_signal_connect(hwnd, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(_OnSwitchPage), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1416 SwitchPageConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1417 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1418 } |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1419 }; |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1420 |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1421 class ObjectView : virtual public Widget |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1422 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1423 private: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1424 bool ItemSelectConnected, ItemContextConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1425 #ifdef DW_LAMBDA |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1426 std::function<int(HTREEITEM, char *, void *)> _ConnectItemSelect; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1427 std::function<int(char *, int, int, void *)> _ConnectItemContext; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1428 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1429 int (*_ConnectItemSelectOld)(ObjectView *, HTREEITEM, char *, void *); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1430 int (*_ConnectItemContextOld)(ObjectView *, char *, int, int, void *); |
2937
cacb6610abfc
C++: Fix incorrect parameter order in Container/Tree select causing crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2936
diff
changeset
|
1431 static int _OnItemSelect(HWND window, HTREEITEM item, char *text, void *data, void *itemdata) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1432 ObjectView *classptr = reinterpret_cast<ObjectView *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1433 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1434 if(classptr->_ConnectItemSelect) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1435 return classptr->_ConnectItemSelect(item, text, itemdata); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1436 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1437 if(classptr->_ConnectItemSelectOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1438 return classptr->_ConnectItemSelectOld(classptr, item, text, itemdata); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1439 return classptr->OnItemSelect(item, text, itemdata); |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1440 } |
2939
ebbc5b16899e
C++: Another couple fixes, context menus and PackAtIndex that got lost during porting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2938
diff
changeset
|
1441 static int _OnItemContext(HWND window, char *text, int x, int y, void *data, void *itemdata) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1442 ObjectView *classptr = reinterpret_cast<ObjectView *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1443 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1444 if(classptr->_ConnectItemContext) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1445 return classptr->_ConnectItemContext(text, x, y, itemdata); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1446 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1447 if(classptr->_ConnectItemContextOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1448 return classptr->_ConnectItemContextOld(classptr, text, x, y, itemdata); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1449 return classptr->OnItemContext(text, x, y, itemdata); |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1450 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1451 protected: |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1452 void SetupObjectView() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1453 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1454 _ConnectItemSelect = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1455 _ConnectItemContext = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1456 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1457 _ConnectItemSelectOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1458 _ConnectItemContextOld = 0; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1459 if(IsOverridden(ObjectView::OnItemSelect, this)) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1460 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1461 ItemSelectConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1462 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1463 ItemSelectConnected = false; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1464 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1465 if(IsOverridden(ObjectView::OnItemContext, this)) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1466 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1467 ItemContextConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1468 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1469 ItemContextConnected = false; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1470 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1471 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1472 // Our signal handler functions to be overriden... |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1473 // If they are not overridden and an event is generated, remove the unused handler |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1474 virtual int OnItemSelect(HTREEITEM item, char *text, void *itemdata) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1475 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_ITEM_SELECT); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1476 ItemSelectConnected = false; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1477 return FALSE; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1478 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1479 virtual int OnItemContext(char *text, int x, int y, void *itemdata) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1480 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_ITEM_CONTEXT); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1481 ItemContextConnected = false; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1482 return FALSE; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1483 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1484 public: |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1485 #ifdef DW_LAMBDA |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1486 void ConnectItemSelect(std::function<int(HTREEITEM, char *, void *)> userfunc) |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1487 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1488 _ConnectItemSelect = userfunc; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1489 if(!ItemSelectConnected) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1490 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1491 ItemSelectConnected = true; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1492 } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1493 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1494 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1495 void ConnectItemSelect(int (*userfunc)(ObjectView *, HTREEITEM, char *, void *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1496 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1497 _ConnectItemSelectOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1498 if(!ItemSelectConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1499 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1500 ItemSelectConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1501 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1502 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1503 #ifdef DW_LAMBDA |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1504 void ConnectItemContext(std::function<int(char *, int, int, void *)> userfunc) |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1505 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1506 _ConnectItemContext = userfunc; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1507 if(!ItemContextConnected) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1508 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1509 ItemContextConnected = true; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1510 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1511 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1512 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1513 void ConnectItemContext(int (*userfunc)(ObjectView *, char *, int, int, void *)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1514 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1515 _ConnectItemContextOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1516 if(!ItemContextConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1517 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1518 ItemContextConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1519 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1520 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1521 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1522 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1523 class Containers : virtual public Focusable, virtual public ObjectView |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1524 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1525 private: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1526 bool ItemEnterConnected, ColumnClickConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1527 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1528 std::function<int(char *, void *)> _ConnectItemEnter; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1529 std::function<int(int)> _ConnectColumnClick; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1530 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1531 int (*_ConnectItemEnterOld)(Containers *, char *, void *); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1532 int (*_ConnectColumnClickOld)(Containers *, int); |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1533 static int _OnItemEnter(HWND window, char *text, void *data, void *itemdata) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1534 Containers *classptr = reinterpret_cast<Containers *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1535 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1536 if(classptr->_ConnectItemEnter) |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1537 return classptr->_ConnectItemEnter(text, itemdata); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1538 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1539 if(classptr->_ConnectItemEnterOld) |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1540 return classptr->_ConnectItemEnterOld(classptr, text, itemdata); |
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1541 return classptr->OnItemEnter(text, itemdata); |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1542 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1543 static int _OnColumnClick(HWND window, int column, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1544 Containers *classptr = reinterpret_cast<Containers *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1545 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1546 if(classptr->_ConnectColumnClick) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1547 return classptr->_ConnectColumnClick(column); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1548 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1549 if(classptr->_ConnectColumnClickOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1550 return classptr->_ConnectColumnClickOld(classptr, column); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1551 return classptr->OnColumnClick(column); |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1552 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1553 protected: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1554 void *allocpointer; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1555 int allocrowcount; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1556 void SetupContainer() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1557 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1558 _ConnectItemEnter = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1559 _ConnectColumnClick = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1560 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1561 _ConnectItemEnterOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1562 _ConnectColumnClickOld = 0; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1563 if(IsOverridden(Container::OnItemEnter, this)) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1564 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1565 ItemEnterConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1566 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1567 ItemEnterConnected = false; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1568 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1569 if(IsOverridden(Container::OnColumnClick, this)) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1570 dw_signal_connect(hwnd, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(_OnColumnClick), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1571 ColumnClickConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1572 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1573 ColumnClickConnected = false; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1574 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1575 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1576 // Our signal handler functions to be overriden... |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1577 // If they are not overridden and an event is generated, remove the unused handler |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1578 virtual int OnItemEnter(char *text, void *itemdata) { |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1579 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_ITEM_ENTER); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1580 ItemEnterConnected = false; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1581 return FALSE; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1582 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1583 virtual int OnColumnClick(int column) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1584 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_COLUMN_CLICK); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1585 ColumnClickConnected = false; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1586 return FALSE; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1587 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1588 public: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1589 // User functions |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1590 void Alloc(int rowcount) { allocpointer = dw_container_alloc(hwnd, rowcount); allocrowcount = rowcount; } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1591 void ChangeRowTitle(int row, char *title) { dw_container_change_row_title(hwnd, row, title); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1592 void Clear(int redraw) { dw_container_clear(hwnd, redraw); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1593 void Clear() { dw_container_clear(hwnd, TRUE); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1594 void Cursor(const char *text) { dw_container_cursor(hwnd, text); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1595 void Cursor(void *data) { dw_container_cursor_by_data(hwnd, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1596 void Delete(int rowcount) { dw_container_delete(hwnd, rowcount); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1597 void DeleteRow(char *title) { dw_container_delete_row(hwnd, title); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1598 void DeleteRow(void *data) { dw_container_delete_row_by_data(hwnd, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1599 void Insert() { dw_container_insert(hwnd, allocpointer, allocrowcount); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1600 void Optimize() { dw_container_optimize(hwnd); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1601 char *QueryNext(unsigned long flags) { return dw_container_query_next(hwnd, flags); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1602 char *QueryStart(unsigned long flags) { return dw_container_query_start(hwnd, flags); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1603 void Scroll(int direction, long rows) { dw_container_scroll(hwnd, direction, rows); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1604 void SetColumnWidth(int column, int width) { dw_container_set_column_width(hwnd, column, width); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1605 void SetRowData(int row, void *data) { dw_container_set_row_data(allocpointer, row, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1606 void SetRowTitle(int row, const char *title) { dw_container_set_row_title(allocpointer, row, title); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1607 void SetStripe(unsigned long oddcolor, unsigned long evencolor) { dw_container_set_stripe(hwnd, oddcolor, evencolor); } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1608 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1609 void ConnectItemEnter(std::function<int(char *, void *)> userfunc) |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1610 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1611 _ConnectItemEnter = userfunc; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1612 if(!ItemEnterConnected) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1613 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1614 ItemEnterConnected = true; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1615 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1616 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1617 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1618 void ConnectItemEnter(int (*userfunc)(Containers *, char *, void *)) |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1619 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1620 _ConnectItemEnterOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1621 if(!ItemEnterConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1622 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1623 ItemEnterConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1624 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1625 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1626 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1627 void ConnectColumnClick(std::function<int(int)> userfunc) |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1628 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1629 _ConnectColumnClick = userfunc; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1630 if(!ColumnClickConnected) { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1631 dw_signal_connect(hwnd, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(_OnColumnClick), this); |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1632 ColumnClickConnected = true; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1633 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1634 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1635 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1636 void ConnectColumnClick(int (*userfunc)(Containers *, int)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1637 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1638 _ConnectColumnClickOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1639 if(!ColumnClickConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1640 dw_signal_connect(hwnd, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(_OnColumnClick), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1641 ColumnClickConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1642 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1643 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1644 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1645 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1646 class Container : public Containers |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1647 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1648 public: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1649 // Constructors |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1650 Container(unsigned long id, int multi) { SetHWND(dw_container_new(id, multi)); SetupObjectView(); SetupContainer(); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1651 Container(int multi) { SetHWND(dw_container_new(0, multi)); SetupObjectView(); SetupContainer(); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1652 Container() { SetHWND(dw_container_new(0, FALSE)); SetupObjectView(); SetupContainer(); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1653 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1654 // User functions |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1655 int Setup(unsigned long *flags, const char *titles[], int count, int separator) { return dw_container_setup(hwnd, flags, (char **)titles, count, separator); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1656 void ChangeItem(int column, int row, void *data) { dw_container_change_item(hwnd, column, row, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1657 int GetColumnType(int column) { return dw_container_get_column_type(hwnd, column); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1658 void SetItem(int column, int row, void *data) { dw_container_set_item(hwnd, allocpointer, column, row, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1659 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1660 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1661 class Filesystem : public Containers |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1662 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1663 public: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1664 // Constructors |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1665 Filesystem(unsigned long id, int multi) { SetHWND(dw_container_new(id, multi)); SetupObjectView(); SetupContainer(); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1666 Filesystem(int multi) { SetHWND(dw_container_new(0, multi)); SetupObjectView(); SetupContainer(); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1667 Filesystem() { SetHWND(dw_container_new(0, FALSE)); SetupObjectView(); SetupContainer(); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1668 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1669 // User functions |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1670 int Setup(unsigned long *flags, const char *titles[], int count) { return dw_filesystem_setup(hwnd, flags, (char **)titles, count); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1671 void ChangeFile(int row, const char *filename, HICN icon) { dw_filesystem_change_file(hwnd, row, filename, icon); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1672 void ChangeItem(int column, int row, void *data) { dw_filesystem_change_item(hwnd, column, row, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1673 int GetColumnType(int column) { return dw_filesystem_get_column_type(hwnd, column); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1674 void SetColumnTitle(const char *title) { dw_filesystem_set_column_title(hwnd, title); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1675 void SetFile(int row, const char *filename, HICN icon) { dw_filesystem_set_file(hwnd, allocpointer, row, filename, icon); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1676 void SetItem(int column, int row, void *data) { dw_filesystem_set_item(hwnd, allocpointer, column, row, data); } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1677 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1678 |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1679 class Tree : virtual public Focusable, virtual public ObjectView |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1680 { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1681 private: |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1682 bool TreeExpandConnected; |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1683 #ifdef DW_LAMBDA |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1684 std::function<int(HTREEITEM)> _ConnectTreeExpand; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1685 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1686 int (*_ConnectTreeExpandOld)(Tree *, HTREEITEM); |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1687 static int _OnTreeExpand(HWND window, HTREEITEM item, void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1688 Tree *classptr = reinterpret_cast<Tree *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1689 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1690 if(classptr->_ConnectTreeExpand) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1691 return classptr->_ConnectTreeExpand(item); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1692 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1693 if(classptr->_ConnectTreeExpandOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1694 return classptr->_ConnectTreeExpandOld(classptr, item); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1695 return classptr->OnTreeExpand(item); |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1696 } |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1697 void SetupTree() { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1698 #ifdef DW_LAMBDA |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1699 _ConnectTreeExpand = 0; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1700 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1701 _ConnectTreeExpandOld = 0; |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1702 if(IsOverridden(Tree::OnTreeExpand, this)) { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1703 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1704 TreeExpandConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1705 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1706 TreeExpandConnected = false; |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1707 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1708 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1709 protected: |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1710 // Our signal handler functions to be overriden... |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1711 // If they are not overridden and an event is generated, remove the unused handler |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1712 virtual int OnTreeExpand(HTREEITEM item) { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1713 dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_TREE_EXPAND); |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1714 TreeExpandConnected = false; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1715 return FALSE; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1716 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1717 public: |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1718 // Constructors |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1719 Tree(unsigned long id) { SetHWND(dw_tree_new(id)); SetupObjectView(); SetupTree(); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1720 Tree() { SetHWND(dw_tree_new(0)); SetupObjectView(); SetupTree(); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1721 |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1722 // User functions |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1723 void Clear() { dw_tree_clear(hwnd); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1724 HTREEITEM GetParent(HTREEITEM item) { return dw_tree_get_parent(hwnd, item); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1725 char *GetTitle(HTREEITEM item) { return dw_tree_get_title(hwnd, item); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1726 HTREEITEM Insert(const char *title, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert(hwnd, title, icon, parent, itemdata); } |
2929
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
1727 HTREEITEM Insert(const char *title, HICN icon, HTREEITEM parent) { return dw_tree_insert(hwnd, title, icon, parent, NULL); } |
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
1728 HTREEITEM Insert(const char *title, HICN icon) { return dw_tree_insert(hwnd, title, icon, 0, NULL); } |
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
1729 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert_after(hwnd, item, title, icon, parent, itemdata); } |
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
1730 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon, HTREEITEM parent) { return dw_tree_insert_after(hwnd, item, title, icon, parent, NULL); } |
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
1731 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon) { return dw_tree_insert_after(hwnd, item, title, icon, 0, NULL); } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1732 void Change(HTREEITEM item, const char *title, HICN icon) { dw_tree_item_change(hwnd, item, title, icon); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1733 void Collapse(HTREEITEM item) { dw_tree_item_collapse(hwnd, item); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1734 void Delete(HTREEITEM item) { dw_tree_item_delete(hwnd, item); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1735 void Expand(HTREEITEM item) { dw_tree_item_expand(hwnd, item); } |
2896
d91aaffca1fc
C++: Fix missing return in DW::Tree::GetData().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2895
diff
changeset
|
1736 void *GetData(HTREEITEM item) { return dw_tree_item_get_data(hwnd, item); } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1737 void Select(HTREEITEM item) { dw_tree_item_select(hwnd, item); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1738 void SetData(HTREEITEM item, void *itemdata) { dw_tree_item_set_data(hwnd, item, itemdata); } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1739 #ifdef DW_LAMBDA |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1740 void ConnectTreeExpand(std::function<int(HTREEITEM)> userfunc) |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1741 { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1742 _ConnectTreeExpand = userfunc; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1743 if(!TreeExpandConnected) { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1744 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1745 TreeExpandConnected = true; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1746 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1747 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1748 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1749 void ConnectTreeExpandOld(int (*userfunc)(Tree *, HTREEITEM)) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1750 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1751 _ConnectTreeExpandOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1752 if(!TreeExpandConnected) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1753 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1754 TreeExpandConnected = true; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1755 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1756 } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1757 }; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1758 |
2899
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1759 class SplitBar : public Widget |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1760 { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1761 public: |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1762 // Constructors |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1763 SplitBar(int orient, Widget *topleft, Widget *bottomright, unsigned long id) { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1764 SetHWND(dw_splitbar_new(orient, topleft ? topleft->GetHWND() : DW_NOHWND, bottomright ? bottomright->GetHWND() : DW_NOHWND, id)); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1765 SplitBar(int orient, Widget *topleft, Widget *bottomright) { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1766 SetHWND(dw_splitbar_new(orient, topleft ? topleft->GetHWND() : DW_NOHWND, bottomright ? bottomright->GetHWND() : DW_NOHWND, 0)); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1767 |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1768 // User functions |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1769 float Get() { return dw_splitbar_get(hwnd); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1770 void Set(float percent) { dw_splitbar_set(hwnd, percent); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1771 }; |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1772 |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1773 class Dialog : public Handle |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1774 { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1775 private: |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1776 DWDialog *dialog; |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1777 public: |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1778 // Constructors |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1779 Dialog(void *data) { dialog = dw_dialog_new(data); SetHandle(reinterpret_cast<void *>(dialog)); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1780 Dialog() { dialog = dw_dialog_new(DW_NULL); SetHandle(reinterpret_cast<void *>(dialog)); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1781 |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1782 // User functions |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1783 void *Wait() { void *retval = dw_dialog_wait(dialog); delete this; return retval; } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1784 int Dismiss(void *data) { return dw_dialog_dismiss(dialog, data); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1785 int Dismiss() { return dw_dialog_dismiss(dialog, NULL); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
1786 }; |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
1787 |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1788 class Mutex : public Handle |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1789 { |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1790 private: |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1791 HMTX mutex; |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1792 public: |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1793 // Constructors |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1794 Mutex() { mutex = dw_mutex_new(); SetHandle(reinterpret_cast<void *>(mutex)); } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1795 // Destructor |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1796 ~Mutex() { dw_mutex_close(mutex); mutex = 0; } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1797 |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1798 // User functions |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1799 void Close() { dw_mutex_close(mutex); mutex = 0; delete this; } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1800 void Lock() { dw_mutex_lock(mutex); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1801 int TryLock() { return dw_mutex_trylock(mutex); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1802 void Unlock() { dw_mutex_unlock(mutex); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1803 }; |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1804 |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1805 class Event : public Handle |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1806 { |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1807 private: |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1808 HEV event, named; |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1809 public: |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1810 // Constructors |
2913
6981feb6210b
C++/OS2: HEV is not a pointer type on OS/2, use 0 instead.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2912
diff
changeset
|
1811 Event() { event = dw_event_new(); named = 0; SetHandle(reinterpret_cast<void *>(event)); } |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1812 Event(const char *name) { |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1813 // Try to attach to an existing event |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1814 named = dw_named_event_get(name); |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1815 if(!named) { |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1816 // Otherwise try to create a new one |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1817 named = dw_named_event_new(name); |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1818 } |
2913
6981feb6210b
C++/OS2: HEV is not a pointer type on OS/2, use 0 instead.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2912
diff
changeset
|
1819 event = 0; |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1820 SetHandle(reinterpret_cast<void *>(named)); |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1821 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1822 // Destructor |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1823 virtual ~Event() { if(event) { dw_event_close(&event); } if(named) { dw_named_event_close(named); } } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1824 |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1825 // User functions |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1826 int Close() { |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1827 int retval = DW_ERROR_UNKNOWN; |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1828 |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1829 if(event) { |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1830 retval = dw_event_close(&event); |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1831 } else if(named) { |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1832 retval = dw_named_event_close(named); |
2913
6981feb6210b
C++/OS2: HEV is not a pointer type on OS/2, use 0 instead.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2912
diff
changeset
|
1833 named = 0; |
2908
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1834 } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1835 delete this; |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1836 return retval; |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1837 } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1838 int Post() { return (named ? dw_named_event_post(named) : dw_event_post(event)); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1839 int Reset() { return (named ? dw_named_event_reset(named) : dw_event_reset(event)); } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1840 int Wait(unsigned long timeout) { return (named ? dw_named_event_wait(named, timeout) : dw_event_wait(event, timeout)); } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1841 }; |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
1842 |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1843 class Timer : public Handle |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1844 { |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1845 private: |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1846 HTIMER timer; |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1847 #ifdef DW_LAMBDA |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1848 std::function<int()> _ConnectTimer; |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1849 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1850 int (*_ConnectTimerOld)(Timer *); |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1851 static int _OnTimer(void *data) { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1852 Timer *classptr = reinterpret_cast<Timer *>(data); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1853 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1854 if(classptr->_ConnectTimer) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1855 return classptr->_ConnectTimer(); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1856 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1857 if(classptr->_ConnectTimerOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1858 return classptr->_ConnectTimerOld(classptr); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1859 return classptr->OnTimer(); |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1860 } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1861 public: |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1862 // Constructors |
2924
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1863 Timer(int interval) { |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1864 #ifdef DW_LAMBDA |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1865 _ConnectTimer = 0; |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1866 #endif |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1867 _ConnectTimerOld = 0; |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1868 timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1869 SetHandle(reinterpret_cast<void *>(timer)); |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1870 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1871 #ifdef DW_LAMBDA |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1872 Timer(int interval, std::function<int()> userfunc) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1873 _ConnectTimer = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1874 _ConnectTimerOld = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1875 timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1876 SetHandle(reinterpret_cast<void *>(timer)); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1877 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1878 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1879 Timer(int interval, int (*userfunc)(Timer *)) { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1880 _ConnectTimerOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1881 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1882 _ConnectTimer = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1883 #endif |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1884 timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1885 SetHandle(reinterpret_cast<void *>(timer)); |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1886 } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1887 // Destructor |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1888 virtual ~Timer() { if(timer) { dw_timer_disconnect(timer); timer = 0; } } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1889 |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1890 // User functions |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1891 HTIMER GetHTIMER() { return timer; } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1892 void Disconnect() { if(timer) { dw_timer_disconnect(timer); timer = 0; } delete this; } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1893 protected: |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1894 // Our signal handler functions to be overriden... |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1895 // If they are not overridden and an event is generated, remove the unused handler |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1896 virtual int OnTimer() { |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1897 if(timer) |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1898 dw_timer_disconnect(timer); |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1899 delete this; |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1900 return FALSE; |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1901 } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1902 }; |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
1903 |
2916
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1904 class Notification final : public Clickable |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1905 { |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1906 public: |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1907 // Constructors |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1908 Notification(const char *title, const char *imagepath, const char *description) { SetHWND(dw_notification_new(title, imagepath, description)); } |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1909 Notification(const char *title, const char *imagepath) { SetHWND(dw_notification_new(title, imagepath, NULL)); } |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1910 Notification(const char *title) { SetHWND(dw_notification_new(title, NULL, NULL)); } |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1911 |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1912 // User functions |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1913 int Send() { int retval = dw_notification_send(hwnd); delete this; return retval; } |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1914 }; |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
1915 |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1916 class Print : public Handle |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1917 { |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1918 private: |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1919 HPRINT print; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1920 #ifdef DW_LAMBDA |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1921 std::function<int(Pixmap *, int)> _ConnectDrawPage; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1922 #endif |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1923 int (*_ConnectDrawPageOld)(Print *, Pixmap *, int); |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1924 static int _OnDrawPage(HPRINT print, HPIXMAP hpm, int page_num, void *data) { |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1925 int retval; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1926 Pixmap *pixmap = new Pixmap(hpm); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1927 Print *classptr = reinterpret_cast<Print *>(data); |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1928 |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1929 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1930 if(classptr->_ConnectDrawPage) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1931 retval = classptr->_ConnectDrawPage(pixmap, page_num); |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1932 else |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1933 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1934 if(classptr->_ConnectDrawPageOld) |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1935 retval = classptr->_ConnectDrawPageOld(classptr, pixmap, page_num); |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1936 else |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1937 retval = classptr->OnDrawPage(pixmap, page_num); |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1938 |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1939 delete pixmap; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1940 return retval; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1941 } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1942 public: |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1943 // Constructors |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1944 #ifdef DW_LAMBDA |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1945 Print(const char *jobname, unsigned long flags, unsigned int pages, std::function<int(Pixmap *, int)> userfunc) { |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1946 print = dw_print_new(jobname, flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1947 SetHandle(reinterpret_cast<void *>(print)); |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1948 _ConnectDrawPage = userfunc; |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1949 _ConnectDrawPageOld = 0; |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1950 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1951 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1952 Print(const char *jobname, unsigned long flags, unsigned int pages, int (*userfunc)(Print *, Pixmap *, int)) { |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1953 print = dw_print_new(jobname, flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1954 SetHandle(reinterpret_cast<void *>(print)); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1955 _ConnectDrawPageOld = userfunc; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1956 #ifdef DW_LAMBDA |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1957 _ConnectDrawPage = 0; |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1958 #endif |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1959 } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1960 // Destructor |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1961 virtual ~Print() { if(print) dw_print_cancel(print); print = 0; } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1962 |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1963 // User functions |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1964 void Cancel() { dw_print_cancel(print); delete this; } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1965 int Run(unsigned long flags) { int retval = dw_print_run(print, flags); delete this; return retval; } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1966 HPRINT GetHPRINT() { return print; } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1967 protected: |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1968 // Our signal handler functions to be overriden... |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1969 // If they are not overridden and an event is generated, remove the unused handler |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1970 virtual int OnDrawPage(Pixmap *pixmap, int page_num) { |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1971 if(print) |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1972 dw_print_cancel(print); |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1973 delete this; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1974 return FALSE; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1975 } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1976 }; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1977 |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1978 class Thread : public Handle |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1979 { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1980 private: |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1981 DWTID tid; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1982 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1983 std::function<void(Thread *)> _ConnectThread; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1984 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1985 void (*_ConnectThreadOld)(Thread *); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1986 static void _OnThread(void *data) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1987 Thread *classptr = reinterpret_cast<Thread *>(data); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1988 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1989 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1990 if(classptr->_ConnectThread) |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1991 classptr->_ConnectThread(classptr); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1992 else |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1993 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1994 if(classptr->_ConnectThreadOld) |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1995 classptr->_ConnectThreadOld(classptr); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1996 else |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1997 classptr->OnThread(classptr); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1998 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
1999 delete classptr; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2000 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2001 public: |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2002 // Constructors |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2003 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2004 Thread(std::function<void(Thread *)> userfunc) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2005 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, THREAD_STACK); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2006 SetHandle(reinterpret_cast<void *>(tid)); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2007 _ConnectThread = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2008 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2009 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2010 Thread(std::function<void(Thread *)> userfunc, int stack) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2011 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, stack); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2012 SetHandle(reinterpret_cast<void *>(tid)); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2013 _ConnectThread = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2014 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2015 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2016 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2017 Thread(void (*userfunc)(Thread *)) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2018 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, THREAD_STACK); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2019 SetHandle(reinterpret_cast<void *>(tid)); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2020 _ConnectThreadOld = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2021 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2022 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2023 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2024 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2025 Thread(void (*userfunc)(Thread *), int stack) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2026 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, stack); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2027 SetHandle(reinterpret_cast<void *>(tid)); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2028 _ConnectThreadOld = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2029 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2030 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2031 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2032 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2033 Thread(int stack) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2034 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, stack); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2035 SetHandle(reinterpret_cast<void *>(tid)); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2036 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2037 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2038 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2039 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2040 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2041 Thread() { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2042 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, THREAD_STACK); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2043 SetHandle(reinterpret_cast<void *>(tid)); |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2044 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2045 #ifdef DW_LAMBDA |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2046 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2047 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2048 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2049 // Destructor |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2050 virtual ~Thread() { if(tid != 0 && dw_thread_id() == tid) dw_thread_end(); tid = 0; } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2051 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2052 // User functions |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2053 void End() { if(tid != 0 && dw_thread_id() == tid) delete this; } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2054 DWTID GetTID() { return tid; } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2055 protected: |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2056 // Our signal handler functions to be overriden... |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2057 // If they are not overridden and an event is generated, remove the unused handler |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2058 virtual void OnThread(Thread *classptr) { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2059 delete this; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2060 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2061 }; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2062 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2063 class App |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2064 { |
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
|
2065 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2066 App() { } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2067 static App *_app; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2068 public: |
2870
7b4e30c19757
C++: Disable singleton safety code for non C++11 compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2869
diff
changeset
|
2069 // 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
|
2070 #ifdef DW_CPP11 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2071 // 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
|
2072 App(App &other) = delete; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2073 // 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
|
2074 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
|
2075 #endif |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2076 // 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
|
2077 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
|
2078 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
|
2079 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
|
2080 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
|
2081 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
|
2082 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; } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2083 // Destrouctor |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2084 ~App() { dw_exit(0); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2085 |
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
|
2086 // User functions |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2087 void Main() { dw_main(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2088 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
|
2089 void MainQuit() { dw_main_quit(); } |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2090 void MainSleep(int milliseconds) { dw_main_sleep(milliseconds); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2091 void Exit(int exitcode) { dw_exit(exitcode); } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2092 void Shutdown() { dw_shutdown(); } |
2901
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2093 int MessageBox(const char *title, int flags, const char *format, ...) { |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2094 int retval; |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2095 va_list args; |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2096 |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2097 va_start(args, format); |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2098 retval = dw_vmessagebox(title, flags, format, args); |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2099 va_end(args); |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2100 |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2101 return retval; |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2102 } |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2103 void Debug(const char *format, ...) { |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2104 va_list args; |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2105 |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2106 va_start(args, format); |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2107 dw_vdebug(format, args); |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2108 va_end(args); |
761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2900
diff
changeset
|
2109 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2110 void Beep(int freq, int dur) { dw_beep(freq, dur); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2111 char *GetDir() { return dw_app_dir(); } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2112 void GetEnvironment(DWEnv *env) { dw_environment_query(env); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2113 int GetScreenWidth() { return dw_screen_width(); } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2114 int GetScreenHeight() { return dw_screen_height(); } |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
2115 void GetPointerPos(long *x, long *y) { dw_pointer_query_pos(x, y); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2116 unsigned long GetColorDepth() { return dw_color_depth_get(); } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2117 char *GetClipboard() { return dw_clipboard_get_text(); } |
2912
08fcbd5fa069
C++: Fix a warning and implement a few features in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2911
diff
changeset
|
2118 void SetClipboard(const char *text) { if(text) dw_clipboard_set_text(text, (int)strlen(text)); } |
08fcbd5fa069
C++: Fix a warning and implement a few features in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2911
diff
changeset
|
2119 void SetClipboard(const char *text, int len) { if(text) dw_clipboard_set_text(text, len); } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2120 void SetDefaultFont(const char *fontname) { dw_font_set_default(fontname); } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2121 unsigned long ColorChoose(unsigned long initial) { return dw_color_choose(initial); } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2122 char *FileBrowse(const char *title, const char *defpath, const char *ext, int flags) { return dw_file_browse(title, defpath, ext, flags); } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2123 char *FontChoose(const char *currfont) { return dw_font_choose(currfont); } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2124 void Free(void *buff) { dw_free(buff); } |
2912
08fcbd5fa069
C++: Fix a warning and implement a few features in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2911
diff
changeset
|
2125 int GetFeature(DWFEATURE feature) { return dw_feature_get(feature); } |
08fcbd5fa069
C++: Fix a warning and implement a few features in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2911
diff
changeset
|
2126 int SetFeature(DWFEATURE feature, int state) { return dw_feature_set(feature, state); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2127 HICN LoadIcon(unsigned long id) { return dw_icon_load(0, id); } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2128 HICN LoadIcon(const char *filename) { return dw_icon_load_from_file(filename); } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2129 HICN LoadIcon(const char *data, int len) { return dw_icon_load_from_data(data, len); } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2130 void FreeIcon(HICN icon) { dw_icon_free(icon); } |
2919
e609aa6a5b93
C++: Attempt to implement page 2 rendering...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2917
diff
changeset
|
2131 void TaskBarInsert(Widget *handle, HICN icon, const char *bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext); } |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
2132 void TaskBarDelete(Widget *handle, HICN icon) { dw_taskbar_delete(handle ? handle->GetHWND() : DW_NOHWND, icon); } |
2938
1184f58135ba
C++: Eliminate remnants of C code I missed while porting to C++.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2937
diff
changeset
|
2133 char * WideToUTF8(const wchar_t * wstring) { return dw_wchar_to_utf8(wstring); } |
1184f58135ba
C++: Eliminate remnants of C code I missed while porting to C++.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2937
diff
changeset
|
2134 wchar_t *UTF8ToWide(const char * utf8string) { return dw_utf8_to_wchar(utf8string); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2135 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2136 |
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
|
2137 // 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
|
2138 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
|
2139 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2140 } /* namespace DW */ |
2936
75f6e21f5a02
C++: Connected the wrong signal for the HTML result, causing crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2933
diff
changeset
|
2141 #endif |