PageRenderTime 11ms CodeModel.GetById 7ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/WidgetInput.h

http://github.com/clintbellanger/flare
C++ Header | 63 lines | 27 code | 14 blank | 22 comment | 0 complexity | 6ab72aa548b1a3aa26777238245a98d3 MD5 | raw file
 1/*
 2Copyright 2011 kitano
 3
 4This file is part of FLARE.
 5
 6FLARE is free software: you can redistribute it and/or modify it under the terms
 7of the GNU General Public License as published by the Free Software Foundation,
 8either version 3 of the License, or (at your option) any later version.
 9
10FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15FLARE.  If not, see http://www.gnu.org/licenses/
16*/
17
18/**
19 * class WidgetInput
20 *
21 * A simple text box with a label above it.
22 * It has two images - one for focused and one for unfocused.
23 */
24
25#ifndef WIDGETINPUT_H
26#define WIDGETINPUT_H
27
28#include "FontEngine.h"
29#include "InputState.h"
30#include <SDL.h>
31#include <string>
32
33class WidgetInput {
34
35protected:
36
37	void loadGraphics(const std::string& filename);
38
39	SDL_Surface *background;
40
41	bool enabled;
42	bool inFocus;
43	bool pressed;
44
45	std::string text; // the text that has been typed into the box
46	unsigned int max_characters;
47	int cursor_frame;
48	
49	Point font_pos;
50
51public:
52	WidgetInput();
53	
54	void logic();
55	void render();
56	bool checkClick();
57	std::string getText() { return text; }
58	void setPosition(int x, int y);
59
60	SDL_Rect pos;
61};
62
63#endif