Mercurial > dwindows
comparison dw.hpp @ 2865:fd32dce7fecd
Initial signal handler support for the C++ bindings.
Need to may App a singleton so we don't require a global "app" variable.
Also need to only attach signal handlers to overloaded callback functions.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 17 Dec 2022 09:03:32 +0000 |
parents | ef7a414f9b71 |
children | 6ea67d0809eb |
comparison
equal
deleted
inserted
replaced
2864:939fbceec13f | 2865:fd32dce7fecd |
---|---|
35 }; | 35 }; |
36 | 36 |
37 // Top-level window class is packable | 37 // Top-level window class is packable |
38 class Window : public Box | 38 class Window : public Box |
39 { | 39 { |
40 private: | |
41 void Setup() { dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); | |
42 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); } | |
43 static int _OnDelete(HWND window, void *data) { return reinterpret_cast<Window *>(data)->OnDelete(); } | |
44 static int _OnConfigure(HWND window, int width, int height, void *data) { return reinterpret_cast<Window *>(data)->OnConfigure(width, height); } | |
40 public: | 45 public: |
41 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); } | 46 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } |
42 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); } | 47 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } |
43 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); } | 48 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); Setup(); } |
44 Window(const char *title) { SetHWND(dw_window_new(HWND_DESKTOP, title, DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | 49 Window(const char *title) { SetHWND(dw_window_new(HWND_DESKTOP, title, DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
45 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); } | 50 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } |
46 Window() { SetHWND(dw_window_new(HWND_DESKTOP, "", DW_FCF_SYSMENU | DW_FCF_TITLEBAR | | 51 Window() { SetHWND(dw_window_new(HWND_DESKTOP, "", DW_FCF_SYSMENU | DW_FCF_TITLEBAR | |
47 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); } | 52 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } |
48 | 53 |
49 void SetText(const char *text) { dw_window_set_text(hwnd, text); } | 54 void SetText(const char *text) { dw_window_set_text(hwnd, text); } |
50 void SetSize(unsigned long width, unsigned long height) { dw_window_set_size(hwnd, width, height); } | 55 void SetSize(unsigned long width, unsigned long height) { dw_window_set_size(hwnd, width, height); } |
51 void Show() { dw_window_show(hwnd); } | 56 void Show() { dw_window_show(hwnd); } |
57 protected: | |
58 virtual int OnDelete() = 0; | |
59 virtual int OnConfigure(int width, int height) = 0; | |
52 }; | 60 }; |
53 | 61 |
54 class App | 62 class App |
55 { | 63 { |
56 public: | 64 public: |