Wrapper classes for the emwin library
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
EwWindow.cpp@1:0b16165ada7c, 2014-04-14 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Apr 14 08:38:33 2014 +0000
- Revision:
- 1:0b16165ada7c
- Parent:
- 0:316c181e9b65
Initialize uninitialized touchState in EwGui
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:316c181e9b65 | 1 | #include "mbed.h" |
embeddedartists | 0:316c181e9b65 | 2 | |
embeddedartists | 0:316c181e9b65 | 3 | #include "EwWindow.h" |
embeddedartists | 0:316c181e9b65 | 4 | |
embeddedartists | 0:316c181e9b65 | 5 | #include "GUI.h" |
embeddedartists | 0:316c181e9b65 | 6 | #include "WM.h" |
embeddedartists | 0:316c181e9b65 | 7 | |
embeddedartists | 0:316c181e9b65 | 8 | static void _callback(WM_MESSAGE* pMsg); |
embeddedartists | 0:316c181e9b65 | 9 | static void _register(GUI_HWIN hWin, EwWindow* win, void (*callbackFunc)(WM_MESSAGE* pMsg, EwWindow* w)); |
embeddedartists | 0:316c181e9b65 | 10 | static void _deregister(GUI_HWIN hWin); |
embeddedartists | 0:316c181e9b65 | 11 | |
embeddedartists | 0:316c181e9b65 | 12 | #define EW_MAX_NUM_WINDOWS (100) |
embeddedartists | 0:316c181e9b65 | 13 | |
embeddedartists | 0:316c181e9b65 | 14 | typedef void (*callbackFunc)(WM_MESSAGE* pMsg, EwWindow* w); |
embeddedartists | 0:316c181e9b65 | 15 | |
embeddedartists | 0:316c181e9b65 | 16 | static GUI_HWIN _regHandles[EW_MAX_NUM_WINDOWS] = {0}; |
embeddedartists | 0:316c181e9b65 | 17 | static EwWindow* _regWindows[EW_MAX_NUM_WINDOWS] = {0}; |
embeddedartists | 0:316c181e9b65 | 18 | static callbackFunc _regCallbacks[EW_MAX_NUM_WINDOWS] = {0}; |
embeddedartists | 0:316c181e9b65 | 19 | |
embeddedartists | 0:316c181e9b65 | 20 | |
embeddedartists | 0:316c181e9b65 | 21 | int EwWindow::_guiWidgetId = GUI_ID_USER; |
embeddedartists | 0:316c181e9b65 | 22 | |
embeddedartists | 0:316c181e9b65 | 23 | EwWindow::EwWindow(EwWindow* parent) { |
embeddedartists | 0:316c181e9b65 | 24 | init(0, 0, 0, 0, parent); |
embeddedartists | 0:316c181e9b65 | 25 | } |
embeddedartists | 0:316c181e9b65 | 26 | |
embeddedartists | 0:316c181e9b65 | 27 | EwWindow::EwWindow(int x, int y, int width, int height, EwWindow* parent) { |
embeddedartists | 0:316c181e9b65 | 28 | init(x, y, width, height, parent); |
embeddedartists | 0:316c181e9b65 | 29 | } |
embeddedartists | 0:316c181e9b65 | 30 | |
embeddedartists | 0:316c181e9b65 | 31 | EwWindow::~EwWindow() { |
embeddedartists | 0:316c181e9b65 | 32 | |
embeddedartists | 0:316c181e9b65 | 33 | _deregister(_hWnd); |
embeddedartists | 0:316c181e9b65 | 34 | |
embeddedartists | 0:316c181e9b65 | 35 | WM_DeleteWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 36 | } |
embeddedartists | 0:316c181e9b65 | 37 | |
embeddedartists | 0:316c181e9b65 | 38 | void EwWindow::setParent(EwWindow* parent) { |
embeddedartists | 0:316c181e9b65 | 39 | WM_HWIN hParent = 0; |
embeddedartists | 0:316c181e9b65 | 40 | if (parent != NULL) { |
embeddedartists | 0:316c181e9b65 | 41 | hParent = parent->_hWnd; |
embeddedartists | 0:316c181e9b65 | 42 | } |
embeddedartists | 0:316c181e9b65 | 43 | |
embeddedartists | 0:316c181e9b65 | 44 | WM_AttachWindow(_hWnd, hParent); |
embeddedartists | 0:316c181e9b65 | 45 | } |
embeddedartists | 0:316c181e9b65 | 46 | |
embeddedartists | 0:316c181e9b65 | 47 | void EwWindow::bringToBottom() { |
embeddedartists | 0:316c181e9b65 | 48 | WM_BringToBottom(_hWnd); |
embeddedartists | 0:316c181e9b65 | 49 | } |
embeddedartists | 0:316c181e9b65 | 50 | |
embeddedartists | 0:316c181e9b65 | 51 | void EwWindow::bringToTop() { |
embeddedartists | 0:316c181e9b65 | 52 | WM_BringToTop(_hWnd); |
embeddedartists | 0:316c181e9b65 | 53 | } |
embeddedartists | 0:316c181e9b65 | 54 | |
embeddedartists | 0:316c181e9b65 | 55 | void EwWindow::disable() { |
embeddedartists | 0:316c181e9b65 | 56 | WM_DisableWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 57 | } |
embeddedartists | 0:316c181e9b65 | 58 | |
embeddedartists | 0:316c181e9b65 | 59 | void EwWindow::enable() { |
embeddedartists | 0:316c181e9b65 | 60 | WM_EnableWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 61 | } |
embeddedartists | 0:316c181e9b65 | 62 | |
embeddedartists | 0:316c181e9b65 | 63 | bool EwWindow::hasTransparency() { |
embeddedartists | 0:316c181e9b65 | 64 | return (WM_GetHasTrans(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 65 | } |
embeddedartists | 0:316c181e9b65 | 66 | |
embeddedartists | 0:316c181e9b65 | 67 | int EwWindow::getX() { |
embeddedartists | 0:316c181e9b65 | 68 | return WM_GetWindowOrgX(_hWnd); |
embeddedartists | 0:316c181e9b65 | 69 | } |
embeddedartists | 0:316c181e9b65 | 70 | |
embeddedartists | 0:316c181e9b65 | 71 | int EwWindow::getY() { |
embeddedartists | 0:316c181e9b65 | 72 | return WM_GetWindowOrgY(_hWnd); |
embeddedartists | 0:316c181e9b65 | 73 | } |
embeddedartists | 0:316c181e9b65 | 74 | |
embeddedartists | 0:316c181e9b65 | 75 | int EwWindow::getWidth() { |
embeddedartists | 0:316c181e9b65 | 76 | return WM_GetWindowSizeX(_hWnd); |
embeddedartists | 0:316c181e9b65 | 77 | } |
embeddedartists | 0:316c181e9b65 | 78 | |
embeddedartists | 0:316c181e9b65 | 79 | int EwWindow::getHeight() { |
embeddedartists | 0:316c181e9b65 | 80 | return WM_GetWindowSizeY(_hWnd); |
embeddedartists | 0:316c181e9b65 | 81 | } |
embeddedartists | 0:316c181e9b65 | 82 | |
embeddedartists | 0:316c181e9b65 | 83 | bool EwWindow::hasInput() { |
embeddedartists | 0:316c181e9b65 | 84 | return (WM_HasCaptured(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 85 | } |
embeddedartists | 0:316c181e9b65 | 86 | |
embeddedartists | 0:316c181e9b65 | 87 | bool EwWindow::hasFocus() { |
embeddedartists | 0:316c181e9b65 | 88 | return (WM_HasFocus(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 89 | } |
embeddedartists | 0:316c181e9b65 | 90 | |
embeddedartists | 0:316c181e9b65 | 91 | bool EwWindow::getStayOnTop() { |
embeddedartists | 0:316c181e9b65 | 92 | return (WM_GetStayOnTop(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 93 | } |
embeddedartists | 0:316c181e9b65 | 94 | |
embeddedartists | 0:316c181e9b65 | 95 | void EwWindow::hide() { |
embeddedartists | 0:316c181e9b65 | 96 | WM_HideWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 97 | } |
embeddedartists | 0:316c181e9b65 | 98 | |
embeddedartists | 0:316c181e9b65 | 99 | void EwWindow::invalidate() { |
embeddedartists | 0:316c181e9b65 | 100 | WM_InvalidateWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 101 | } |
embeddedartists | 0:316c181e9b65 | 102 | |
embeddedartists | 0:316c181e9b65 | 103 | bool EwWindow::isCompletelyCovered() { |
embeddedartists | 0:316c181e9b65 | 104 | return (WM_IsCompletelyCovered(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 105 | } |
embeddedartists | 0:316c181e9b65 | 106 | |
embeddedartists | 0:316c181e9b65 | 107 | bool EwWindow::isCompletelyVisible() { |
embeddedartists | 0:316c181e9b65 | 108 | return (WM_IsCompletelyVisible(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 109 | } |
embeddedartists | 0:316c181e9b65 | 110 | |
embeddedartists | 0:316c181e9b65 | 111 | bool EwWindow::isEnabled() { |
embeddedartists | 0:316c181e9b65 | 112 | return (WM_IsEnabled(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 113 | } |
embeddedartists | 0:316c181e9b65 | 114 | |
embeddedartists | 0:316c181e9b65 | 115 | bool EwWindow::isVisible() { |
embeddedartists | 0:316c181e9b65 | 116 | return (WM_IsVisible(_hWnd) == 1); |
embeddedartists | 0:316c181e9b65 | 117 | } |
embeddedartists | 0:316c181e9b65 | 118 | |
embeddedartists | 0:316c181e9b65 | 119 | void EwWindow::makeModal() { |
embeddedartists | 0:316c181e9b65 | 120 | WM_MakeModal(_hWnd); |
embeddedartists | 0:316c181e9b65 | 121 | } |
embeddedartists | 0:316c181e9b65 | 122 | |
embeddedartists | 0:316c181e9b65 | 123 | void EwWindow::moveTo(int x, int y) { |
embeddedartists | 0:316c181e9b65 | 124 | WM_MoveChildTo(_hWnd, x, y); |
embeddedartists | 0:316c181e9b65 | 125 | } |
embeddedartists | 0:316c181e9b65 | 126 | |
embeddedartists | 0:316c181e9b65 | 127 | void EwWindow::moveToAbs(int x, int y) { |
embeddedartists | 0:316c181e9b65 | 128 | WM_MoveTo(_hWnd, x, y); |
embeddedartists | 0:316c181e9b65 | 129 | } |
embeddedartists | 0:316c181e9b65 | 130 | |
embeddedartists | 0:316c181e9b65 | 131 | void EwWindow::move(int dx, int dy) { |
embeddedartists | 0:316c181e9b65 | 132 | WM_MoveWindow(_hWnd, dx, dy); |
embeddedartists | 0:316c181e9b65 | 133 | } |
embeddedartists | 0:316c181e9b65 | 134 | |
embeddedartists | 0:316c181e9b65 | 135 | void EwWindow::repaint() { |
embeddedartists | 0:316c181e9b65 | 136 | WM_Paint(_hWnd); |
embeddedartists | 0:316c181e9b65 | 137 | } |
embeddedartists | 0:316c181e9b65 | 138 | |
embeddedartists | 0:316c181e9b65 | 139 | void EwWindow::repaintAll() { |
embeddedartists | 0:316c181e9b65 | 140 | WM_PaintWindowAndDescs(_hWnd); |
embeddedartists | 0:316c181e9b65 | 141 | } |
embeddedartists | 0:316c181e9b65 | 142 | |
embeddedartists | 0:316c181e9b65 | 143 | void EwWindow::resize(int dx, int dy) { |
embeddedartists | 0:316c181e9b65 | 144 | WM_ResizeWindow(_hWnd, dx, dy); |
embeddedartists | 0:316c181e9b65 | 145 | } |
embeddedartists | 0:316c181e9b65 | 146 | |
embeddedartists | 0:316c181e9b65 | 147 | void EwWindow::resizeTo(int width, int height) { |
embeddedartists | 0:316c181e9b65 | 148 | WM_SetSize(_hWnd, width, height); |
embeddedartists | 0:316c181e9b65 | 149 | } |
embeddedartists | 0:316c181e9b65 | 150 | |
embeddedartists | 0:316c181e9b65 | 151 | void EwWindow::setHasTransparency(bool has) { |
embeddedartists | 0:316c181e9b65 | 152 | if (has) { |
embeddedartists | 0:316c181e9b65 | 153 | WM_SetHasTrans(_hWnd); |
embeddedartists | 0:316c181e9b65 | 154 | } else { |
embeddedartists | 0:316c181e9b65 | 155 | WM_ClrHasTrans(_hWnd); |
embeddedartists | 0:316c181e9b65 | 156 | } |
embeddedartists | 0:316c181e9b65 | 157 | } |
embeddedartists | 0:316c181e9b65 | 158 | |
embeddedartists | 0:316c181e9b65 | 159 | void EwWindow::setStayOnTop(bool onTop) { |
embeddedartists | 0:316c181e9b65 | 160 | WM_SetStayOnTop(_hWnd, (onTop ? 1 : 0)); |
embeddedartists | 0:316c181e9b65 | 161 | } |
embeddedartists | 0:316c181e9b65 | 162 | |
embeddedartists | 0:316c181e9b65 | 163 | void EwWindow::show() { |
embeddedartists | 0:316c181e9b65 | 164 | WM_ShowWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 165 | } |
embeddedartists | 0:316c181e9b65 | 166 | |
embeddedartists | 0:316c181e9b65 | 167 | void EwWindow::setFocus() { |
embeddedartists | 0:316c181e9b65 | 168 | WM_SetFocus(_hWnd); |
embeddedartists | 0:316c181e9b65 | 169 | } |
embeddedartists | 0:316c181e9b65 | 170 | |
embeddedartists | 0:316c181e9b65 | 171 | void EwWindow::update() { |
embeddedartists | 0:316c181e9b65 | 172 | WM_Update(_hWnd); |
embeddedartists | 0:316c181e9b65 | 173 | } |
embeddedartists | 0:316c181e9b65 | 174 | |
embeddedartists | 0:316c181e9b65 | 175 | void EwWindow::updateAll() { |
embeddedartists | 0:316c181e9b65 | 176 | WM_UpdateWindowAndDescs(_hWnd); |
embeddedartists | 0:316c181e9b65 | 177 | } |
embeddedartists | 0:316c181e9b65 | 178 | |
embeddedartists | 0:316c181e9b65 | 179 | ewColor_t EwWindow::setDesktopColor(ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 180 | return WM_SetDesktopColor(c); |
embeddedartists | 0:316c181e9b65 | 181 | } |
embeddedartists | 0:316c181e9b65 | 182 | |
embeddedartists | 0:316c181e9b65 | 183 | bool EwWindow::paintEvent() { |
embeddedartists | 0:316c181e9b65 | 184 | return false; |
embeddedartists | 0:316c181e9b65 | 185 | } |
embeddedartists | 0:316c181e9b65 | 186 | |
embeddedartists | 0:316c181e9b65 | 187 | bool EwWindow::touchEvent(int x, int y, EwTouchState_t state) { |
embeddedartists | 0:316c181e9b65 | 188 | return false; |
embeddedartists | 0:316c181e9b65 | 189 | } |
embeddedartists | 0:316c181e9b65 | 190 | |
embeddedartists | 0:316c181e9b65 | 191 | bool EwWindow::focusEvent(bool gotFocus) { |
embeddedartists | 0:316c181e9b65 | 192 | return false; |
embeddedartists | 0:316c181e9b65 | 193 | } |
embeddedartists | 0:316c181e9b65 | 194 | |
embeddedartists | 0:316c181e9b65 | 195 | bool EwWindow::resizedEvent() { |
embeddedartists | 0:316c181e9b65 | 196 | return false; |
embeddedartists | 0:316c181e9b65 | 197 | } |
embeddedartists | 0:316c181e9b65 | 198 | |
embeddedartists | 0:316c181e9b65 | 199 | void EwWindow::_setNewHandle(GUI_HWIN hWnd, void (*callbackFunc)(WM_MESSAGE* pMsg, EwWindow* w)) { |
embeddedartists | 0:316c181e9b65 | 200 | _deregister(_hWnd); |
embeddedartists | 0:316c181e9b65 | 201 | WM_DeleteWindow(_hWnd); |
embeddedartists | 0:316c181e9b65 | 202 | |
embeddedartists | 0:316c181e9b65 | 203 | _hWnd = hWnd; |
embeddedartists | 0:316c181e9b65 | 204 | _register(_hWnd, this, callbackFunc); |
embeddedartists | 0:316c181e9b65 | 205 | } |
embeddedartists | 0:316c181e9b65 | 206 | |
embeddedartists | 0:316c181e9b65 | 207 | GUI_HWIN EwWindow::_getHandle(EwWindow* w) { |
embeddedartists | 0:316c181e9b65 | 208 | GUI_HWIN h = 0; |
embeddedartists | 0:316c181e9b65 | 209 | WM_CALLBACK *pCb; |
embeddedartists | 0:316c181e9b65 | 210 | |
embeddedartists | 0:316c181e9b65 | 211 | if (w) { |
embeddedartists | 0:316c181e9b65 | 212 | h = w->_hWnd; |
embeddedartists | 0:316c181e9b65 | 213 | pCb = WM_GetCallback(h); |
embeddedartists | 0:316c181e9b65 | 214 | |
embeddedartists | 0:316c181e9b65 | 215 | // If the windows is a frame window return its client window instead |
embeddedartists | 0:316c181e9b65 | 216 | // since the main window handle shouldn't be used when adding child |
embeddedartists | 0:316c181e9b65 | 217 | // windows |
embeddedartists | 0:316c181e9b65 | 218 | if (pCb == FRAMEWIN_Callback) { |
embeddedartists | 0:316c181e9b65 | 219 | h = WM_GetClientWindow(h); |
embeddedartists | 0:316c181e9b65 | 220 | } |
embeddedartists | 0:316c181e9b65 | 221 | |
embeddedartists | 0:316c181e9b65 | 222 | } |
embeddedartists | 0:316c181e9b65 | 223 | |
embeddedartists | 0:316c181e9b65 | 224 | return h; |
embeddedartists | 0:316c181e9b65 | 225 | } |
embeddedartists | 0:316c181e9b65 | 226 | |
embeddedartists | 0:316c181e9b65 | 227 | void EwWindow::init(int x, int y, int width, int height, EwWindow* parent) { |
embeddedartists | 0:316c181e9b65 | 228 | |
embeddedartists | 0:316c181e9b65 | 229 | // TODO: flags |
embeddedartists | 0:316c181e9b65 | 230 | |
embeddedartists | 0:316c181e9b65 | 231 | if (parent) { |
embeddedartists | 0:316c181e9b65 | 232 | _hWnd = WM_CreateWindowAsChild(x, y, width, height, _getHandle(parent), |
embeddedartists | 0:316c181e9b65 | 233 | (WM_CF_SHOW | WM_CF_MEMDEV), _callback, 0); |
embeddedartists | 0:316c181e9b65 | 234 | } else { |
embeddedartists | 0:316c181e9b65 | 235 | _hWnd = WM_CreateWindow(x, y, width, height, (WM_CF_SHOW | WM_CF_MEMDEV), |
embeddedartists | 0:316c181e9b65 | 236 | _callback, 0); |
embeddedartists | 0:316c181e9b65 | 237 | } |
embeddedartists | 0:316c181e9b65 | 238 | |
embeddedartists | 0:316c181e9b65 | 239 | _register(_hWnd, this, NULL); |
embeddedartists | 0:316c181e9b65 | 240 | } |
embeddedartists | 0:316c181e9b65 | 241 | |
embeddedartists | 0:316c181e9b65 | 242 | static void _callback(WM_MESSAGE* pMsg) { |
embeddedartists | 0:316c181e9b65 | 243 | |
embeddedartists | 0:316c181e9b65 | 244 | GUI_PID_STATE* pState; |
embeddedartists | 0:316c181e9b65 | 245 | EwTouchState_t touchState; |
embeddedartists | 0:316c181e9b65 | 246 | |
embeddedartists | 0:316c181e9b65 | 247 | bool msgHandled = false; |
embeddedartists | 0:316c181e9b65 | 248 | |
embeddedartists | 0:316c181e9b65 | 249 | |
embeddedartists | 0:316c181e9b65 | 250 | for (int i = 0; i < EW_MAX_NUM_WINDOWS; i++) { |
embeddedartists | 0:316c181e9b65 | 251 | if (_regHandles[i] == pMsg->hWin) { |
embeddedartists | 0:316c181e9b65 | 252 | |
embeddedartists | 0:316c181e9b65 | 253 | // callback is overriden |
embeddedartists | 0:316c181e9b65 | 254 | if (_regCallbacks[i] != NULL) { |
embeddedartists | 0:316c181e9b65 | 255 | _regCallbacks[i](pMsg, _regWindows[i]); |
embeddedartists | 0:316c181e9b65 | 256 | |
embeddedartists | 0:316c181e9b65 | 257 | // it is the responsibility of the overriden callback function |
embeddedartists | 0:316c181e9b65 | 258 | // to handle all messages or forward those that aren't handled |
embeddedartists | 0:316c181e9b65 | 259 | // to default handler. |
embeddedartists | 0:316c181e9b65 | 260 | msgHandled = false; |
embeddedartists | 0:316c181e9b65 | 261 | } |
embeddedartists | 0:316c181e9b65 | 262 | |
embeddedartists | 0:316c181e9b65 | 263 | else { |
embeddedartists | 0:316c181e9b65 | 264 | |
embeddedartists | 0:316c181e9b65 | 265 | switch (pMsg->MsgId) { |
embeddedartists | 0:316c181e9b65 | 266 | case WM_PAINT: |
embeddedartists | 0:316c181e9b65 | 267 | msgHandled = _regWindows[i]->paintEvent(); |
embeddedartists | 0:316c181e9b65 | 268 | break; |
embeddedartists | 0:316c181e9b65 | 269 | case WM_TOUCH: |
embeddedartists | 0:316c181e9b65 | 270 | pState = (GUI_PID_STATE*)pMsg->Data.p; |
embeddedartists | 0:316c181e9b65 | 271 | if (pState->Pressed == 1) { |
embeddedartists | 0:316c181e9b65 | 272 | touchState = TouchStatePressed; |
embeddedartists | 0:316c181e9b65 | 273 | } |
embeddedartists | 0:316c181e9b65 | 274 | else if (pState->Pressed == 0) { |
embeddedartists | 0:316c181e9b65 | 275 | touchState = TouchStateReleased; |
embeddedartists | 0:316c181e9b65 | 276 | } |
embeddedartists | 0:316c181e9b65 | 277 | else { |
embeddedartists | 0:316c181e9b65 | 278 | touchState = TouchStateReleasedOutside; |
embeddedartists | 0:316c181e9b65 | 279 | } |
embeddedartists | 0:316c181e9b65 | 280 | |
embeddedartists | 0:316c181e9b65 | 281 | msgHandled = _regWindows[i]->touchEvent(pState->x, pState->y, touchState); |
embeddedartists | 0:316c181e9b65 | 282 | |
embeddedartists | 0:316c181e9b65 | 283 | break; |
embeddedartists | 0:316c181e9b65 | 284 | case WM_SET_FOCUS: |
embeddedartists | 0:316c181e9b65 | 285 | msgHandled = _regWindows[i]->focusEvent(pMsg->Data.v == 1); |
embeddedartists | 0:316c181e9b65 | 286 | break; |
embeddedartists | 0:316c181e9b65 | 287 | case WM_SIZE: |
embeddedartists | 0:316c181e9b65 | 288 | msgHandled = _regWindows[i]->resizedEvent(); |
embeddedartists | 0:316c181e9b65 | 289 | break; |
embeddedartists | 0:316c181e9b65 | 290 | |
embeddedartists | 0:316c181e9b65 | 291 | default: |
embeddedartists | 0:316c181e9b65 | 292 | msgHandled = false; |
embeddedartists | 0:316c181e9b65 | 293 | } |
embeddedartists | 0:316c181e9b65 | 294 | |
embeddedartists | 0:316c181e9b65 | 295 | |
embeddedartists | 0:316c181e9b65 | 296 | } |
embeddedartists | 0:316c181e9b65 | 297 | |
embeddedartists | 0:316c181e9b65 | 298 | |
embeddedartists | 0:316c181e9b65 | 299 | |
embeddedartists | 0:316c181e9b65 | 300 | break; |
embeddedartists | 0:316c181e9b65 | 301 | } |
embeddedartists | 0:316c181e9b65 | 302 | } |
embeddedartists | 0:316c181e9b65 | 303 | |
embeddedartists | 0:316c181e9b65 | 304 | if (!msgHandled) { |
embeddedartists | 0:316c181e9b65 | 305 | WM_DefaultProc(pMsg); |
embeddedartists | 0:316c181e9b65 | 306 | } |
embeddedartists | 0:316c181e9b65 | 307 | } |
embeddedartists | 0:316c181e9b65 | 308 | |
embeddedartists | 0:316c181e9b65 | 309 | static void _register(GUI_HWIN hWin, EwWindow* win, void (*callbackFunc)(WM_MESSAGE* pMsg, EwWindow* w)) { |
embeddedartists | 0:316c181e9b65 | 310 | for (int i = 0; i < EW_MAX_NUM_WINDOWS; i++) { |
embeddedartists | 0:316c181e9b65 | 311 | if (_regWindows[i] == NULL) { |
embeddedartists | 0:316c181e9b65 | 312 | _regWindows[i] = win; |
embeddedartists | 0:316c181e9b65 | 313 | _regHandles[i] = hWin; |
embeddedartists | 0:316c181e9b65 | 314 | _regCallbacks[i] = callbackFunc; |
embeddedartists | 0:316c181e9b65 | 315 | |
embeddedartists | 0:316c181e9b65 | 316 | if (callbackFunc != NULL) { |
embeddedartists | 0:316c181e9b65 | 317 | WM_SetCallback(hWin, _callback); |
embeddedartists | 0:316c181e9b65 | 318 | } |
embeddedartists | 0:316c181e9b65 | 319 | |
embeddedartists | 0:316c181e9b65 | 320 | break; |
embeddedartists | 0:316c181e9b65 | 321 | } |
embeddedartists | 0:316c181e9b65 | 322 | } |
embeddedartists | 0:316c181e9b65 | 323 | } |
embeddedartists | 0:316c181e9b65 | 324 | |
embeddedartists | 0:316c181e9b65 | 325 | static void _deregister(GUI_HWIN hWin) { |
embeddedartists | 0:316c181e9b65 | 326 | |
embeddedartists | 0:316c181e9b65 | 327 | for (int i = 0; i < EW_MAX_NUM_WINDOWS; i++) { |
embeddedartists | 0:316c181e9b65 | 328 | if (_regHandles[i] == hWin) { |
embeddedartists | 0:316c181e9b65 | 329 | _regWindows[i] = NULL; |
embeddedartists | 0:316c181e9b65 | 330 | _regHandles[i] = 0; |
embeddedartists | 0:316c181e9b65 | 331 | _regCallbacks[i] = NULL; |
embeddedartists | 0:316c181e9b65 | 332 | break; |
embeddedartists | 0:316c181e9b65 | 333 | } |
embeddedartists | 0:316c181e9b65 | 334 | } |
embeddedartists | 0:316c181e9b65 | 335 | } |
embeddedartists | 0:316c181e9b65 | 336 |