Basic swim GUI for LPC4088
Fork of DMBasicGUI by
Embed:
(wiki syntax)
Show/hide line numbers
DigitButton.h
00001 /* 00002 * Copyright 2014 Embedded Artists AB 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef DIGITBUTTON_H 00018 #define DIGITBUTTON_H 00019 00020 #include "Clickable.h" 00021 #include "Image.h" 00022 00023 /** 00024 * The DigitButton is used in the same way as the Button so see it for an example 00025 */ 00026 class DigitButton : public Clickable { 00027 public: 00028 00029 /** Creates a new button 00030 * 00031 * This button will use a SWIM window to draw on. That window will use 00032 * part of the full size frame buffer to draw on. 00033 * 00034 * @param fb the frame buffer 00035 * @param x the upper left corner of the button 00036 * @param y the upper left corner of the button 00037 * @param width the width of the button 00038 * @param height the height of the button 00039 */ 00040 DigitButton(COLOR_T* fb, uint16_t x, uint16_t y, uint16_t width, uint16_t height); 00041 virtual ~DigitButton(); 00042 00043 /** Loads the mandatory "normal" state image and the optional "pressed" state image 00044 * 00045 * @param imgUp the file with the image for the normal state 00046 * @param imgDown the file with the image for the pressed state (or NULL to use the same) 00047 * 00048 * @returns 00049 * true on success 00050 * false on failure 00051 */ 00052 bool loadImages(const char* imgUp, const char* imgDown = 0); 00053 00054 /** Loads the mandatory "normal" state image and the optional "pressed" state image 00055 * 00056 * @param imgUp the decoded image for the normal state 00057 * @param imgDown the decoded image for the pressed state (or NULL to use the same) 00058 * 00059 * @returns 00060 * true on success 00061 * false on failure 00062 */ 00063 bool loadImages(const Image::ImageData_t* imgUp, const Image::ImageData_t* imgDown = 0); 00064 00065 /** Loads the mandatory "normal" state image and the optional "pressed" state image 00066 * 00067 * @param imgUp the image for the normal state 00068 * @param imgDown the image for the pressed state (or NULL to use the same) 00069 * 00070 * @returns 00071 * true on success 00072 * false on failure 00073 */ 00074 bool loadImages(const unsigned char* imgUp, unsigned int imgUpSize, 00075 const unsigned char* imgDown = 0, unsigned int imgDownSize = 0); 00076 00077 void setNumDigits(unsigned int num); 00078 void setValue(unsigned int val); 00079 00080 /** Draws the button (on a new framebuffer if one is specified) 00081 * @param fb the frame buffer 00082 */ 00083 virtual void draw(COLOR_T* fb = 0); 00084 00085 private: 00086 Image::ImageData_t _imgUp; 00087 Image::ImageData_t _imgDown; 00088 unsigned int _value; 00089 unsigned int _digits; 00090 unsigned int _img_y_offset; 00091 unsigned int _img_digit_height; 00092 unsigned int _img_digit_width; 00093 unsigned int _img_digit_size; 00094 00095 void drawDigits(Image::ImageData_t& img); 00096 }; 00097 00098 #endif /* IMAGEBUTTON_H */
Generated on Wed Jul 13 2022 03:01:50 by 1.7.2