CrystalSpace

Public API Reference

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

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 "csutil/parray.h"
00032 
00033 class csSkin;
00034 class csApp;
00035 class csComponent;
00036 class csButton;
00037 class csWindow;
00038 class csDialog;
00039 class csListBox;
00040 class csListBoxItem;
00041 class csBackground;
00042 
00070 class csSkinSlice
00071 {
00072 public:
00074   virtual ~csSkinSlice ()
00075   { Deinitialize (); }
00076 
00085   virtual void Initialize (csApp * /*iApp*/, csSkin * /*Parent*/) {}
00086 
00095   virtual void Deinitialize () {}
00096 
00098   virtual const char *GetName () const = 0;
00099 
00101   virtual void Apply (csComponent &This);
00102 
00113   virtual void Reset (csComponent &This);
00114 
00116   virtual void Draw (csComponent &This) = 0;
00117 };
00118 
00145 class csSkin : public csPDelArray<csSkinSlice>
00146 {
00148   csApp *app;
00149 
00150 public:
00152   const char *Prefix;
00153 
00155   csSkin () : csPDelArray<csSkinSlice> (16, 16), Prefix (0) {}
00156 
00157   virtual ~csSkin () { }
00158 
00160   static int CompareKey (csSkinSlice* const& Item, void* Key);
00161 
00163   static int Compare (csSkinSlice* const& Item1, csSkinSlice* const& Item2);
00164 
00166   void Apply (csComponent *iComp);
00167 
00169   virtual void Initialize (csApp *iApp);
00170 
00172   virtual void Deinitialize ();
00173 
00175   const char *GetConfigStr (const char *iSection, const char *iKey, const char *iDefault);
00177   bool GetConfigYesNo (const char *iSection, const char *iKey, bool iDefault);
00178 
00180   void Load (csBackground &oBack, const char *iSection, const char *iPrefix);
00181 
00182 private:
00183   bool ReadGradient (const char *iText, csRGBcolor *color, int iNum);
00184 };
00185 
00191 class csButtonSkin : public csSkinSlice
00192 {
00193 public:
00195   virtual const char *GetName () const
00196   { return "Button"; }
00197 
00199   virtual void SuggestSize (csButton &This, int &w, int &h) = 0;
00200 };
00201 
00207 class csWindowSkin : public csSkinSlice
00208 {
00209 public:
00211   virtual const char *GetName () const
00212   { return "Window"; }
00213 
00215   virtual csButton *CreateButton (csWindow &This, int ButtonID) = 0;
00216 
00218   virtual void PlaceGadgets (csWindow &This) = 0;
00219 
00221   virtual void SetState (csWindow &This, int Which, bool State) = 0;
00222 
00224   virtual void SetBorderSize (csWindow &This) = 0;
00225 };
00226 
00232 class csDialogSkin : public csSkinSlice
00233 {
00234 public:
00236   virtual const char *GetName () const
00237   { return "Dialog"; }
00238 
00240   virtual void SetBorderSize (csDialog &This) = 0;
00241 };
00242 
00248 class csTitlebarSkin : public csSkinSlice
00249 {
00250 public:
00252   virtual const char *GetName () const
00253   { return "Titlebar"; }
00254 };
00255 
00261 class csListBoxSkin : public csSkinSlice
00262 {
00263 public:
00265   virtual const char *GetName () const
00266   { return "Listbox"; }
00267 
00269   virtual void SuggestSize (csListBox &This, int &w, int &h) = 0;
00270 };
00271 
00277 class csListBoxItemSkin : public csSkinSlice
00278 {
00279 public:
00281   virtual const char *GetName () const
00282   { return "ListboxItem"; }
00283 };
00284 
00285 
00291 class csScrollBarSkin : public csSkinSlice
00292 {
00293 public:
00295   virtual const char *GetName () const
00296   { return "ScrollBar"; }
00297 };
00298 
00319 #define CSWS_SKIN_DECLARE(name,base)    \
00320   class name : public base      \
00321   {                             \
00322   public:                       \
00323     name ()                     \
00324     {
00325 
00330 #define CSWS_SKIN_SLICE(comp)   \
00331       InsertSorted (new cs##comp##Skin, Compare);
00332 
00342 #define CSWS_SKIN_DECLARE_END   \
00343     }                           \
00344   }
00345 
00348 #endif // __CS_CSSKIN_H__

Generated for Crystal Space by doxygen 1.2.14