Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csskin.h

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 __CSSKIN_H__
00021 #define __CSSKIN_H__
00022 
00023 #include "csutil/csvector.h"
00024 
00025 class csSkin;
00026 class csSkinSlice;
00027 class csApp;
00028 class csComponent;
00029 class csButton;
00030 class csWindow;
00031 class csDialog;
00032 class csListBox;
00033 class csListBoxItem;
00034 class csBackground;
00035 
00062 class csSkin : public csVector
00063 {
00065   csApp *app;
00066 
00067 public:
00069   const char *Prefix;
00070 
00072   csSkin () : csVector (16, 16), Prefix (NULL) {}
00073 
00075   virtual ~csSkin ();
00076 
00078   virtual bool FreeItem (csSome Item);
00079 
00081   virtual int CompareKey (csSome Item, csConstSome Key, int) const;
00082 
00084   virtual int Compare (csSome Item1, csSome Item2, int) const;
00085 
00087   csSkinSlice *Get (int iIndex)
00088   { return (csSkinSlice *)csVector::Get (iIndex); }
00089 
00091   void Apply (csComponent *iComp);
00092 
00094   virtual void Initialize (csApp *iApp);
00095 
00097   virtual void Deinitialize ();
00098 
00100   const char *GetConfigStr (const char *iSection, const char *iKey, const char *iDefault);
00102   bool GetConfigYesNo (const char *iSection, const char *iKey, bool iDefault);
00103 
00105   void Load (csBackground &oBack, const char *iSection, const char *iPrefix);
00106 
00107 private:
00108   bool ReadGradient (const char *iText, csRGBcolor *color, int iNum);
00109 };
00110 
00138 class csSkinSlice
00139 {
00140 public:
00142   virtual ~csSkinSlice ()
00143   { Deinitialize (); }
00144 
00153   virtual void Initialize (csApp * /*iApp*/, csSkin * /*Parent*/) {}
00154 
00163   virtual void Deinitialize () {}
00164 
00166   virtual const char *GetName () = 0;
00167 
00169   virtual void Apply (csComponent &This);
00170 
00181   virtual void Reset (csComponent &This);
00182 
00184   virtual void Draw (csComponent &This) = 0;
00185 };
00186 
00192 class csButtonSkin : public csSkinSlice
00193 {
00194 public:
00196   virtual const char *GetName ()
00197   { return "Button"; }
00198 
00200   virtual void SuggestSize (csButton &This, int &w, int &h) = 0;
00201 };
00202 
00208 class csWindowSkin : public csSkinSlice
00209 {
00210 public:
00212   virtual const char *GetName ()
00213   { return "Window"; }
00214 
00216   virtual csButton *CreateButton (csWindow &This, int ButtonID) = 0;
00217 
00219   virtual void PlaceGadgets (csWindow &This) = 0;
00220 
00222   virtual void SetState (csWindow &This, int Which, bool State) = 0;
00223 
00225   virtual void SetBorderSize (csWindow &This) = 0;
00226 };
00227 
00233 class csDialogSkin : public csSkinSlice
00234 {
00235 public:
00237   virtual const char *GetName ()
00238   { return "Dialog"; }
00239 
00241   virtual void SetBorderSize (csDialog &This) = 0;
00242 };
00243 
00249 class csTitlebarSkin : public csSkinSlice
00250 {
00251 public:
00253   virtual const char *GetName ()
00254   { return "Titlebar"; }
00255 };
00256 
00262 class csListBoxSkin : public csSkinSlice
00263 {
00264 public:
00266   virtual const char *GetName ()
00267   { return "Listbox"; }
00268 
00270   virtual void SuggestSize (csListBox &This, int &w, int &h) = 0;
00271 };
00272 
00278 class csListBoxItemSkin : public csSkinSlice
00279 {
00280 public:
00282   virtual const char *GetName ()
00283   { return "ListboxItem"; }
00284 };
00285 
00286 
00292 class csScrollBarSkin : public csSkinSlice
00293 {
00294 public:
00296   virtual const char *GetName ()
00297   { return "ScrollBar"; }
00298 };
00299 
00321 #define CSWS_SKIN_DECLARE(name,base)    \
00322   class name : public base      \
00323   {                             \
00324   public:                       \
00325     name ()                     \
00326     {
00327 
00332 #define CSWS_SKIN_SLICE(comp)   \
00333       InsertSorted (new cs##comp##Skin);
00334 
00344 #define CSWS_SKIN_DECLARE_END   \
00345     }                           \
00346   }
00347 
00348 #endif // __CSSKIN_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000