Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

stylemanager_default.cpp

Go to the documentation of this file.
00001 /*
00002         ClanGUI, copyrights by various people. Have a look in the CREDITS file.
00003         
00004         This sourcecode is distributed using the Library GNU Public Licence,
00005         version 2 or (at your option) any later version. Please read LICENSE
00006         for details.
00007 */
00008 
00009 #include "precomp.h"
00010 
00011 #include <stdio.h>
00012 #include <string>
00013 
00014 #include "API/Display/Display/display.h"
00015 #include "API/Display/Display/surface.h"
00016 #include "API/Core/Resources/resource_manager.h"
00017 #include "API/GUI/stylemanager_default.h"
00018 
00019 #include "stylemanager_default_generic.h"
00020 #include "label_default.h"
00021 #include "button_default.h"
00022 #include "frame_default.h"
00023 #include "combobox_default.h"
00024 #include "inputbox_default.h"
00025 #include "scrollbar_default.h"
00026 #include "progressbar_default.h"
00027 #include "menubar_default.h"
00028 #include "menuitem_default.h"
00029 #include "popupmenu_default.h"
00030 #include "checkbox_default.h"
00031 #include "listbox_default.h"
00032 #include "window_default.h"
00033 #include "filedialog_default.h"
00034 
00035 // Construction:
00036 
00037 CL_StyleManager_Default::CL_StyleManager_Default(CL_ResourceManager *resources)
00038 :
00039         CL_StyleManager(resources)
00040 {
00041         impl = new CL_StyleManager_Default_Generic;
00042         impl->resources = resources;
00043 }
00044 
00045 CL_StyleManager_Default::~CL_StyleManager_Default()
00046 {
00047         delete impl;
00048 }
00049 
00050 // Attributes:
00051 
00052 const std::string &CL_StyleManager_Default::get_default_font() const
00053 {
00054         return impl->default_font;
00055 }
00056 
00057 const std::string &CL_StyleManager_Default::get_combo_normal() const
00058 {
00059         return impl->combo_normal;
00060 }
00061 
00062 const std::string &CL_StyleManager_Default::get_combo_toggled() const
00063 {
00064         return impl->combo_toggled;
00065 }
00066 
00067 const std::string &CL_StyleManager_Default::get_combo_disabled() const
00068 {
00069         return impl->combo_disabled;
00070 }
00071 
00072 const std::string &CL_StyleManager_Default::get_checkbox_checked() const
00073 {
00074         return impl->checkbox_checked;
00075 }
00076 
00077 const std::string &CL_StyleManager_Default::get_checkbox_unchecked() const
00078 {
00079         return impl->checkbox_unchecked;
00080 }
00081 
00082 const std::string &CL_StyleManager_Default::get_checkbox_disabled() const
00083 {
00084         return impl->checkbox_disabled;
00085 }
00086 
00087 // Operations:
00088 
00089 void CL_StyleManager_Default::set_default_font(const std::string &font)
00090 {
00091         impl->default_font = font;
00092 }
00093 
00094 void CL_StyleManager_Default::set_combo_normal(const std::string &normal)
00095 {
00096         impl->combo_normal = normal;
00097 }
00098 
00099 void CL_StyleManager_Default::set_combo_toggled(const std::string &toggled)
00100 {
00101         impl->combo_toggled = toggled;
00102 }
00103 
00104 void CL_StyleManager_Default::set_combo_disabled(const std::string &disabled)
00105 {
00106         impl->combo_disabled = disabled;
00107 }
00108 
00109 void CL_StyleManager_Default::set_checkbox_checked(const std::string &checked)
00110 {
00111         impl->checkbox_checked = checked;
00112 }
00113 
00114 void CL_StyleManager_Default::set_checkbox_unchecked(const std::string &unchecked)
00115 {
00116         impl->checkbox_unchecked = unchecked;
00117 }
00118 
00119 void CL_StyleManager_Default::set_checkbox_disabled(const std::string &disabled)
00120 {
00121         impl->checkbox_disabled = disabled;
00122 }
00123 
00124 // Functions:
00125 
00126 void CL_StyleManager_Default::fill_rect(int x1, int y1, int x2, int y2, GUIColor col)
00127 {
00128         float r = 1.0f;
00129         float g = 0.0f;
00130         float b = 1.0f;
00131         float a = 1.0f;
00132 
00133         impl->get_color(col, r, g, b, a);
00134 
00135         CL_Display::fill_rect(x1, y1, x2, y2, r, g, b);
00136 }
00137 
00138 void CL_StyleManager_Default::draw_rect(int x1, int y1, int x2, int y2, GUIColor col)
00139 {
00140         float r = 1.0f;
00141         float g = 0.0f;
00142         float b = 1.0f;
00143         float a = 1.0f;
00144 
00145         impl->get_color(col, r, g, b, a);
00146 
00147         CL_Display::draw_rect(x1, y1, x2, y2, r, g, b);
00148 }
00149 
00150 void CL_StyleManager_Default::draw_line(int x1, int y1, int x2, int y2, GUIColor col)
00151 {
00152         float r = 1.0f;
00153         float g = 0.0f;
00154         float b = 1.0f;
00155         float a = 1.0f;
00156 
00157         impl->get_color(col, r, g, b, a);
00158 
00159         CL_Display::draw_line(x1, y1, x2, y2, r, g, b, a);
00160 }
00161 
00162 void CL_StyleManager_Default::draw_box(int x1, int y1, int x2, int y2, GUIColor topleft, GUIColor bottomright)
00163 {
00164         float r = 1.0f;
00165         float g = 0.0f;
00166         float b = 1.0f;
00167         float a = 1.0f;
00168 
00169         impl->get_color(topleft, r, g, b, a);
00170 
00171         CL_Display::draw_line(x1, y1, x2 - 1, y1, r, g, b, a);
00172         CL_Display::draw_line(x1, y1 + 1, x1, y2 - 1, r, g, b, a);
00173         
00174         r = 1.0f;
00175         g = 0.0f;
00176         b = 1.0f;
00177         a = 1.0f;
00178 
00179         impl->get_color(bottomright, r, g, b, a);
00180 
00181         CL_Display::draw_line(x1 + 1, y2 - 1, x2 - 1, y2 - 1, r, g, b, a);
00182         CL_Display::draw_line(x2 - 1, y1 + 1, x2 - 1, y2 - 2, r, g, b, a);
00183 }
00184 
00185 // Overridables:
00186 
00187 CL_Component *CL_StyleManager_Default::create_component(
00188         const std::string &type,
00189         const CL_ComponentOptions &options,
00190         CL_Component *parent)
00191 {
00192         if (type == "label") return new CL_Label(options, parent, this);
00193         if (type == "button") return new CL_Button(options, parent, this);
00194         if (type == "frame") return new CL_Frame(options, parent, this);
00195         if (type == "combobox") return new CL_ComboBox(options, parent, this);
00196         if (type == "inputbox") return new CL_InputBox(options, parent, this);
00197         if (type == "scrollbar") return new CL_ScrollBar(options, parent, this);
00198         if (type == "progressbar") return new CL_ProgressBar(options, parent, this);
00199 //      if (type == "menubar") return new CL_MenuBar(options, parent, this);
00200 //      if (type == "popupmenu") return new CL_PopupMenu(options, parent, this);
00201 //      if (type == "menuitem") return new CL_MenuItem(options, parent, this);
00202         if (type == "checkbox") return new CL_CheckBox(options, parent, this);
00203         if (type == "listbox") return new CL_ListBox(options, parent, this);
00204         if (type == "window") return new CL_Window(options, parent, this);
00205         if (type == "filedialog") return new CL_FileDialog(options, parent, this);
00206 
00207         throw CL_Error(std::string("Failed to create component of type ") + type);
00208         return NULL;
00209 }
00210 
00211 void CL_StyleManager_Default::connect_styles(
00212         const std::string &type,
00213         const CL_ComponentOptions &options,
00214         CL_Component *owner)
00215 {
00216         if (type == "label")
00217                 owner->attach_style(new CL_Label_Default((CL_Label *) owner, options, this));
00218 
00219         else if (type == "button")
00220                 owner->attach_style(new CL_Button_Default((CL_Button *) owner, options, this));
00221 
00222         else if (type == "frame")
00223                 owner->attach_style(new CL_Frame_Default((CL_Frame *) owner, options, this));
00224 
00225         else if (type == "combobox")
00226                 owner->attach_style(new CL_ComboBox_Default((CL_ComboBox *) owner, options, this));
00227 
00228         else if (type == "inputbox")
00229                 owner->attach_style(new CL_InputBox_Default((CL_InputBox *) owner, options, this));
00230 
00231         else if (type == "scrollbar")
00232                 owner->attach_style(new CL_ScrollBar_Default((CL_ScrollBar *) owner, options, this));
00233 
00234         else if (type == "progressbar")
00235                 owner->attach_style(new CL_ProgressBar_Default((CL_ProgressBar *) owner, options, this));
00236 
00237 //      else if (type == "menubar")
00238 //              owner->attach_style(new CL_MenuBar_Default((CL_MenuBar *) owner, options, this));
00239 
00240 //      else if (type == "popupmenu")
00241 //              owner->attach_style(new CL_PopupMenu_Default((CL_PopupMenu *) owner, options, this));
00242 
00243 //      else if (type == "menuitem")
00244 //              owner->attach_style(new CL_MenuItem_Default((CL_MenuItem *) owner, options, this));
00245 
00246         else if (type == "checkbox")
00247                 owner->attach_style(new CL_CheckBox_Default((CL_CheckBox *) owner, options, this));
00248 
00249         else if (type == "listbox")
00250                 owner->attach_style(new CL_ListBox_Default((CL_ListBox *) owner, options, this));
00251 
00252         else if (type == "window")
00253                 owner->attach_style(new CL_Window_Default((CL_Window *) owner, options, this));
00254 
00255         else if (type == "filedialog")
00256                 owner->attach_style(new CL_FileDialog_Default((CL_FileDialog *) owner, options, this));
00257 }

Generated at Wed Apr 4 19:54:04 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001