KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWOptionDataBase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWOptionDataBase.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWOptionDataBase - an option database
15 // .SECTION Description
16 // This class can be used to store entries specifying how to automatically
17 // override the default settings/look&feel of any vtkKWWidget subclass at
18 // run-time.
19 //
20 // For example, you may want all your vtkKWPushButton objects to use a blue
21 // background by default; this can be done by adding the following entry
22 // to the application's option database at startup:
23 // myapplication->GetOptionDataBase()->AddEntry(
24 // "vtkKWPushButton", "SetBackgroundColor", "0.2 0.2 0.8");
25 // From then on, anytime a vtkKWPushButton is created (using Create()), its
26 // look&feel is configured and overriden automatically given the entries in
27 // the database (here, its BackgroundColor is set to a blue-ish color).
28 //
29 // Collections of entries can be grouped inside a *theme*, subclass of
30 // vtkKWTheme. Check the Examples/Cxx/Theme for more details.
31 // Each vtkKWApplication object has a unique instance of a vtkKWOptionDataBase.
32 //
33 // Note that each entry is added as a pattern, a command, and a value:
34 //
35 // - the value can be empty if the command does not support any parameter, say:
36 // AddEntry("vtkKWPushButton", "SetReliefToGroove", NULL)
37 //
38 // - the pattern can specify a constraint on the object context, i.e. require
39 // that the command/value should only be applied if the object is of a
40 // specific class *and* has specific parents; this provides a way to
41 // configure widgets only when they are found inside other widgets:
42 // AddEntry("vtkKWMessageDialog*vtkKWPushButton", "SetReliefToGroove",NULL)
43 // => this entry will configure all vtkKWPushButton objects only if
44 // they are found to be a child *or* a sub-child of a vtkKWMessageDialog.
45 // AddEntry("vtkKWFrame.vtkKWPushButton", "SetReliefToGroove",NULL)
46 // => this entry will configure all vtkKWPushButton objects only if
47 // they are found to be an *immediate* child of a vtkKWFrame.
48 // Of course, combinations can be used, say:
49 // AddEntry("vtkKWMessageDialog*vtkKWFrame.vtkKWPushButton", ...
50 //
51 // - the pattern can specify a unique (terminal) slot suffix, that will be
52 // used to configure a sub-object instead of the object itself. The
53 // sub-object is retrieved by calling Get'slot name' on the object.
54 // AddEntry("vtkKWFrameWithLabel:CollapsibleFrame", "SetReliefToSolid", 0);
55 // => this entry will configure the sub-object retrieved by calling
56 // GetCollapsibleFrame on any vtkKWFrameWithLabel object, not the object
57 // itself. This can be useful to customize specific part of a mega-widget.
58 //
59 // .SECTION Thanks
60 // This work is part of the National Alliance for Medical Image
61 // Computing (NAMIC), funded by the National Institutes of Health
62 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
63 // Information on the National Centers for Biomedical Computing
64 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
65 // .SECTION See Also
66 // vtkKWTheme
67 
68 #ifndef __vtkKWOptionDataBase_h
69 #define __vtkKWOptionDataBase_h
70 
71 #include "vtkKWObject.h"
72 
73 class vtkKWOptionDataBaseInternals;
74 class vtkKWWidget;
75 
77 {
78 public:
79  static vtkKWOptionDataBase* New();
80  vtkTypeRevisionMacro(vtkKWOptionDataBase, vtkKWObject);
81  void PrintSelf(ostream& os, vtkIndent indent);
82  void DeepCopy(vtkKWOptionDataBase *p);
83 
84  // Description:
85  // Add a new entry in the database.
86  // Return the unique Id of the entry
87  virtual int AddEntry(
88  const char *pattern, const char *command, const char *value);
89  virtual int AddEntryAsInt(
90  const char *pattern, const char *command, int value);
91  virtual int AddEntryAsInt3(
92  const char *pattern, const char *command, int v0, int v1, int v2);
93  virtual int AddEntryAsInt3(
94  const char *pattern, const char *command, int value3[3]);
95  virtual int AddEntryAsDouble(
96  const char *pattern, const char *command, double value);
97  virtual int AddEntryAsDouble3(
98  const char *pattern, const char *command, double v0, double v1, double v2);
99  virtual int AddEntryAsDouble3(
100  const char *pattern, const char *command, double value3[3]);
101 
102  // Description:
103  // Remove all entries.
104  virtual void RemoveAllEntries();
105 
106  // Description:
107  // Get number of entries.
108  virtual int GetNumberOfEntries();
109 
110  // Description:
111  // Configure a widget according to the options in the database.
112  // Return the Id of the entry if found, -1 otherwise
113  virtual void ConfigureWidget(vtkKWWidget *obj);
114 
115  // Description:
116  // Convenience method to set all the known background color options to a
117  // specific color.
118  virtual void AddBackgroundColorOptions(double r, double g, double b);
119  virtual void AddBackgroundColorOptions(double rgb[3])
120  { this->AddBackgroundColorOptions(rgb[0], rgb[1], rgb[2]); };
121 
122  // Description:
123  // Convenience method to set all the known font options to a
124  // specific font.
125  virtual void AddFontOptions(const char *font);
126 
127 protected:
130 
131  // PIMPL Encapsulation for STL containers
132  //BTX
133  vtkKWOptionDataBaseInternals *Internals;
134  //ETX
135 
136 private:
137 
138  vtkKWOptionDataBase(const vtkKWOptionDataBase&); // Not implemented
139  void operator=(const vtkKWOptionDataBase&); // Not implemented
140 };
141 
142 #endif