Wrapper classes for the emwin library

Dependents:   app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin

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?

UserRevisionLine numberNew contents of line
embeddedartists 0:316c181e9b65 1
embeddedartists 0:316c181e9b65 2 #ifndef EWDROPDOWN_H
embeddedartists 0:316c181e9b65 3 #define EWDROPDOWN_H
embeddedartists 0:316c181e9b65 4
embeddedartists 0:316c181e9b65 5 #include "EwPainter.h"
embeddedartists 0:316c181e9b65 6 #include "EwWindow.h"
embeddedartists 0:316c181e9b65 7 #include "EwFunctionPointer.h"
embeddedartists 0:316c181e9b65 8
embeddedartists 0:316c181e9b65 9 #include "DROPDOWN.h"
embeddedartists 0:316c181e9b65 10
embeddedartists 0:316c181e9b65 11 // TODO: move to EwScrollbar.h ----------------->
embeddedartists 0:316c181e9b65 12 #include "SCROLLBAR.h"
embeddedartists 0:316c181e9b65 13
embeddedartists 0:316c181e9b65 14 enum ewScrollBarColorIndex_t {
embeddedartists 0:316c181e9b65 15 ScrollBarColorIndexThumb = SCROLLBAR_CI_THUMB,
embeddedartists 0:316c181e9b65 16 ScrollBarColorIndexShaft = SCROLLBAR_CI_SHAFT,
embeddedartists 0:316c181e9b65 17 ScrollBarColorIndexArrow = SCROLLBAR_CI_ARROW,
embeddedartists 0:316c181e9b65 18 };
embeddedartists 0:316c181e9b65 19 // <---------------------------------------------
embeddedartists 0:316c181e9b65 20
embeddedartists 0:316c181e9b65 21 enum ewDropDownColorIndex_t {
embeddedartists 0:316c181e9b65 22 DropDownColorIndexUnselected = DROPDOWN_CI_UNSEL,
embeddedartists 0:316c181e9b65 23 DropDownColorIndexSelected = DROPDOWN_CI_SEL,
embeddedartists 0:316c181e9b65 24 DropDownColorIndexSelFocus = DROPDOWN_CI_SELFOCUS,
embeddedartists 0:316c181e9b65 25 };
embeddedartists 0:316c181e9b65 26
embeddedartists 0:316c181e9b65 27 /**
embeddedartists 0:316c181e9b65 28 * This is a wrapper class for the emwin DROPDOWN interface.
embeddedartists 0:316c181e9b65 29 */
embeddedartists 0:316c181e9b65 30 class EwDropDown : public EwWindow {
embeddedartists 0:316c181e9b65 31 public:
embeddedartists 0:316c181e9b65 32
embeddedartists 0:316c181e9b65 33 EwDropDown(EwWindow* parent = 0);
embeddedartists 0:316c181e9b65 34 EwDropDown(int x, int y, int width, int height, EwWindow* parent = 0);
embeddedartists 0:316c181e9b65 35
embeddedartists 0:316c181e9b65 36
embeddedartists 0:316c181e9b65 37 void addString(const char* s);
embeddedartists 0:316c181e9b65 38 void collapse();
embeddedartists 0:316c181e9b65 39 void decrementSelection();
embeddedartists 0:316c181e9b65 40 void deleteItem(uint32_t idx);
embeddedartists 0:316c181e9b65 41 void expand();
embeddedartists 0:316c181e9b65 42 bool isItemDisabled(uint32_t idx);
embeddedartists 0:316c181e9b65 43 bool getItemText(uint32_t idx, char* pBuffer, int maxSize);
embeddedartists 0:316c181e9b65 44 int getNumItems();
embeddedartists 0:316c181e9b65 45 int32_t getSelectedIndex();
embeddedartists 0:316c181e9b65 46 void incrementSelection();
embeddedartists 0:316c181e9b65 47 void insertString(const char* s, uint32_t idx);
embeddedartists 0:316c181e9b65 48 void setAutoScroll(bool on);
embeddedartists 0:316c181e9b65 49 void setBackgroundColor(ewDropDownColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 50 void setColor(ewDropDownColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 51 void setFont(const ewFont_t* pFont);
embeddedartists 0:316c181e9b65 52 void setItemEnableState(uint32_t idx, bool enabled);
embeddedartists 0:316c181e9b65 53 void setScrollbarColor(ewScrollBarColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 54 void setScrollbarWidth(uint32_t width);
embeddedartists 0:316c181e9b65 55 void setSelectedItem(int32_t idx);
embeddedartists 0:316c181e9b65 56 void setItemSpacing(uint32_t spacing);
embeddedartists 0:316c181e9b65 57 void setTextAlign(ewTextAlign_t align);
embeddedartists 0:316c181e9b65 58 void setTextColor(ewDropDownColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 59 void setTextHeight(uint32_t height);
embeddedartists 0:316c181e9b65 60 void setUpMode(bool upMode);
embeddedartists 0:316c181e9b65 61
embeddedartists 0:316c181e9b65 62 /**
embeddedartists 0:316c181e9b65 63 * Register a member function that will called when a selection
embeddedartists 0:316c181e9b65 64 * in the drop-down list has changed.
embeddedartists 0:316c181e9b65 65 *
embeddedartists 0:316c181e9b65 66 * @param tptr pointer to the object to call the member function on
embeddedartists 0:316c181e9b65 67 * @param mptr pointer to the member function to be called
embeddedartists 0:316c181e9b65 68 */
embeddedartists 0:316c181e9b65 69 template<typename T>
embeddedartists 0:316c181e9b65 70 void setSelectionChangedListener(T* tptr, void (T::*mptr)(EwWindow* w)) {
embeddedartists 0:316c181e9b65 71 if((mptr != NULL) && (tptr != NULL)) {
embeddedartists 0:316c181e9b65 72 _selChangedListener.attach(tptr, mptr);
embeddedartists 0:316c181e9b65 73 }
embeddedartists 0:316c181e9b65 74 }
embeddedartists 0:316c181e9b65 75
embeddedartists 0:316c181e9b65 76 /**
embeddedartists 0:316c181e9b65 77 * Register a function that will called when the a selection
embeddedartists 0:316c181e9b65 78 * in the drop-down list has changed.
embeddedartists 0:316c181e9b65 79 *
embeddedartists 0:316c181e9b65 80 * @param fptr A pointer to a void function that will be called
embeddedartists 0:316c181e9b65 81 */
embeddedartists 0:316c181e9b65 82 void setSelectionChangedListener(void (*fptr)(EwWindow* w));
embeddedartists 0:316c181e9b65 83
embeddedartists 0:316c181e9b65 84 static ewColor_t getDefaultBackgroundColor(ewDropDownColorIndex_t idx);
embeddedartists 0:316c181e9b65 85 static ewColor_t getDefaultColor(ewDropDownColorIndex_t idx);
embeddedartists 0:316c181e9b65 86 static ewColor_t getDefaultScrollbarColor(ewDropDownColorIndex_t idx);
embeddedartists 0:316c181e9b65 87 static const ewFont_t* getDefaultFont();
embeddedartists 0:316c181e9b65 88
embeddedartists 0:316c181e9b65 89 void setDefaultBackgroundColor(ewDropDownColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 90 static void setDefaultColor(ewDropDownColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 91 static void setDefaultFont(const ewFont_t* pFont);
embeddedartists 0:316c181e9b65 92 static void setDefaultScrollbarColor(ewScrollBarColorIndex_t idx, ewColor_t c);
embeddedartists 0:316c181e9b65 93
embeddedartists 0:316c181e9b65 94 private:
embeddedartists 0:316c181e9b65 95
embeddedartists 0:316c181e9b65 96 EwFunctionPointer _selChangedListener;
embeddedartists 0:316c181e9b65 97
embeddedartists 0:316c181e9b65 98 void init(int x, int y, int width, int height, EwWindow* parent);
embeddedartists 0:316c181e9b65 99 void handleSelectionChanged();
embeddedartists 0:316c181e9b65 100
embeddedartists 0:316c181e9b65 101 static void _callback(WM_MESSAGE* pMsg, EwWindow* w);
embeddedartists 0:316c181e9b65 102
embeddedartists 0:316c181e9b65 103
embeddedartists 0:316c181e9b65 104 };
embeddedartists 0:316c181e9b65 105
embeddedartists 0:316c181e9b65 106 #endif