optionComponent.h
Go to the documentation of this file.00001 #ifndef OPTION_COMPONENT_H
00002 #define OPTION_COMPONENT_H
00003
00013 #include "ttfDraw.h"
00014 #include "drawSurface.h"
00015 #include "labelComponent.h"
00016 #include "buttonComponent.h"
00017 #include "fillSurface.h"
00018
00019
00023 class OptionComponent : public FocusComponentInterface {
00024 friend class optionLine;
00025 TTF_Draw& ttf;
00026 unsigned long fore_color;
00027 unsigned long focused_color;
00028 unsigned long back_color;
00029 int font_size;
00030 bool activated;
00031 int titleMaxWidth;
00032 VXV::Grid base_offset;
00033 unsigned int selected_row;
00034 int decided_row;
00035
00036 LabelComponent* selected_icon;
00037
00038 public:
00042 class optionLine {
00043 optionLine(void);
00044
00045 public:
00046 unsigned int selected_col;
00047 FillSurface* under_bar;
00048
00052 class text_t {
00053 public:
00054 Uint16* text;
00055 DrawSurface* surface;
00056 DrawSurface* focused;
00057 LabelComponent* label;
00058 ButtonComponent* button;
00059
00060 text_t(void)
00061 :text(NULL), surface(NULL), focused(NULL), label(NULL), button(NULL){};
00062 ~text_t(void);
00063 };
00064 text_t* title;
00065 std::vector<text_t*> items;
00066 VXV::Grid offset;
00067
00068 Uint16* copyString(const char* str);
00069 Uint16* copyString(const unsigned short* str);
00070
00071 optionLine(const VXV::Grid& base_offset);
00072 ~optionLine(void);
00073 void setTitle(const char* name);
00074 void setTitle(const unsigned short* name);
00075 void addItem(const char* item);
00076 void addItem(const unsigned short* item);
00077 void setSelected(int index);
00078 };
00079
00080 DrawSurface* createSurface(Uint16* text,
00081 unsigned long fore, unsigned long back);
00082 void createLabel(optionLine::text_t& text);
00083 void createButton(optionLine::text_t& text);
00084
00085 public:
00086 std::vector<optionLine*> lines;
00087
00088 OptionComponent(TTF_Draw& ttf_resource, int fontSize,
00089 LabelComponent* selectedIcon);
00090 ~OptionComponent(void);
00091 bool draw(unsigned long ticks, const UserInput& ui);
00092 void setFontSize(int size);
00093 void setBaseOffset(const VXV::Grid& offset);
00094 void setColor(unsigned long fore, unsigned long back = Black,
00095 unsigned long focused = Blue);
00096 void activate(void);
00097 void setIconRow(int row);
00098 void setSelectedIndex(unsigned int row, unsigned int nth);
00099 int getSelected(unsigned int row);
00100 bool isDecided(void);
00101 int getDecidedRow(void);
00102
00103 void beginFocus(void);
00104 void endFocus(void);
00105 };
00106
00107 #endif
00108