00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "precomp.h"
00010 #include <stdio.h>
00011 #include "API/Display/Display/surface.h"
00012 #include "API/Display/Font/font.h"
00013 #include "API/Core/Resources/resource_manager.h"
00014 #include "API/GUI/gui_manager.h"
00015 #include "combobox_default.h"
00016 #include "button_default.h"
00017
00018 #define X_TEXT_OFFSET 4
00019 #define Y_TEXT_OFFSET 2
00020
00021 CL_ComboBox_Default::CL_ComboBox_Default(
00022 CL_ComboBox *_combobox,
00023 const CL_ComponentOptions &options,
00024 CL_StyleManager_Default *_style) : CL_ComponentStyle(_combobox), combobox(_combobox)
00025 {
00026 style = _style;
00027 resources = style->get_resources();
00028 fnt_options = CL_Font::load("ComboBox/font", resources);
00029 sur_select_normal = CL_Surface::load("ComboBox/select_normal", resources);
00030 sur_select_toggled = CL_Surface::load("ComboBox/select_toggled", resources);
00031 sur_select_disabled = CL_Surface::load("ComboBox/select_disabled", resources);
00032
00033 button_width = sur_select_normal->get_width();
00034 button_height = sur_select_normal->get_height();
00035
00036 CL_Rect pos = combobox->get_position();
00037 pos.y1 += button_height;
00038 combobox->set_position(pos);
00039
00040 select_list = NULL;
00041
00042
00043
00044 CL_ComponentOptions b_options;
00045 #ifdef BORLAND
00046 b_options.options.insert(std::make_pair(std::string("x") , std::string(CL_String(combobox->get_width()-button_width-1))));
00047 b_options.options.insert(std::make_pair(std::string("y") , std::string("0")));
00048 b_options.options.insert(std::make_pair(std::string("width") , std::string(CL_String(button_width))));
00049 b_options.options.insert(std::make_pair(std::string("height") , std::string(CL_String(button_height))));
00050 b_options.options.insert(std::make_pair(std::string("sur_normal") , std::string("Combobox/select_normal")));
00051 b_options.options.insert(std::make_pair(std::string("sur_toggled") , std::string("Combobox/select_toggled")));
00052 b_options.options.insert(std::make_pair(std::string("sur_disabled") , std::string("Combobox/select_disabled")));
00053 #else
00054 b_options.options.insert(std::make_pair<std::string const, std::string>("x", CL_String(combobox->get_width()-button_width-1)));
00055 b_options.options.insert(std::make_pair<std::string const, std::string>("y", "0"));
00056 b_options.options.insert(std::make_pair<std::string const, std::string>("width", CL_String(button_width)));
00057 b_options.options.insert(std::make_pair<std::string const, std::string>("height", CL_String(button_height)));
00058 b_options.options.insert(std::make_pair<std::string const, std::string>("sur_normal", "Combobox/select_normal"));
00059 b_options.options.insert(std::make_pair<std::string const, std::string>("sur_toggled", "Combobox/select_toggled"));
00060 b_options.options.insert(std::make_pair<std::string const, std::string>("sur_disabled", "Combobox/select_disabled"));
00061 #endif
00062
00063
00064
00065
00066
00067
00068
00069
00070 slot_activated = combobox->sig_activated().connect(CL_CreateSlot(this, &CL_ComboBox_Default::on_listbox_activated));
00071
00072 slot_paint = combobox->sig_paint().connect(CL_CreateSlot(this, &CL_ComboBox_Default::on_paint));
00073 }
00074
00075 CL_ComboBox_Default::~CL_ComboBox_Default()
00076 {
00077
00078
00079
00080
00081
00082 }
00083
00084 void CL_ComboBox_Default::on_paint()
00085 {
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 fnt_options->print_left(X_TEXT_OFFSET, Y_TEXT_OFFSET, combobox->get_current_text().c_str());
00101 }
00102
00103 void CL_ComboBox_Default::on_listbox_activated(int index)
00104 {
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
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_Default::on_listbox_highlighted(int selection)
00142 {
00143 combobox->set_current_item(selection);
00144
00145
00146 }
00147
00148 void CL_ComboBox_Default::on_listbox_cancel()
00149 {
00150
00151
00153