CrystalSpace

Public API Reference

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

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/csvector.h"
00032 
00033 class csSkin;
00034 class csSkinSlice;
00035 class csApp;
00036 class csComponent;
00037 class csButton;
00038 class csWindow;
00039 class csDialog;
00040 class csListBox;
00041 class csListBoxItem;
00042 class csBackground;
00043 
00070 class csSkin : public csVector
00071 {
00073   csApp *app;
00074 
00075 public:
00077   const char *Prefix;
00078 
00080   csSkin () : csVector (16, 16), Prefix (NULL) {}
00081 
00083   virtual ~csSkin ();
00084 
00086   virtual bool FreeItem (void* Item);
00087 
00089   virtual int CompareKey (void* Item, const void* Key, int) const;
00090 
00092   virtual int Compare (void* Item1, void* Item2, int) const;
00093 
00095   csSkinSlice *Get (int iIndex)
00096   { return (csSkinSlice *)csVector::Get (iIndex); }
00097 
00099   void Apply (csComponent *iComp);
00100 
00102   virtual void Initialize (csApp *iApp);
00103 
00105   virtual void Deinitialize ();
00106 
00108   const char *GetConfigStr (const char *iSection, const char *iKey, const char *iDefault);
00110   bool GetConfigYesNo (const char *iSection, const char *iKey, bool iDefault);
00111 
00113   void Load (csBackground &oBack, const char *iSection, const char *iPrefix);
00114 
00115 private:
00116   bool ReadGradient (const char *iText, csRGBcolor *color, int iNum);
00117 };
00118 
00146 class csSkinSlice
00147 {
00148 public:
00150   virtual ~csSkinSlice ()
00151   { Deinitialize (); }
00152 
00161   virtual void Initialize (csApp * /*iApp*/, csSkin * /*Parent*/) {}
00162 
00171   virtual void Deinitialize () {}
00172 
00174   virtual const char *GetName () = 0;
00175 
00177   virtual void Apply (csComponent &This);
00178 
00189   virtual void Reset (csComponent &This);
00190 
00192   virtual void Draw (csComponent &This) = 0;
00193 };
00194 
00200 class csButtonSkin : public csSkinSlice
00201 {
00202 public:
00204   virtual const char *GetName ()
00205   { return "Button"; }
00206 
00208   virtual void SuggestSize (csButton &This, int &w, int &h) = 0;
00209 };
00210 
00216 class csWindowSkin : public csSkinSlice
00217 {
00218 public:
00220   virtual const char *GetName ()
00221   { return "Window"; }
00222 
00224   virtual csButton *CreateButton (csWindow &This, int ButtonID) = 0;
00225 
00227   virtual void PlaceGadgets (csWindow &This) = 0;
00228 
00230   virtual void SetState (csWindow &This, int Which, bool State) = 0;
00231 
00233   virtual void SetBorderSize (csWindow &This) = 0;
00234 };
00235 
00241 class csDialogSkin : public csSkinSlice
00242 {
00243 public:
00245   virtual const char *GetName ()
00246   { return "Dialog"; }
00247 
00249   virtual void SetBorderSize (csDialog &This) = 0;
00250 };
00251 
00257 class csTitlebarSkin : public csSkinSlice
00258 {
00259 public:
00261   virtual const char *GetName ()
00262   { return "Titlebar"; }
00263 };
00264 
00270 class csListBoxSkin : public csSkinSlice
00271 {
00272 public:
00274   virtual const char *GetName ()
00275   { return "Listbox"; }
00276 
00278   virtual void SuggestSize (csListBox &This, int &w, int &h) = 0;
00279 };
00280 
00286 class csListBoxItemSkin : public csSkinSlice
00287 {
00288 public:
00290   virtual const char *GetName ()
00291   { return "ListboxItem"; }
00292 };
00293 
00294 
00300 class csScrollBarSkin : public csSkinSlice
00301 {
00302 public:
00304   virtual const char *GetName ()
00305   { return "ScrollBar"; }
00306 };
00307 
00328 #define CSWS_SKIN_DECLARE(name,base)    \
00329   class name : public base      \
00330   {                             \
00331   public:                       \
00332     name ()                     \
00333     {
00334 
00339 #define CSWS_SKIN_SLICE(comp)   \
00340       InsertSorted (new cs##comp##Skin);
00341 
00351 #define CSWS_SKIN_DECLARE_END   \
00352     }                           \
00353   }
00354 
00357 #endif // __CS_CSSKIN_H__

Generated for Crystal Space by doxygen 1.2.14