Basic swim GUI for LPC4088
Fork of DMBasicGUI by
Application/ImageButton.h@38:1b7c79a10e14, 2016-03-14 (annotated)
- Committer:
- redbird
- Date:
- Mon Mar 14 20:14:06 2016 -0600
- Revision:
- 38:1b7c79a10e14
- Parent:
- 17:6e2abf107800
revert programming
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 2:efae611de184 | 1 | /* |
embeddedartists | 2:efae611de184 | 2 | * Copyright 2014 Embedded Artists AB |
embeddedartists | 2:efae611de184 | 3 | * |
embeddedartists | 2:efae611de184 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 2:efae611de184 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 2:efae611de184 | 6 | * You may obtain a copy of the License at |
embeddedartists | 2:efae611de184 | 7 | * |
embeddedartists | 2:efae611de184 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 2:efae611de184 | 9 | * |
embeddedartists | 2:efae611de184 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 2:efae611de184 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 2:efae611de184 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 2:efae611de184 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 2:efae611de184 | 14 | * limitations under the License. |
embeddedartists | 2:efae611de184 | 15 | */ |
embeddedartists | 2:efae611de184 | 16 | |
embeddedartists | 3:3fabfe3339b8 | 17 | #ifndef IMAGEBUTTON_H |
embeddedartists | 3:3fabfe3339b8 | 18 | #define IMAGEBUTTON_H |
embeddedartists | 2:efae611de184 | 19 | |
embeddedartists | 2:efae611de184 | 20 | #include "Clickable.h" |
embeddedartists | 2:efae611de184 | 21 | #include "Image.h" |
embeddedartists | 17:6e2abf107800 | 22 | #include "Resource.h" |
embeddedartists | 2:efae611de184 | 23 | |
embeddedartists | 2:efae611de184 | 24 | /** |
embeddedartists | 2:efae611de184 | 25 | * The ImageButton is used in the same way as the Button so see it for an example |
embeddedartists | 2:efae611de184 | 26 | */ |
embeddedartists | 2:efae611de184 | 27 | class ImageButton : public Clickable { |
embeddedartists | 2:efae611de184 | 28 | public: |
embeddedartists | 2:efae611de184 | 29 | |
embeddedartists | 2:efae611de184 | 30 | /** Creates a new button |
embeddedartists | 2:efae611de184 | 31 | * |
embeddedartists | 2:efae611de184 | 32 | * This button will use a SWIM window to draw on. That window will use |
embeddedartists | 2:efae611de184 | 33 | * part of the full size frame buffer to draw on. |
embeddedartists | 2:efae611de184 | 34 | * |
embeddedartists | 2:efae611de184 | 35 | * @param fb the frame buffer |
embeddedartists | 2:efae611de184 | 36 | * @param x the upper left corner of the button |
embeddedartists | 2:efae611de184 | 37 | * @param y the upper left corner of the button |
embeddedartists | 2:efae611de184 | 38 | * @param width the width of the button |
embeddedartists | 2:efae611de184 | 39 | * @param height the height of the button |
embeddedartists | 11:265884fa7fdd | 40 | * @param caption optional text to put below the image |
embeddedartists | 11:265884fa7fdd | 41 | * @param color text color |
embeddedartists | 3:3fabfe3339b8 | 42 | */ |
embeddedartists | 11:265884fa7fdd | 43 | ImageButton(COLOR_T* fb, uint16_t x, uint16_t y, uint16_t width, uint16_t height, |
embeddedartists | 11:265884fa7fdd | 44 | const char* caption=NULL, COLOR_T color=BLACK); |
embeddedartists | 10:651861441108 | 45 | virtual ~ImageButton(); |
embeddedartists | 3:3fabfe3339b8 | 46 | |
embeddedartists | 3:3fabfe3339b8 | 47 | /** Loads the mandatory "normal" state image and the optional "pressed" state image |
embeddedartists | 3:3fabfe3339b8 | 48 | * |
embeddedartists | 4:a73760d09423 | 49 | * @param imgUp the file with the image for the normal state |
embeddedartists | 4:a73760d09423 | 50 | * @param imgDown the file with the image for the pressed state (or NULL to use the same) |
embeddedartists | 4:a73760d09423 | 51 | * |
embeddedartists | 4:a73760d09423 | 52 | * @returns |
embeddedartists | 4:a73760d09423 | 53 | * true on success |
embeddedartists | 4:a73760d09423 | 54 | * false on failure |
embeddedartists | 4:a73760d09423 | 55 | */ |
embeddedartists | 4:a73760d09423 | 56 | bool loadImages(const char* imgUp, const char* imgDown = 0); |
embeddedartists | 4:a73760d09423 | 57 | |
embeddedartists | 4:a73760d09423 | 58 | /** Loads the mandatory "normal" state image and the optional "pressed" state image |
embeddedartists | 4:a73760d09423 | 59 | * |
embeddedartists | 17:6e2abf107800 | 60 | * @param imgUp the image for the normal state |
embeddedartists | 17:6e2abf107800 | 61 | * @param imgUpSize the size of the imgUp data |
embeddedartists | 17:6e2abf107800 | 62 | * @param imgDown the image for the pressed state (or NULL to use the same) |
embeddedartists | 17:6e2abf107800 | 63 | * @param imgUpSize the size of the imgDown data |
embeddedartists | 3:3fabfe3339b8 | 64 | * |
embeddedartists | 3:3fabfe3339b8 | 65 | * @returns |
embeddedartists | 3:3fabfe3339b8 | 66 | * true on success |
embeddedartists | 3:3fabfe3339b8 | 67 | * false on failure |
embeddedartists | 2:efae611de184 | 68 | */ |
embeddedartists | 4:a73760d09423 | 69 | bool loadImages(const unsigned char* imgUp, unsigned int imgUpSize, |
embeddedartists | 4:a73760d09423 | 70 | const unsigned char* imgDown = 0, unsigned int imgDownSize = 0); |
embeddedartists | 3:3fabfe3339b8 | 71 | |
embeddedartists | 17:6e2abf107800 | 72 | /** Loads the mandatory "normal" state image and the optional "pressed" state image |
embeddedartists | 17:6e2abf107800 | 73 | * |
embeddedartists | 17:6e2abf107800 | 74 | * @param resImgUp the resource for the normal state image |
embeddedartists | 17:6e2abf107800 | 75 | * @param resImgDown the resource for the pressed state image (or NULL to use the same) |
embeddedartists | 17:6e2abf107800 | 76 | * |
embeddedartists | 17:6e2abf107800 | 77 | * @returns |
embeddedartists | 17:6e2abf107800 | 78 | * true on success |
embeddedartists | 17:6e2abf107800 | 79 | * false on failure |
embeddedartists | 17:6e2abf107800 | 80 | */ |
embeddedartists | 17:6e2abf107800 | 81 | bool loadImages(Resource* resImgUp, Resource* resImgDown = 0); |
embeddedartists | 17:6e2abf107800 | 82 | |
embeddedartists | 11:265884fa7fdd | 83 | /** Specifys a color that will be considered transparent (i.e. will not be drawn) |
embeddedartists | 11:265884fa7fdd | 84 | * @param tColor the transparent color |
embeddedartists | 11:265884fa7fdd | 85 | */ |
embeddedartists | 11:265884fa7fdd | 86 | void setTransparency(COLOR_T tColor); |
embeddedartists | 11:265884fa7fdd | 87 | |
embeddedartists | 6:7917b0894655 | 88 | /** Draws the button (on a new framebuffer if one is specified) |
embeddedartists | 6:7917b0894655 | 89 | * @param fb the frame buffer |
embeddedartists | 2:efae611de184 | 90 | */ |
embeddedartists | 6:7917b0894655 | 91 | virtual void draw(COLOR_T* fb = 0); |
embeddedartists | 2:efae611de184 | 92 | |
embeddedartists | 2:efae611de184 | 93 | private: |
embeddedartists | 2:efae611de184 | 94 | Image::ImageData_t _imgUp; |
embeddedartists | 2:efae611de184 | 95 | Image::ImageData_t _imgDown; |
embeddedartists | 11:265884fa7fdd | 96 | char* _caption; |
embeddedartists | 11:265884fa7fdd | 97 | COLOR_T _captionColor; |
embeddedartists | 11:265884fa7fdd | 98 | bool _transparent; |
embeddedartists | 11:265884fa7fdd | 99 | COLOR_T _transparentColor; |
embeddedartists | 2:efae611de184 | 100 | }; |
embeddedartists | 2:efae611de184 | 101 | |
embeddedartists | 3:3fabfe3339b8 | 102 | #endif /* IMAGEBUTTON_H */ |