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

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    vtkKWMenu.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 vtkKWMenu - a menu widget
00015 // .SECTION Description
00016 // This class is the Menu abstraction.
00017 
00018 #ifndef __vtkKWMenu_h
00019 #define __vtkKWMenu_h
00020 
00021 #include "vtkKWCoreWidget.h"
00022 
00023 class vtkKWMenuInternals;
00024 
00025 class KWWidgets_EXPORT vtkKWMenu : public vtkKWCoreWidget
00026 {
00027 public:
00028   static vtkKWMenu* New();
00029   vtkTypeRevisionMacro(vtkKWMenu,vtkKWCoreWidget);
00030   void PrintSelf(ostream& os, vtkIndent indent);
00031  
00032   // Description: 
00033   // Append/Insert a standard command menu item to the menu.
00034   // The 'object' argument is the object that will have the method called on
00035   // it. The 'method' argument is the name of the method to be called and any
00036   // arguments in string form. If the object is NULL, the method is still
00037   // evaluated as a simple command. 
00038   // A vtkKWMenu::CommandItemAddedEvent event is generated as well.
00039   // Return index of the menu item that was created/inserted, -1 on error
00040   virtual int AddCommand(const char *label);
00041   virtual int AddCommand(const char *label, 
00042                          vtkObject *object, const char *method);
00043   virtual int InsertCommand(int index, const char *label);
00044   virtual int InsertCommand(int index, const char *label, 
00045                             vtkObject *object, const char *method);
00046 
00047   // Description:
00048   // Set/Get the command for an existing menu item. This can also be used
00049   // on checkbutton and radiobutton entries (i.e. any menu item that was
00050   // created with a command).
00051   // Note that the output of GetItemCommand is a pointer to a
00052   // temporary buffer that should be copied *immediately* to your own storage.
00053   virtual void SetItemCommand(
00054     int index, vtkObject *object, const char *method);
00055   virtual const char* GetItemCommand(int index);
00056 
00057   // Description: 
00058   // Get the index of the first menu item that is using a specific command.
00059   // You can also use GetIndexOfItem to retrieve the menu item using a 
00060   // specific label.
00061   virtual int GetIndexOfCommandItem(vtkObject *object, const char *method);
00062 
00063   // Description: 
00064   // Append/Insert a checkbutton menu item to the menu.
00065   // A vtkKWMenu::CheckButtonItemAddedEvent event is generated as well.
00066   // Return index of the menu item that was created/inserted, -1 on error
00067   virtual int AddCheckButton(const char *label);
00068   virtual int AddCheckButton(const char *label,
00069                              vtkObject *object, const char *method);
00070   virtual int InsertCheckButton(int index, const char *label);
00071   virtual int InsertCheckButton(int index, const char *label,
00072                                 vtkObject *object, const char *method);
00073 
00074   // Description: 
00075   // Set/Get an checkbutton or radiobutton selected state (where 1
00076   // means selected, 0 means deselected). 
00077   // Note that you can *not* set the selected state of a radiobutton to 0;
00078   // a radiobutton is part of a group, to deselect it one needs to select
00079   // another radiobutton in that group (therefore, unselecting a 
00080   // radiobutton has no meaning).
00081   // Items can be referred to by index or label.
00082   virtual void SetItemSelectedState(int index, int state);
00083   virtual void SetItemSelectedState(const char *label, int state);
00084   virtual int GetItemSelectedState(int index);
00085   virtual int GetItemSelectedState(const char *label);
00086 
00087   // Description: 
00088   // Select/Deselect a checkbutton or radiobutton.
00089   // These methods are just front-end to SetItemSelectedState. The same
00090   // constraints apply, i.e. you can *not* deselect a radiobutton (but
00091   // should select another radiobutton in the same group).
00092   // Items can be referred to by index or label.
00093   virtual void SelectItem(int index);
00094   virtual void SelectItem(const char *label);
00095   virtual void DeselectItem(int index);
00096   virtual void DeselectItem(const char *label);
00097 
00098   // Description: 
00099   // Append/Insert a radiobutton menu item to the menu.
00100   // Radiobuttons can be grouped together using either the 
00101   // PutItemInGroup method or the SetItemGroupName method.
00102   // By default, each newly created radiobutton share the same group already.
00103   // A vtkKWMenu::RadioButtonItemAddedEvent event is generated as well.
00104   // Return index of the menu item that was created/inserted, -1 on error
00105   virtual int AddRadioButton(const char *label);
00106   virtual int AddRadioButton(const char *label, 
00107                              vtkObject *object, const char *method);
00108   virtual int InsertRadioButton(int index, const char *label);
00109   virtual int InsertRadioButton(int index, const char *label, 
00110                                 vtkObject *object, const char *method);
00111 
00112   // Description: 
00113   // Append/Insert a radiobutton menu item to the menu using an image
00114   // instead of a label. The image name should be a valid Tk image name.
00115   // Radiobuttons can be grouped together using either the 
00116   // PutItemInGroup method or the SetItemGroupName method.
00117   // By default, each newly created radiobutton share the same group already.
00118   // A vtkKWMenu::RadioButtonItemAddedEvent event is generated as well.
00119   // Return index of the menu item that was created/inserted, -1 on error
00120   virtual int AddRadioButtonImage(const char *imgname);
00121   virtual int AddRadioButtonImage(const char *imgname,
00122                                   vtkObject *object, const char *method);
00123   virtual int InsertRadioButtonImage(int index, const char *imgname);
00124   virtual int InsertRadioButtonImage(int index, const char *imgname,
00125                                      vtkObject *object, const char *method);
00126 
00127   // Description: 
00128   // Group items together so that when one is selected, the other
00129   // ones are automatically deselected. This makes sense for radiobutton
00130   // items where each item should be assigned a different 'selected value'
00131   // using the SetItemSelectedValue method.
00132   // This method puts the item specified by 'index' in the 
00133   // group the item specificied by 'index_g' is already a member of.
00134   // Note that put(index_a, index_g) and put(index_b, index_g)
00135   // will put index_a and index_b in the same group as index_g, but
00136   // put(index_a, index_g) and put(index_g, index_b) will put
00137   // index_a in the same group as index_g, then put index_g in the same
00138   // group as index_b, thus resulting as index_a being in a different group
00139   // as index_g/index_b.
00140   // Another way to group items together is to make sure they all share the
00141   // same group name (see SetItemGroupName), which is what is really done by
00142   // PutItemInGroup anyway.
00143   // By default, each newly created radiobutton share the same group already,
00144   // new checkbuttons are assigned to their own group, and other items type
00145   // have no group.
00146   virtual void PutItemInGroup(int index, int index_g);
00147 
00148   // Description:
00149   // Set/Get the *local* group name to use to group a set of items together
00150   // (i.e. selecting one item in the group will deselect the others).
00151   // This makes sense for radiobutton items where each item should
00152   // be assigned a different 'selected value' using the SetItemSelectedValue
00153   // method. Another way to group items together is to use the PutItemInGroup
00154   // method, which at the end of the day will make sure items share the same
00155   // group name.
00156   // Note that the group name should be unique within *this* menu instance (if
00157   // you need a global name that can be shared between menus, check the more
00158   // advanced SetItemVariableName method). The group name should stick to
00159   // the usual variable naming convention (no spaces, start with a letter,
00160   // etc); note that it will be cleaned automatically anyway and
00161   // stored that way.
00162   // By default, each newly created radiobutton share the same group already,
00163   // new checkbuttons are assigned to their own group, and other items type
00164   // have no group.
00165   virtual const char* GetItemGroupName(int index);
00166   virtual void SetItemGroupName(int index, const char *group_name);
00167 
00168   // Description:
00169   // Set/Get the value associated to the selected state of a checkbutton
00170   // or radiobutton menu item. Convenience methods are provided to Set/Get
00171   // that value as an integer.
00172   // By default, checkbutton are assigned a selected value of 1. Radiobuttons
00173   // are assigned a value corresponding to their own label (or image name).
00174   // Note that the output of GetItemSelectedValue is a pointer to a
00175   // temporary buffer that should be copied *immediately* to your own storage.
00176   // Returns the value, or -1 if called on the wrong type of menu item
00177   virtual void SetItemSelectedValue(int index, const char *value);
00178   virtual const char* GetItemSelectedValue(int index);
00179   virtual void SetItemSelectedValueAsInt(int index, int value);
00180   virtual int GetItemSelectedValueAsInt(int index);
00181 
00182   // Description:
00183   // Set/Get the index of an item given its selected value (as set by
00184   // SetItemSelectedValue).
00185   virtual int GetIndexOfItemWithSelectedValue(const char *value);
00186   virtual int GetIndexOfItemWithSelectedValueAsInt(int value);
00187 
00188   // Description: 
00189   // Select the item which selected value (as it was set per item
00190   // using SetItemSelectedValue) matches a given value. Convenience method is
00191   // provided to select the item using a value as an integer.
00192   // Returns the item that was selected, -1 otherwise.
00193   virtual int SelectItemWithSelectedValue(const char *value);
00194   virtual int SelectItemWithSelectedValueAsInt(int value);
00195 
00196   // Description: 
00197   // Select the item in a group which selected value (as it was set per item
00198   // using SetItemSelectedValue) matches a given value. Convenience method is
00199   // provided to select the item using a value as an integer.
00200   // Returns the item that was selected, -1 otherwise.
00201   virtual int SelectItemInGroupWithSelectedValue(
00202     const char *group_name, const char *value);
00203   virtual int SelectItemInGroupWithSelectedValueAsInt(
00204     const char *group_name, int value);
00205 
00206   // Description: 
00207   // Get the index of the selected item in a group.
00208   // If group is not specified, use the group of the last entry; note that
00209   // this will only work there is only one group in the menu.
00210   // Return -1 on error.
00211   virtual int GetIndexOfSelectedItemInGroup(const char *group_name);
00212   virtual int GetIndexOfSelectedItem();
00213 
00214   // Description:
00215   // Set/Get the value associated to the de-selected state of a checkbutton
00216   // menu item (no allowed for radiobuttons). Can be safely left as is
00217   // most of the time, unless you want to store very specific selected
00218   // and deselected values for a checkbutton and retrieve them later on.
00219   // By default, checkbutton are assigned a selected value of 0. Radiobuttons
00220   // do not have a deselected value: a radiobutton is part of a group, to
00221   // deselect it one needs to select another radiobutton in that group
00222   // (therefore, unselecting a radiobutton has no meaning).
00223   // Note that the output of GetItemDeselectedValue is a pointer to a
00224   // temporary buffer that should be copied *immediately* to your own storage.
00225   // Returns the value, or -1 if called on the wrong type of menu item
00226   virtual void SetItemDeselectedValue(int index, const char *value);
00227   virtual void SetItemDeselectedValueAsInt(int index, int value);
00228   virtual int GetItemDeselectedValueAsInt(int index);
00229   virtual const char* GetItemDeselectedValue(int index);
00230 
00231   // Description: 
00232   // Append/Insert a separator to the menu.
00233   // A vtkKWMenu::SeparatorItemAddedEvent event is generated as well.
00234   // Return index of the menu item that was created/inserted, -1 on error
00235   virtual int AddSeparator();
00236   virtual int InsertSeparator(int index);
00237   
00238   // Description: 
00239   // Append/Insert a sub-menu (cascade) to the menu.
00240   // A vtkKWMenu::CascadeItemAddedEvent event is generated as well.
00241   // Return index of the menu item that was created/inserted, -1 on error
00242   virtual int AddCascade(const char *label, vtkKWMenu *menu);
00243   virtual int InsertCascade(int index, const char *label, vtkKWMenu *menu);
00244 
00245   // Description: 
00246   // Get the index of the first sub-menu (cascade) item that is using a
00247   // specific menu object.
00248   virtual int GetIndexOfCascadeItem(vtkKWMenu *menu);
00249 
00250   // Description:
00251   // Set the sub-menu for an existing sub-menu (cascade) item.
00252   virtual void SetItemCascade(int index, vtkKWMenu*);
00253   virtual void SetItemCascade(int index, const char *menu_name);
00254   virtual vtkKWMenu* GetItemCascade(int index);
00255 
00256   // Description:
00257   // Returns the integer index of the menu item using a specific label.
00258   // You can also use GetIndexOfCommandItem to retrieve the menu item using a
00259   // specific command (if that menu item supports a command).
00260   virtual int GetIndexOfItem(const char *label);
00261 
00262   // Description:
00263   // Checks if an item with a given label is in the menu.
00264   virtual int HasItem(const char *label);
00265 
00266   // Description:
00267   // Returns the type of a specific menu item.
00268   //BTX
00269   enum
00270   {
00271     UnknownItemType = 0,
00272     RadioButtonItemType,
00273     CheckButtonItemType,
00274     CommandItemType,
00275     SeparatorItemType,
00276     CascadeItemType
00277   };
00278   //ETX
00279   virtual int GetItemType(int index);
00280 
00281   // Description:
00282   // Set/Get the label of a specific menu item at a given index.
00283   // Note that the output of GetItemLabel is a pointer to a
00284   // temporary buffer that should be copied *immediately* to your own storage.
00285   virtual int SetItemLabel(int index, const char *label);
00286   virtual const char* GetItemLabel(int index);
00287 
00288   // Description:
00289   // Call the callback/command of a specific menu item specified by its
00290   // index.
00291   virtual void InvokeItem(int index);
00292 
00293   // Description:
00294   // Delete the menu item specified by its given index.
00295   // Be careful, there is a bug in Tk, that will break other items
00296   // in the menu below the one being deleted, unless a new item is added.
00297   virtual void DeleteItem(int index);
00298   virtual void DeleteAllItems();
00299   
00300   // Description:
00301   // Returns the number of items.
00302   virtual int GetNumberOfItems();
00303   
00304   // Description:
00305   // Set/Get state of the menu item with a given index or label.
00306   // Valid constants can be found in vtkKWOptions::StateType.
00307   virtual void SetItemState(int index, int state);
00308   virtual void SetItemStateToDisabled(int index);
00309   virtual void SetItemStateToNormal(int index);
00310   virtual void SetItemState(const char *label, int state);
00311   virtual void SetItemStateToDisabled(const char *label);
00312   virtual void SetItemStateToNormal(const char *label);
00313   virtual int GetItemState(int index);
00314   virtual int GetItemState(const char *label);
00315 
00316   // Description:
00317   // Set the state of all entries.
00318   // Valid constants can be found in vtkKWOptions::StateType.
00319   // This should not be used directly, this is done by 
00320   // SetEnabled()/UpdateEnableState(). 
00321   // Overriden to pass to all menu entries.
00322   virtual void SetState(int state);
00323 
00324   // Description:
00325   // Set the image of a menu item. A valid Tk image name or the index of
00326   // a predefined icon (as found in vtkKWIcon) should be passed.
00327   // Check the SetItemCompoundMode method if you want to display both the
00328   // image and the label at the same time.
00329   virtual void SetItemImage(int index, const char *imgname);
00330   virtual void SetItemImageToPredefinedIcon(int index, int icon_index);
00331   virtual void SetItemImageToIcon(int index, vtkKWIcon *icon);
00332 
00333   // Description:
00334   // Set the select image of a menu item.
00335   // The select image is available only for checkbutton and radiobutton 
00336   // entries. This method can be used to specify the image to display in
00337   // the menu item when it is selected (instead of the regular image). 
00338   virtual void SetItemSelectImage(int index, const char *imgname);
00339   virtual void SetItemSelectImageToPredefinedIcon(int index, int icon_index);
00340   virtual void SetItemSelectImageToIcon(int index, vtkKWIcon *icon);
00341 
00342   // Description:
00343   // Specifies if the menu item should display text and bitmaps/images at the
00344   // same time, and if so, where the bitmap/image should be placed relative 
00345   // to the text. 
00346   // Valid constants can be found in vtkKWOptions::CompoundModeType.
00347   // The (default) value CompoundModeNone specifies that the bitmap or image 
00348   // should (if defined) be displayed instead of the text. 
00349   // Check the SetItemMarginVisibility method too.
00350   virtual void SetItemCompoundMode(int index, int mode);
00351   virtual int GetItemCompoundMode(int index);
00352   virtual void SetItemCompoundModeToNone(int index);
00353   virtual void SetItemCompoundModeToLeft(int index);
00354   virtual void SetItemCompoundModeToCenter(int index);
00355   virtual void SetItemCompoundModeToRight(int index);
00356   virtual void SetItemCompoundModeToTop(int index);
00357   virtual void SetItemCompoundModeToBottom(int index);
00358 
00359   // Description:
00360   // Set the visibility of the standard margin of a menu item.
00361   // Hiding the margin is useful when creating palette with images in them,
00362   // i.e., color palettes, pattern palettes, etc.
00363   virtual void SetItemMarginVisibility(int index, int flag);
00364 
00365   // Description:
00366   // Set the visibility of the indicator of a menu item.
00367   // Available only for checkbutton and radiobutton entries.
00368   virtual void SetItemIndicatorVisibility(int index, int flag);
00369 
00370   // Description:
00371   // Specifies a string to display at the right side of the menu entry. 
00372   // Normally describes an accelerator keystroke sequence that may be typed
00373   // to invoke the same function as the menu entry. This is an arbitrary
00374   // string, not a key binding per say, i.e. pressing the accelerator
00375   // key does not automatically call the command associated to this
00376   // menu item. To do so, the corresponding key binding must be set and
00377   // associated to the item's command, if any. The SetBindingForItemAccelerator
00378   // method can be used to that effect.
00379   virtual void SetItemAccelerator(int index, const char *accelerator);
00380 
00381   // Description:
00382   // This method retrieves the accelerator attached to a menu item, convert
00383   // it to the proper keybinding (say, Ctrl+0 is converted into <Control-0>),
00384   // and set that binding on a specific 'widget' so that whenever that widget
00385   // has the focus and that key binding is pressed, the item's command will
00386   // be invokved. A typical use for this method is to set a menu item's
00387   // accelerator using SetItemAccelerator, then associate the corresponding
00388   // binding to the toplevel this menu is attached to. For example:
00389   //   menu->SetItemAccelerator(1, "Ctrl+0");
00390   //   menu->SetBindingForItemAccelerator(1, menu->GetParentTopLevel());
00391   // this last line is pretty much the same as this one below:
00392   //   menu->GetParentTopLevel()->SetBinding(
00393   //          "<Control-0>", menu->GetItemCommand(1));
00394   // but the accelerator to key-binding conversion is done automatically.
00395   // Note that if the accelerator has not been set (or if it has been reset
00396   // to an empty string or NULL), this method will *not* remove the binding
00397   // (since it has no knowledge of what the previous accelerator was), this
00398   // is up to the developper to do so by calling RemoveBinding for example.
00399   virtual void SetBindingForItemAccelerator(int index, vtkKWWidget*);
00400   virtual void RemoveBindingForItemAccelerator(int index, vtkKWWidget*);
00401 
00402   // Description:
00403   // Set/Get the help string for a given item specified by its index.
00404   // The help string will be displayed automatically in the status bar
00405   // of the window containing the menu, if any.
00406   // Note that the output of GetItemHelpString is a pointer to a
00407   // temporary buffer that should be copied *immediately* to your own storage.
00408   virtual void SetItemHelpString(int index, const char *help);
00409   virtual const char* GetItemHelpString(int index);
00410 
00411   // Description:
00412   // Set the index of a character to underline in the menu item specified by 
00413   // its index. Note that you can also specify that character
00414   // by using the special '&' marker in the label of the menu item 
00415   // (ex: "&File", or "Sa&ve File").
00416   virtual void SetItemUnderline(int index, int underline_index);
00417 
00418   // Description:
00419   // Set/Get a column break flag at a specific index.
00420   virtual void SetItemColumnBreak(int index, int flag);
00421 
00422   // Description:
00423   // Set/Get the name of a *global* variable to set when a checkbutton or a 
00424   // radiobutton menu item is selected. Whenever selected, a checkbutton
00425   // or radiobutton will set its variable to the value that was associated
00426   // to it using SetItemSelectedValue. When deselected a checkbutton set
00427   // its variable to the value that was associated to it using 
00428   // SetItemDeselectedValue.
00429   // Setting the same variable names for different radiobuttons is the
00430   // actual way to put them in the same *group* (i.e. selecting one 
00431   // radiobutton in the group will deselect the others). Is is recommended
00432   // to use either the PutItemInGroup method to group buttons 
00433   // together, or the SetItemGroupName method, which are just  
00434   // front-ends to the SetItemVariable method, but build a global variable
00435   // name out of the current menu instance name and a local group name.
00436   // Note that the variable name should be unique within *this* menu 
00437   // instance as well as *all* other menu instances so that it can be
00438   // shared between menus if needed. Most of the time, using a global name
00439   // will not be needed and we therefore recommend you pick a local global
00440   // name by using the SetItemGroupName. This variable name should
00441   // stick to the usual variable naming convention (no spaces, start with
00442   // a letter, etc). One way to create such a group name is, for example, to
00443   // concatenate the Tcl name (GetTclName()) or the widget name
00444   // (GetWidgetName()) of the menu instance with some string suffix 
00445   // describing the variable; a different signature is available to create
00446   // such composite name automatically, but the CreateItemVariableName can 
00447   // be used as well. 
00448   // By default, each newly created radiobutton share the same variable
00449   // name already. Each newly created checkbutton is assigned a unique 
00450   // variable name.
00451   // Note that the output of GetItemVariable is a pointer to a
00452   // temporary buffer that should be copied *immediately* to your own storage.
00453   virtual const char* GetItemVariable(int index);
00454   virtual void SetItemVariable(int index, const char *varname);
00455   virtual void SetItemVariable(
00456     int index, vtkKWObject *object, const char *suffix);
00457 
00458   // Description: 
00459   // Convenience method to create a variable name out of an object
00460   // (say, this instance) and an arbitrary suffix (say, the menu item label). 
00461   // Such a variable name can be used to call SetItemVariable on a 
00462   // checkbutton or radiobutton menu item.
00463   // Note that spaces and unusual characters are automatically removed
00464   // from the 'suffix'. 
00465   // This method allocates enough memory (using 'new') for that name and
00466   // returns a pointer to that location. This pointer should be deleted
00467   // by the user using 'delete []'.
00468   virtual char* CreateItemVariableName(
00469     vtkKWObject *object, const char *suffix);
00470 
00471   // Description: 
00472   // Set/Get the value for a variable name given a variable name (as retrieved
00473   // using GetItemVariable() for example).
00474   // This will affect the menu entries accordingly (i.e. setting the 
00475   // variable will select/deselect the entries).
00476   // Note that the output of GetItemVariableValue is a pointer to a
00477   // temporary buffer that should be copied *immediately* to your own storage.
00478   virtual const char* GetItemVariableValue(const char *varname);
00479   virtual void SetItemVariableValue(const char *varname, const char *value);
00480   virtual int GetItemVariableValueAsInt(const char *varname);
00481   virtual void SetItemVariableValueAsInt(const char *varname, int value);
00482 
00483   // Description: 
00484   // Get the index of an item gien its variable name and its selected value.
00485   virtual int GetIndexOfItemWithVariableAndSelectedValue(
00486     const char *varname, const char *value);
00487   virtual int GetIndexOfItemWithVariableAndSelectedValueAsInt(
00488     const char *varname, int value);
00489 
00490   // Description:
00491   // Set/Get if this menu is a tearoff menu.  By dafault this value is off.
00492   virtual void SetTearOff(int val);
00493   vtkGetMacro(TearOff, int);
00494   vtkBooleanMacro(TearOff, int);
00495 
00496   // Description:
00497   // Pop-up the menu at screen coordinates x, y
00498   virtual void PopUp(int x, int y);
00499 
00500   // Description:
00501   // Get the Tk option of a specific menu item. Internal use.
00502   // Note that the output of GetItemOption is a pointer to a
00503   // temporary buffer that should be copied *immediately* to your own storage.
00504   virtual int HasItemOption(int index, const char *option);
00505   virtual const char* GetItemOption(int index, const char *option);
00506 
00507   // Description:
00508   // Events. The ItemAddedEvent events are generated when menu entries are
00509   // addded or inserted (say, RadioButtonItemAddedEvent).
00510   // The MenuItemInvokedEvent is sent when a menu entry is invoked (i.e.,
00511   // a mouse button is released over the entry).
00512   // The following parameters are also passed as client data:
00513   // - the index of the new menu item: int
00514   //BTX
00515   enum
00516   {
00517     RadioButtonItemAddedEvent = 10000,
00518     CheckButtonItemAddedEvent,
00519     CommandItemAddedEvent,
00520     SeparatorItemAddedEvent,
00521     CascadeItemAddedEvent,
00522     MenuItemInvokedEvent
00523   };
00524   //ETX
00525 
00526   // Description:
00527   // Set/Get the background color of the widget.
00528   virtual void GetBackgroundColor(double *r, double *g, double *b);
00529   virtual double* GetBackgroundColor();
00530   virtual void SetBackgroundColor(double r, double g, double b);
00531   virtual void SetBackgroundColor(double rgb[3])
00532     { this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
00533   
00534   // Description:
00535   // Set/Get the foreground color of the widget.
00536   virtual void GetForegroundColor(double *r, double *g, double *b);
00537   virtual double* GetForegroundColor();
00538   virtual void SetForegroundColor(double r, double g, double b);
00539   virtual void SetForegroundColor(double rgb[3])
00540     { this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); };
00541 
00542   // Description:
00543   // Set/Get the active background color of the widget. An element
00544   // (a widget or portion of a widget) is active if the mouse cursor is
00545   // positioned over the element and pressing a mouse button will cause some
00546   // action to occur.
00547   virtual void GetActiveBackgroundColor(double *r, double *g, double *b);
00548   virtual double* GetActiveBackgroundColor();
00549   virtual void SetActiveBackgroundColor(double r, double g, double b);
00550   virtual void SetActiveBackgroundColor(double rgb[3])
00551     { this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); };
00552   
00553   // Description:
00554   // Set/Get the active foreground color of the widget. An element
00555   // (a widget or portion of a widget) is active if the mouse cursor is
00556   // positioned over the element and pressing a mouse button will cause some
00557   // action to occur.
00558   virtual void GetActiveForegroundColor(double *r, double *g, double *b);
00559   virtual double* GetActiveForegroundColor();
00560   virtual void SetActiveForegroundColor(double r, double g, double b);
00561   virtual void SetActiveForegroundColor(double rgb[3])
00562     { this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); };
00563   
00564   // Description:
00565   // Set/Get the foreground color of the widget when it is disabled.
00566   virtual void GetDisabledForegroundColor(double *r, double *g, double *b);
00567   virtual double* GetDisabledForegroundColor();
00568   virtual void SetDisabledForegroundColor(double r, double g, double b);
00569   virtual void SetDisabledForegroundColor(double rgb[3])
00570     { this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); };
00571 
00572   // Description:
00573   // Set/Get the background color to use when the widget is selected.
00574   virtual void GetSelectColor(double *r, double *g, double *b);
00575   virtual double* GetSelectColor();
00576   virtual void SetSelectColor(double r, double g, double b);
00577   virtual void SetSelectColor(double rgb[3])
00578     { this->SetSelectColor(rgb[0], rgb[1], rgb[2]); };
00579 
00580   // Description:
00581   // Set/Get the border width, a non-negative value indicating the width of
00582   // the 3-D border to draw around the outside of the widget (if such a border
00583   // is being drawn; the Relief option typically determines this).
00584   virtual void SetBorderWidth(int);
00585   virtual int GetBorderWidth();
00586   
00587   // Description:
00588   // Set/Get the 3-D effect desired for the widget. 
00589   // The value indicates how the interior of the widget should appear
00590   // relative to its exterior. 
00591   // Valid constants can be found in vtkKWOptions::ReliefType.
00592   virtual void SetRelief(int);
00593   virtual int GetRelief();
00594   virtual void SetReliefToRaised();
00595   virtual void SetReliefToSunken();
00596   virtual void SetReliefToFlat();
00597   virtual void SetReliefToRidge();
00598   virtual void SetReliefToSolid();
00599   virtual void SetReliefToGroove();
00600 
00601   // Description:
00602   // Specifies the font to use when drawing text inside the widget. 
00603   // You can use predefined font names (e.g. 'system'), or you can specify
00604   // a set of font attributes with a platform-independent name, for example,
00605   // 'times 12 bold'. In this example, the font is specified with a three
00606   // element list: the first element is the font family, the second is the
00607   // size, the third is a list of style parameters (normal, bold, roman, 
00608   // italic, underline, overstrike). Example: 'times 12 {bold italic}'.
00609   // The Times, Courier and Helvetica font families are guaranteed to exist
00610   // and will be matched to the corresponding (closest) font on your system.
00611   // If you are familiar with the X font names specification, you can also
00612   // describe the font that way (say, '*times-medium-r-*-*-12*').
00613   virtual void SetFont(const char *font);
00614   virtual const char* GetFont();
00615 
00616   // Description:
00617   // Set or get enabled state.
00618   // This method has been overriden to propagate the state to all its
00619   // menu entries by calling UpdateEnableState(), *even* if the
00620   // state (this->Enabled) is actually unchanged by the function. This
00621   // make sure all the menu entries have been enabled/disabled properly.
00622   virtual void SetEnabled(int);
00623 
00624   // Description:
00625   // This method has been overriden to propagate the state to all its
00626   // menu entries by calling SetState().
00627   // Update the "enable" state of the object and its internal parts.
00628   // Depending on different Ivars (this->Enabled, the application's 
00629   // Limited Edition Mode, etc.), the "enable" state of the object is updated
00630   // and propagated to its internal parts/subwidgets. This will, for example,
00631   // enable/disable parts of the widget UI, enable/disable the visibility
00632   // of 3D widgets, etc.
00633   virtual void UpdateEnableState();
00634 
00635   // Description:
00636   // Callbacks: for active menu item doc line help
00637   virtual void DisplayHelpCallback(const char *widget_name);
00638   virtual void CommandInvokedCallback(const char *command);
00639   
00640 protected:
00641   vtkKWMenu();
00642   ~vtkKWMenu();
00643   
00644   // Description: 
00645   // Create the widget.
00646   virtual void CreateWidget();
00647   
00648   // Description: 
00649   // Add a generic menu item (defined by type)
00650   // Return index of the menu item that was created/inserted, -1 on error
00651   virtual int AddGeneric(const char *type, const char *label, 
00652                          const char* extra);
00653   virtual int InsertGeneric(int index, const char *type, const char *label, 
00654                             const char* extra);
00655 
00656   // Description: 
00657   // Given a label, allocate and create a clean label that is stripped
00658   // out of its underline marker (ex: "&Open File" is cleaned as "Open File", 
00659   // "Sa&ve File" is cleaned as "Save File"). 
00660   // Return 1 if a clean label was created: the 'clean_label' parameter 
00661   // should be freed later on by the user by calling 'delete []'. The 
00662   // 'underline' parameter is set to the position of the underline marker.
00663   // Return 0 if the label was already cleaned: the 'clean_label' parameter 
00664   // is set to the value of 'label' (set, *not* allocated). The 
00665   // 'underline' parameter is set to -1.
00666   virtual int GetLabelWithoutUnderline(
00667     const char *label, char **clean_label, int *underline_index);
00668 
00669   int TearOff;
00670 
00671   // Description:
00672   // Returns the integer index of the active menu item of a given menu.
00673   // Be extra careful with this method: most menus seems to be clone of
00674   // themselves, according to the Tk doc:
00675   //   When a menu is set as a menubar for a toplevel window, or when a menu
00676   //   is torn off, a clone of the menu is made. This clone is a menu widget
00677   //   in its own right, but it is a child of the original. Changes in the
00678   //   configuration of the original are reflected in the clone. Additionally, 
00679   //   any cascades that are pointed to are also cloned so that menu traversal
00680   //   will work right. 
00681   // Sadly, the active item of a menu is not something that is synchronized
00682   // between a menu and its clone. Querying the active item on the current
00683   // instance might therefore not work, because a clone is in fact being
00684   // interacted upon. This kind of situation is mostly encountered when
00685   // Tk events like <<MenuSelect>> are processed, and can therefore be solved
00686   // by making sure the callbacks are passing the %W parameter around: this
00687   // gets resolved to the widget name of the clone.
00688   virtual int GetIndexOfActiveItem(const char *widget_name);
00689 
00690   // Description:
00691   // Get the suffix out of variable name that was created using 
00692   // CreateItemVariableName
00693   const char* GetSuffixOutOfCreatedItemVariableName(const char *varname);
00694 
00695   // Description:
00696   // Convert key accelerator to binding
00697   virtual void ConvertItemAcceleratorToKeyBinding(
00698     const char *accelerator, char **keybinding);
00699 
00700   // Description:
00701   // PIMPL Encapsulation for STL containers
00702   vtkKWMenuInternals *Internals;
00703   
00704 private:
00705 
00706   vtkKWMenu(const vtkKWMenu&); // Not implemented
00707   void operator=(const vtkKWMenu&); // Not implemented
00708 };
00709 
00710 #endif

Generated on Sat Dec 12 16:04:54 2009 for KWWidgets by  doxygen 1.6.1