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