00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "precomp.h"
00010 #include "combobox_generic.h"
00011 #include "API/GUI/component_options.h"
00012
00013 CL_ComponentOptions CL_ComboBox_Generic::create_options(
00014 const CL_Rect &pos)
00015 {
00016 CL_ComponentOptions options;
00017
00018 options.add_option_as_int("x", pos.x1);
00019 options.add_option_as_int("y", pos.y1);
00020 options.add_option_as_int("width", pos.get_width());
00021
00022 options.add_option_as_int("height", 16);
00023
00024 return options;
00025 }
00026
00027 CL_ComboBox_Generic::CL_ComboBox_Generic(CL_ComboBox *self, const CL_ComponentOptions &options, CL_StyleManager *style)
00028 :
00029 combobox(self)
00030 {
00031 highlighted_item = 0;
00032 select_button = NULL;
00033 activated = false;
00034
00035 int num_values = options.count("value");
00036 for (int i=0;i<num_values;i++)
00037 {
00038 items.push_back(options.get_value("value", i));
00039 }
00040 }
00041
00042 CL_ComboBox_Generic::~CL_ComboBox_Generic()
00043 {
00044 }
00045
00046 int CL_ComboBox_Generic::get_count() const
00047 {
00048 return items.size();
00049 }
00050
00051 std::list<std::string> &CL_ComboBox_Generic::get_items()
00052 {
00053 return items;
00054 }
00055
00056 std::string CL_ComboBox_Generic::get_current_text() const
00057 {
00058 int count = highlighted_item;
00059 std::list<std::string>::const_iterator it;
00060 for (it = items.begin(); it != items.end() && count > 0; it++, count--);
00061 if (it != items.end())
00062 return *it;
00063
00064 char buf[100];
00065 sprintf(buf, "Listbox has illegal value: %d", highlighted_item);
00066 throw CL_Error(buf);
00067 }
00068
00069 std::string CL_ComboBox_Generic::get_text(int index) const
00070 {
00071 return "";
00072 }
00073
00074 int CL_ComboBox_Generic::get_current_item() const
00075 {
00076 return 0;
00077 }
00078
00079 bool CL_ComboBox_Generic::is_selected(int index) const
00080 {
00081 return false;
00082 }
00083
00084 int CL_ComboBox_Generic::insert_item(const std::string &text, int index)
00085 {
00086 return 0;
00087 }
00088
00089 void CL_ComboBox_Generic::remove_item(int index)
00090 {
00091 }
00092
00093 void CL_ComboBox_Generic::change_item(const std::string &text, int index)
00094 {
00095 }
00096
00097 void CL_ComboBox_Generic::set_current_item(int index)
00098 {
00099 highlighted_item = index;
00100 sig_highlighted(highlighted_item);
00101 }
00102
00103 void CL_ComboBox_Generic::clear_selection()
00104 {
00105 }
00106
00107 void CL_ComboBox_Generic::sort(bool ascending)
00108 {
00109 }
00110
00111 void CL_ComboBox_Generic::clear()
00112 {
00113 }
00114
00115 void CL_ComboBox_Generic::set_select_button(CL_Button *_select_button)
00116 {
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 }
00140
00141 void CL_ComboBox_Generic::select_clicked()
00142 {
00143
00144
00145
00146
00147
00148
00149
00150
00151 }