A basic graphics package for the LPC4088 Display Module.
Dependents: lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more
Fork of DMBasicGUI by
Application/DigitButton.h@9:ce69a7adfe9c, 2015-01-20 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Jan 20 09:05:30 2015 +0100
- Revision:
- 9:ce69a7adfe9c
- Parent:
- 7:4ba7bd9d32ef
- Child:
- 10:651861441108
- Added support in DigitButton and ImageButton to pass a pre-loaded image
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 7:4ba7bd9d32ef | 1 | /* |
embeddedartists | 7:4ba7bd9d32ef | 2 | * Copyright 2014 Embedded Artists AB |
embeddedartists | 7:4ba7bd9d32ef | 3 | * |
embeddedartists | 7:4ba7bd9d32ef | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 7:4ba7bd9d32ef | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 7:4ba7bd9d32ef | 6 | * You may obtain a copy of the License at |
embeddedartists | 7:4ba7bd9d32ef | 7 | * |
embeddedartists | 7:4ba7bd9d32ef | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 7:4ba7bd9d32ef | 9 | * |
embeddedartists | 7:4ba7bd9d32ef | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 7:4ba7bd9d32ef | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 7:4ba7bd9d32ef | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 7:4ba7bd9d32ef | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 7:4ba7bd9d32ef | 14 | * limitations under the License. |
embeddedartists | 7:4ba7bd9d32ef | 15 | */ |
embeddedartists | 7:4ba7bd9d32ef | 16 | |
embeddedartists | 7:4ba7bd9d32ef | 17 | #ifndef DIGITBUTTON_H |
embeddedartists | 7:4ba7bd9d32ef | 18 | #define DIGITBUTTON_H |
embeddedartists | 7:4ba7bd9d32ef | 19 | |
embeddedartists | 7:4ba7bd9d32ef | 20 | #include "Clickable.h" |
embeddedartists | 7:4ba7bd9d32ef | 21 | #include "Image.h" |
embeddedartists | 7:4ba7bd9d32ef | 22 | |
embeddedartists | 7:4ba7bd9d32ef | 23 | /** |
embeddedartists | 7:4ba7bd9d32ef | 24 | * The DigitButton is used in the same way as the Button so see it for an example |
embeddedartists | 7:4ba7bd9d32ef | 25 | */ |
embeddedartists | 7:4ba7bd9d32ef | 26 | class DigitButton : public Clickable { |
embeddedartists | 7:4ba7bd9d32ef | 27 | public: |
embeddedartists | 7:4ba7bd9d32ef | 28 | |
embeddedartists | 7:4ba7bd9d32ef | 29 | /** Creates a new button |
embeddedartists | 7:4ba7bd9d32ef | 30 | * |
embeddedartists | 7:4ba7bd9d32ef | 31 | * This button will use a SWIM window to draw on. That window will use |
embeddedartists | 7:4ba7bd9d32ef | 32 | * part of the full size frame buffer to draw on. |
embeddedartists | 7:4ba7bd9d32ef | 33 | * |
embeddedartists | 7:4ba7bd9d32ef | 34 | * @param fb the frame buffer |
embeddedartists | 7:4ba7bd9d32ef | 35 | * @param x the upper left corner of the button |
embeddedartists | 7:4ba7bd9d32ef | 36 | * @param y the upper left corner of the button |
embeddedartists | 7:4ba7bd9d32ef | 37 | * @param width the width of the button |
embeddedartists | 7:4ba7bd9d32ef | 38 | * @param height the height of the button |
embeddedartists | 7:4ba7bd9d32ef | 39 | */ |
embeddedartists | 7:4ba7bd9d32ef | 40 | DigitButton(COLOR_T* fb, uint16_t x, uint16_t y, uint16_t width, uint16_t height); |
embeddedartists | 7:4ba7bd9d32ef | 41 | ~DigitButton(); |
embeddedartists | 7:4ba7bd9d32ef | 42 | |
embeddedartists | 7:4ba7bd9d32ef | 43 | /** Loads the mandatory "normal" state image and the optional "pressed" state image |
embeddedartists | 7:4ba7bd9d32ef | 44 | * |
embeddedartists | 7:4ba7bd9d32ef | 45 | * @param imgUp the file with the image for the normal state |
embeddedartists | 7:4ba7bd9d32ef | 46 | * @param imgDown the file with the image for the pressed state (or NULL to use the same) |
embeddedartists | 7:4ba7bd9d32ef | 47 | * |
embeddedartists | 7:4ba7bd9d32ef | 48 | * @returns |
embeddedartists | 7:4ba7bd9d32ef | 49 | * true on success |
embeddedartists | 7:4ba7bd9d32ef | 50 | * false on failure |
embeddedartists | 7:4ba7bd9d32ef | 51 | */ |
embeddedartists | 7:4ba7bd9d32ef | 52 | bool loadImages(const char* imgUp, const char* imgDown = 0); |
embeddedartists | 7:4ba7bd9d32ef | 53 | |
embeddedartists | 7:4ba7bd9d32ef | 54 | /** Loads the mandatory "normal" state image and the optional "pressed" state image |
embeddedartists | 7:4ba7bd9d32ef | 55 | * |
embeddedartists | 9:ce69a7adfe9c | 56 | * @param imgUp the decoded image for the normal state |
embeddedartists | 9:ce69a7adfe9c | 57 | * @param imgDown the decoded image for the pressed state (or NULL to use the same) |
embeddedartists | 9:ce69a7adfe9c | 58 | * |
embeddedartists | 9:ce69a7adfe9c | 59 | * @returns |
embeddedartists | 9:ce69a7adfe9c | 60 | * true on success |
embeddedartists | 9:ce69a7adfe9c | 61 | * false on failure |
embeddedartists | 9:ce69a7adfe9c | 62 | */ |
embeddedartists | 9:ce69a7adfe9c | 63 | bool loadImages(const Image::ImageData_t* imgUp, const Image::ImageData_t* imgDown = 0); |
embeddedartists | 9:ce69a7adfe9c | 64 | |
embeddedartists | 9:ce69a7adfe9c | 65 | /** Loads the mandatory "normal" state image and the optional "pressed" state image |
embeddedartists | 9:ce69a7adfe9c | 66 | * |
embeddedartists | 7:4ba7bd9d32ef | 67 | * @param imgUp the image for the normal state |
embeddedartists | 7:4ba7bd9d32ef | 68 | * @param imgDown the image for the pressed state (or NULL to use the same) |
embeddedartists | 7:4ba7bd9d32ef | 69 | * |
embeddedartists | 7:4ba7bd9d32ef | 70 | * @returns |
embeddedartists | 7:4ba7bd9d32ef | 71 | * true on success |
embeddedartists | 7:4ba7bd9d32ef | 72 | * false on failure |
embeddedartists | 7:4ba7bd9d32ef | 73 | */ |
embeddedartists | 7:4ba7bd9d32ef | 74 | bool loadImages(const unsigned char* imgUp, unsigned int imgUpSize, |
embeddedartists | 7:4ba7bd9d32ef | 75 | const unsigned char* imgDown = 0, unsigned int imgDownSize = 0); |
embeddedartists | 7:4ba7bd9d32ef | 76 | |
embeddedartists | 7:4ba7bd9d32ef | 77 | void setNumDigits(unsigned int num); |
embeddedartists | 7:4ba7bd9d32ef | 78 | void setValue(unsigned int val); |
embeddedartists | 7:4ba7bd9d32ef | 79 | |
embeddedartists | 7:4ba7bd9d32ef | 80 | /** Draws the button (on a new framebuffer if one is specified) |
embeddedartists | 7:4ba7bd9d32ef | 81 | * @param fb the frame buffer |
embeddedartists | 7:4ba7bd9d32ef | 82 | */ |
embeddedartists | 7:4ba7bd9d32ef | 83 | virtual void draw(COLOR_T* fb = 0); |
embeddedartists | 7:4ba7bd9d32ef | 84 | |
embeddedartists | 7:4ba7bd9d32ef | 85 | private: |
embeddedartists | 7:4ba7bd9d32ef | 86 | Image::ImageData_t _imgUp; |
embeddedartists | 7:4ba7bd9d32ef | 87 | Image::ImageData_t _imgDown; |
embeddedartists | 7:4ba7bd9d32ef | 88 | unsigned int _value; |
embeddedartists | 7:4ba7bd9d32ef | 89 | unsigned int _digits; |
embeddedartists | 7:4ba7bd9d32ef | 90 | unsigned int _img_y_offset; |
embeddedartists | 7:4ba7bd9d32ef | 91 | unsigned int _img_digit_height; |
embeddedartists | 7:4ba7bd9d32ef | 92 | unsigned int _img_digit_width; |
embeddedartists | 7:4ba7bd9d32ef | 93 | unsigned int _img_digit_size; |
embeddedartists | 7:4ba7bd9d32ef | 94 | |
embeddedartists | 7:4ba7bd9d32ef | 95 | void drawDigits(Image::ImageData_t& img); |
embeddedartists | 7:4ba7bd9d32ef | 96 | }; |
embeddedartists | 7:4ba7bd9d32ef | 97 | |
embeddedartists | 7:4ba7bd9d32ef | 98 | #endif /* IMAGEBUTTON_H */ |