Wrapper classes for the emwin library
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
EwDropDown.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 "EwDropDown.h" |
embeddedartists | 0:316c181e9b65 | 4 | |
embeddedartists | 0:316c181e9b65 | 5 | |
embeddedartists | 0:316c181e9b65 | 6 | EwDropDown::EwDropDown(EwWindow* parent) : EwWindow(parent) { |
embeddedartists | 0:316c181e9b65 | 7 | init(0, 0, 0, 0, parent); |
embeddedartists | 0:316c181e9b65 | 8 | } |
embeddedartists | 0:316c181e9b65 | 9 | |
embeddedartists | 0:316c181e9b65 | 10 | EwDropDown::EwDropDown(int x, int y, int width, int height, EwWindow* parent) : |
embeddedartists | 0:316c181e9b65 | 11 | EwWindow(x, y, width, height, parent) { |
embeddedartists | 0:316c181e9b65 | 12 | |
embeddedartists | 0:316c181e9b65 | 13 | init(x, y, width, height, parent); |
embeddedartists | 0:316c181e9b65 | 14 | } |
embeddedartists | 0:316c181e9b65 | 15 | |
embeddedartists | 0:316c181e9b65 | 16 | void EwDropDown::addString(const char* s) { |
embeddedartists | 0:316c181e9b65 | 17 | DROPDOWN_AddString(_hWnd, s); |
embeddedartists | 0:316c181e9b65 | 18 | } |
embeddedartists | 0:316c181e9b65 | 19 | |
embeddedartists | 0:316c181e9b65 | 20 | void EwDropDown::collapse() { |
embeddedartists | 0:316c181e9b65 | 21 | DROPDOWN_Collapse(_hWnd); |
embeddedartists | 0:316c181e9b65 | 22 | } |
embeddedartists | 0:316c181e9b65 | 23 | |
embeddedartists | 0:316c181e9b65 | 24 | void EwDropDown::decrementSelection() { |
embeddedartists | 0:316c181e9b65 | 25 | DROPDOWN_DecSel(_hWnd); |
embeddedartists | 0:316c181e9b65 | 26 | } |
embeddedartists | 0:316c181e9b65 | 27 | |
embeddedartists | 0:316c181e9b65 | 28 | void EwDropDown::deleteItem(uint32_t idx) { |
embeddedartists | 0:316c181e9b65 | 29 | DROPDOWN_DeleteItem(_hWnd, idx); |
embeddedartists | 0:316c181e9b65 | 30 | } |
embeddedartists | 0:316c181e9b65 | 31 | |
embeddedartists | 0:316c181e9b65 | 32 | void EwDropDown::expand() { |
embeddedartists | 0:316c181e9b65 | 33 | DROPDOWN_Expand(_hWnd); |
embeddedartists | 0:316c181e9b65 | 34 | } |
embeddedartists | 0:316c181e9b65 | 35 | |
embeddedartists | 0:316c181e9b65 | 36 | bool EwDropDown::isItemDisabled(uint32_t idx) { |
embeddedartists | 0:316c181e9b65 | 37 | return (DROPDOWN_GetItemDisabled(_hWnd, idx) == 1); |
embeddedartists | 0:316c181e9b65 | 38 | } |
embeddedartists | 0:316c181e9b65 | 39 | |
embeddedartists | 0:316c181e9b65 | 40 | bool EwDropDown::getItemText(uint32_t idx, char* pBuffer, int maxSize) { |
embeddedartists | 0:316c181e9b65 | 41 | return (DROPDOWN_GetItemText(_hWnd, idx, pBuffer, maxSize) == 0); |
embeddedartists | 0:316c181e9b65 | 42 | } |
embeddedartists | 0:316c181e9b65 | 43 | |
embeddedartists | 0:316c181e9b65 | 44 | int EwDropDown::getNumItems() { |
embeddedartists | 0:316c181e9b65 | 45 | return DROPDOWN_GetNumItems(_hWnd); |
embeddedartists | 0:316c181e9b65 | 46 | } |
embeddedartists | 0:316c181e9b65 | 47 | |
embeddedartists | 0:316c181e9b65 | 48 | int32_t EwDropDown::getSelectedIndex() { |
embeddedartists | 0:316c181e9b65 | 49 | return DROPDOWN_GetSel(_hWnd); |
embeddedartists | 0:316c181e9b65 | 50 | } |
embeddedartists | 0:316c181e9b65 | 51 | |
embeddedartists | 0:316c181e9b65 | 52 | void EwDropDown::incrementSelection() { |
embeddedartists | 0:316c181e9b65 | 53 | DROPDOWN_IncSel(_hWnd); |
embeddedartists | 0:316c181e9b65 | 54 | } |
embeddedartists | 0:316c181e9b65 | 55 | |
embeddedartists | 0:316c181e9b65 | 56 | void EwDropDown::insertString(const char* s, uint32_t idx) { |
embeddedartists | 0:316c181e9b65 | 57 | DROPDOWN_InsertString(_hWnd, s, idx); |
embeddedartists | 0:316c181e9b65 | 58 | } |
embeddedartists | 0:316c181e9b65 | 59 | |
embeddedartists | 0:316c181e9b65 | 60 | void EwDropDown::setAutoScroll(bool on) { |
embeddedartists | 0:316c181e9b65 | 61 | DROPDOWN_SetAutoScroll(_hWnd, (on ? 1 : 0)); |
embeddedartists | 0:316c181e9b65 | 62 | } |
embeddedartists | 0:316c181e9b65 | 63 | |
embeddedartists | 0:316c181e9b65 | 64 | void EwDropDown::setBackgroundColor(ewDropDownColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 65 | DROPDOWN_SetBkColor(_hWnd, idx, c); |
embeddedartists | 0:316c181e9b65 | 66 | } |
embeddedartists | 0:316c181e9b65 | 67 | |
embeddedartists | 0:316c181e9b65 | 68 | void EwDropDown::setColor(ewDropDownColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 69 | DROPDOWN_SetColor(_hWnd, idx, c); |
embeddedartists | 0:316c181e9b65 | 70 | } |
embeddedartists | 0:316c181e9b65 | 71 | |
embeddedartists | 0:316c181e9b65 | 72 | void EwDropDown::setFont(const ewFont_t* pFont) { |
embeddedartists | 0:316c181e9b65 | 73 | DROPDOWN_SetFont(_hWnd, pFont); |
embeddedartists | 0:316c181e9b65 | 74 | } |
embeddedartists | 0:316c181e9b65 | 75 | |
embeddedartists | 0:316c181e9b65 | 76 | void EwDropDown::setItemEnableState(uint32_t idx, bool enabled) { |
embeddedartists | 0:316c181e9b65 | 77 | DROPDOWN_SetItemDisabled(_hWnd, idx, (enabled ? 1 : 0)); |
embeddedartists | 0:316c181e9b65 | 78 | } |
embeddedartists | 0:316c181e9b65 | 79 | |
embeddedartists | 0:316c181e9b65 | 80 | void EwDropDown::setScrollbarColor(ewScrollBarColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 81 | DROPDOWN_SetScrollbarColor(_hWnd, idx, c); |
embeddedartists | 0:316c181e9b65 | 82 | } |
embeddedartists | 0:316c181e9b65 | 83 | |
embeddedartists | 0:316c181e9b65 | 84 | void EwDropDown::setScrollbarWidth(uint32_t width) { |
embeddedartists | 0:316c181e9b65 | 85 | DROPDOWN_SetScrollbarWidth(_hWnd, width); |
embeddedartists | 0:316c181e9b65 | 86 | } |
embeddedartists | 0:316c181e9b65 | 87 | |
embeddedartists | 0:316c181e9b65 | 88 | void EwDropDown::setSelectedItem(int32_t idx) { |
embeddedartists | 0:316c181e9b65 | 89 | DROPDOWN_SetSel(_hWnd, idx); |
embeddedartists | 0:316c181e9b65 | 90 | } |
embeddedartists | 0:316c181e9b65 | 91 | |
embeddedartists | 0:316c181e9b65 | 92 | void EwDropDown::setItemSpacing(uint32_t spacing) { |
embeddedartists | 0:316c181e9b65 | 93 | DROPDOWN_SetItemSpacing(_hWnd, spacing); |
embeddedartists | 0:316c181e9b65 | 94 | } |
embeddedartists | 0:316c181e9b65 | 95 | |
embeddedartists | 0:316c181e9b65 | 96 | void EwDropDown::setTextAlign(ewTextAlign_t align) { |
embeddedartists | 0:316c181e9b65 | 97 | DROPDOWN_SetTextAlign(_hWnd, align); |
embeddedartists | 0:316c181e9b65 | 98 | } |
embeddedartists | 0:316c181e9b65 | 99 | |
embeddedartists | 0:316c181e9b65 | 100 | void EwDropDown::setTextColor(ewDropDownColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 101 | DROPDOWN_SetTextColor(_hWnd, idx, c); |
embeddedartists | 0:316c181e9b65 | 102 | } |
embeddedartists | 0:316c181e9b65 | 103 | |
embeddedartists | 0:316c181e9b65 | 104 | void EwDropDown::setTextHeight(uint32_t height) { |
embeddedartists | 0:316c181e9b65 | 105 | DROPDOWN_SetTextHeight(_hWnd, height); |
embeddedartists | 0:316c181e9b65 | 106 | } |
embeddedartists | 0:316c181e9b65 | 107 | |
embeddedartists | 0:316c181e9b65 | 108 | void EwDropDown::setUpMode(bool upMode) { |
embeddedartists | 0:316c181e9b65 | 109 | DROPDOWN_SetUpMode(_hWnd, (upMode ? 1 : 0)); |
embeddedartists | 0:316c181e9b65 | 110 | } |
embeddedartists | 0:316c181e9b65 | 111 | |
embeddedartists | 0:316c181e9b65 | 112 | void EwDropDown::setSelectionChangedListener(void (*fptr)(EwWindow* w)) { |
embeddedartists | 0:316c181e9b65 | 113 | _selChangedListener.attach(fptr); |
embeddedartists | 0:316c181e9b65 | 114 | } |
embeddedartists | 0:316c181e9b65 | 115 | |
embeddedartists | 0:316c181e9b65 | 116 | ewColor_t EwDropDown::getDefaultBackgroundColor(ewDropDownColorIndex_t idx) { |
embeddedartists | 0:316c181e9b65 | 117 | return DROPDOWN_GetDefaultBkColor(idx); |
embeddedartists | 0:316c181e9b65 | 118 | } |
embeddedartists | 0:316c181e9b65 | 119 | |
embeddedartists | 0:316c181e9b65 | 120 | ewColor_t EwDropDown::getDefaultColor(ewDropDownColorIndex_t idx) { |
embeddedartists | 0:316c181e9b65 | 121 | return DROPDOWN_GetDefaultColor(idx); |
embeddedartists | 0:316c181e9b65 | 122 | } |
embeddedartists | 0:316c181e9b65 | 123 | |
embeddedartists | 0:316c181e9b65 | 124 | ewColor_t EwDropDown::getDefaultScrollbarColor(ewDropDownColorIndex_t idx) { |
embeddedartists | 0:316c181e9b65 | 125 | return DROPDOWN_GetDefaultScrollbarColor(idx); |
embeddedartists | 0:316c181e9b65 | 126 | } |
embeddedartists | 0:316c181e9b65 | 127 | |
embeddedartists | 0:316c181e9b65 | 128 | const ewFont_t* EwDropDown::getDefaultFont() { |
embeddedartists | 0:316c181e9b65 | 129 | return DROPDOWN_GetDefaultFont(); |
embeddedartists | 0:316c181e9b65 | 130 | } |
embeddedartists | 0:316c181e9b65 | 131 | |
embeddedartists | 0:316c181e9b65 | 132 | void EwDropDown::setDefaultBackgroundColor(ewDropDownColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 133 | DROPDOWN_SetDefaultBkColor(idx, c); |
embeddedartists | 0:316c181e9b65 | 134 | } |
embeddedartists | 0:316c181e9b65 | 135 | |
embeddedartists | 0:316c181e9b65 | 136 | void EwDropDown::setDefaultColor(ewDropDownColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 137 | DROPDOWN_SetDefaultColor(idx, c); |
embeddedartists | 0:316c181e9b65 | 138 | } |
embeddedartists | 0:316c181e9b65 | 139 | |
embeddedartists | 0:316c181e9b65 | 140 | void EwDropDown::setDefaultFont(const ewFont_t* pFont) { |
embeddedartists | 0:316c181e9b65 | 141 | DROPDOWN_SetDefaultFont(pFont); |
embeddedartists | 0:316c181e9b65 | 142 | } |
embeddedartists | 0:316c181e9b65 | 143 | |
embeddedartists | 0:316c181e9b65 | 144 | void EwDropDown::setDefaultScrollbarColor(ewScrollBarColorIndex_t idx, ewColor_t c) { |
embeddedartists | 0:316c181e9b65 | 145 | DROPDOWN_SetDefaultScrollbarColor(idx, c); |
embeddedartists | 0:316c181e9b65 | 146 | } |
embeddedartists | 0:316c181e9b65 | 147 | |
embeddedartists | 0:316c181e9b65 | 148 | |
embeddedartists | 0:316c181e9b65 | 149 | void EwDropDown::init(int x, int y, int width, int height, EwWindow* parent) { |
embeddedartists | 0:316c181e9b65 | 150 | DROPDOWN_Handle h; |
embeddedartists | 0:316c181e9b65 | 151 | GUI_HWIN hWin = 0; |
embeddedartists | 0:316c181e9b65 | 152 | |
embeddedartists | 0:316c181e9b65 | 153 | |
embeddedartists | 0:316c181e9b65 | 154 | if (parent) { |
embeddedartists | 0:316c181e9b65 | 155 | hWin = _getHandle(parent); |
embeddedartists | 0:316c181e9b65 | 156 | } |
embeddedartists | 0:316c181e9b65 | 157 | |
embeddedartists | 0:316c181e9b65 | 158 | h = DROPDOWN_CreateEx(x, y, width, height, hWin, (WM_CF_SHOW| WM_CF_MEMDEV), |
embeddedartists | 0:316c181e9b65 | 159 | 0, _guiWidgetId++); |
embeddedartists | 0:316c181e9b65 | 160 | _setNewHandle(h, _callback); |
embeddedartists | 0:316c181e9b65 | 161 | } |
embeddedartists | 0:316c181e9b65 | 162 | |
embeddedartists | 0:316c181e9b65 | 163 | void EwDropDown::handleSelectionChanged() { |
embeddedartists | 0:316c181e9b65 | 164 | _selChangedListener.call(this); |
embeddedartists | 0:316c181e9b65 | 165 | } |
embeddedartists | 0:316c181e9b65 | 166 | |
embeddedartists | 0:316c181e9b65 | 167 | |
embeddedartists | 0:316c181e9b65 | 168 | |
embeddedartists | 0:316c181e9b65 | 169 | void EwDropDown::_callback(WM_MESSAGE* pMsg, EwWindow* w) { |
embeddedartists | 0:316c181e9b65 | 170 | bool selChanged = false; |
embeddedartists | 0:316c181e9b65 | 171 | |
embeddedartists | 0:316c181e9b65 | 172 | EwDropDown* b = (EwDropDown*)w; |
embeddedartists | 0:316c181e9b65 | 173 | |
embeddedartists | 0:316c181e9b65 | 174 | |
embeddedartists | 0:316c181e9b65 | 175 | if (pMsg->MsgId == WM_NOTIFY_PARENT && pMsg->Data.v == WM_NOTIFICATION_SEL_CHANGED) { |
embeddedartists | 0:316c181e9b65 | 176 | selChanged = true; |
embeddedartists | 0:316c181e9b65 | 177 | } |
embeddedartists | 0:316c181e9b65 | 178 | DROPDOWN_Callback(pMsg); |
embeddedartists | 0:316c181e9b65 | 179 | |
embeddedartists | 0:316c181e9b65 | 180 | |
embeddedartists | 0:316c181e9b65 | 181 | if (selChanged) { |
embeddedartists | 0:316c181e9b65 | 182 | b->handleSelectionChanged(); |
embeddedartists | 0:316c181e9b65 | 183 | } |
embeddedartists | 0:316c181e9b65 | 184 | |
embeddedartists | 0:316c181e9b65 | 185 | } |
embeddedartists | 0:316c181e9b65 | 186 |