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 EmbeddedArtists AB

Committer:
embeddedartists
Date:
Thu Jan 08 19:28:22 2015 +0100
Revision:
7:4ba7bd9d32ef
Child:
9:ce69a7adfe9c
- Added pressed() and bounds() functions to Clickable
- Added DigitButton
- Added swim_put_image_xy() to be able to tell where an image is drawn
- Moved AppImageViewer and AppSettings from this lib into the main program

Who changed what in which revision?

UserRevisionLine numberNew 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 7:4ba7bd9d32ef 56 * @param imgUp the image for the normal state
embeddedartists 7:4ba7bd9d32ef 57 * @param imgDown the image for the pressed state (or NULL to use the same)
embeddedartists 7:4ba7bd9d32ef 58 *
embeddedartists 7:4ba7bd9d32ef 59 * @returns
embeddedartists 7:4ba7bd9d32ef 60 * true on success
embeddedartists 7:4ba7bd9d32ef 61 * false on failure
embeddedartists 7:4ba7bd9d32ef 62 */
embeddedartists 7:4ba7bd9d32ef 63 bool loadImages(const unsigned char* imgUp, unsigned int imgUpSize,
embeddedartists 7:4ba7bd9d32ef 64 const unsigned char* imgDown = 0, unsigned int imgDownSize = 0);
embeddedartists 7:4ba7bd9d32ef 65
embeddedartists 7:4ba7bd9d32ef 66 void setNumDigits(unsigned int num);
embeddedartists 7:4ba7bd9d32ef 67 void setValue(unsigned int val);
embeddedartists 7:4ba7bd9d32ef 68
embeddedartists 7:4ba7bd9d32ef 69 /** Draws the button (on a new framebuffer if one is specified)
embeddedartists 7:4ba7bd9d32ef 70 * @param fb the frame buffer
embeddedartists 7:4ba7bd9d32ef 71 */
embeddedartists 7:4ba7bd9d32ef 72 virtual void draw(COLOR_T* fb = 0);
embeddedartists 7:4ba7bd9d32ef 73
embeddedartists 7:4ba7bd9d32ef 74 private:
embeddedartists 7:4ba7bd9d32ef 75 Image::ImageData_t _imgUp;
embeddedartists 7:4ba7bd9d32ef 76 Image::ImageData_t _imgDown;
embeddedartists 7:4ba7bd9d32ef 77 unsigned int _value;
embeddedartists 7:4ba7bd9d32ef 78 unsigned int _digits;
embeddedartists 7:4ba7bd9d32ef 79 unsigned int _img_y_offset;
embeddedartists 7:4ba7bd9d32ef 80 unsigned int _img_digit_height;
embeddedartists 7:4ba7bd9d32ef 81 unsigned int _img_digit_width;
embeddedartists 7:4ba7bd9d32ef 82 unsigned int _img_digit_size;
embeddedartists 7:4ba7bd9d32ef 83
embeddedartists 7:4ba7bd9d32ef 84 void drawDigits(Image::ImageData_t& img);
embeddedartists 7:4ba7bd9d32ef 85 };
embeddedartists 7:4ba7bd9d32ef 86
embeddedartists 7:4ba7bd9d32ef 87 #endif /* IMAGEBUTTON_H */