00001 #ifndef CSLAF_h 00002 #define CSLAF_h 00003 00004 // USES SDL_Surface 00005 // USES SDL_Rect 00006 00007 #ifdef WIN32 00008 #pragma warning(disable : 4786 ) 00009 #endif 00010 00011 #include <vector> 00012 #include <string> 00013 #include "CSLog.h" 00014 #include "CSMouseCursor.h" 00015 00016 class CSGrafikElement; 00017 typedef std::vector<CSGrafikElement *> CSGrafikElements; 00018 00019 #include <SDL.h> 00020 00021 const int LAF_ICON_TYPE_CLOSE = 1; 00022 const int LAF_ICON_TYPE_WARN = 2; 00023 const int LAF_ICON_TYPE_ERROR = 3; 00024 const int LAF_ICON_TYPE_INFO = 4; 00025 const int LAF_ICON_TYPE_QUESTION = 5; 00026 const int LAF_ICON_TYPE_UP = 6; 00027 const int LAF_ICON_TYPE_LEFT = 7; 00028 const int LAF_ICON_TYPE_DOWN = 8; 00029 const int LAF_ICON_TYPE_RIGHT = 9; 00030 00031 const int LAF_MOUSE_CURSOR_DEFAULT = 1; 00032 const int LAF_MOUSE_CURSOR_SIZING_DOWN_RIGHT = 2; 00033 const int LAF_MOUSE_CURSOR_SIZING_DOWN_LEFT = 3; 00034 const int LAF_MOUSE_CURSOR_SIZING_UP_RIGHT = 4; 00035 const int LAF_MOUSE_CURSOR_SIZING_UP_LEFT = 5; 00036 const int LAF_MOUSE_CURSOR_SIZING_DOWN = 6; 00037 const int LAF_MOUSE_CURSOR_SIZING_UP = 7; 00038 const int LAF_MOUSE_CURSOR_SIZING_LEFT = 8; 00039 const int LAF_MOUSE_CURSOR_SIZING_RIGHT = 9; 00040 00041 class CSFont; 00042 class CSBorder; 00043 class CSArea; 00044 class CSIcon; 00045 class CSLAF 00046 { 00047 private: 00048 static CSGrafikElements mGUIElements; 00049 static int mCurrentLAFId; 00050 static CSLAF *mLAF; 00051 CSMouseCursor *mSizingMouseCursorInstance; 00052 CSMouseCursor *mDefaultMouseCursorInstance; 00053 00054 protected: 00055 int cursorRate; 00056 int windowTitleInterIconOffset; 00057 int windowTitleIconBorderVerticalOffset; 00058 int windowTitleIconBorderHorizontalOffset; 00059 int windowSizingOffset; //!< \todo to sizing allow sizing not just in lower right corner! 00060 00061 int borderDefaultBrightestColor; 00062 00063 int windowBackColorEnabled; 00064 int windowBackColorDisabled; 00065 int windowTextColorEnabled; 00066 int windowTextColorDisabled; 00067 int buttonBackColorEnabled; 00068 int buttonBackColorDisabled; 00069 int scrollbarBackColor; 00070 int menuBarBackColorEnabled; 00071 int menuBarBackColorDisabled; 00072 int menuBackColorEnabled; 00073 int menuBackColorDisabled; 00074 00075 int titleTextColorEnabled; //!< \todo Window (title) with disabled color 00076 int titleTextColorDisabled; 00077 int titleColorEnabled; 00078 int titleColorDisabled; 00079 00080 int checkBoxColorEnabled; 00081 int checkBoxColorDisabled; 00082 int listboxColorEnabled; 00083 int listboxColorDisabled; 00084 int listboxTextColorEnabled; 00085 int listboxTextColorDisabled; 00086 int menuTextColorEnabled; 00087 int menuTextColorDisabled; 00088 00089 int textfieldColorDisabled; 00090 int textfieldColorEnabled; 00091 int textfieldTextColorEnabled; //!< \todo textField with disabled color 00092 int textfieldTextColorDisabled; 00093 00094 int textAreaTextColorEnabled; 00095 int textAreaTextColorDisabled; //!< \todo textArea with disabled color 00096 int textAreaColorEnabled; 00097 int textAreaColorDisabled; 00098 int textAreaCursorColor; 00099 00100 int listboxVerticalLineSpacing; 00101 int listboxHorizontalLineSpacing; 00102 int textAreaVerticalLineSpacing; 00103 int textAreaHorizontalLineSpacing; //!<space between border 00104 int textfieldHorizontalSpacing; 00105 int textfieldVerticalSpacing; 00106 int labelHorizontalSpacing; 00107 int labelVerticalSpacing; 00108 int buttonHorizontalSpacing; 00109 int buttonVerticalSpacing; 00110 int menuBarHorizontalSpacing; 00111 int menuBarVerticalSpacing; 00112 int menuItemHorzintalSpacing; 00113 int menuItemVerticalSpacing; 00114 int elementHorizontalSpacing; //!< in Window (e.g.) if elements are arranged automatically 00115 //!< these is the space between two elements 00116 int elementVerticalSpacing; //!< in Window (e.g.) if elements are arranged automatically 00117 //!< these is the space between two elements 00118 00119 int comboboxItemsShown; 00120 int checkBoxSize; 00121 00122 int menuOpenXOffset; 00123 int menuOpenYOffset; 00124 00125 void destroyMouseCursors(); 00126 00127 int getBackgroundColorEnabledInternal(const std::string &classType); 00128 int getBackgroundColorDisabledInternal(const std::string &classType); 00129 00130 int getTextColorEnabledInternal(const std::string &classType); 00131 int getTextColorDisabledInternal(const std::string &classType); 00132 00133 int getHorizontalElementSpacingInternal(const std::string &classType); 00134 int getVerticalElementSpacingInternal(const std::string &classType); 00135 00136 CSArea *getAreaInternal(const std::string &classType, int state = 0); 00137 CSFont *getFontInternal(const std::string &classType); 00138 CSBorder *getBorderInternal(const std::string &classType, int state); 00139 CSIcon *getIconInternal(int iconType); 00140 CSMouseCursor *getMouseCursorInternal(int type); 00141 00142 public: 00143 static const char *CLASS; 00144 00145 int tooltipThreshold; 00146 00147 //! Mouse Cursor changes are only recognized with 00148 //! a lafChanged() call! 00149 std::string mDefaultMouseCursor; 00150 std::string mSizingMouseCursor; 00151 00152 std::string proportionalFontName; 00153 std::string monoSpacedFontName; 00154 00155 std::string closeIconFileEnabled; 00156 std::string closeIconFileDisabled; 00157 std::string warnIconFileEnabled; 00158 std::string warnIconFileDisabled; 00159 std::string errorIconFileEnabled; 00160 std::string errorIconFileDisabled; 00161 std::string infoIconFileEnabled; 00162 std::string infoIconFileDisabled; 00163 std::string questionIconFileEnabled; 00164 std::string questionIconFileDisabled; 00165 std::string upIconFileEnabled; 00166 std::string upIconFileDisabled; 00167 std::string downIconFileEnabled; 00168 std::string downIconFileDisabled; 00169 std::string leftIconFileEnabled; 00170 std::string leftIconFileDisabled; 00171 std::string rightIconFileEnabled; 00172 std::string rightIconFileDisabled; 00173 00174 00175 static void addElement(CSGrafikElement *element); 00176 static void removeElement(CSGrafikElement *element); 00177 static void lafChanged(); 00178 static void setCurrentLAF(CSLAF &laf); 00179 static CSLAF *getCurrentLAF(); 00180 00181 CSLAF() ; 00182 virtual ~CSLAF(); 00183 00184 00185 virtual int getBackgroundColorEnabled(const std::string &classType) {return getBackgroundColorEnabledInternal(classType);} 00186 virtual int getBackgroundColorDisabled(const std::string &classType) {return getBackgroundColorDisabledInternal(classType);} 00187 00188 virtual int getTextColorEnabled(const std::string &classType){return getTextColorEnabledInternal(classType);} 00189 virtual int getTextColorDisabled(const std::string &classType){return getTextColorDisabledInternal(classType);} 00190 00191 virtual int getHorizontalElementSpacing(const std::string &classType) {return getHorizontalElementSpacingInternal(classType);} 00192 virtual int getVerticalElementSpacing(const std::string &classType) {return getVerticalElementSpacingInternal(classType);} 00193 00194 virtual int getBorderDefaultBrightestColor() {return borderDefaultBrightestColor;} 00195 virtual int getComboboxItemsShown() {return comboboxItemsShown;} 00196 virtual int getMenuOpenXOffset() {return menuOpenXOffset;} 00197 virtual int getMenuOpenYOffset() {return menuOpenYOffset;} 00198 virtual int getWindowSizingOffset() {return windowSizingOffset;} //!< \todo to sizing allow sizing not just in lower right corner! 00199 00200 //! state for buttons! 00201 //! otherwise ignored 00202 virtual CSBorder *getBorder(const std::string &classType, int state = 0) {return getBorderInternal(classType, state);} 00203 virtual CSArea *getArea(const std::string &classType, int state = 0) {return getAreaInternal(classType, state);} 00204 virtual CSIcon *getIcon(int iconType) {return getIconInternal(iconType);} 00205 00206 CSMouseCursor *getMouseCursor(int type) {return getMouseCursorInternal(type);} 00207 CSFont *getFont(std::string classType){return getFontInternal(classType);} 00208 virtual int getTextAreaCursorColor() {return textAreaCursorColor;} 00209 00210 virtual void reset(void); 00211 virtual std::string getType() {return (std::string) CLASS;} 00212 virtual int getCursorRate() {return cursorRate;}; // 500 milliseconds 00213 virtual int getCheckBoxSize() {return checkBoxSize;} 00214 00215 }; 00216 00217 #endif CSLAF_h