1 /* 2 * This file is part of wxSmith plugin for Code::Blocks Studio 3 * Copyright (C) 2006-2007 Bartlomiej Swiecki 4 * 5 * wxSmith is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * wxSmith is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with wxSmith. If not, see <http://www.gnu.org/licenses/>. 17 * 18 * $Revision: 11434 $ 19 * $Id: wxsstyle.h 11434 2018-08-07 07:12:59Z fuscated $ 20 * $HeadURL: svn://svn.code.sf.net/p/codeblocks/code/branches/release-20.xx/src/plugins/contrib/wxSmith/wxwidgets/wxsstyle.h $ 21 */ 22 23 #ifndef __WXSSTYLE_H 24 #define __WXSSTYLE_H 25 26 #ifndef WX_PRECOMP 27 #include <wx/arrstr.h> 28 #endif 29 30 #include "../wxscodinglang.h" 31 #include <wx/dynarray.h> 32 #include <wx/arrstr.h> 33 34 // TODO: Think about non-macro implementation 35 36 /* ************************************************************************** */ 37 /* Available style flags */ 38 /* ************************************************************************** */ 39 40 const long wxsSFXRC = 0x00000001; ///< This style can be used in XRC mode 41 const long wxsSFWin = 0x00000002; ///< This style can be used in Windows (any) 42 const long wxsSFWin95 = 0x00000004; ///< This style can be used in Win95 43 const long wxsSFWinCE = 0x00000008; ///< This style can be used in WinCE 44 const long wxsSFGTK = 0x00000010; ///< This style can be used in GTK+ (any GTK) 45 const long wxsSFGTK12 = 0x00000020; ///< This style can be used in GTK (1.2 only) 46 const long wxsSFGTK20 = 0x00000040; ///< This style can be used in GTK (1.2 only) 47 const long wxsSFOSX = 0x00000080; ///< This style can be used in MAC (any OSX port Cocoa or Carbon) 48 const long wxsSFCOCOA = 0x00000100; ///< This style can be used in MAC (OSX port Cocoa API) 49 const long wxsSFCARBON = 0x00000200; ///< This style can be used in MAC (MacOS for Carbon CFM) 50 const long wxsSFMotif = 0x00000400; ///< This style can be used in Motif 51 const long wxsSFMGL = 0x00000800; ///< This style can be used in MGL 52 const long wxsSFOS2 = 0x00001000; ///< This style can be used in OS2 53 const long wxsSFX11 = 0x00002000; ///< This style can be used in X11 54 const long wxsSFPALMOS = 0x00004000; ///< This style can be used in PALMOS 55 const long wxsSFUNIV = 0x00008000; ///< This style can be used in wxUNIV 56 const long wxsSFAll = 0x0000FFFF; ///< This style can be used anywhere 57 const long wxsSFExt = 0x80000000; ///< This is extended style 58 59 /** Structure describing one widget's stule */ 60 struct wxsStyle 61 { 62 wxString Name; ///< Style name 63 long Value; ///< Value of style 64 long Flags; ///< Style flags 65 66 /** Checking if this is style category */ IsCategorywxsStyle67 inline bool IsCategory() const{ return Value == ((long)-1); } 68 69 /** Checking if this is extended style */ IsExtrawxsStyle70 inline bool IsExtra() const { return ( Flags & wxsSFExt ) != 0; } 71 }; 72 73 /** \brief Class managing giving set of styles 74 * 75 * This class is managing style sets, one per one set, NOT per instance of 76 * item. It means that item must have extra long variables to remember style 77 * settings. 78 */ 79 class wxsStyleSet 80 { 81 public: 82 83 /** \brief Ctor, takes array of styles 84 * \param Default default style 85 */ 86 wxsStyleSet(const wxChar* DefaultStyle=_T("")); 87 88 /** \brief Adding new style to array */ 89 void AddStyle(const wxChar* Name,long Value,long Flags); 90 91 /** \brief Notifying the end of style declaration */ 92 void EndStyle(); 93 94 /** \brief Dctor */ 95 ~wxsStyleSet(); 96 97 /** \brief Getting names array */ GetNames(bool IsExtra)98 inline const wxArrayString& GetNames(bool IsExtra) const { return IsExtra?ExStyleNames:StyleNames; } 99 100 /** \brief Getting style bits array (each style has unique bit) */ GetBits(bool IsExtra)101 inline const wxArrayLong& GetBits(bool IsExtra) const { return IsExtra?ExStyleBits:StyleBits; } 102 103 /** \brief Getting values array (real values used inside wxWidgets) */ GetValues(bool IsExtra)104 inline const wxArrayLong& GetValues(bool IsExtra) const { return IsExtra?ExStyleValues:StyleValues; } 105 106 /** \brief Getting style flags array */ GetFlags(bool IsExtra)107 inline const wxArrayLong& GetFlags(bool IsExtra) const { return IsExtra?ExStyleFlags:StyleFlags; } 108 109 /** \brief Getting default style bits */ GetDefaultBits(bool IsExtra)110 inline long GetDefaultBits(bool IsExtra) const { return IsExtra?0:Default; } 111 112 /** \brief Generating Bitfield from given string (where styles are separated through '|') */ 113 long GetBits(const wxString& Style,bool IsExtra) const; 114 115 /** \brief Converting given style set bitfield to wxString using given language (note that CPP is same format like the one used in XRC files) */ 116 wxString GetString(long Bits,bool IsExtra,wxsCodingLang Language) const; 117 118 /** \brief Converting style bits to value which can be used in wxWidgets */ 119 long GetWxStyle(long StyleBits,bool IsExtra=false) const; 120 121 private: 122 123 const wxChar* DefaultStr; 124 long Default; 125 wxArrayString StyleNames; 126 wxArrayLong StyleBits; 127 wxArrayLong StyleValues; 128 wxArrayLong StyleFlags; 129 130 wxArrayString ExStyleNames; 131 wxArrayLong ExStyleBits; 132 wxArrayLong ExStyleValues; 133 wxArrayLong ExStyleFlags; 134 }; 135 136 /* ************************************************************************** */ 137 /* Useful defines used while creating set of widget's styles */ 138 /* ************************************************************************** */ 139 140 /** Beginning definition of array (source file) */ 141 #define WXS_ST_BEGIN(name,DefaultStyle) \ 142 const wxsStyleSet* Get##name##StyleSet(); \ 143 static const wxsStyleSet* name = Get##name##StyleSet(); \ 144 const wxsStyleSet* Get##name##StyleSet() \ 145 { \ 146 static wxsStyleSet Set(DefaultStyle); \ 147 148 /** Adding new style into list 149 * 150 * This style will be set as available on all platforms 151 */ 152 #define WXS_ST(name) \ 153 Set.AddStyle(_T(#name), name, wxsSFAll & ~wxsSFExt); 154 155 /** Adding new extended style into list 156 * 157 * This style will be set as available on all platforms 158 */ 159 #define WXS_EXST(name) \ 160 Set.AddStyle(_T(#name), name, wxsSFAll | wxsSFExt); 161 162 /** Adding new style with platform masks 163 * 164 * \param name - style's name 165 * \param Include - flags with included platforms (use wxsSFAll if excluding only) 166 * \param Exclude - flags with excluded platforms (use 0 when including only) 167 * \param InXRC - true if this style can be used when resource uses XRC files 168 */ 169 #define WXS_ST_MASK(name,Include,Exclude,InXRC) \ 170 Set.AddStyle(_T(#name), name, \ 171 ((Include) & (~(Exclude)) & (~(wxsSFExt|wxsSFXRC))) | \ 172 ((InXRC) ? wxsSFXRC : 0 ) ); 173 174 /** Adding new extended style with platform masks 175 * 176 * \param name - style's name 177 * \param Include - flags with included platforms (use wxsSFAll if excluding only) 178 * \param Exclude - flags with excluded platforms (use 0 when including only) 179 * \param InXRC - true if this style can be used when resource uses XRC files 180 */ 181 #define WXS_EXST_MASK(name,Include,Exclude,InXRC) \ 182 Set.AddStyle(_T(#name), name, \ 183 ((Include) & (~(Exclude)) & (~wxsSFXRC)) | \ 184 ((InXRC) ? wxsSFXRC : 0 ) | wxsSFExt ); 185 186 /** Beginning new category */ 187 #define WXS_ST_CATEGORY(name) \ 188 Set.AddStyle(_T(#name),-1, 0); 189 190 /** Ending creation of list */ 191 #define WXS_ST_END() \ 192 Set.EndStyle(); \ 193 return &Set; \ 194 } 195 196 /** adding all default window's style */ 197 #define WXS_ST_DEFAULTS() \ 198 WXS_ST_CATEGORY("wxWindow") \ 199 WXS_ST(wxBORDER_SIMPLE) \ 200 WXS_ST(wxBORDER_DOUBLE) \ 201 WXS_ST(wxBORDER_SUNKEN) \ 202 WXS_ST(wxBORDER_RAISED) \ 203 WXS_ST(wxBORDER_STATIC) \ 204 WXS_ST(wxBORDER_NONE) \ 205 WXS_ST(wxTRANSPARENT_WINDOW) \ 206 WXS_ST(wxTAB_TRAVERSAL) \ 207 WXS_ST(wxWANTS_CHARS) \ 208 WXS_ST(wxNO_FULL_REPAINT_ON_RESIZE) \ 209 WXS_ST(wxVSCROLL) \ 210 WXS_ST(wxHSCROLL) \ 211 WXS_ST(wxALWAYS_SHOW_SB) \ 212 WXS_ST(wxCLIP_CHILDREN) \ 213 WXS_ST(wxFULL_REPAINT_ON_RESIZE) \ 214 WXS_EXST(wxWS_EX_BLOCK_EVENTS) \ 215 WXS_EXST(wxWS_EX_VALIDATE_RECURSIVELY) 216 217 #endif 218