00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef header_inputbox_generic
00010 #define header_inputbox_generic
00011
00012 #include "API/GUI/inputbox.h"
00013
00014 class CL_InputBox_Generic
00015 {
00016 public:
00017 static CL_ComponentOptions create_options(
00018 const CL_Rect &pos,
00019 const std::string &text,
00020 bool password_mode,
00021 bool readonly,
00022 int maxlength);
00023
00024 CL_InputBox_Generic(CL_InputBox *self, const CL_ComponentOptions &options, CL_StyleManager *style);
00025 ~CL_InputBox_Generic() {};
00026
00027 CL_InputBox *inputbox;
00028
00029 bool password_mode;
00030 bool read_only;
00031
00032 bool edited;
00033
00034 int cursor_position;
00035
00036 int max_length;
00037
00038 std::string text;
00039
00040 CL_Signal_v1<const std::string &> sig_changed;
00041 CL_Signal_v1<const std::string &> sig_return_pressed;
00042
00043 CL_Slot slot_key_down;
00044 CL_Slot slot_key_up;
00045 CL_Slot slot_mouse_move;
00046
00047 void on_key_down(CL_Component *comp, CL_InputDevice *device, CL_Key key);
00048 void on_key_up(CL_Component *comp, CL_InputDevice *device, CL_Key key);
00049 void on_mouse_move(CL_Component *comp, CL_InputDevice *device, int x, int y);
00050
00051 void set_text(const std::string &text);
00052 const std::string &get_marked_text() const;
00053 void set_max_length(int length);
00054 void select_all();
00055 void deselect();
00056 void set_selection(int start, int length);
00057 void set_cursor_position(int pos);
00058 void backspace();
00059 void del();
00060 void cut();
00061 void move_cursor(int delta, bool mark);
00062 void move_cursor_word(int delta, bool mark);
00063 void home(bool mark);
00064 void end(bool mark);
00065 int get_selection_start();
00066 int get_selection_length();
00067
00068 private:
00069 bool selecting;
00070 bool mouse_selecting;
00071 int selection_start;
00072 int selection_end;
00073
00074 bool ctrl_down;
00075 bool shift_down;
00076
00077 void check_selection();
00078
00079 void update_text(CL_Key key);
00080 int get_mouse_position(int x, int y);
00081 };
00082
00083 #endif