Simple integer calculator using FRDM-KL25Z and Adafruit 2.8" TFT with touch \\ "Dentaku" means "Desktop Calculator" in Japanese \\ On 5-Dec-2015, Support for FRDM-K64F, FRDM-K22F, NUCLEO-F411RE added.

Dependencies:   SPI_STMPE610 UniGraphic mbed vt100

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TFTMenu.h Source File

TFTMenu.h

00001 /** mbed oscilloscope my implementation of a oscillo scope
00002  * Copyright (c) 2014, 2015 Motoo Tanaka @ Design Methodology Lab
00003  *
00004  * TFTMenu.h
00005  *
00006  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00007  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00008  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00009  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00010  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00011  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00012  * THE SOFTWARE.
00013  */
00014 #ifndef _TFT_MENU_H_
00015 #define _TFT_MENU_H_ defined
00016 
00017 typedef void (*FuncPtr)(void) ;
00018 
00019 class TFTMenuItem {
00020 public:
00021 TFTMenuItem(int x1, int y1, int x2, int y2, FuncPtr fnc, 
00022     char *name, uint16_t mc, uint16_t fc,
00023     int l_margin = 7, int t_margin = 10) ;
00024 ~TFTMenuItem() ;
00025 virtual bool hit(int x, int y) ;
00026 virtual void draw(int offset_x = 0, int offset_y = 0) ;
00027 virtual void font_margin(int x, int y) ;
00028 void highlight(int offset_x = 0, int offset_y = 0) ;
00029 uint16_t getColor(void) ;
00030 void doIt(void) ;
00031 const char *name(void) { return label ; }
00032 
00033 protected:
00034 char *label ;
00035 uint16_t font_color ;
00036 uint16_t menu_color ;
00037 int top ; 
00038 int bottom ;
00039 int left ;
00040 int right ;
00041 int left_margin ;
00042 int top_margin ;
00043 FuncPtr func ;
00044 private:
00045 } ;
00046 
00047 class TFTRadioButton : public TFTMenuItem {
00048 public:
00049 TFTRadioButton(int x1, int y1, int x2, int y2, FuncPtr fnc, 
00050     char *name, uint16_t mc, uint16_t fc,
00051     char *altname = 0, uint16_t altmc = 0, uint16_t altfc = 0, 
00052     bool sel = false) ;
00053 ~TFTRadioButton() ;
00054 
00055 virtual bool hit(int x, int y) ;
00056 virtual void draw(int offset_x = 0, int offset_y = 0) ;
00057 
00058 void select(bool value) ;
00059 
00060 protected:
00061 bool selected ;
00062 char *alt_label ;
00063 uint16_t alt_font_color ;
00064 uint16_t alt_menu_color ;
00065 // FuncPtr alt_func ;
00066 private:
00067 } ;
00068 
00069 class TFTMenu {
00070 public:
00071 TFTMenu() ; // constructor
00072 ~TFTMenu() ; // destructor 
00073 private:
00074 } ;
00075 
00076 #endif /* _TFT_MENU_H_ */