EmbeddedArtists AB / ewgui

Dependents:   app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EwDropDown.cpp Source File

EwDropDown.cpp

00001 #include "mbed.h"
00002 
00003 #include "EwDropDown.h"
00004 
00005 
00006 EwDropDown::EwDropDown(EwWindow* parent) : EwWindow(parent) {
00007     init(0, 0, 0, 0, parent);
00008 }
00009 
00010 EwDropDown::EwDropDown(int x, int y, int width, int height, EwWindow* parent) :
00011             EwWindow(x, y, width, height, parent) {
00012 
00013     init(x, y, width, height, parent);
00014 }
00015 
00016 void EwDropDown::addString(const char* s) {
00017     DROPDOWN_AddString(_hWnd, s);
00018 }
00019 
00020 void EwDropDown::collapse() {
00021     DROPDOWN_Collapse(_hWnd);
00022 }
00023 
00024 void EwDropDown::decrementSelection() {
00025     DROPDOWN_DecSel(_hWnd);
00026 }
00027 
00028 void EwDropDown::deleteItem(uint32_t idx) {
00029     DROPDOWN_DeleteItem(_hWnd, idx);
00030 }
00031 
00032 void EwDropDown::expand() {
00033     DROPDOWN_Expand(_hWnd);
00034 }
00035 
00036 bool EwDropDown::isItemDisabled(uint32_t idx) {
00037     return (DROPDOWN_GetItemDisabled(_hWnd, idx) == 1);
00038 }
00039 
00040 bool EwDropDown::getItemText(uint32_t idx, char* pBuffer, int maxSize) {
00041     return (DROPDOWN_GetItemText(_hWnd, idx, pBuffer, maxSize) == 0);
00042 }
00043 
00044 int EwDropDown::getNumItems() {
00045     return DROPDOWN_GetNumItems(_hWnd);
00046 }
00047 
00048 int32_t EwDropDown::getSelectedIndex() {
00049     return DROPDOWN_GetSel(_hWnd);
00050 }
00051 
00052 void EwDropDown::incrementSelection() {
00053     DROPDOWN_IncSel(_hWnd);
00054 }
00055 
00056 void EwDropDown::insertString(const char* s, uint32_t idx) {
00057     DROPDOWN_InsertString(_hWnd, s, idx);
00058 }
00059 
00060 void EwDropDown::setAutoScroll(bool on) {
00061     DROPDOWN_SetAutoScroll(_hWnd, (on ? 1 : 0));
00062 }
00063 
00064 void EwDropDown::setBackgroundColor(ewDropDownColorIndex_t idx, ewColor_t c) {
00065     DROPDOWN_SetBkColor(_hWnd, idx, c);
00066 }
00067 
00068 void EwDropDown::setColor(ewDropDownColorIndex_t idx, ewColor_t c) {
00069     DROPDOWN_SetColor(_hWnd, idx, c);
00070 }
00071 
00072 void EwDropDown::setFont(const ewFont_t* pFont) {
00073     DROPDOWN_SetFont(_hWnd, pFont);
00074 }
00075 
00076 void EwDropDown::setItemEnableState(uint32_t idx, bool enabled) {
00077     DROPDOWN_SetItemDisabled(_hWnd, idx, (enabled ? 1 : 0));
00078 }
00079 
00080 void EwDropDown::setScrollbarColor(ewScrollBarColorIndex_t idx, ewColor_t c) {
00081     DROPDOWN_SetScrollbarColor(_hWnd, idx, c);
00082 }
00083 
00084 void EwDropDown::setScrollbarWidth(uint32_t width) {
00085     DROPDOWN_SetScrollbarWidth(_hWnd, width);
00086 }
00087 
00088 void EwDropDown::setSelectedItem(int32_t idx) {
00089     DROPDOWN_SetSel(_hWnd, idx);
00090 }
00091 
00092 void EwDropDown::setItemSpacing(uint32_t spacing) {
00093     DROPDOWN_SetItemSpacing(_hWnd, spacing);
00094 }
00095 
00096 void EwDropDown::setTextAlign(ewTextAlign_t align) {
00097     DROPDOWN_SetTextAlign(_hWnd, align);
00098 }
00099 
00100 void EwDropDown::setTextColor(ewDropDownColorIndex_t idx, ewColor_t c) {
00101     DROPDOWN_SetTextColor(_hWnd, idx, c);
00102 }
00103 
00104 void EwDropDown::setTextHeight(uint32_t height) {
00105     DROPDOWN_SetTextHeight(_hWnd, height);
00106 }
00107 
00108 void EwDropDown::setUpMode(bool upMode) {
00109     DROPDOWN_SetUpMode(_hWnd, (upMode ? 1 : 0));
00110 }
00111 
00112 void EwDropDown::setSelectionChangedListener(void (*fptr)(EwWindow* w)) {
00113     _selChangedListener.attach(fptr);
00114 }
00115 
00116 ewColor_t EwDropDown::getDefaultBackgroundColor(ewDropDownColorIndex_t idx) {
00117     return DROPDOWN_GetDefaultBkColor(idx);
00118 }
00119 
00120 ewColor_t EwDropDown::getDefaultColor(ewDropDownColorIndex_t idx) {
00121     return DROPDOWN_GetDefaultColor(idx);
00122 }
00123 
00124 ewColor_t EwDropDown::getDefaultScrollbarColor(ewDropDownColorIndex_t idx) {
00125     return DROPDOWN_GetDefaultScrollbarColor(idx);
00126 }
00127 
00128 const ewFont_t* EwDropDown::getDefaultFont() {
00129     return DROPDOWN_GetDefaultFont();
00130 }
00131 
00132 void EwDropDown::setDefaultBackgroundColor(ewDropDownColorIndex_t idx, ewColor_t c) {
00133     DROPDOWN_SetDefaultBkColor(idx, c);
00134 }
00135 
00136 void EwDropDown::setDefaultColor(ewDropDownColorIndex_t idx, ewColor_t c) {
00137     DROPDOWN_SetDefaultColor(idx, c);
00138 }
00139 
00140 void EwDropDown::setDefaultFont(const ewFont_t* pFont) {
00141     DROPDOWN_SetDefaultFont(pFont);
00142 }
00143 
00144 void EwDropDown::setDefaultScrollbarColor(ewScrollBarColorIndex_t idx, ewColor_t c) {
00145     DROPDOWN_SetDefaultScrollbarColor(idx, c);
00146 }
00147 
00148 
00149 void EwDropDown::init(int x, int y, int width, int height, EwWindow* parent) {
00150     DROPDOWN_Handle h;
00151     GUI_HWIN hWin = 0;
00152 
00153 
00154     if (parent) {
00155         hWin = _getHandle(parent);
00156     }
00157 
00158     h = DROPDOWN_CreateEx(x, y, width, height, hWin, (WM_CF_SHOW| WM_CF_MEMDEV),
00159             0, _guiWidgetId++);
00160     _setNewHandle(h, _callback);
00161 }
00162 
00163 void EwDropDown::handleSelectionChanged() {
00164     _selChangedListener.call(this);
00165 }
00166 
00167 
00168 
00169 void EwDropDown::_callback(WM_MESSAGE* pMsg, EwWindow* w) {
00170     bool selChanged = false;
00171 
00172     EwDropDown* b = (EwDropDown*)w;
00173 
00174 
00175     if (pMsg->MsgId == WM_NOTIFY_PARENT && pMsg->Data.v == WM_NOTIFICATION_SEL_CHANGED) {
00176         selChanged = true;
00177     }
00178     DROPDOWN_Callback(pMsg);
00179 
00180 
00181     if (selChanged) {
00182         b->handleSelectionChanged();
00183     }
00184 
00185 }
00186