Mercurial > dwindows
annotate dw.hpp @ 2961:b9bd130f438a
C++: Step 3 of the std::string transition.
Convert the class overrides to use std::string instead of char*.
Implement functions that take arrays of strings to std::vector<std::string>.
Begin converting dwtestoo to use std::string instead of C style strings.
Temporarily rename C style Connect functions to have a C at the end.
It isn't clear to me why, but clang is telling me they are ambiguous.
Even though the lambda explicitly specifies std::string it can't decide
between the std::string or char* versions of the functions.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 23 Feb 2023 15:24:36 +0000 |
parents | 1dabe9c6c67b |
children | e6072eb914ce |
rev | line source |
---|---|
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1 // Dynamic Windows C++ Language Bindings |
2947
edb4307ac7ce
Update copyright date, readme, license and changelog for upcoming release.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2941
diff
changeset
|
2 // Copyright (C) 2022-2023 Brian Smith |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
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 #ifndef _HPP_DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6 #define _HPP_DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 #include <dw.h> |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
8 #include <cstring> |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
9 #include <string> |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
10 #include <vector> |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
11 |
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
|
12 // 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
|
13 #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
|
14 #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
|
15 #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
|
16 #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
|
17 #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
|
18 #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
|
19 |
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
|
20 // 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
|
21 #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
|
22 (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
|
23 #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
|
24 #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
|
25 #endif |
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
26 |
2873
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
27 // Attempt to allow compilation on GCC older than 4.7 |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
28 #if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)) |
2873
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
29 #define override |
2926
5b584c5ddc96
C++: GCC before 4.7 also doesn't support final.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2925
diff
changeset
|
30 #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
|
31 #endif |
0bbfb19022e7
C++: GCC prior to 4.7 does not support the override keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2872
diff
changeset
|
32 |
2925
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
33 // 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
|
34 #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
|
35 #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
|
36 #endif |
32bd25b05918
C++: Fix MSVC older than 2012 which does not support final keyword.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2924
diff
changeset
|
37 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
38 namespace DW |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
39 { |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
40 |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
41 #define _DW_THREAD_STACK 10000 |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
42 |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
43 // Macro to convert an allocated C string buffer to std::string, free the buffer and return the std::string |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
44 #define _dw_string_free_return(a) std::string utf8string = a ? std::string(a) : std::string(); if(a) dw_free(a); return utf8string; |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
45 |
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
|
46 // 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
|
47 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
|
48 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
|
49 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
|
50 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
|
51 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
52 // 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
|
53 // The base system handles |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
54 class Handle |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
55 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
56 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
57 void *handle; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
58 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
|
59 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
60 void *GetHandle() { return handle; } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
61 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
62 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
63 // Widget class allows packing and style |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
64 class Widget : public Handle |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
65 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
66 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
67 void SetHWND(HWND newhwnd) { |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
68 hwnd = newhwnd; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
69 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
|
70 // 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
|
71 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
|
72 } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
73 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
|
74 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
75 HWND GetHWND() { return hwnd; } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
76 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
|
77 Widget *FromID(int id) { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
78 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
|
79 if(child) { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
80 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
|
81 } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
82 return DW_NULL; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
83 } |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
84 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
|
85 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
|
86 void SetData(const char *dataname, void *data) { dw_window_set_data(hwnd, dataname, data); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
87 void SetData(std::string dataname, void *data) { dw_window_set_data(hwnd, dataname.c_str(), data); } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
88 void *GetData(const char *dataname) { return dw_window_get_data(hwnd, dataname); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
89 void *GetData(std::string dataname) { return dw_window_get_data(hwnd, dataname.c_str()); } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
90 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
|
91 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
|
92 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
|
93 void SetTooltip(const char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
94 void SetTooltip(std::string bubbletext) { dw_window_set_tooltip(hwnd, bubbletext.c_str()); } |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
95 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
|
96 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
97 |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
98 // 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
|
99 class Boxes : virtual public Widget |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
100 { |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
101 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
102 // User functions |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
119 }; |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
120 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
121 class Box : public Boxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
122 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
123 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
124 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
125 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
|
126 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
|
127 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
128 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
129 // Special scrollable box |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
130 class ScrollBox : public Boxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
131 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
132 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
133 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
134 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
|
135 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
|
136 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
137 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
138 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
|
139 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
|
140 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
141 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
142 // 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
|
143 // 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
|
144 #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
|
145 |
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
|
146 // 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
|
147 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
|
148 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
149 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
|
150 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
|
151 #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
|
152 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
|
153 #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
|
154 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
|
155 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
|
156 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
|
157 #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
|
158 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
|
159 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
|
160 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 protected: |
2929
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
165 virtual ~Clickable() {} |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
166 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
|
167 #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
|
168 _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
|
169 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
170 _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
|
171 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
|
172 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
|
173 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
|
174 } |
2911
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
175 else { |
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
176 ClickedConnected = false; |
f27fe14eef82
C++: MenuItem constructors need to call Setup() and Clickable::ClickedConnected may
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2908
diff
changeset
|
177 } |
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
|
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 // 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
|
180 // 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 } |
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 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
|
187 #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
|
188 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
|
189 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
190 _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
|
191 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
|
192 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
|
193 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
|
194 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
195 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
196 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
197 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
|
198 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
199 _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
|
200 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
|
201 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
|
202 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
|
203 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
204 } |
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
|
205 }; |
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 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
|
208 { |
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 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
|
210 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
|
211 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
|
212 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
|
213 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
214 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
|
215 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
|
216 // 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 MenuItem *AppendItem(const char *title); |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
223 MenuItem *AppendItem(std::string title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
224 MenuItem *AppendItem(std::string title, unsigned long flags, int check, Menus *submenu); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
225 MenuItem *AppendItem(std::string title, unsigned long flags, int check); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
226 MenuItem *AppendItem(std::string title, Menus *submenu); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
227 MenuItem *AppendItem(std::string 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
|
228 }; |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
229 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
230 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
|
231 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
232 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
|
233 // 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
|
234 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
|
235 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
|
236 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
237 // 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
|
238 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
|
239 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
|
240 }; |
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
|
241 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
242 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
|
243 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
244 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
|
245 // 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
|
246 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
|
247 }; |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
248 |
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
|
249 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
|
250 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
251 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
|
252 // 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
|
253 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
|
254 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
|
255 } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
256 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
|
257 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
|
258 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
259 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
|
260 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
|
261 } |
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
|
262 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
|
263 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
|
264 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
265 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
|
266 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
|
267 } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
268 MenuItem(Menus *menu, std::string title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
269 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), id, flags, end, check, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
270 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
271 MenuItem(Menus *menu, std::string title, unsigned long flags, int check, Menus *submenu) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
272 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, flags, TRUE, check, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
273 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
274 MenuItem(Menus *menu, std::string title, unsigned long flags, int check) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
275 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, flags, TRUE, check, DW_NOMENU)); Setup(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
276 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
277 MenuItem(Menus *menu, std::string title, Menus *submenu) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
278 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, 0, TRUE, FALSE, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
279 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
280 MenuItem(Menus *menu, std::string title) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
281 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, 0, TRUE, FALSE, DW_NOMENU)); Setup(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
282 } |
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
|
283 |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
284 // 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
|
285 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
|
286 }; |
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 |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
288 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
|
289 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
|
290 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
291 |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
292 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
|
293 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
|
294 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
295 |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
296 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
|
297 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
|
298 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
299 |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
300 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
|
301 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
|
302 } |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
303 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
|
304 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
|
305 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
306 |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
307 MenuItem *Menus::AppendItem(std::string title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
308 return new MenuItem(this, title.c_str(), id, flags, end, check, submenu); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
309 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
310 |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
311 MenuItem *Menus::AppendItem(std::string title, unsigned long flags, int check, Menus *submenu) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
312 return new MenuItem(this, title.c_str(), flags, check, submenu); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
313 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
314 |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
315 MenuItem *Menus::AppendItem(std::string title, unsigned long flags, int check) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
316 return new MenuItem(this, title.c_str(), flags, check); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
317 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
318 |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
319 MenuItem *Menus::AppendItem(std::string title, Menus *submenu) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
320 return new MenuItem(this, title.c_str(), submenu); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
321 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
322 MenuItem *Menus::AppendItem(std::string title) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
323 return new MenuItem(this, title.c_str()); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
324 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
325 |
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
|
326 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
327 // 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
|
328 class Window : public Boxes |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
329 { |
2865
fd32dce7fecd
Initial signal handler support for the C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2861
diff
changeset
|
330 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
|
331 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
|
332 #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
|
333 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
|
334 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
|
335 #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
|
336 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
|
337 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
|
338 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
|
339 #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
|
340 _ConnectDelete = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
341 _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
|
342 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
343 _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
|
344 _ConnectConfigureOld = 0; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
345 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
|
346 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
|
347 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
|
348 DeleteConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
349 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
350 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
|
351 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
352 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
|
353 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
|
354 ConfigureConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
355 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
356 ConfigureConnected = false; |
2906
9d6280f206bd
Minor code cleanups in the template and C++ bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2905
diff
changeset
|
357 } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
358 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
359 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
|
360 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
|
361 #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
|
362 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
|
363 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
|
364 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
365 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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 #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
|
371 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
|
372 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
|
373 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
374 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
|
375 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
|
376 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
|
377 MenuBar *menu; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
378 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
379 // Constructors |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
380 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
|
381 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
382 Window(HWND owner, std::string title, unsigned long style) { SetHWND(dw_window_new(owner, title.c_str(), style)); Setup(); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
383 Window(std::string title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title.c_str(), style)); Setup(); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
384 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
|
385 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
|
386 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
387 Window(std::string title) { SetHWND(dw_window_new(HWND_DESKTOP, title.c_str(), DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
388 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
|
389 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
|
390 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
|
391 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
392 // User functions |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
393 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
394 void SetText(std::string text) { dw_window_set_text(hwnd, text.c_str()); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
395 char *GetCText() { return dw_window_get_text(hwnd); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
396 std::string GetText() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
397 char *retval = dw_window_get_text(hwnd); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
398 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
399 } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 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
|
413 if(menu) { |
2890
ab4c86ddc63a
C++: Fix a logic error reported by MSVC 2022.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2889
diff
changeset
|
414 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
|
415 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
416 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
|
417 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
|
418 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
419 } |
2889
4b075e64536c
C++: Add some simple menu code to see if things are working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2885
diff
changeset
|
420 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
|
421 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
|
422 long x, y; |
2890
ab4c86ddc63a
C++: Fix a logic error reported by MSVC 2022.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2889
diff
changeset
|
423 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
|
424 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
425 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
|
426 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
|
427 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
|
428 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
429 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
430 #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
|
431 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
|
432 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
433 _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
|
434 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
|
435 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
|
436 DeleteConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
437 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
438 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
|
439 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
440 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
441 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
442 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
|
443 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
444 _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
|
445 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
|
446 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
|
447 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
|
448 } else { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
449 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
|
450 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
451 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
452 #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
|
453 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
|
454 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
455 _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
|
456 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
|
457 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
|
458 ConfigureConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
459 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
460 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
|
461 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
462 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
463 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
464 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
|
465 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
466 _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
|
467 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
|
468 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
|
469 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
|
470 } else { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
471 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
|
472 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
473 } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
474 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
475 // 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
|
476 // 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
|
477 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
|
478 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
|
479 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
|
480 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
|
481 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
482 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
|
483 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
|
484 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
|
485 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
|
486 }; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
487 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
488 |
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
|
489 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
|
490 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
491 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
|
492 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
493 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
|
494 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
495 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
|
496 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
|
497 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
498 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
499 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
500 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
|
501 { |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
502 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
|
503 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
|
504 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
|
505 |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
506 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
|
507 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
|
508 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
|
509 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
510 } |
df1b7f7d1703
C++: Finish up the menu classes, not sure if this is ideal yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2884
diff
changeset
|
511 |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
512 // Class for focusable widgets |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
513 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
|
514 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
515 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
516 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
|
517 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
|
518 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
|
519 }; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
520 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
521 // 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
|
522 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
|
523 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
524 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
525 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
526 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
527 void SetText(std::string text) { dw_window_set_text(hwnd, text.c_str()); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
528 char *GetCText() { return dw_window_get_text(hwnd); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
529 std::string GetText() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
530 char *retval = dw_window_get_text(hwnd); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
531 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
532 } |
2874
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 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
535 class Button : public TextButton |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
536 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
537 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
538 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
539 Button(const char *text, unsigned long id) { SetHWND(dw_button_new(text, id)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
540 Button(std::string text, unsigned long id) { SetHWND(dw_button_new(text.c_str(), id)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
541 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
|
542 Button(const char *text) { SetHWND(dw_button_new(text, 0)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
543 Button(std::string text) { SetHWND(dw_button_new(text.c_str(), 0)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
544 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
|
545 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
546 |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
547 class BitmapWidget : virtual public Widget |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
548 { |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
549 public: |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
550 // User functions |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
551 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
|
552 void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
553 void Set(std::string file) { dw_window_set_bitmap(hwnd, 0, file.c_str()); } |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
554 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
|
555 }; |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
556 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
557 // Image based button |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
558 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
|
559 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
560 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
561 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
562 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 BitmapButton(const char *text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, 0, data, len)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
568 BitmapButton(std::string text, unsigned long id) { SetHWND(dw_bitmapbutton_new(text.c_str(), id)); Setup(); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
569 BitmapButton(std::string text, unsigned long id, std::string file) { SetHWND(dw_bitmapbutton_new_from_file(text.c_str(), id, file.c_str())); Setup(); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
570 BitmapButton(std::string text, std::string file) { SetHWND(dw_bitmapbutton_new_from_file(text.c_str(), 0, file.c_str())); Setup(); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
571 BitmapButton(std::string text, unsigned long id, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text.c_str(), id, data, len)); Setup(); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
572 BitmapButton(std::string text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text.c_str(), 0, data, len)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
573 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
574 |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
575 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
|
576 { |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
577 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
578 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
579 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
|
580 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
|
581 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
582 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
583 class CheckBox : public CheckBoxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
584 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
585 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
586 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
587 CheckBox(const char *text, unsigned long id) { SetHWND(dw_checkbox_new(text, id)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
588 CheckBox(std::string text, unsigned long id) { SetHWND(dw_checkbox_new(text.c_str(), id)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
589 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
|
590 CheckBox(const char *text) { SetHWND(dw_checkbox_new(text, 0)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
591 CheckBox(std::string text) { SetHWND(dw_checkbox_new(text.c_str(), 0)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
592 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
|
593 }; |
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 class RadioButton : public CheckBoxes |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
596 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
597 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
598 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
599 RadioButton(const char *text, unsigned long id) { SetHWND(dw_radiobutton_new(text, id)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
600 RadioButton(std::string text, unsigned long id) { SetHWND(dw_radiobutton_new(text.c_str(), id)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
601 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
|
602 RadioButton(const char *text) { SetHWND(dw_radiobutton_new(text, 0)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
603 RadioButton(std::string text) { SetHWND(dw_radiobutton_new(text.c_str(), 0)); Setup(); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
604 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
|
605 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
606 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
607 // 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
|
608 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
|
609 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
610 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
611 // User functions |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
612 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
613 void SetText(std::string text) { dw_window_set_text(hwnd, text.c_str()); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
614 char *GetCText() { return dw_window_get_text(hwnd); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
615 std::string GetText() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
616 char *retval = dw_window_get_text(hwnd); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
617 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
618 } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
619 int SetFont(const char *font) { return dw_window_set_font(hwnd, font); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
620 char *GetCFont() { return dw_window_get_font(hwnd); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
621 std::string GetFont() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
622 char *retval = dw_window_get_font(hwnd); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
623 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
624 } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
625 }; |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
626 |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
627 // 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
|
628 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
|
629 { |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
630 public: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
631 // Constructors |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
632 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
|
633 Text(const char *text) { SetHWND(dw_text_new(text, 0)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
634 Text(std::string text, unsigned long id) { SetHWND(dw_text_new(text.c_str(), id)); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
635 Text(std::string text) { SetHWND(dw_text_new(text.c_str(), 0)); } |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
636 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
|
637 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
|
638 }; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
639 |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
640 class StatusText : public TextWidget |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
641 { |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
642 public: |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
643 // Constructors |
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
644 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
|
645 StatusText(const char *text) { SetHWND(dw_status_text_new(text, 0)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
646 StatusText(std::string text, unsigned long id) { SetHWND(dw_status_text_new(text.c_str(), id)); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
647 StatusText(std::string text) { SetHWND(dw_status_text_new(text.c_str(), 0)); } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
648 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
|
649 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
|
650 }; |
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
651 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
652 // 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
|
653 class Bitmap : public BitmapWidget |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
654 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
655 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
656 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
657 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
|
658 Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
659 Bitmap(std::string file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file.c_str()); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
660 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
|
661 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
|
662 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
663 |
2879
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
664 // 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
|
665 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
|
666 { |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
667 public: |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
668 // Constructors |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
669 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
|
670 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
|
671 |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
672 // User functions |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
673 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
|
674 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
|
675 }; |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
676 |
ec7f6e28166d
C++: Add Calendar widget and fix an issue in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2878
diff
changeset
|
677 |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
678 // 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
|
679 class Drawable |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
680 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
681 public: |
2929
2ab97b349958
C++: Add Page 3 - Tree to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2928
diff
changeset
|
682 virtual ~Drawable() { } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 virtual void DrawText(int x, int y, const char *text) = 0; |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
689 virtual void DrawText(int x, int y, std::string text) = 0; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 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
|
697 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
698 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
699 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
|
700 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
701 private: |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
702 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
|
703 #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
|
704 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
|
705 std::function<int(int, int)> _ConnectConfigure; |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
706 std::function<int(char c, int, int, char *)> _ConnectCKeyPress; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
707 std::function<int(char c, int, int, std::string)> _ConnectKeyPress; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
708 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
|
709 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
|
710 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
|
711 #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
|
712 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
|
713 int (*_ConnectConfigureOld)(Render *, int width, int height); |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
714 int (*_ConnectCKeyPressOld)(Render *, char c, int vk, int state, char *utf8); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
715 int (*_ConnectKeyPressOld)(Render *, char c, int vk, int state, std::string 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 #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
|
721 _ConnectExpose = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
722 _ConnectConfigure = 0; |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
723 _ConnectCKeyPress = 0; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
724 _ConnectKeyPress = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
725 _ConnectButtonPress = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
726 _ConnectButtonRelease = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
727 _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
|
728 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
729 _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
|
730 _ConnectConfigureOld = 0; |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
731 _ConnectCKeyPressOld = 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
|
732 _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
|
733 _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
|
734 _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
|
735 _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
|
736 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
|
737 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
|
738 ExposeConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
739 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
740 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
|
741 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
742 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
|
743 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
|
744 ConfigureConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
745 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
746 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
|
747 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
748 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
|
749 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
|
750 KeyPressConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
751 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
752 KeyPressConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
753 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
754 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
|
755 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
|
756 ButtonPressConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
757 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
758 ButtonPressConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
759 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
760 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
|
761 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
|
762 ButtonReleaseConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
763 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
764 ButtonReleaseConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
765 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
766 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
|
767 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
|
768 MotionNotifyConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
769 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
770 MotionNotifyConnected = false; |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
771 } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
772 } |
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
|
773 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
|
774 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
|
775 #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
|
776 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
|
777 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
|
778 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
779 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
|
780 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
|
781 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
|
782 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
|
783 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
|
784 #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
|
785 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
|
786 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
|
787 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
788 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
|
789 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
|
790 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
|
791 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
|
792 Render *classptr = reinterpret_cast<Render *>(data); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
793 std::string utf8string = utf8 ? std::string(utf8) : std::string(); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
794 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
795 if(classptr->_ConnectCKeyPress) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
796 return classptr->_ConnectCKeyPress(c, vk, state, utf8); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
797 else if(classptr->_ConnectKeyPress) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
798 return classptr->_ConnectKeyPress(c, vk, state, utf8string); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
799 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
800 if(classptr->_ConnectCKeyPressOld) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
801 return classptr->_ConnectCKeyPressOld(classptr, c, vk, state, utf8); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
802 else if(classptr->_ConnectKeyPressOld) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
803 return classptr->_ConnectKeyPressOld(classptr, c, vk, state, utf8string); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
804 return classptr->OnKeyPress(c, vk, state, utf8string); } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
805 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
|
806 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
|
807 #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
|
808 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
|
809 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
|
810 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
811 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
|
812 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
|
813 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
|
814 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
|
815 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
|
816 #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
|
817 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
|
818 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
|
819 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
820 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
|
821 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
|
822 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
|
823 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
|
824 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
|
825 #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
|
826 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
|
827 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
|
828 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
829 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
|
830 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
|
831 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
|
832 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
833 // Constructors |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
834 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
|
835 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
|
836 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
837 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
838 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
|
839 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
|
840 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
|
841 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
|
842 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
|
843 void DrawText(int x, int y, const char *text) { dw_draw_text(hwnd, DW_NULL, x, y, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
844 void DrawText(int x, int y, std::string text) { dw_draw_text(hwnd, DW_NULL, x, y, text.c_str()); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
845 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
|
846 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
|
847 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
848 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
|
849 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
|
850 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
|
851 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
852 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
|
853 int SetFont(const char *fontname) { return dw_window_set_font(hwnd, fontname); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
854 int SetFont(std::string fontname) { return dw_window_set_font(hwnd, fontname.c_str()); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
855 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(hwnd, DW_NULL, text, width, height); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
856 void GetTextExtents(std::string text, int *width, int *height) { dw_font_text_extents_get(hwnd, DW_NULL, text.c_str(), width, height); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
857 char *GetCFont() { return dw_window_get_font(hwnd); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
858 std::string GetFont() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
859 char *retval = dw_window_get_font(hwnd); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
860 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
861 } |
2878
a290573a8b7c
C++: Implement StatusText class, reorganize Text widgets to eliminate
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2877
diff
changeset
|
862 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
|
863 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
|
864 #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
|
865 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
|
866 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
867 _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
|
868 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
|
869 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
|
870 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
|
871 } |
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 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
873 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
874 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
|
875 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
876 _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
|
877 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
|
878 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
|
879 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
|
880 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
881 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
882 #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
|
883 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
|
884 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
885 _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
|
886 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
|
887 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
|
888 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
|
889 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
890 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
891 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
892 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
|
893 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
894 _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
|
895 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
|
896 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
|
897 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
|
898 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
899 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
900 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
901 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
|
902 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
903 _ConnectCKeyPress = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
904 if(!KeyPressConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
905 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
906 KeyPressConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
907 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
908 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
909 void ConnectKeyPress(std::function<int(char, int, int, std::string)> userfunc) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
910 { |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
911 _ConnectKeyPress = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
912 if(!KeyPressConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
913 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
|
914 KeyPressConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
915 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
916 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
917 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
918 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
|
919 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
920 _ConnectCKeyPressOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
921 if(!KeyPressConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
922 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
923 KeyPressConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
924 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
925 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
926 void ConnectKeyPress(int (*userfunc)(Render *, char, int, int, std::string)) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
927 { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
928 _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
|
929 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
|
930 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
|
931 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
|
932 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
933 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
934 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
935 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
|
936 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
937 _ConnectButtonPress = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
938 if(!KeyPressConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
939 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
|
940 ButtonPressConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
941 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
942 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
943 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
944 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
|
945 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
946 _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
|
947 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
|
948 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
|
949 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
|
950 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
951 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
952 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
953 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
|
954 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
955 _ConnectButtonRelease = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
956 if(!KeyPressConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
957 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
|
958 ButtonReleaseConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
959 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
960 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
961 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
962 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
|
963 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
964 _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
|
965 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
|
966 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
|
967 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
|
968 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
969 } |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
970 #ifdef DW_LAMBDA |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
971 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
|
972 { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
973 _ConnectMotionNotify = userfunc; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
974 if(!MotionNotifyConnected) { |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
975 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
|
976 MotionNotifyConnected = true; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
977 } |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
978 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
979 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
980 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
|
981 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
982 _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
|
983 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
|
984 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
|
985 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
|
986 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
987 } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
988 protected: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
989 // 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
|
990 // 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
|
991 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
|
992 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
|
993 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
|
994 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
|
995 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 }; |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1001 virtual int OnKeyPress(char c, int vk, int state, std::string utf8) { |
2898
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1002 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
|
1003 KeyPressConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1004 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1005 }; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1006 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
|
1007 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
|
1008 ButtonPressConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1009 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1010 }; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1011 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
|
1012 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
|
1013 ButtonReleaseConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1014 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1015 }; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1016 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
|
1017 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
|
1018 MotionNotifyConnected = false; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1019 return FALSE; |
d53fee198085
C++: Add KeyPress, ButtonPress, ButtonRelease and MotionNotify signals to Render.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2897
diff
changeset
|
1020 }; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1021 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1022 |
2919
e609aa6a5b93
C++: Attempt to implement page 2 rendering...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2917
diff
changeset
|
1023 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
|
1024 { |
2877
6f31b7991fa0
C++: Fix Combobox class by making the parent classes virtual.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2876
diff
changeset
|
1025 private: |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1026 void SetHPIXMAP(HPIXMAP newpixmap) { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1027 hpixmap = newpixmap; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1028 SetHandle(reinterpret_cast<void *>(newpixmap)); |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1029 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1030 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
|
1031 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
|
1032 bool hpmprot; |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1033 public: |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1034 // Constructors |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 } |
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1045 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
|
1046 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename)); |
2950
0577a97fe36d
Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2947
diff
changeset
|
1047 pwidth = dw_pixmap_get_width(hpixmap); |
0577a97fe36d
Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2947
diff
changeset
|
1048 pheight = dw_pixmap_get_height(hpixmap); |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1049 hpmprot = false; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1050 } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1051 Pixmap(Render *window, std::string filename) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1052 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename.c_str())); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1053 pwidth = dw_pixmap_get_width(hpixmap); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1054 pheight = dw_pixmap_get_height(hpixmap); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1055 hpmprot = false; |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1056 } |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1057 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
|
1058 SetHPIXMAP(hpm); |
2950
0577a97fe36d
Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2947
diff
changeset
|
1059 pwidth = dw_pixmap_get_width(hpixmap); |
0577a97fe36d
Added dw_pixmap_get_width() and dw_pixmap_get_height() by request for language bindings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2947
diff
changeset
|
1060 pheight = dw_pixmap_get_height(hpixmap); |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1061 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
|
1062 } |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1063 // Destructor |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
1064 ~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
|
1065 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1066 // User functions |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1067 HPIXMAP GetHPIXMAP() { return hpixmap; } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1068 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
|
1069 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
|
1070 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
|
1071 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
|
1072 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
|
1073 void DrawText(int x, int y, const char *text) { dw_draw_text(DW_NOHWND, hpixmap, x, y, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1074 void DrawText(int x, int y, std::string text) { dw_draw_text(DW_NOHWND, hpixmap, x, y, text.c_str()); } |
2874
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1075 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
|
1076 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
|
1077 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1078 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
|
1079 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
|
1080 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1081 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
|
1082 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
|
1083 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1084 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
|
1085 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
|
1086 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1087 int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1088 int SetFont(std::string fontname) { return dw_pixmap_set_font(hpixmap, fontname.c_str()); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1089 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1090 void GetTextExtents(std::string text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text.c_str(), 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
|
1091 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
|
1092 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
|
1093 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
|
1094 }; |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1095 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1096 // 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
|
1097 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
|
1098 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1099 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
|
1100 } |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1101 |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1102 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
|
1103 { |
585d0053b766
C++: Implement buttons, images, render, pixmap and boxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2873
diff
changeset
|
1104 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
|
1105 } |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
1106 |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1107 // 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
|
1108 class HTML : public Widget |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1109 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1110 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
|
1111 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
|
1112 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1113 std::function<int(int, char *)> _ConnectCChanged; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1114 std::function<int(int, char *, void *)> _ConnectCResult; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1115 std::function<int(int, std::string)> _ConnectChanged; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1116 std::function<int(int, std::string, void *)> _ConnectResult; |
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
|
1117 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1118 int (*_ConnectCChangedOld)(HTML *, int status, char *url); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1119 int (*_ConnectCResultOld)(HTML *, int status, char *result, void *scriptdata); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1120 int (*_ConnectChangedOld)(HTML *, int status, std::string url); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1121 int (*_ConnectResultOld)(HTML *, int status, std::string 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
|
1122 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
|
1123 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1124 _ConnectCChanged = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1125 _ConnectCResult = 0; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1126 _ConnectChanged = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1127 _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
|
1128 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1129 _ConnectCChangedOld = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1130 _ConnectCResultOld = 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 _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
|
1132 _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
|
1133 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
|
1134 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
|
1135 ChangedConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1136 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1137 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
|
1138 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1139 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
|
1140 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
|
1141 ResultConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1142 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1143 ResultConnected = false; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1144 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1145 } |
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
|
1146 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
|
1147 HTML *classptr = reinterpret_cast<HTML *>(data); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1148 std::string utf8string = url ? std::string(url) : std::string(); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1149 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1150 if(classptr->_ConnectCChanged) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1151 return classptr->_ConnectCChanged(status, url); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1152 else if(classptr->_ConnectChanged) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1153 return classptr->_ConnectChanged(status, utf8string); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1154 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1155 if(classptr->_ConnectCChangedOld) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1156 return classptr->_ConnectCChangedOld(classptr, status, url); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1157 else if(classptr->_ConnectChangedOld) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1158 return classptr->_ConnectChangedOld(classptr, status, utf8string); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1159 return classptr->OnChanged(status, utf8string); } |
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
|
1160 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
|
1161 HTML *classptr = reinterpret_cast<HTML *>(data); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1162 std::string utf8string = result ? std::string(result) : std::string(); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1163 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1164 if(classptr->_ConnectCResult) |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1165 return classptr->_ConnectResult(status, result, scriptdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1166 else if(classptr->_ConnectResult) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1167 return classptr->_ConnectResult(status, utf8string, scriptdata); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1168 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1169 if(classptr->_ConnectCResultOld) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1170 return classptr->_ConnectCResultOld(classptr, status, result, scriptdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1171 else if(classptr->_ConnectResultOld) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1172 return classptr->_ConnectResultOld(classptr, status, utf8string, scriptdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1173 return classptr->OnResult(status, utf8string, scriptdata); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1174 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1175 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1176 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
|
1177 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
|
1178 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1179 // User functions |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1180 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
|
1181 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
|
1182 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
|
1183 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
|
1184 int URL(const char *url) { return dw_html_url(hwnd, url); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1185 int JavascriptRun(std::string script, void *scriptdata) { return dw_html_javascript_run(hwnd, script.c_str(), scriptdata); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1186 int JavascriptRun(std::string script) { return dw_html_javascript_run(hwnd, script.c_str(), NULL); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1187 int Raw(std::string buffer) { return dw_html_raw(hwnd, buffer.c_str()); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1188 int URL(std::string url) { return dw_html_url(hwnd, url.c_str()); } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1189 #ifdef DW_LAMBDA |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1190 void ConnectChangedC(std::function<int(int, char *)> 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
|
1191 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1192 _ConnectCChanged = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1193 if(!ChangedConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1194 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1195 ChangedConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1196 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1197 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1198 void ConnectChanged(std::function<int(int, std::string)> userfunc) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1199 { |
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
|
1200 _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
|
1201 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
|
1202 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
|
1203 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
|
1204 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1205 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1206 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1207 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
|
1208 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1209 _ConnectCChangedOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1210 if(!ChangedConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1211 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1212 ChangedConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1213 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1214 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1215 void ConnectChanged(int (*userfunc)(HTML *, int, std::string)) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1216 { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1217 _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
|
1218 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
|
1219 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
|
1220 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
|
1221 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1222 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1223 #ifdef DW_LAMBDA |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1224 void ConnectResultC(std::function<int(int, char *, void *)> 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
|
1225 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1226 _ConnectCResult = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1227 if(!ResultConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1228 dw_signal_connect(hwnd, DW_SIGNAL_HTML_RESULT, DW_SIGNAL_FUNC(_OnResult), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1229 ResultConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1230 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1231 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1232 void ConnectResult(std::function<int(int, std::string, void *)> userfunc) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1233 { |
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
|
1234 _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
|
1235 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
|
1236 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
|
1237 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
|
1238 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1239 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1240 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1241 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
|
1242 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1243 _ConnectCResultOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1244 if(!ResultConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1245 dw_signal_connect(hwnd, DW_SIGNAL_HTML_RESULT, DW_SIGNAL_FUNC(_OnResult), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1246 ResultConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1247 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1248 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1249 void ConnectResult(int (*userfunc)(HTML *, int, std::string, void *)) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1250 { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1251 _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
|
1252 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
|
1253 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
|
1254 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
|
1255 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1256 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1257 protected: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1258 // 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
|
1259 // If they are not overridden and an event is generated, remove the unused handler |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1260 virtual int OnChanged(int status, std::string 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
|
1261 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
|
1262 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
|
1263 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
|
1264 } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1265 virtual int OnResult(int status, std::string result, void *scriptdata) { |
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
|
1266 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
|
1267 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
|
1268 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
|
1269 }; |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1270 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1271 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1272 // 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
|
1273 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
|
1274 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1275 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1276 // 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
|
1277 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
|
1278 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
|
1279 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1280 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1281 class Entryfield : public TextEntry |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1282 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1283 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1284 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1285 Entryfield(const char *text, unsigned long id) { SetHWND(dw_entryfield_new(text, id)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1286 Entryfield(std::string text, unsigned long id) { SetHWND(dw_entryfield_new(text.c_str(), id)); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1287 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
|
1288 Entryfield(const char *text) { SetHWND(dw_entryfield_new(text, 0)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1289 Entryfield(std::string text) { SetHWND(dw_entryfield_new(text.c_str(), 0)); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1290 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
|
1291 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1292 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1293 class EntryfieldPassword : public TextEntry |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1294 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1295 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1296 // Constructors |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1297 EntryfieldPassword(const char *text, unsigned long id) { SetHWND(dw_entryfield_password_new(text, id)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1298 EntryfieldPassword(std::string text, unsigned long id) { SetHWND(dw_entryfield_password_new(text.c_str(), id)); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1299 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
|
1300 EntryfieldPassword(const char *text) { SetHWND(dw_entryfield_password_new(text, 0)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1301 EntryfieldPassword(std::string text) { SetHWND(dw_entryfield_password_new(text.c_str(), 0)); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1302 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
|
1303 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1304 |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1305 // 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
|
1306 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
|
1307 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1308 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
|
1309 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
|
1310 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1311 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
|
1312 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1313 int (*_ConnectListSelectOld)(ListBoxes *, 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
|
1314 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
|
1315 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
|
1316 #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
|
1317 if(classptr->_ConnectListSelect) |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1318 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
|
1319 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1320 if(classptr->_ConnectListSelectOld) |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1321 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
|
1322 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
|
1323 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1324 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1325 // User functions |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1326 void Append(const char *text) { dw_listbox_append(hwnd, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1327 void Append(std::string text) { dw_listbox_append(hwnd, text.c_str()); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1328 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
|
1329 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
|
1330 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
|
1331 void GetListText(unsigned int index, char *buffer, unsigned int length) { dw_listbox_get_text(hwnd, index, buffer, length); } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1332 std::string GetListText(unsigned int index) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1333 int length = 1025; |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1334 char *buffer = (char *)alloca(length); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1335 |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1336 if(buffer) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1337 memset(buffer, 0, length); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1338 dw_listbox_get_text(hwnd, index, buffer, length); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1339 return std::string(buffer); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1340 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1341 return std::string(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1342 } |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1343 void SetListText(unsigned int index, char *buffer) { dw_listbox_set_text(hwnd, index, buffer); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1344 void SetListText(unsigned int index, std::string buffer) { dw_listbox_set_text(hwnd, index, buffer.c_str()); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1345 void Insert(const char *text, int pos) { dw_listbox_insert(hwnd, text, pos); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1346 void Insert(std::string text, int pos) { dw_listbox_insert(hwnd, text.c_str(), pos); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1347 void ListAppend(char **text, int count) { dw_listbox_list_append(hwnd, text, count); } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1348 void ListAppend(std::vector<std::string> text) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1349 int count = (int)text.size(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1350 const char **ctext = (const char **)alloca(sizeof(char *) * count); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1351 |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1352 if(count > 0 && ctext) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1353 for(int z=0; z<count; z++) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1354 ctext[z] = text[z].c_str(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1355 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1356 dw_listbox_list_append(hwnd, (char **)ctext, count); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1357 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1358 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1359 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
|
1360 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
|
1361 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
|
1362 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
|
1363 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1364 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
|
1365 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1366 _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
|
1367 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
|
1368 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
|
1369 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
|
1370 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1371 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1372 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1373 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
|
1374 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1375 _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
|
1376 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
|
1377 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
|
1378 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
|
1379 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1380 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1381 protected: |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1382 void Setup() { |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1383 #ifdef DW_LAMBDA |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1384 _ConnectListSelect = 0; |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1385 #endif |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1386 _ConnectListSelectOld = 0; |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1387 if(IsOverridden(ListBoxes::OnListSelect, this)) { |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1388 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1389 ListSelectConnected = true; |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1390 } |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1391 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1392 // 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
|
1393 // 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
|
1394 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
|
1395 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
|
1396 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
|
1397 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
|
1398 } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1399 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1400 |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1401 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
|
1402 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1403 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1404 // Constructors |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1405 ComboBox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1406 ComboBox(std::string text, unsigned long id) { SetHWND(dw_combobox_new(text.c_str(), id)); Setup(); } |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1407 ComboBox(unsigned long id) { SetHWND(dw_combobox_new("", id)); Setup(); } |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1408 ComboBox(const char *text) { SetHWND(dw_combobox_new(text, 0)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1409 ComboBox(std::string text) { SetHWND(dw_combobox_new(text.c_str(), 0)); Setup(); } |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1410 ComboBox() { SetHWND(dw_combobox_new("", 0)); Setup(); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1411 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1412 |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1413 class ListBox : public ListBoxes |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1414 { |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1415 public: |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1416 // Constructors |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1417 ListBox(unsigned long id, int multi) { SetHWND(dw_listbox_new(id, multi)); Setup(); } |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1418 ListBox(unsigned long id) { SetHWND(dw_listbox_new(id, FALSE)); Setup(); } |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1419 ListBox(int multi) { SetHWND(dw_listbox_new(0, multi)); Setup(); } |
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
1420 ListBox() { SetHWND(dw_listbox_new(0, FALSE)); Setup(); } |
2876
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1421 }; |
e201a984d855
C++: Implement Entryfield, EntryfieldPassword, Listbox and HTML widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2874
diff
changeset
|
1422 |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1423 // 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
|
1424 class Ranged : virtual public Widget |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1425 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1426 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
|
1427 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
|
1428 #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
|
1429 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
|
1430 #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
|
1431 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
|
1432 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
|
1433 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
|
1434 #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
|
1435 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
|
1436 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
|
1437 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1438 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
|
1439 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
|
1440 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
|
1441 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1442 protected: |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1443 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
|
1444 #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
|
1445 _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
|
1446 #endif |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1447 _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
|
1448 if(IsOverridden(Ranged::OnValueChanged, this)) { |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1449 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
|
1450 ValueChangedConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1451 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1452 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
|
1453 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1454 } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1455 // 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
|
1456 // 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
|
1457 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
|
1458 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
|
1459 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
|
1460 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
|
1461 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1462 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
|
1463 #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
|
1464 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
|
1465 { |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1466 _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
|
1467 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
|
1468 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
|
1469 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
|
1470 } |
99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2880
diff
changeset
|
1471 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1472 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1473 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
|
1474 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1475 _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
|
1476 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
|
1477 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
|
1478 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
|
1479 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1480 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1481 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1482 |
2931
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1483 class Percent : public Widget |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1484 { |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1485 public: |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1486 // Constructors |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1487 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
|
1488 Percent() { SetHWND(dw_percent_new(0)); } |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1489 |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1490 // User functions |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1491 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
|
1492 }; |
30c1f37713b6
C++: Add page 5 - Buttons to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2930
diff
changeset
|
1493 |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1494 class Slider : public Ranged |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1495 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1496 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1497 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1498 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
|
1499 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
|
1500 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1501 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1502 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
|
1503 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
|
1504 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1505 |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1506 class ScrollBar : public Ranged |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1507 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1508 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1509 // Constructors |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
1510 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
|
1511 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
|
1512 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1513 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1514 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
|
1515 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
|
1516 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
|
1517 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1518 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1519 class SpinButton : public Ranged, public TextEntry |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1520 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1521 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1522 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1523 SpinButton(const char *text, unsigned long id) { SetHWND(dw_spinbutton_new(text, id)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1524 SpinButton(std::string text, unsigned long id) { SetHWND(dw_spinbutton_new(text.c_str(), id)); Setup(); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1525 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
|
1526 SpinButton(const char *text) { SetHWND(dw_spinbutton_new(text, 0)); Setup(); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1527 SpinButton(std::string text) { SetHWND(dw_spinbutton_new(text.c_str(), 0)); Setup(); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1528 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
|
1529 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1530 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1531 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
|
1532 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
|
1533 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
|
1534 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1535 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1536 // Multi-line Edit widget |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1537 class MLE : public Focusable |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1538 { |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1539 public: |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1540 // Constructors |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1541 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
|
1542 MLE() { SetHWND(dw_mle_new(0)); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1543 |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1544 // User functions |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1545 void Freeze() { dw_mle_freeze(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1546 void Thaw() { dw_mle_thaw(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1547 void Clear() { dw_mle_clear(hwnd); } |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1548 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
|
1549 void Export(char *buffer, int startpoint, int length) { dw_mle_export(hwnd, buffer, startpoint, length); } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1550 std::string Export(int startpoint, int length) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1551 char *buffer = (char *)alloca(length + 1); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1552 |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1553 if(buffer) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1554 memset(buffer, 0, length + 1); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1555 dw_mle_export(hwnd, buffer, startpoint, length); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1556 return std::string(buffer); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1557 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1558 return std::string(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1559 } |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1560 int Import(const char *buffer, int startpoint) { return dw_mle_import(hwnd, buffer, startpoint); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1561 int Import(std::string buffer, int startpoint) { return dw_mle_import(hwnd, buffer.c_str(), startpoint); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1562 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
|
1563 void Search(const char *text, int point, unsigned long flags) { dw_mle_search(hwnd, text, point, flags); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1564 void Search(std::string text, int point, unsigned long flags) { dw_mle_search(hwnd, text.c_str(), point, flags); } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1565 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
|
1566 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
|
1567 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
|
1568 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
|
1569 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
|
1570 int SetFont(const char *font) { return dw_window_set_font(hwnd, font); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1571 int SetFont(std::string font) { return dw_window_set_font(hwnd, font.c_str()); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1572 char *GetCFont() { return dw_window_get_font(hwnd); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1573 std::string GetFont() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1574 char *retval = dw_window_get_font(hwnd); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1575 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1576 } |
2880
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1577 }; |
2ba0959eb3cf
C++: Implement Slider, Scrollbar, SpinButton, and MLE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2879
diff
changeset
|
1578 |
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
|
1579 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
|
1580 { |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1581 private: |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1582 bool SwitchPageConnected; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1583 #ifdef DW_LAMBDA |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1584 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
|
1585 #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
|
1586 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
|
1587 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
|
1588 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
|
1589 #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
|
1590 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
|
1591 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
|
1592 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1593 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
|
1594 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
|
1595 return classptr->OnSwitchPage(pageid); |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1596 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1597 protected: |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1598 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
|
1599 #ifdef DW_LAMBDA |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1600 _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
|
1601 #endif |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
1602 _ConnectSwitchPageOld = 0; |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1603 if(IsOverridden(Notebook::OnSwitchPage, this)) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1604 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
|
1605 SwitchPageConnected = true; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1606 } else { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1607 SwitchPageConnected = false; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1608 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1609 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1610 // 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
|
1611 // 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
|
1612 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
|
1613 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
|
1614 SwitchPageConnected = false; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1615 return FALSE; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1616 } |
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
|
1617 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
|
1618 // 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
|
1619 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
|
1620 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
|
1621 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
|
1622 |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1623 // User functions |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1624 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
|
1625 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
|
1626 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
|
1627 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
|
1628 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
|
1629 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
|
1630 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
|
1631 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
|
1632 void PageSetText(unsigned long pageid, const char *text) { dw_notebook_page_set_text(hwnd, pageid, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1633 void PageSetStatusText(unsigned long pageid, std::string text) { dw_notebook_page_set_status_text(hwnd, pageid, text.c_str()); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1634 void PageSetText(unsigned long pageid, std::string text) { dw_notebook_page_set_text(hwnd, pageid, text.c_str()); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1635 #ifdef DW_LAMBDA |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1636 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
|
1637 { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1638 _ConnectSwitchPage = userfunc; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1639 if(!SwitchPageConnected) { |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1640 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
|
1641 SwitchPageConnected = true; |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1642 } |
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1643 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1644 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1645 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
|
1646 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1647 _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
|
1648 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
|
1649 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
|
1650 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
|
1651 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1652 } |
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
|
1653 }; |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
1654 |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1655 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
|
1656 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1657 private: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1658 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
|
1659 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1660 std::function<int(HTREEITEM, char *, void *)> _ConnectCItemSelect; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1661 std::function<int(char *, int, int, void *)> _ConnectCItemContext; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1662 std::function<int(HTREEITEM, std::string, void *)> _ConnectItemSelect; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1663 std::function<int(std::string, int, int, void *)> _ConnectItemContext; |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1664 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1665 int (*_ConnectCItemSelectOld)(ObjectView *, HTREEITEM, char *, void *); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1666 int (*_ConnectCItemContextOld)(ObjectView *, char *, int, int, void *); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1667 int (*_ConnectItemSelectOld)(ObjectView *, HTREEITEM, std::string, void *); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1668 int (*_ConnectItemContextOld)(ObjectView *, std::string, 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
|
1669 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
|
1670 ObjectView *classptr = reinterpret_cast<ObjectView *>(data); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1671 std::string utf8string = text ? std::string(text) : std::string(); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1672 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1673 if(classptr->_ConnectCItemSelect) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1674 return classptr->_ConnectCItemSelect(item, text, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1675 else if(classptr->_ConnectItemSelect) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1676 return classptr->_ConnectItemSelect(item, utf8string, 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
|
1677 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1678 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
|
1679 return classptr->_ConnectItemSelectOld(classptr, item, text, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1680 else if(classptr->_ConnectItemSelectOld) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1681 return classptr->_ConnectItemSelectOld(classptr, item, utf8string, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1682 return classptr->OnItemSelect(item, utf8string, 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
|
1683 } |
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
|
1684 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
|
1685 ObjectView *classptr = reinterpret_cast<ObjectView *>(data); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1686 std::string utf8string = text ? std::string(text) : std::string(); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1687 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1688 if(classptr->_ConnectCItemContext) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1689 return classptr->_ConnectCItemContext(text, x, y, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1690 else if(classptr->_ConnectItemContext) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1691 return classptr->_ConnectItemContext(utf8string, x, y, 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
|
1692 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1693 if(classptr->_ConnectCItemContextOld) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1694 return classptr->_ConnectCItemContextOld(classptr, text, x, y, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1695 else if(classptr->_ConnectItemContextOld) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1696 return classptr->_ConnectItemContextOld(classptr, utf8string, x, y, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1697 return classptr->OnItemContext(utf8string, 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
|
1698 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1699 protected: |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1700 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
|
1701 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1702 _ConnectCItemSelect = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1703 _ConnectCItemContext = 0; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1704 _ConnectItemSelect = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1705 _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
|
1706 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1707 _ConnectCItemSelectOld = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1708 _ConnectCItemContextOld = 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
|
1709 _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
|
1710 _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
|
1711 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
|
1712 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
|
1713 ItemSelectConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1714 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1715 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
|
1716 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1717 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
|
1718 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
|
1719 ItemContextConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1720 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1721 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
|
1722 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1723 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1724 // 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
|
1725 // If they are not overridden and an event is generated, remove the unused handler |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1726 virtual int OnItemSelect(HTREEITEM item, std::string 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
|
1727 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
|
1728 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
|
1729 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
|
1730 } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1731 virtual int OnItemContext(std::string text, int x, int y, 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
|
1732 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
|
1733 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
|
1734 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
|
1735 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1736 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
|
1737 #ifdef DW_LAMBDA |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1738 void ConnectItemSelectC(std::function<int(HTREEITEM, 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
|
1739 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1740 _ConnectCItemSelect = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1741 if(!ItemSelectConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1742 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1743 ItemSelectConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1744 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1745 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1746 void ConnectItemSelect(std::function<int(HTREEITEM, std::string, void *)> userfunc) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1747 { |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1748 _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
|
1749 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
|
1750 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
|
1751 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
|
1752 } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
1753 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1754 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1755 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
|
1756 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1757 _ConnectCItemSelectOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1758 if(!ItemSelectConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1759 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1760 ItemSelectConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1761 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1762 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1763 void ConnectItemSelect(int (*userfunc)(ObjectView *, HTREEITEM, std::string, void *)) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1764 { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1765 _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
|
1766 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
|
1767 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
|
1768 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
|
1769 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1770 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1771 #ifdef DW_LAMBDA |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1772 void ConnectItemContextC(std::function<int(char *, int, int, 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
|
1773 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1774 _ConnectCItemContext = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1775 if(!ItemContextConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1776 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1777 ItemContextConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1778 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1779 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1780 void ConnectItemContext(std::function<int(std::string, int, int, void *)> userfunc) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1781 { |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1782 _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
|
1783 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
|
1784 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
|
1785 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
|
1786 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1787 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1788 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1789 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
|
1790 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1791 _ConnectCItemContextOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1792 if(!ItemContextConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1793 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1794 ItemContextConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1795 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1796 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1797 void ConnectItemContext(int (*userfunc)(ObjectView *, std::string, int, int, void *)) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1798 { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1799 _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
|
1800 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
|
1801 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
|
1802 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
|
1803 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1804 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1805 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1806 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1807 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
|
1808 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1809 private: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1810 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
|
1811 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1812 std::function<int(char *, void *)> _ConnectCItemEnter; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1813 std::function<int(std::string, 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
|
1814 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
|
1815 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1816 int (*_ConnectCItemEnterOld)(Containers *, char *, void *); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1817 int (*_ConnectItemEnterOld)(Containers *, std::string, 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
|
1818 int (*_ConnectColumnClickOld)(Containers *, int); |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1819 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
|
1820 Containers *classptr = reinterpret_cast<Containers *>(data); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1821 std::string utf8string = text ? std::string(text) : std::string(); |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1822 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1823 if(classptr->_ConnectCItemEnter) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1824 return classptr->_ConnectCItemEnter(text, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1825 else if(classptr->_ConnectItemEnter) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1826 return classptr->_ConnectItemEnter(utf8string, 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
|
1827 #endif |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1828 if(classptr->_ConnectCItemEnterOld) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1829 return classptr->_ConnectCItemEnterOld(classptr, text, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1830 else if(classptr->_ConnectItemEnterOld) |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1831 return classptr->_ConnectItemEnterOld(classptr, utf8string, itemdata); |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1832 return classptr->OnItemEnter(utf8string, 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
|
1833 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1834 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
|
1835 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
|
1836 #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
|
1837 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
|
1838 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
|
1839 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1840 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
|
1841 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
|
1842 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
|
1843 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1844 protected: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1845 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
|
1846 int allocrowcount; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1847 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
|
1848 #ifdef DW_LAMBDA |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1849 _ConnectCItemEnter = 0; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1850 _ConnectItemEnter = 0; |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1851 _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
|
1852 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1853 _ConnectItemEnterOld = 0; |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1854 _ConnectCItemEnterOld = 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
|
1855 _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
|
1856 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
|
1857 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
|
1858 ItemEnterConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1859 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1860 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
|
1861 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1862 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
|
1863 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
|
1864 ColumnClickConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1865 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
1866 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
|
1867 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1868 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1869 // 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
|
1870 // If they are not overridden and an event is generated, remove the unused handler |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1871 virtual int OnItemEnter(std::string 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
|
1872 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
|
1873 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
|
1874 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
|
1875 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1876 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
|
1877 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
|
1878 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
|
1879 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
|
1880 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1881 public: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1882 // 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
|
1883 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
|
1884 void ChangeRowTitle(int row, char *title) { dw_container_change_row_title(hwnd, row, title); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1885 void ChangeRowTitle(int row, std::string title) { dw_container_change_row_title(hwnd, row, title.c_str()); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1886 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
|
1887 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
|
1888 void Cursor(const char *text) { dw_container_cursor(hwnd, text); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1889 void Cursor(std::string text) { dw_container_cursor(hwnd, text.c_str()); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1890 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
|
1891 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
|
1892 void DeleteRow(char *title) { dw_container_delete_row(hwnd, title); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1893 void DeleteRow(std::string title) { dw_container_delete_row(hwnd, title.c_str()); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1894 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
|
1895 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
|
1896 void Optimize() { dw_container_optimize(hwnd); } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1897 char *QueryCNext(unsigned long flags) { return dw_container_query_next(hwnd, flags); } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1898 char *QueryCStart(unsigned long flags) { return dw_container_query_start(hwnd, flags); } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1899 std::string QueryNext(unsigned long flags) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1900 char *retval = dw_container_query_next(hwnd, flags); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1901 return retval ? std::string(retval) : std::string(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1902 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1903 std::string QueryStart(unsigned long flags) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1904 char *retval = dw_container_query_start(hwnd, flags); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1905 return retval ? std::string(retval) : std::string(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1906 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1907 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
|
1908 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
|
1909 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
|
1910 void SetRowTitle(int row, const char *title) { dw_container_set_row_title(allocpointer, row, title); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
1911 void SetRowTitle(int row, const std::string title) { dw_container_set_row_title(allocpointer, row, title.c_str()); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1912 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
|
1913 #ifdef DW_LAMBDA |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
1914 void ConnectItemEnterC(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
|
1915 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1916 _ConnectCItemEnter = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1917 if(!ItemEnterConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1918 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1919 ItemEnterConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1920 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1921 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1922 void ConnectItemEnter(std::function<int(std::string, void *)> userfunc) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1923 { |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1924 _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
|
1925 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
|
1926 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
|
1927 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
|
1928 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1929 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1930 #endif |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1931 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
|
1932 { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1933 _ConnectCItemEnterOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1934 if(!ItemEnterConnected) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1935 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1936 ItemEnterConnected = true; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1937 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1938 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1939 void ConnectItemEnter(int (*userfunc)(Containers *, std::string, void *)) |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
1940 { |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1941 _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
|
1942 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
|
1943 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
|
1944 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
|
1945 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1946 } |
2895
5a6bf6bd3001
C++: Divide up C++11 and Lambda support since some compilers can
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2893
diff
changeset
|
1947 #ifdef DW_LAMBDA |
2930
d8117d36ed27
C++: Add Page 4 - Container to dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2929
diff
changeset
|
1948 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
|
1949 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1950 _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
|
1951 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
|
1952 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
|
1953 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
|
1954 } |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1955 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1956 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1957 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
|
1958 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1959 _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
|
1960 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
|
1961 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
|
1962 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
|
1963 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
1964 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1965 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1966 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1967 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
|
1968 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1969 public: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1970 // Constructors |
2941
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1971 Container(unsigned long id, int multi) { SetHWND(dw_container_new(id, multi)); } |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1972 Container(int multi) { SetHWND(dw_container_new(0, multi)); } |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1973 Container() { SetHWND(dw_container_new(0, 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
|
1974 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1975 // User functions |
2941
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1976 int Setup(unsigned long *flags, const char *titles[], int count, int separator) { |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1977 int retval = dw_container_setup(hwnd, flags, (char **)titles, count, separator); |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1978 SetupObjectView(); SetupContainer(); |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1979 return retval; |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1980 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1981 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
|
1982 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
|
1983 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
|
1984 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1985 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1986 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
|
1987 { |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1988 public: |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1989 // Constructors |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1990 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
|
1991 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
|
1992 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
|
1993 |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
1994 // User functions |
2941
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1995 int Setup(unsigned long *flags, const char *titles[], int count) { |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1996 int retval = dw_filesystem_setup(hwnd, flags, (char **)titles, count); |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1997 SetupObjectView(); SetupContainer(); |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1998 return retval; |
7a057db0bd36
C++: Fix Container signals on GTK by moving the signal setup...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2940
diff
changeset
|
1999 } |
2961
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2000 int Setup(std::vector<unsigned long> flags, std::vector<std::string> titles) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2001 int count = (int)flags.size(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2002 |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2003 // Use the smallest of the two lists |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2004 if(count > titles.size()) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2005 count = (int)titles.size(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2006 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2007 // Convert our vectors into a arrays of unsigned long and C strings |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2008 const char **ctitles = (const char **)alloca(sizeof(char *) * count); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2009 unsigned long *cflags = (unsigned long *)alloca(sizeof(unsigned long) * count); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2010 for(int z=0; z<count; z++) { |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2011 ctitles[z] = titles[z].c_str(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2012 cflags[z] = flags[z]; |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2013 } |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2014 int retval = dw_filesystem_setup(hwnd, cflags, (char **)ctitles, count); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2015 SetupObjectView(); SetupContainer(); |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2016 return retval; |
b9bd130f438a
C++: Step 3 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2960
diff
changeset
|
2017 } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
2018 void ChangeFile(int row, const char *filename, HICN icon) { dw_filesystem_change_file(hwnd, row, filename, icon); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2019 void ChangeFile(int row, std::string filename, HICN icon) { dw_filesystem_change_file(hwnd, row, filename.c_str(), icon); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
2020 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
|
2021 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
|
2022 void SetColumnTitle(const char *title) { dw_filesystem_set_column_title(hwnd, title); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2023 void SetColumnTitle(std::string title) { dw_filesystem_set_column_title(hwnd, title.c_str()); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
2024 void SetFile(int row, const char *filename, HICN icon) { dw_filesystem_set_file(hwnd, allocpointer, row, filename, icon); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2025 void SetFile(int row, std::string filename, HICN icon) { dw_filesystem_set_file(hwnd, allocpointer, row, filename.c_str(), icon); } |
2892
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
2026 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
|
2027 }; |
387a6242fa77
C++: Add the Container and Filesystem classes, plus the base for Tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2891
diff
changeset
|
2028 |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2029 class Tree : virtual public Focusable, virtual public ObjectView |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2030 { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2031 private: |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2032 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
|
2033 #ifdef DW_LAMBDA |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2034 std::function<int(HTREEITEM)> _ConnectTreeExpand; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2035 #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
|
2036 int (*_ConnectTreeExpandOld)(Tree *, HTREEITEM); |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2037 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
|
2038 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
|
2039 #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
|
2040 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
|
2041 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
|
2042 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2043 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
|
2044 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
|
2045 return classptr->OnTreeExpand(item); |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2046 } |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
2047 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
|
2048 #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
|
2049 _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
|
2050 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2051 _ConnectTreeExpandOld = 0; |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2052 if(IsOverridden(Tree::OnTreeExpand, this)) { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2053 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
|
2054 TreeExpandConnected = true; |
2903
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
2055 } else { |
9fd16f694a77
C++: MSVC does not seem to initialize the class fields...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2901
diff
changeset
|
2056 TreeExpandConnected = false; |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2057 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2058 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2059 protected: |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2060 // Our signal handler functions to be overriden... |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2061 // 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
|
2062 virtual int OnTreeExpand(HTREEITEM item) { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2063 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
|
2064 TreeExpandConnected = false; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2065 return FALSE; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2066 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2067 public: |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2068 // Constructors |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2069 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
|
2070 Tree() { SetHWND(dw_tree_new(0)); SetupObjectView(); SetupTree(); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2071 |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2072 // User functions |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2073 void Clear() { dw_tree_clear(hwnd); } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2074 HTREEITEM GetParent(HTREEITEM item) { return dw_tree_get_parent(hwnd, item); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2075 char *GetCTitle(HTREEITEM item) { return dw_tree_get_title(hwnd, item); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2076 std::string GetTitle(HTREEITEM item) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2077 char *retval = dw_tree_get_title(hwnd, item); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2078 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2079 } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2080 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
|
2081 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
|
2082 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
|
2083 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
|
2084 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
|
2085 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon) { return dw_tree_insert_after(hwnd, item, title, icon, 0, NULL); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2086 HTREEITEM Insert(std::string title, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert(hwnd, title.c_str(), icon, parent, itemdata); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2087 HTREEITEM Insert(std::string title, HICN icon, HTREEITEM parent) { return dw_tree_insert(hwnd, title.c_str(), icon, parent, NULL); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2088 HTREEITEM Insert(std::string title, HICN icon) { return dw_tree_insert(hwnd, title.c_str(), icon, 0, NULL); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2089 HTREEITEM InsertAfter(std::string title, HTREEITEM item, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert_after(hwnd, item, title.c_str(), icon, parent, itemdata); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2090 HTREEITEM InsertAfter(std::string title, HTREEITEM item, HICN icon, HTREEITEM parent) { return dw_tree_insert_after(hwnd, item, title.c_str(), icon, parent, NULL); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2091 HTREEITEM InsertAfter(std::string title, HTREEITEM item, HICN icon) { return dw_tree_insert_after(hwnd, item, title.c_str(), icon, 0, NULL); } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2092 void Change(HTREEITEM item, const char *title, HICN icon) { dw_tree_item_change(hwnd, item, title, icon); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2093 void Change(HTREEITEM item, std::string title, HICN icon) { dw_tree_item_change(hwnd, item, title.c_str(), icon); } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2094 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
|
2095 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
|
2096 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
|
2097 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
|
2098 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
|
2099 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
|
2100 #ifdef DW_LAMBDA |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2101 void ConnectTreeExpand(std::function<int(HTREEITEM)> userfunc) |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2102 { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2103 _ConnectTreeExpand = userfunc; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2104 if(!TreeExpandConnected) { |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2105 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
|
2106 TreeExpandConnected = true; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2107 } |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2108 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2109 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2110 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
|
2111 { |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2112 _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
|
2113 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
|
2114 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
|
2115 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
|
2116 } |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2117 } |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2118 }; |
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2119 |
2899
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2120 class SplitBar : public Widget |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2121 { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2122 public: |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2123 // Constructors |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2124 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
|
2125 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
|
2126 SplitBar(int orient, Widget *topleft, Widget *bottomright) { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2127 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
|
2128 |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2129 // User functions |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2130 float Get() { return dw_splitbar_get(hwnd); } |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2131 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
|
2132 }; |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2133 |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2134 class Dialog : public Handle |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2135 { |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2136 private: |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2137 DWDialog *dialog; |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2138 public: |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2139 // Constructors |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2140 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
|
2141 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
|
2142 |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2143 // User functions |
425dc0126818
C++: Implement SplitBar and Dialog classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2898
diff
changeset
|
2144 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
|
2145 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
|
2146 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
|
2147 }; |
2893
5ae86b395927
C++: Implement the Tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2892
diff
changeset
|
2148 |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2149 class Mutex : public Handle |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2150 { |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2151 private: |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2152 HMTX mutex; |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2153 public: |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2154 // Constructors |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2155 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
|
2156 // Destructor |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2157 ~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
|
2158 |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2159 // 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
|
2160 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
|
2161 void Lock() { dw_mutex_lock(mutex); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2162 int TryLock() { return dw_mutex_trylock(mutex); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2163 void Unlock() { dw_mutex_unlock(mutex); } |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2164 }; |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2165 |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2166 class Event : public Handle |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2167 { |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2168 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
|
2169 HEV event, named; |
2900
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2170 public: |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2171 // 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
|
2172 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
|
2173 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
|
2174 // 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
|
2175 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
|
2176 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
|
2177 // 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
|
2178 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
|
2179 } |
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
|
2180 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
|
2181 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
|
2182 } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2183 Event(std::string name) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2184 // Try to attach to an existing event |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2185 named = dw_named_event_get(name.c_str()); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2186 if(!named) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2187 // Otherwise try to create a new one |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2188 named = dw_named_event_new(name.c_str()); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2189 } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2190 event = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2191 SetHandle(reinterpret_cast<void *>(named)); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2192 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2193 // 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
|
2194 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
|
2195 |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2196 // 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
|
2197 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
|
2198 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
|
2199 |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
2200 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
|
2201 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
|
2202 } 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
|
2203 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
|
2204 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
|
2205 } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
2206 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
|
2207 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
|
2208 } |
1567f787b965
C++: Add Notebook class and add named event support to the Event class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2907
diff
changeset
|
2209 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
|
2210 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
|
2211 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
|
2212 }; |
fe31d4535270
C++: Implement Event and Mutex classes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2899
diff
changeset
|
2213 |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2214 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
|
2215 { |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2216 private: |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2217 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
|
2218 #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
|
2219 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
|
2220 #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
|
2221 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
|
2222 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
|
2223 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
|
2224 #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
|
2225 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
|
2226 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
|
2227 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2228 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
|
2229 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
|
2230 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
|
2231 } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2232 public: |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2233 // Constructors |
2924
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
2234 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
|
2235 #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
|
2236 _ConnectTimer = 0; |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
2237 #endif |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
2238 _ConnectTimerOld = 0; |
248e32f744f0
C++: Attempt to get dwtestoo working with old pre-lambda compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2923
diff
changeset
|
2239 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
|
2240 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
|
2241 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2242 #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
|
2243 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
|
2244 _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
|
2245 _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
|
2246 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
|
2247 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
|
2248 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2249 #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
|
2250 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
|
2251 _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
|
2252 #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
|
2253 _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
|
2254 #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
|
2255 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
|
2256 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
|
2257 } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2258 // Destructor |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2259 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
|
2260 |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2261 // 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
|
2262 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
|
2263 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
|
2264 protected: |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2265 // 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
|
2266 // 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
|
2267 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
|
2268 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
|
2269 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
|
2270 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
|
2271 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
|
2272 } |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2273 }; |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2274 |
2916
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2275 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
|
2276 { |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2277 public: |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2278 // Constructors |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2279 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
|
2280 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
|
2281 Notification(const char *title) { SetHWND(dw_notification_new(title, NULL, NULL)); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2282 Notification(std::string title, std::string imagepath, std::string description) { SetHWND(dw_notification_new(title.c_str(), imagepath.c_str(), description.c_str())); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2283 Notification(std::string title, std::string imagepath) { SetHWND(dw_notification_new(title.c_str(), imagepath.c_str(), NULL)); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2284 Notification(std::string title) { SetHWND(dw_notification_new(title.c_str(), NULL, NULL)); } |
2916
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2285 |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2286 // User functions |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2287 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
|
2288 }; |
fe43f8667d3d
C++: Implement Notification class, and enable dwtestoo code that relied on
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2914
diff
changeset
|
2289 |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2290 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
|
2291 { |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2292 private: |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2293 HPRINT print; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2294 #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
|
2295 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
|
2296 #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
|
2297 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
|
2298 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
|
2299 int retval; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2300 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
|
2301 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
|
2302 |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2303 #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
|
2304 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
|
2305 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
|
2306 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
|
2307 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2308 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
|
2309 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
|
2310 else |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2311 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
|
2312 |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2313 delete pixmap; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2314 return retval; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2315 } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2316 public: |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2317 // Constructors |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2318 #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
|
2319 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
|
2320 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
|
2321 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
|
2322 _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
|
2323 _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
|
2324 } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2325 Print(std::string jobname, unsigned long flags, unsigned int pages, std::function<int(Pixmap *, int)> userfunc) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2326 print = dw_print_new(jobname.c_str(), flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2327 SetHandle(reinterpret_cast<void *>(print)); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2328 _ConnectDrawPage = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2329 _ConnectDrawPageOld = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2330 } |
2923
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2331 #endif |
969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2922
diff
changeset
|
2332 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
|
2333 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
|
2334 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
|
2335 _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
|
2336 #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
|
2337 _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
|
2338 #endif |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2339 } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2340 Print(std::string jobname, unsigned long flags, unsigned int pages, int (*userfunc)(Print *, Pixmap *, int)) { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2341 print = dw_print_new(jobname.c_str(), flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2342 SetHandle(reinterpret_cast<void *>(print)); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2343 _ConnectDrawPageOld = userfunc; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2344 #ifdef DW_LAMBDA |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2345 _ConnectDrawPage = 0; |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2346 #endif |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2347 } |
2921
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2348 // Destructor |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2349 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
|
2350 |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2351 // User functions |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2352 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
|
2353 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
|
2354 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
|
2355 protected: |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2356 // 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
|
2357 // 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
|
2358 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
|
2359 if(print) |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2360 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
|
2361 delete this; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2362 return FALSE; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2363 } |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2364 }; |
235fef840df2
C++: Implement Print class and enable the print code in dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2920
diff
changeset
|
2365 |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2366 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
|
2367 { |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2368 private: |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2369 DWTID tid; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2370 #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
|
2371 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
|
2372 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2373 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
|
2374 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
|
2375 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
|
2376 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2377 #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
|
2378 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
|
2379 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
|
2380 else |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2381 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2382 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
|
2383 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
|
2384 else |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2385 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
|
2386 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2387 delete classptr; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2388 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2389 public: |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2390 // Constructors |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2391 #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
|
2392 Thread(std::function<void(Thread *)> userfunc) { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2393 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, _DW_THREAD_STACK); |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2394 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
|
2395 _ConnectThread = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2396 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2397 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2398 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
|
2399 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
|
2400 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
|
2401 _ConnectThread = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2402 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2403 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2404 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2405 Thread(void (*userfunc)(Thread *)) { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2406 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, _DW_THREAD_STACK); |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2407 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
|
2408 _ConnectThreadOld = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2409 #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
|
2410 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2411 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2412 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2413 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
|
2414 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
|
2415 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
|
2416 _ConnectThreadOld = userfunc; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2417 #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
|
2418 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2419 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2420 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2421 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
|
2422 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
|
2423 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
|
2424 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2425 #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
|
2426 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2427 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2428 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2429 Thread() { |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2430 tid = dw_thread_new(DW_SIGNAL_FUNC(_OnThread), this, _DW_THREAD_STACK); |
2933
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2431 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
|
2432 _ConnectThreadOld = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2433 #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
|
2434 _ConnectThread = 0; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2435 #endif |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2436 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2437 // Destructor |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2438 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
|
2439 |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2440 // User functions |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2441 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
|
2442 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
|
2443 protected: |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2444 // 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
|
2445 // 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
|
2446 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
|
2447 delete this; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2448 } |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2449 }; |
3cdb02171b01
C++: Implement Thread class and add the last page Thread/Event.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2932
diff
changeset
|
2450 |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2451 class App |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2452 { |
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
|
2453 protected: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2454 App() { } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2455 static App *_app; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2456 public: |
2870
7b4e30c19757
C++: Disable singleton safety code for non C++11 compilers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2869
diff
changeset
|
2457 // 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
|
2458 #ifdef DW_CPP11 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2459 // 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
|
2460 App(App &other) = delete; |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2461 // 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
|
2462 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
|
2463 #endif |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2464 // 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
|
2465 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
|
2466 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
|
2467 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
|
2468 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
|
2469 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
|
2470 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; } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2471 static App *Init(std::string appid) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), DW_NULL); dw_init(TRUE, 0, DW_NULL); } return _app; } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2472 static App *Init(std::string appid, std::string appname) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), appname.c_str()); dw_init(TRUE, 0, DW_NULL); } return _app; } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2473 static App *Init(int argc, char *argv[], std::string appid) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), DW_NULL); dw_init(TRUE, argc, argv); } return _app; } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2474 static App *Init(int argc, char *argv[], std::string appid, std::string appname) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), appname.c_str()); 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
|
2475 // Destrouctor |
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2476 ~App() { dw_exit(0); } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2477 |
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
|
2478 // User functions |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2479 void Main() { dw_main(); } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2480 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
|
2481 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
|
2482 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
|
2483 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
|
2484 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
|
2485 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
|
2486 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
|
2487 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
|
2488 |
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
|
2489 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
|
2490 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
|
2491 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
|
2492 |
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
|
2493 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
|
2494 } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2495 int MessageBox(std::string title, int flags, std::string format, ...) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2496 int retval; |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2497 const char *cformat = format.c_str(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2498 va_list args; |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2499 |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2500 va_start(args, format); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2501 retval = dw_vmessagebox(title.c_str(), flags, cformat, args); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2502 va_end(args); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2503 |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2504 return retval; |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2505 } |
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
|
2506 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
|
2507 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
|
2508 |
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
|
2509 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
|
2510 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
|
2511 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
|
2512 } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2513 void Debug(std::string format, ...) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2514 const char *cformat = format.c_str(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2515 va_list args; |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2516 |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2517 va_start(args, format); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2518 dw_vdebug(cformat, args); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2519 va_end(args); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2520 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2521 void Beep(int freq, int dur) { dw_beep(freq, dur); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2522 char *GetCDir() { return dw_app_dir(); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2523 std::string GetDir() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2524 char *retval = dw_app_dir(); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2525 return std::string(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2526 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2527 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
|
2528 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
|
2529 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
|
2530 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
|
2531 unsigned long GetColorDepth() { return dw_color_depth_get(); } |
2960
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2532 char *GetCClipboard() { return dw_clipboard_get_text(); } |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2533 std::string GetClipboard() { |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2534 char *retval = dw_clipboard_get_text(); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2535 _dw_string_free_return(retval); |
1dabe9c6c67b
C++: Step 2 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2959
diff
changeset
|
2536 } |
2912
08fcbd5fa069
C++: Fix a warning and implement a few features in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2911
diff
changeset
|
2537 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
|
2538 void SetClipboard(const char *text, int len) { if(text) dw_clipboard_set_text(text, len); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2539 void SetClipboard(std::string text) { dw_clipboard_set_text(text.c_str(), (int)strlen(text.c_str())); } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2540 void SetClipboard(std::string text, int len) { dw_clipboard_set_text(text.c_str(), 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
|
2541 void SetDefaultFont(const char *fontname) { dw_font_set_default(fontname); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2542 void SetDefaultFont(std::string fontname) { dw_font_set_default(fontname.c_str()); } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2543 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
|
2544 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
|
2545 char *FontChoose(const char *currfont) { return dw_font_choose(currfont); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2546 std::string FileBrowse(std::string title, std::string defpath, std::string ext, int flags) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2547 char *retval = dw_file_browse(title.c_str(), defpath.c_str(), ext.c_str(), flags); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2548 return retval ? std::string(retval) : std::string(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2549 } |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2550 std::string FontChoose(std::string currfont) { |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2551 char *retval = dw_font_choose(currfont.c_str()); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2552 return retval ? std::string(retval) : std::string(); |
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2553 } |
2905
0f5008c05134
C++: Implement Timer class, a bunch of destructors and functions in App.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2903
diff
changeset
|
2554 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
|
2555 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
|
2556 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
|
2557 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
|
2558 HICN LoadIcon(const char *filename) { return dw_icon_load_from_file(filename); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2559 HICN LoadIcon(std::string filename) { return dw_icon_load_from_file(filename.c_str()); } |
2914
8af64b6d75a9
C++: Start rewriting dwtest in C++ as dwtestoo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2913
diff
changeset
|
2560 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
|
2561 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
|
2562 void TaskBarInsert(Widget *handle, HICN icon, const char *bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext); } |
2959
cde59690d3dd
C++: Step 1 of the std::string transition.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2950
diff
changeset
|
2563 void TaskBarInsert(Widget *handle, HICN icon, std::string bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext.c_str()); } |
2917
77e5d6743013
C++: Implement most of Page 2 (Render) except the actual rendering.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2916
diff
changeset
|
2564 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
|
2565 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
|
2566 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
|
2567 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2568 |
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
|
2569 // 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
|
2570 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
|
2571 |
2940
60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2939
diff
changeset
|
2572 } // 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
|
2573 #endif |