CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csws/csskin.h

Go to the documentation of this file.
00001 /*
00002     Crystal Space Windowing System: Skin interface
00003     Copyright (C) 2000 by Andrew Zabolotny, <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSSKIN_H__
00021 #define __CS_CSSKIN_H__
00022 
00031 #include "csextern.h"
00032  
00033 #include "csutil/parray.h"
00034 
00035 class csSkin;
00036 class csApp;
00037 class csComponent;
00038 class csButton;
00039 class csWindow;
00040 class csDialog;
00041 class csListBox;
00042 class csListBoxItem;
00043 class csBackground;
00044 
00072 class CS_CSWS_EXPORT csSkinSlice
00073 {
00074 public:
00076   virtual ~csSkinSlice ()
00077   { Deinitialize (); }
00078 
00087   virtual void Initialize (csApp * /*iApp*/, csSkin * /*Parent*/) {}
00088 
00097   virtual void Deinitialize () {}
00098 
00100   virtual const char *GetName () const = 0;
00101 
00103   virtual void Apply (csComponent &This);
00104 
00115   virtual void Reset (csComponent &This);
00116 
00118   virtual void Draw (csComponent &This) = 0;
00119 };
00120 
00121 /*
00122   @@@ Hack:
00123   When CS_CSWS_EXPORT is configured for exporting from a shared library,
00124   VC refuses to compile csSkin if it inherits from 
00125   csPDelArray<csSkinSlice>, as csSkinSlice contains abstract methods.
00126   Work around this by inheriting from csSkinSliceNonAbstr instead which
00127   has no abstract methods.
00128  */
00129 class CS_CSWS_EXPORT csSkinSliceNonAbstr : public csSkinSlice
00130 {
00131 public:
00132   virtual const char *GetName () const { return 0; };
00133   virtual void Draw (csComponent &This) {};
00134 };
00135 
00162 class CS_CSWS_EXPORT csSkin : public csPDelArray<csSkinSliceNonAbstr>
00163 {
00165   csApp *app;
00166 
00167 public:
00169   const char *Prefix;
00170 
00172   csSkin () : csPDelArray<csSkinSliceNonAbstr> (16, 16), Prefix (0) {}
00173 
00174   virtual ~csSkin () { }
00175 
00177   static int CompareKey (csSkinSliceNonAbstr* const&, char const* const& Key);
00178 
00180   static csArrayCmp<csSkinSliceNonAbstr*,char const*> KeyCmp(char const* n)
00181   { return csArrayCmp<csSkinSliceNonAbstr*,char const*>(n, CompareKey); }
00182 
00184   static int Compare(csSkinSliceNonAbstr* const&, csSkinSliceNonAbstr* const&);
00185 
00187   void Apply (csComponent *iComp);
00188 
00190   virtual void Initialize (csApp *iApp);
00191 
00193   virtual void Deinitialize ();
00194 
00196   const char *GetConfigStr (const char *iSection, const char *iKey,
00197                             const char *iDefault);
00199   bool GetConfigYesNo (const char *iSection, const char *iKey, bool iDefault);
00200 
00202   void Load (csBackground &oBack, const char *iSection, const char *iPrefix);
00203 
00204 private:
00205   bool ReadGradient (const char *iText, csRGBcolor *color, int iNum);
00206 };
00207 
00213 class CS_CSWS_EXPORT csButtonSkin : public csSkinSlice
00214 {
00215 public:
00217   virtual const char *GetName () const
00218   { return "Button"; }
00219 
00221   virtual void SuggestSize (csButton &This, int &w, int &h) = 0;
00222 };
00223 
00229 class CS_CSWS_EXPORT csWindowSkin : public csSkinSlice
00230 {
00231 public:
00233   virtual const char *GetName () const
00234   { return "Window"; }
00235 
00237   virtual csButton *CreateButton (csWindow &This, int ButtonID) = 0;
00238 
00240   virtual void PlaceGadgets (csWindow &This) = 0;
00241 
00243   virtual void SetState (csWindow &This, int Which, bool State) = 0;
00244 
00246   virtual void SetBorderSize (csWindow &This) = 0;
00247 };
00248 
00254 class CS_CSWS_EXPORT csDialogSkin : public csSkinSlice
00255 {
00256 public:
00258   virtual const char *GetName () const
00259   { return "Dialog"; }
00260 
00262   virtual void SetBorderSize (csDialog &This) = 0;
00263 };
00264 
00270 class CS_CSWS_EXPORT csTitlebarSkin : public csSkinSlice
00271 {
00272 public:
00274   virtual const char *GetName () const
00275   { return "Titlebar"; }
00276 };
00277 
00283 class CS_CSWS_EXPORT csListBoxSkin : public csSkinSlice
00284 {
00285 public:
00287   virtual const char *GetName () const
00288   { return "Listbox"; }
00289 
00291   virtual void SuggestSize (csListBox &This, int &w, int &h) = 0;
00292 };
00293 
00299 class CS_CSWS_EXPORT csListBoxItemSkin : public csSkinSlice
00300 {
00301 public:
00303   virtual const char *GetName () const
00304   { return "ListboxItem"; }
00305 };
00306 
00307 
00313 class CS_CSWS_EXPORT csScrollBarSkin : public csSkinSlice
00314 {
00315 public:
00317   virtual const char *GetName () const
00318   { return "ScrollBar"; }
00319 };
00320 
00341 #define CSWS_SKIN_DECLARE(name,base)    \
00342   class name : public base      \
00343   {                             \
00344   public:                       \
00345     name ()                     \
00346     {
00347 
00352 #define CSWS_SKIN_SLICE(comp)   \
00353       InsertSorted ((csSkinSliceNonAbstr*)new cs##comp##Skin, Compare);
00354 
00364 #define CSWS_SKIN_DECLARE_END   \
00365     }                           \
00366   }
00367 
00370 #endif // __CS_CSSKIN_H__

Generated for Crystal Space by doxygen 1.2.18