debian/tmp/usr/include/KWWidgets/vtkKWOptionDataBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWOptionDataBase.h,v $
00004 
00005   Copyright (c) Kitware, Inc.
00006   All rights reserved.
00007   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 // .NAME vtkKWOptionDataBase - an option database
00015 // .SECTION Description
00016 // This class can be used to store entries specifying how to automatically
00017 // override the default settings/look&feel of any vtkKWWidget subclass at
00018 // run-time. 
00019 //
00020 // For example, you may want all your vtkKWPushButton objects to use a blue
00021 // background by default; this can be done by adding the following entry
00022 // to the application's option database at startup:
00023 //   myapplication->GetOptionDataBase()->AddEntry(
00024 //      "vtkKWPushButton", "SetBackgroundColor", "0.2 0.2 0.8");
00025 // From then on, anytime a vtkKWPushButton is created (using Create()), its 
00026 // look&feel is configured and overriden automatically given the entries in
00027 // the database (here, its BackgroundColor is set to a blue-ish color). 
00028 //
00029 // Collections of entries can be grouped inside a *theme*, subclass of
00030 // vtkKWTheme. Check the Examples/Cxx/Theme for more details.
00031 // Each vtkKWApplication object has a unique instance of a vtkKWOptionDataBase.
00032 //
00033 // Note that each entry is added as a pattern, a command, and a value:
00034 //
00035 // - the value can be empty if the command does not support any parameter, say:
00036 //     AddEntry("vtkKWPushButton", "SetReliefToGroove", NULL)
00037 //
00038 // - the pattern can specify a constraint on the object context, i.e. require
00039 //   that the command/value should only be applied if the object is of a 
00040 //   specific class *and* has specific parents; this provides a way to 
00041 //   configure widgets only when they are found inside other widgets:
00042 //     AddEntry("vtkKWMessageDialog*vtkKWPushButton", "SetReliefToGroove",NULL)
00043 //   => this entry will configure all vtkKWPushButton objects only if
00044 //   they are found to be a child *or* a sub-child of a vtkKWMessageDialog.
00045 //     AddEntry("vtkKWFrame.vtkKWPushButton", "SetReliefToGroove",NULL)
00046 //   => this entry will configure all vtkKWPushButton objects only if
00047 //   they are found to be an *immediate* child of a vtkKWFrame.
00048 //   Of course, combinations can be used, say:
00049 //     AddEntry("vtkKWMessageDialog*vtkKWFrame.vtkKWPushButton", ...
00050 //
00051 // - the pattern can specify a unique (terminal) slot suffix, that will be
00052 //   used to configure a sub-object instead of the object itself. The 
00053 //   sub-object is retrieved by calling Get'slot name' on the object.
00054 //     AddEntry("vtkKWFrameWithLabel:CollapsibleFrame", "SetReliefToSolid", 0);
00055 //   => this entry will configure the sub-object retrieved by calling
00056 //   GetCollapsibleFrame on any vtkKWFrameWithLabel object, not the object
00057 //   itself. This can be useful to customize specific part of a mega-widget.
00058 //
00059 // .SECTION Thanks
00060 // This work is part of the National Alliance for Medical Image
00061 // Computing (NAMIC), funded by the National Institutes of Health
00062 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
00063 // Information on the National Centers for Biomedical Computing
00064 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
00065 // .SECTION See Also
00066 // vtkKWTheme
00067 
00068 #ifndef __vtkKWOptionDataBase_h
00069 #define __vtkKWOptionDataBase_h
00070 
00071 #include "vtkKWObject.h"
00072 
00073 class vtkKWOptionDataBaseInternals;
00074 class vtkKWWidget;
00075 
00076 class KWWidgets_EXPORT vtkKWOptionDataBase : public vtkKWObject
00077 {
00078 public:
00079   static vtkKWOptionDataBase* New();
00080   vtkTypeRevisionMacro(vtkKWOptionDataBase, vtkKWObject);
00081   void PrintSelf(ostream& os, vtkIndent indent);
00082   void DeepCopy(vtkKWOptionDataBase *p);
00083 
00084   // Description:
00085   // Add a new entry in the database.
00086   // Return the unique Id of the entry
00087   virtual int AddEntry(
00088     const char *pattern, const char *command, const char *value);
00089   virtual int AddEntryAsInt(
00090     const char *pattern, const char *command, int value);
00091   virtual int AddEntryAsInt3(
00092     const char *pattern, const char *command, int v0, int v1, int v2);
00093   virtual int AddEntryAsInt3(
00094     const char *pattern, const char *command, int value3[3]);
00095   virtual int AddEntryAsDouble(
00096     const char *pattern, const char *command, double value);
00097   virtual int AddEntryAsDouble3(
00098     const char *pattern, const char *command, double v0, double v1, double v2);
00099   virtual int AddEntryAsDouble3(
00100     const char *pattern, const char *command, double value3[3]);
00101 
00102   // Description:
00103   // Remove all entries.
00104   virtual void RemoveAllEntries();
00105 
00106   // Description:
00107   // Get number of entries.
00108   virtual int GetNumberOfEntries();
00109 
00110   // Description:
00111   // Configure a widget according to the options in the database.
00112   // Return the Id of the entry if found, -1 otherwise
00113   virtual void ConfigureWidget(vtkKWWidget *obj);
00114 
00115   // Description:
00116   // Convenience method to set all the known background color options to a 
00117   // specific color.
00118   virtual void AddBackgroundColorOptions(double r, double g, double b);
00119   virtual void AddBackgroundColorOptions(double rgb[3])
00120     { this->AddBackgroundColorOptions(rgb[0], rgb[1], rgb[2]); };
00121 
00122   // Description:
00123   // Convenience method to set all the known font options to a 
00124   // specific font.
00125   virtual void AddFontOptions(const char *font);
00126 
00127 protected:
00128   vtkKWOptionDataBase();
00129   ~vtkKWOptionDataBase();
00130 
00131   // PIMPL Encapsulation for STL containers
00132   //BTX
00133   vtkKWOptionDataBaseInternals *Internals;
00134   //ETX
00135 
00136 private:
00137 
00138   vtkKWOptionDataBase(const vtkKWOptionDataBase&); // Not implemented
00139   void operator=(const vtkKWOptionDataBase&); // Not implemented
00140 };
00141 
00142 #endif