Phoenard
PHNButton.h
Go to the documentation of this file.
1 /*
2 The MIT License (MIT)
3 
4 This file is part of the Phoenard Arduino library
5 Copyright (c) 2014 Phoenard
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 THE SOFTWARE.
24 */
25 
31 #include "PHNWidget.h"
32 #include "PHNImage.h"
33 
34 #ifndef _PHN_BUTTON_H_
35 #define _PHN_BUTTON_H_
36 
45 class PHN_Button : public PHN_Widget, public PHN_TextContainer {
46 public:
48  const PHN_Image &image(int index) { return images[index]; }
50  void setImage(int index, const PHN_Image &image);
52  void setImage(const PHN_Image &image);
54  void setImagePalette(int index, const PHN_Palette &palette);
55 
56  virtual void setTextRaw(const char* text, int textLen);
57  virtual const char* text() { return ""; }
58  virtual void draw(void);
59  virtual void update(void);
60 
61 private:
62  PHN_Image images[3];
63 };
64 
65 #endif
const PHN_Image & image(int index)
Gets a state image set, where index 0=normal, 1=pressed, 2=clicked.
Definition: PHNButton.h:48
void setImage(int index, const PHN_Image &image)
Sets a state image, where index 0=normal, 1=pressed, 2=clicked.
Definition: PHNButton.cpp:32
Contains the PHN_Image class for storing image information and several macros for creating images...
A color Palette that can store up to 256 colors.
Definition: PHNPalette.h:43
Stores the information needed to draw an image to screen.
Definition: PHNImage.h:48
Abstraction for a widget that can store and update text.
Definition: PHNTextContainer.h:41
virtual void setTextRaw(const char *text, int textLen)
Sets the new text to display using a buffer and length.
Definition: PHNButton.cpp:28
A single widget which covers a rectangular area of the screen.
Definition: PHNWidget.h:145
virtual void draw(void)
Draw function routine, where widgets must perform drawing.
Definition: PHNButton.cpp:49
virtual void update(void)
Update function routine, where widget logic must be performed.
Definition: PHNButton.cpp:69
The button widget can be clicked by the user, showing three states.
Definition: PHNButton.h:45
Holds the PHN_Widget and PHN_WidgetContainer classes used for managing widgets.
virtual const char * text()
Gets the text displayed.
Definition: PHNButton.h:57
void setImagePalette(int index, const PHN_Palette &palette)
Change for individual states what colors are used, where index 0=normal, 1=pressed, 2=clicked.
Definition: PHNButton.cpp:37