/usr/include/KWWidgets/vtkKWMenu.h is in libkwwidgets1-dev 1.0.0~cvs20100930-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | /*=========================================================================
Module: vtkKWMenu.h,v
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkKWMenu - a menu widget
// .SECTION Description
// This class is the Menu abstraction.
#ifndef __vtkKWMenu_h
#define __vtkKWMenu_h
#include "vtkKWCoreWidget.h"
class vtkKWMenuInternals;
class KWWidgets_EXPORT vtkKWMenu : public vtkKWCoreWidget
{
public:
static vtkKWMenu* New();
vtkTypeRevisionMacro(vtkKWMenu,vtkKWCoreWidget);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Append/Insert a standard command menu item to the menu.
// The 'object' argument is the object that will have the method called on
// it. The 'method' argument is the name of the method to be called and any
// arguments in string form. If the object is NULL, the method is still
// evaluated as a simple command.
// A vtkKWMenu::CommandItemAddedEvent event is generated as well.
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddCommand(const char *label);
virtual int AddCommand(const char *label,
vtkObject *object, const char *method);
virtual int InsertCommand(int index, const char *label);
virtual int InsertCommand(int index, const char *label,
vtkObject *object, const char *method);
// Description:
// Set/Get the command for an existing menu item. This can also be used
// on checkbutton and radiobutton entries (i.e. any menu item that was
// created with a command).
// Note that the output of GetItemCommand is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
virtual void SetItemCommand(
int index, vtkObject *object, const char *method);
virtual const char* GetItemCommand(int index);
// Description:
// Get the index of the first menu item that is using a specific command.
// You can also use GetIndexOfItem to retrieve the menu item using a
// specific label.
virtual int GetIndexOfCommandItem(vtkObject *object, const char *method);
// Description:
// Append/Insert a checkbutton menu item to the menu.
// A vtkKWMenu::CheckButtonItemAddedEvent event is generated as well.
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddCheckButton(const char *label);
virtual int AddCheckButton(const char *label,
vtkObject *object, const char *method);
virtual int InsertCheckButton(int index, const char *label);
virtual int InsertCheckButton(int index, const char *label,
vtkObject *object, const char *method);
// Description:
// Set/Get an checkbutton or radiobutton selected state (where 1
// means selected, 0 means deselected).
// Note that you can *not* set the selected state of a radiobutton to 0;
// a radiobutton is part of a group, to deselect it one needs to select
// another radiobutton in that group (therefore, unselecting a
// radiobutton has no meaning).
// Items can be referred to by index or label.
virtual void SetItemSelectedState(int index, int state);
virtual void SetItemSelectedState(const char *label, int state);
virtual int GetItemSelectedState(int index);
virtual int GetItemSelectedState(const char *label);
// Description:
// Select/Deselect a checkbutton or radiobutton.
// These methods are just front-end to SetItemSelectedState. The same
// constraints apply, i.e. you can *not* deselect a radiobutton (but
// should select another radiobutton in the same group).
// Items can be referred to by index or label.
virtual void SelectItem(int index);
virtual void SelectItem(const char *label);
virtual void DeselectItem(int index);
virtual void DeselectItem(const char *label);
// Description:
// Append/Insert a radiobutton menu item to the menu.
// Radiobuttons can be grouped together using either the
// PutItemInGroup method or the SetItemGroupName method.
// By default, each newly created radiobutton share the same group already.
// A vtkKWMenu::RadioButtonItemAddedEvent event is generated as well.
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddRadioButton(const char *label);
virtual int AddRadioButton(const char *label,
vtkObject *object, const char *method);
virtual int InsertRadioButton(int index, const char *label);
virtual int InsertRadioButton(int index, const char *label,
vtkObject *object, const char *method);
// Description:
// Append/Insert a radiobutton menu item to the menu using an image
// instead of a label. The image name should be a valid Tk image name.
// Radiobuttons can be grouped together using either the
// PutItemInGroup method or the SetItemGroupName method.
// By default, each newly created radiobutton share the same group already.
// A vtkKWMenu::RadioButtonItemAddedEvent event is generated as well.
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddRadioButtonImage(const char *imgname);
virtual int AddRadioButtonImage(const char *imgname,
vtkObject *object, const char *method);
virtual int InsertRadioButtonImage(int index, const char *imgname);
virtual int InsertRadioButtonImage(int index, const char *imgname,
vtkObject *object, const char *method);
// Description:
// Group items together so that when one is selected, the other
// ones are automatically deselected. This makes sense for radiobutton
// items where each item should be assigned a different 'selected value'
// using the SetItemSelectedValue method.
// This method puts the item specified by 'index' in the
// group the item specificied by 'index_g' is already a member of.
// Note that put(index_a, index_g) and put(index_b, index_g)
// will put index_a and index_b in the same group as index_g, but
// put(index_a, index_g) and put(index_g, index_b) will put
// index_a in the same group as index_g, then put index_g in the same
// group as index_b, thus resulting as index_a being in a different group
// as index_g/index_b.
// Another way to group items together is to make sure they all share the
// same group name (see SetItemGroupName), which is what is really done by
// PutItemInGroup anyway.
// By default, each newly created radiobutton share the same group already,
// new checkbuttons are assigned to their own group, and other items type
// have no group.
virtual void PutItemInGroup(int index, int index_g);
// Description:
// Set/Get the *local* group name to use to group a set of items together
// (i.e. selecting one item in the group will deselect the others).
// This makes sense for radiobutton items where each item should
// be assigned a different 'selected value' using the SetItemSelectedValue
// method. Another way to group items together is to use the PutItemInGroup
// method, which at the end of the day will make sure items share the same
// group name.
// Note that the group name should be unique within *this* menu instance (if
// you need a global name that can be shared between menus, check the more
// advanced SetItemVariableName method). The group name should stick to
// the usual variable naming convention (no spaces, start with a letter,
// etc); note that it will be cleaned automatically anyway and
// stored that way.
// By default, each newly created radiobutton share the same group already,
// new checkbuttons are assigned to their own group, and other items type
// have no group.
virtual const char* GetItemGroupName(int index);
virtual void SetItemGroupName(int index, const char *group_name);
// Description:
// Set/Get the value associated to the selected state of a checkbutton
// or radiobutton menu item. Convenience methods are provided to Set/Get
// that value as an integer.
// By default, checkbutton are assigned a selected value of 1. Radiobuttons
// are assigned a value corresponding to their own label (or image name).
// Note that the output of GetItemSelectedValue is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
// Returns the value, or -1 if called on the wrong type of menu item
virtual void SetItemSelectedValue(int index, const char *value);
virtual const char* GetItemSelectedValue(int index);
virtual void SetItemSelectedValueAsInt(int index, int value);
virtual int GetItemSelectedValueAsInt(int index);
// Description:
// Set/Get the index of an item given its selected value (as set by
// SetItemSelectedValue).
virtual int GetIndexOfItemWithSelectedValue(const char *value);
virtual int GetIndexOfItemWithSelectedValueAsInt(int value);
// Description:
// Select the item which selected value (as it was set per item
// using SetItemSelectedValue) matches a given value. Convenience method is
// provided to select the item using a value as an integer.
// Returns the item that was selected, -1 otherwise.
virtual int SelectItemWithSelectedValue(const char *value);
virtual int SelectItemWithSelectedValueAsInt(int value);
// Description:
// Select the item in a group which selected value (as it was set per item
// using SetItemSelectedValue) matches a given value. Convenience method is
// provided to select the item using a value as an integer.
// Returns the item that was selected, -1 otherwise.
virtual int SelectItemInGroupWithSelectedValue(
const char *group_name, const char *value);
virtual int SelectItemInGroupWithSelectedValueAsInt(
const char *group_name, int value);
// Description:
// Get the index of the selected item in a group.
// If group is not specified, use the group of the last entry; note that
// this will only work there is only one group in the menu.
// Return -1 on error.
virtual int GetIndexOfSelectedItemInGroup(const char *group_name);
virtual int GetIndexOfSelectedItem();
// Description:
// Set/Get the value associated to the de-selected state of a checkbutton
// menu item (no allowed for radiobuttons). Can be safely left as is
// most of the time, unless you want to store very specific selected
// and deselected values for a checkbutton and retrieve them later on.
// By default, checkbutton are assigned a selected value of 0. Radiobuttons
// do not have a deselected value: a radiobutton is part of a group, to
// deselect it one needs to select another radiobutton in that group
// (therefore, unselecting a radiobutton has no meaning).
// Note that the output of GetItemDeselectedValue is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
// Returns the value, or -1 if called on the wrong type of menu item
virtual void SetItemDeselectedValue(int index, const char *value);
virtual void SetItemDeselectedValueAsInt(int index, int value);
virtual int GetItemDeselectedValueAsInt(int index);
virtual const char* GetItemDeselectedValue(int index);
// Description:
// Append/Insert a separator to the menu.
// A vtkKWMenu::SeparatorItemAddedEvent event is generated as well.
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddSeparator();
virtual int InsertSeparator(int index);
// Description:
// Append/Insert a sub-menu (cascade) to the menu.
// A vtkKWMenu::CascadeItemAddedEvent event is generated as well.
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddCascade(const char *label, vtkKWMenu *menu);
virtual int InsertCascade(int index, const char *label, vtkKWMenu *menu);
// Description:
// Get the index of the first sub-menu (cascade) item that is using a
// specific menu object.
virtual int GetIndexOfCascadeItem(vtkKWMenu *menu);
// Description:
// Set the sub-menu for an existing sub-menu (cascade) item.
virtual void SetItemCascade(int index, vtkKWMenu*);
virtual void SetItemCascade(int index, const char *menu_name);
virtual vtkKWMenu* GetItemCascade(int index);
// Description:
// Returns the integer index of the menu item using a specific label.
// You can also use GetIndexOfCommandItem to retrieve the menu item using a
// specific command (if that menu item supports a command).
virtual int GetIndexOfItem(const char *label);
// Description:
// Checks if an item with a given label is in the menu.
virtual int HasItem(const char *label);
// Description:
// Returns the type of a specific menu item.
//BTX
enum
{
UnknownItemType = 0,
RadioButtonItemType,
CheckButtonItemType,
CommandItemType,
SeparatorItemType,
CascadeItemType
};
//ETX
virtual int GetItemType(int index);
// Description:
// Set/Get the label of a specific menu item at a given index.
// Note that the output of GetItemLabel is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
virtual int SetItemLabel(int index, const char *label);
virtual const char* GetItemLabel(int index);
// Description:
// Call the callback/command of a specific menu item specified by its
// index.
virtual void InvokeItem(int index);
// Description:
// Delete the menu item specified by its given index.
// Be careful, there is a bug in Tk, that will break other items
// in the menu below the one being deleted, unless a new item is added.
virtual void DeleteItem(int index);
virtual void DeleteAllItems();
// Description:
// Returns the number of items.
virtual int GetNumberOfItems();
// Description:
// Set/Get state of the menu item with a given index or label.
// Valid constants can be found in vtkKWOptions::StateType.
virtual void SetItemState(int index, int state);
virtual void SetItemStateToDisabled(int index);
virtual void SetItemStateToNormal(int index);
virtual void SetItemState(const char *label, int state);
virtual void SetItemStateToDisabled(const char *label);
virtual void SetItemStateToNormal(const char *label);
virtual int GetItemState(int index);
virtual int GetItemState(const char *label);
// Description:
// Set the state of all entries.
// Valid constants can be found in vtkKWOptions::StateType.
// This should not be used directly, this is done by
// SetEnabled()/UpdateEnableState().
// Overriden to pass to all menu entries.
virtual void SetState(int state);
// Description:
// Set the image of a menu item. A valid Tk image name or the index of
// a predefined icon (as found in vtkKWIcon) should be passed.
// Check the SetItemCompoundMode method if you want to display both the
// image and the label at the same time.
virtual void SetItemImage(int index, const char *imgname);
virtual void SetItemImageToPredefinedIcon(int index, int icon_index);
virtual void SetItemImageToIcon(int index, vtkKWIcon *icon);
// Description:
// Set the select image of a menu item.
// The select image is available only for checkbutton and radiobutton
// entries. This method can be used to specify the image to display in
// the menu item when it is selected (instead of the regular image).
virtual void SetItemSelectImage(int index, const char *imgname);
virtual void SetItemSelectImageToPredefinedIcon(int index, int icon_index);
virtual void SetItemSelectImageToIcon(int index, vtkKWIcon *icon);
// Description:
// Specifies if the menu item should display text and bitmaps/images at the
// same time, and if so, where the bitmap/image should be placed relative
// to the text.
// Valid constants can be found in vtkKWOptions::CompoundModeType.
// The (default) value CompoundModeNone specifies that the bitmap or image
// should (if defined) be displayed instead of the text.
// Check the SetItemMarginVisibility method too.
virtual void SetItemCompoundMode(int index, int mode);
virtual int GetItemCompoundMode(int index);
virtual void SetItemCompoundModeToNone(int index);
virtual void SetItemCompoundModeToLeft(int index);
virtual void SetItemCompoundModeToCenter(int index);
virtual void SetItemCompoundModeToRight(int index);
virtual void SetItemCompoundModeToTop(int index);
virtual void SetItemCompoundModeToBottom(int index);
// Description:
// Set the visibility of the standard margin of a menu item.
// Hiding the margin is useful when creating palette with images in them,
// i.e., color palettes, pattern palettes, etc.
virtual void SetItemMarginVisibility(int index, int flag);
// Description:
// Set the visibility of the indicator of a menu item.
// Available only for checkbutton and radiobutton entries.
virtual void SetItemIndicatorVisibility(int index, int flag);
// Description:
// Specifies a string to display at the right side of the menu entry.
// Normally describes an accelerator keystroke sequence that may be typed
// to invoke the same function as the menu entry. This is an arbitrary
// string, not a key binding per say, i.e. pressing the accelerator
// key does not automatically call the command associated to this
// menu item. To do so, the corresponding key binding must be set and
// associated to the item's command, if any. The SetBindingForItemAccelerator
// method can be used to that effect.
virtual void SetItemAccelerator(int index, const char *accelerator);
// Description:
// This method retrieves the accelerator attached to a menu item, convert
// it to the proper keybinding (say, Ctrl+0 is converted into <Control-0>),
// and set that binding on a specific 'widget' so that whenever that widget
// has the focus and that key binding is pressed, the item's command will
// be invokved. A typical use for this method is to set a menu item's
// accelerator using SetItemAccelerator, then associate the corresponding
// binding to the toplevel this menu is attached to. For example:
// menu->SetItemAccelerator(1, "Ctrl+0");
// menu->SetBindingForItemAccelerator(1, menu->GetParentTopLevel());
// this last line is pretty much the same as this one below:
// menu->GetParentTopLevel()->SetBinding(
// "<Control-0>", menu->GetItemCommand(1));
// but the accelerator to key-binding conversion is done automatically.
// Note that if the accelerator has not been set (or if it has been reset
// to an empty string or NULL), this method will *not* remove the binding
// (since it has no knowledge of what the previous accelerator was), this
// is up to the developper to do so by calling RemoveBinding for example.
virtual void SetBindingForItemAccelerator(int index, vtkKWWidget*);
virtual void RemoveBindingForItemAccelerator(int index, vtkKWWidget*);
// Description:
// Set/Get the help string for a given item specified by its index.
// The help string will be displayed automatically in the status bar
// of the window containing the menu, if any.
// Note that the output of GetItemHelpString is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
virtual void SetItemHelpString(int index, const char *help);
virtual const char* GetItemHelpString(int index);
// Description:
// Set the index of a character to underline in the menu item specified by
// its index. Note that you can also specify that character
// by using the special '&' marker in the label of the menu item
// (ex: "&File", or "Sa&ve File").
virtual void SetItemUnderline(int index, int underline_index);
// Description:
// Set/Get a column break flag at a specific index.
virtual void SetItemColumnBreak(int index, int flag);
// Description:
// Set/Get the name of a *global* variable to set when a checkbutton or a
// radiobutton menu item is selected. Whenever selected, a checkbutton
// or radiobutton will set its variable to the value that was associated
// to it using SetItemSelectedValue. When deselected a checkbutton set
// its variable to the value that was associated to it using
// SetItemDeselectedValue.
// Setting the same variable names for different radiobuttons is the
// actual way to put them in the same *group* (i.e. selecting one
// radiobutton in the group will deselect the others). Is is recommended
// to use either the PutItemInGroup method to group buttons
// together, or the SetItemGroupName method, which are just
// front-ends to the SetItemVariable method, but build a global variable
// name out of the current menu instance name and a local group name.
// Note that the variable name should be unique within *this* menu
// instance as well as *all* other menu instances so that it can be
// shared between menus if needed. Most of the time, using a global name
// will not be needed and we therefore recommend you pick a local global
// name by using the SetItemGroupName. This variable name should
// stick to the usual variable naming convention (no spaces, start with
// a letter, etc). One way to create such a group name is, for example, to
// concatenate the Tcl name (GetTclName()) or the widget name
// (GetWidgetName()) of the menu instance with some string suffix
// describing the variable; a different signature is available to create
// such composite name automatically, but the CreateItemVariableName can
// be used as well.
// By default, each newly created radiobutton share the same variable
// name already. Each newly created checkbutton is assigned a unique
// variable name.
// Note that the output of GetItemVariable is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
virtual const char* GetItemVariable(int index);
virtual void SetItemVariable(int index, const char *varname);
virtual void SetItemVariable(
int index, vtkKWObject *object, const char *suffix);
// Description:
// Convenience method to create a variable name out of an object
// (say, this instance) and an arbitrary suffix (say, the menu item label).
// Such a variable name can be used to call SetItemVariable on a
// checkbutton or radiobutton menu item.
// Note that spaces and unusual characters are automatically removed
// from the 'suffix'.
// This method allocates enough memory (using 'new') for that name and
// returns a pointer to that location. This pointer should be deleted
// by the user using 'delete []'.
virtual char* CreateItemVariableName(
vtkKWObject *object, const char *suffix);
// Description:
// Set/Get the value for a variable name given a variable name (as retrieved
// using GetItemVariable() for example).
// This will affect the menu entries accordingly (i.e. setting the
// variable will select/deselect the entries).
// Note that the output of GetItemVariableValue is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
virtual const char* GetItemVariableValue(const char *varname);
virtual void SetItemVariableValue(const char *varname, const char *value);
virtual int GetItemVariableValueAsInt(const char *varname);
virtual void SetItemVariableValueAsInt(const char *varname, int value);
// Description:
// Get the index of an item gien its variable name and its selected value.
virtual int GetIndexOfItemWithVariableAndSelectedValue(
const char *varname, const char *value);
virtual int GetIndexOfItemWithVariableAndSelectedValueAsInt(
const char *varname, int value);
// Description:
// Set/Get if this menu is a tearoff menu. By dafault this value is off.
virtual void SetTearOff(int val);
vtkGetMacro(TearOff, int);
vtkBooleanMacro(TearOff, int);
// Description:
// Pop-up the menu at screen coordinates x, y
virtual void PopUp(int x, int y);
// Description:
// Get the Tk option of a specific menu item. Internal use.
// Note that the output of GetItemOption is a pointer to a
// temporary buffer that should be copied *immediately* to your own storage.
virtual int HasItemOption(int index, const char *option);
virtual const char* GetItemOption(int index, const char *option);
// Description:
// Events. The ItemAddedEvent events are generated when menu entries are
// addded or inserted (say, RadioButtonItemAddedEvent).
// The MenuItemInvokedEvent is sent when a menu entry is invoked (i.e.,
// a mouse button is released over the entry).
// The following parameters are also passed as client data:
// - the index of the new menu item: int
//BTX
enum
{
RadioButtonItemAddedEvent = 10000,
CheckButtonItemAddedEvent,
CommandItemAddedEvent,
SeparatorItemAddedEvent,
CascadeItemAddedEvent,
MenuItemInvokedEvent
};
//ETX
// Description:
// Set/Get the background color of the widget.
virtual void GetBackgroundColor(double *r, double *g, double *b);
virtual double* GetBackgroundColor();
virtual void SetBackgroundColor(double r, double g, double b);
virtual void SetBackgroundColor(double rgb[3])
{ this->SetBackgroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the foreground color of the widget.
virtual void GetForegroundColor(double *r, double *g, double *b);
virtual double* GetForegroundColor();
virtual void SetForegroundColor(double r, double g, double b);
virtual void SetForegroundColor(double rgb[3])
{ this->SetForegroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the active background color of the widget. An element
// (a widget or portion of a widget) is active if the mouse cursor is
// positioned over the element and pressing a mouse button will cause some
// action to occur.
virtual void GetActiveBackgroundColor(double *r, double *g, double *b);
virtual double* GetActiveBackgroundColor();
virtual void SetActiveBackgroundColor(double r, double g, double b);
virtual void SetActiveBackgroundColor(double rgb[3])
{ this->SetActiveBackgroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the active foreground color of the widget. An element
// (a widget or portion of a widget) is active if the mouse cursor is
// positioned over the element and pressing a mouse button will cause some
// action to occur.
virtual void GetActiveForegroundColor(double *r, double *g, double *b);
virtual double* GetActiveForegroundColor();
virtual void SetActiveForegroundColor(double r, double g, double b);
virtual void SetActiveForegroundColor(double rgb[3])
{ this->SetActiveForegroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the foreground color of the widget when it is disabled.
virtual void GetDisabledForegroundColor(double *r, double *g, double *b);
virtual double* GetDisabledForegroundColor();
virtual void SetDisabledForegroundColor(double r, double g, double b);
virtual void SetDisabledForegroundColor(double rgb[3])
{ this->SetDisabledForegroundColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the background color to use when the widget is selected.
virtual void GetSelectColor(double *r, double *g, double *b);
virtual double* GetSelectColor();
virtual void SetSelectColor(double r, double g, double b);
virtual void SetSelectColor(double rgb[3])
{ this->SetSelectColor(rgb[0], rgb[1], rgb[2]); };
// Description:
// Set/Get the border width, a non-negative value indicating the width of
// the 3-D border to draw around the outside of the widget (if such a border
// is being drawn; the Relief option typically determines this).
virtual void SetBorderWidth(int);
virtual int GetBorderWidth();
// Description:
// Set/Get the 3-D effect desired for the widget.
// The value indicates how the interior of the widget should appear
// relative to its exterior.
// Valid constants can be found in vtkKWOptions::ReliefType.
virtual void SetRelief(int);
virtual int GetRelief();
virtual void SetReliefToRaised();
virtual void SetReliefToSunken();
virtual void SetReliefToFlat();
virtual void SetReliefToRidge();
virtual void SetReliefToSolid();
virtual void SetReliefToGroove();
// Description:
// Specifies the font to use when drawing text inside the widget.
// You can use predefined font names (e.g. 'system'), or you can specify
// a set of font attributes with a platform-independent name, for example,
// 'times 12 bold'. In this example, the font is specified with a three
// element list: the first element is the font family, the second is the
// size, the third is a list of style parameters (normal, bold, roman,
// italic, underline, overstrike). Example: 'times 12 {bold italic}'.
// The Times, Courier and Helvetica font families are guaranteed to exist
// and will be matched to the corresponding (closest) font on your system.
// If you are familiar with the X font names specification, you can also
// describe the font that way (say, '*times-medium-r-*-*-12*').
virtual void SetFont(const char *font);
virtual const char* GetFont();
// Description:
// Set or get enabled state.
// This method has been overriden to propagate the state to all its
// menu entries by calling UpdateEnableState(), *even* if the
// state (this->Enabled) is actually unchanged by the function. This
// make sure all the menu entries have been enabled/disabled properly.
virtual void SetEnabled(int);
// Description:
// This method has been overriden to propagate the state to all its
// menu entries by calling SetState().
// Update the "enable" state of the object and its internal parts.
// Depending on different Ivars (this->Enabled, the application's
// Limited Edition Mode, etc.), the "enable" state of the object is updated
// and propagated to its internal parts/subwidgets. This will, for example,
// enable/disable parts of the widget UI, enable/disable the visibility
// of 3D widgets, etc.
virtual void UpdateEnableState();
// Description:
// Callbacks: for active menu item doc line help
virtual void DisplayHelpCallback(const char *widget_name);
virtual void CommandInvokedCallback(const char *command);
protected:
vtkKWMenu();
~vtkKWMenu();
// Description:
// Create the widget.
virtual void CreateWidget();
// Description:
// Add a generic menu item (defined by type)
// Return index of the menu item that was created/inserted, -1 on error
virtual int AddGeneric(const char *type, const char *label,
const char* extra);
virtual int InsertGeneric(int index, const char *type, const char *label,
const char* extra);
// Description:
// Given a label, allocate and create a clean label that is stripped
// out of its underline marker (ex: "&Open File" is cleaned as "Open File",
// "Sa&ve File" is cleaned as "Save File").
// Return 1 if a clean label was created: the 'clean_label' parameter
// should be freed later on by the user by calling 'delete []'. The
// 'underline' parameter is set to the position of the underline marker.
// Return 0 if the label was already cleaned: the 'clean_label' parameter
// is set to the value of 'label' (set, *not* allocated). The
// 'underline' parameter is set to -1.
virtual int GetLabelWithoutUnderline(
const char *label, char **clean_label, int *underline_index);
int TearOff;
// Description:
// Returns the integer index of the active menu item of a given menu.
// Be extra careful with this method: most menus seems to be clone of
// themselves, according to the Tk doc:
// When a menu is set as a menubar for a toplevel window, or when a menu
// is torn off, a clone of the menu is made. This clone is a menu widget
// in its own right, but it is a child of the original. Changes in the
// configuration of the original are reflected in the clone. Additionally,
// any cascades that are pointed to are also cloned so that menu traversal
// will work right.
// Sadly, the active item of a menu is not something that is synchronized
// between a menu and its clone. Querying the active item on the current
// instance might therefore not work, because a clone is in fact being
// interacted upon. This kind of situation is mostly encountered when
// Tk events like <<MenuSelect>> are processed, and can therefore be solved
// by making sure the callbacks are passing the %W parameter around: this
// gets resolved to the widget name of the clone.
virtual int GetIndexOfActiveItem(const char *widget_name);
// Description:
// Get the suffix out of variable name that was created using
// CreateItemVariableName
const char* GetSuffixOutOfCreatedItemVariableName(const char *varname);
// Description:
// Convert key accelerator to binding
virtual void ConvertItemAcceleratorToKeyBinding(
const char *accelerator, char **keybinding);
// Description:
// PIMPL Encapsulation for STL containers
vtkKWMenuInternals *Internals;
private:
vtkKWMenu(const vtkKWMenu&); // Not implemented
void operator=(const vtkKWMenu&); // Not implemented
};
#endif
|