Mercurial > dwindows
comparison dw.hpp @ 2884:06e475feaac0
C++: Split Menu and MenuBar to prevent type conflicts.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 22 Dec 2022 14:51:21 +0000 |
parents | 99311a9091af |
children | df1b7f7d1703 |
comparison
equal
deleted
inserted
replaced
2883:d301fed4bc23 | 2884:06e475feaac0 |
---|---|
171 | 171 |
172 class Menu : public Menus | 172 class Menu : public Menus |
173 { | 173 { |
174 public: | 174 public: |
175 // Constructors | 175 // Constructors |
176 Menu(HWND location) { SetHMENUI(dw_menubar_new(location)); } | |
177 Menu(unsigned long id) { SetHMENUI(dw_menu_new(id)); } | 176 Menu(unsigned long id) { SetHMENUI(dw_menu_new(id)); } |
178 Menu() { SetHMENUI(dw_menu_new(0)); } | 177 Menu() { SetHMENUI(dw_menu_new(0)); } |
179 }; | 178 }; |
180 | 179 |
180 class MenuBar : public Menus | |
181 { | |
182 public: | |
183 // Constructors | |
184 MenuBar(HWND location) { SetHMENUI(dw_menubar_new(location)); } | |
185 }; | |
186 | |
187 | |
181 class MenuItem : public Clickable | 188 class MenuItem : public Clickable |
182 { | 189 { |
183 public: | 190 public: |
184 // Constructors | 191 // Constructors |
185 MenuItem(Menus *menu, const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { | 192 MenuItem(Menus *menu, const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) { |
186 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, id, flags, end, check, submenu ? submenu->GetHMENUI() : DW_NULL)); | 193 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, id, flags, end, check, submenu ? submenu->GetHMENUI() : 0)); |
187 } | 194 } |
188 | 195 |
189 // User functions | 196 // User functions |
190 void SetState(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); } | 197 void SetState(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); } |
191 void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); } | 198 void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); } |
219 return reinterpret_cast<Window *>(data)->OnDelete(); } | 226 return reinterpret_cast<Window *>(data)->OnDelete(); } |
220 static int _OnConfigure(HWND window, int width, int height, void *data) { | 227 static int _OnConfigure(HWND window, int width, int height, void *data) { |
221 if(reinterpret_cast<Window *>(data)->_ConnectConfigure) | 228 if(reinterpret_cast<Window *>(data)->_ConnectConfigure) |
222 return reinterpret_cast<Window *>(data)->_ConnectConfigure(width, height); | 229 return reinterpret_cast<Window *>(data)->_ConnectConfigure(width, height); |
223 return reinterpret_cast<Window *>(data)->OnConfigure(width, height); } | 230 return reinterpret_cast<Window *>(data)->OnConfigure(width, height); } |
224 Menu *menu; | 231 MenuBar *menu; |
225 public: | 232 public: |
226 // Constructors | 233 // Constructors |
227 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } | 234 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } |
228 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } | 235 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } |
229 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); Setup(); } | 236 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); Setup(); } |
243 int Raise() { return dw_window_raise(hwnd); } | 250 int Raise() { return dw_window_raise(hwnd); } |
244 int Lower() { return dw_window_lower(hwnd); } | 251 int Lower() { return dw_window_lower(hwnd); } |
245 void Redraw() { dw_window_redraw(hwnd); } | 252 void Redraw() { dw_window_redraw(hwnd); } |
246 void Default(Widget *defaultitem) { if(defaultitem) dw_window_default(hwnd, defaultitem->GetHWND()); } | 253 void Default(Widget *defaultitem) { if(defaultitem) dw_window_default(hwnd, defaultitem->GetHWND()); } |
247 void SetIcon(HICN icon) { dw_window_set_icon(hwnd, icon); } | 254 void SetIcon(HICN icon) { dw_window_set_icon(hwnd, icon); } |
248 Menu *MenuBar() { if(menu == DW_NULL) menu = new Menu(hwnd); return menu; } | 255 MenuBar *MenuBarNew() { if(!menu) menu = new MenuBar(hwnd); return menu; } |
249 #ifdef DW_CPP11 | 256 #ifdef DW_CPP11 |
250 void ConnectDelete(std::function<int()> userfunc) | 257 void ConnectDelete(std::function<int()> userfunc) |
251 #else | 258 #else |
252 void ConnectDelete(int (*userfunc)()) | 259 void ConnectDelete(int (*userfunc)()) |
253 #endif | 260 #endif |