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 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895
|
/*=========================================================================
Module: $RCSfile: vtkKWApplicationSettingsInterface.cxx,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.
=========================================================================*/
#include "vtkKWApplicationSettingsInterface.h"
#include "vtkKWApplication.h"
#include "vtkKWBalloonHelpManager.h"
#include "vtkKWCheckButton.h"
#include "vtkKWFrame.h"
#include "vtkKWFrameWithLabel.h"
#include "vtkKWInternationalization.h"
#include "vtkKWLabel.h"
#include "vtkKWMenu.h"
#include "vtkKWMenuButton.h"
#include "vtkKWMenuButtonWithLabel.h"
#include "vtkKWMessageDialog.h"
#include "vtkKWPushButton.h"
#include "vtkKWToolbar.h"
#include "vtkKWToolbarSet.h"
#include "vtkKWUserInterfaceManagerNotebook.h"
#include "vtkKWWindow.h"
#include "vtkObjectFactory.h"
#include <vtksys/ios/sstream>
//----------------------------------------------------------------------------
#define VTK_KW_APPLICATION_SETTINGS_DPI_FORMAT "%.1lf"
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkKWApplicationSettingsInterface);
vtkCxxRevisionMacro(vtkKWApplicationSettingsInterface, "$Revision: 1.63 $");
//----------------------------------------------------------------------------
vtkKWApplicationSettingsInterface::vtkKWApplicationSettingsInterface()
{
this->SetName(
ks_("Application Settings Panel|Title|Application Settings"));
this->Window = NULL;
// Interface settings
this->InterfaceSettingsFrame = NULL;
this->PromptBeforeExitCheckButton = NULL;
this->SendErrorLogBeforeExitCheckButton = NULL;
this->SaveUserInterfaceGeometryCheckButton = NULL;
this->SplashScreenVisibilityCheckButton = NULL;
this->BalloonHelpVisibilityCheckButton = NULL;
this->ViewPanelPositionOptionMenu = NULL;
// Interface customization
this->InterfaceCustomizationFrame = NULL;
this->ResetDragAndDropButton = NULL;
// Toolbar settings
this->ToolbarSettingsFrame = NULL;
this->FlatToolbarsCheckButton = NULL;
this->FlatToolbarWidgetsCheckButton = NULL;
// Print settings
this->PrintSettingsFrame = NULL;
this->DPIOptionMenu = NULL;
}
//----------------------------------------------------------------------------
vtkKWApplicationSettingsInterface::~vtkKWApplicationSettingsInterface()
{
this->SetWindow(NULL);
// Interface settings
if (this->InterfaceSettingsFrame)
{
this->InterfaceSettingsFrame->Delete();
this->InterfaceSettingsFrame = NULL;
}
if (this->PromptBeforeExitCheckButton)
{
this->PromptBeforeExitCheckButton->Delete();
this->PromptBeforeExitCheckButton = NULL;
}
if (this->SendErrorLogBeforeExitCheckButton)
{
this->SendErrorLogBeforeExitCheckButton->Delete();
this->SendErrorLogBeforeExitCheckButton = NULL;
}
if (this->SaveUserInterfaceGeometryCheckButton)
{
this->SaveUserInterfaceGeometryCheckButton->Delete();
this->SaveUserInterfaceGeometryCheckButton = NULL;
}
if (this->SplashScreenVisibilityCheckButton)
{
this->SplashScreenVisibilityCheckButton->Delete();
this->SplashScreenVisibilityCheckButton = NULL;
}
if (this->BalloonHelpVisibilityCheckButton)
{
this->BalloonHelpVisibilityCheckButton->Delete();
this->BalloonHelpVisibilityCheckButton = NULL;
}
if (this->ViewPanelPositionOptionMenu)
{
this->ViewPanelPositionOptionMenu->Delete();
this->ViewPanelPositionOptionMenu = NULL;
}
// Interface customization
if (this->InterfaceCustomizationFrame)
{
this->InterfaceCustomizationFrame->Delete();
this->InterfaceCustomizationFrame = NULL;
}
if (this->ResetDragAndDropButton)
{
this->ResetDragAndDropButton->Delete();
this->ResetDragAndDropButton = NULL;
}
// Toolbar settings
if (this->ToolbarSettingsFrame)
{
this->ToolbarSettingsFrame->Delete();
this->ToolbarSettingsFrame = NULL;
}
if (this->FlatToolbarsCheckButton)
{
this->FlatToolbarsCheckButton->Delete();
this->FlatToolbarsCheckButton = NULL;
}
if (this->FlatToolbarWidgetsCheckButton)
{
this->FlatToolbarWidgetsCheckButton->Delete();
this->FlatToolbarWidgetsCheckButton = NULL;
}
// Print settings
if (this->PrintSettingsFrame)
{
this->PrintSettingsFrame->Delete();
this->PrintSettingsFrame = NULL;
}
if (this->DPIOptionMenu)
{
this->DPIOptionMenu->Delete();
this->DPIOptionMenu = NULL;
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::SetWindow(vtkKWWindow *arg)
{
if (this->Window == arg)
{
return;
}
this->Window = arg;
this->Modified();
this->Update();
}
// ---------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::Create()
{
if (this->IsCreated())
{
vtkErrorMacro("The panel is already created.");
return;
}
// Create the superclass instance (and set the application)
this->Superclass::Create();
vtksys_ios::ostringstream tk_cmd;
vtkKWWidget *page;
vtkKWFrame *frame;
vtkKWMenu *menu;
// --------------------------------------------------------------
// Add a "Preferences" page
this->AddPage(this->GetName());
page = this->GetPageWidget(this->GetName());
// --------------------------------------------------------------
// Interface settings : main frame
if (!this->InterfaceSettingsFrame)
{
this->InterfaceSettingsFrame = vtkKWFrameWithLabel::New();
}
this->InterfaceSettingsFrame->SetParent(this->GetPagesParentWidget());
this->InterfaceSettingsFrame->Create();
this->InterfaceSettingsFrame->SetLabelText(
ks_("Application Settings|Interface Settings"));
tk_cmd << "pack " << this->InterfaceSettingsFrame->GetWidgetName()
<< " -side top -anchor nw -fill x -padx 2 -pady 2 "
<< " -in " << page->GetWidgetName() << endl;
frame = this->InterfaceSettingsFrame->GetFrame();
// --------------------------------------------------------------
// Interface settings : Prompt before exit ?
if (!this->PromptBeforeExitCheckButton)
{
this->PromptBeforeExitCheckButton = vtkKWCheckButton::New();
}
this->PromptBeforeExitCheckButton->SetParent(frame);
this->PromptBeforeExitCheckButton->Create();
this->PromptBeforeExitCheckButton->SetText(
ks_("Application Settings|Confirm on exit"));
this->PromptBeforeExitCheckButton->SetCommand(this, "PromptBeforeExitCallback");
this->PromptBeforeExitCheckButton->SetBalloonHelpString(
k_("A confirmation dialog will be presented to the user on exit."));
tk_cmd << "pack " << this->PromptBeforeExitCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
// --------------------------------------------------------------
// Interface settings : Send error log on exit ?
if (!this->SendErrorLogBeforeExitCheckButton)
{
this->SendErrorLogBeforeExitCheckButton = vtkKWCheckButton::New();
}
this->SendErrorLogBeforeExitCheckButton->SetParent(frame);
this->SendErrorLogBeforeExitCheckButton->Create();
this->SendErrorLogBeforeExitCheckButton->SetText(
ks_("Application Settings|Confirm send error log on exit"));
this->SendErrorLogBeforeExitCheckButton->SetCommand(
this, "SendErrorLogBeforeExitCallback");
this->SendErrorLogBeforeExitCheckButton->SetBalloonHelpString(
k_("A confirmation dialog will prompt the user to send the error log "
"on exit."));
tk_cmd << "pack " << this->SendErrorLogBeforeExitCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
// --------------------------------------------------------------
// Interface settings : Save application geometry on exit ?
if (!this->SaveUserInterfaceGeometryCheckButton)
{
this->SaveUserInterfaceGeometryCheckButton = vtkKWCheckButton::New();
}
this->SaveUserInterfaceGeometryCheckButton->SetParent(frame);
this->SaveUserInterfaceGeometryCheckButton->Create();
this->SaveUserInterfaceGeometryCheckButton->SetText(
ks_("Application Settings|Save user interface size and position on exit"));
this->SaveUserInterfaceGeometryCheckButton->SetCommand(
this, "SaveUserInterfaceGeometryCallback");
this->SaveUserInterfaceGeometryCheckButton->SetBalloonHelpString(
k_("Save the user interface size and location on exit and restore it "
"on startup."));
tk_cmd << "pack "
<< this->SaveUserInterfaceGeometryCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
// --------------------------------------------------------------
// Interface settings : Show splash screen ?
if (this->GetApplication()->GetSupportSplashScreen())
{
if (!this->SplashScreenVisibilityCheckButton)
{
this->SplashScreenVisibilityCheckButton = vtkKWCheckButton::New();
}
this->SplashScreenVisibilityCheckButton->SetParent(frame);
this->SplashScreenVisibilityCheckButton->Create();
this->SplashScreenVisibilityCheckButton->SetText(
ks_("Application Settings|Show splash screen"));
this->SplashScreenVisibilityCheckButton->SetCommand(
this, "SplashScreenVisibilityCallback");
this->SplashScreenVisibilityCheckButton->SetBalloonHelpString(
k_("Display the splash information screen at startup."));
tk_cmd << "pack " << this->SplashScreenVisibilityCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
}
// --------------------------------------------------------------
// Interface settings : Show balloon help ?
if (!this->BalloonHelpVisibilityCheckButton)
{
this->BalloonHelpVisibilityCheckButton = vtkKWCheckButton::New();
}
this->BalloonHelpVisibilityCheckButton->SetParent(frame);
this->BalloonHelpVisibilityCheckButton->Create();
this->BalloonHelpVisibilityCheckButton->SetText(
ks_("Application Settings|Show balloon help"));
this->BalloonHelpVisibilityCheckButton->SetCommand(
this, "BalloonHelpVisibilityCallback");
this->BalloonHelpVisibilityCheckButton->SetBalloonHelpString(
k_("Display help in a yellow popup-box on the screen when you rest the "
"mouse over an item that supports it."));
tk_cmd << "pack " << this->BalloonHelpVisibilityCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
// --------------------------------------------------------------
// Interface settings : View Panel Position
if (!this->ViewPanelPositionOptionMenu)
{
this->ViewPanelPositionOptionMenu = vtkKWMenuButtonWithLabel::New();
}
this->ViewPanelPositionOptionMenu->SetParent(frame);
this->ViewPanelPositionOptionMenu->Create();
this->ViewPanelPositionOptionMenu->GetLabel()->SetText(
ks_("Application Settings|Position of view panel:"));
menu = this->ViewPanelPositionOptionMenu->GetWidget()->GetMenu();
menu->AddRadioButton(ks_("Position|Left"),
this, "ViewPanelPositionCallback");
menu->AddRadioButton(ks_("Position|Right"),
this, "ViewPanelPositionCallback");
tk_cmd << "pack " << this->ViewPanelPositionOptionMenu->GetWidgetName()
<< " -side top -anchor w -padx 2 -pady 2" << endl;
// --------------------------------------------------------------
// Interface customization : main frame
if (!this->InterfaceCustomizationFrame)
{
this->InterfaceCustomizationFrame = vtkKWFrameWithLabel::New();
}
this->InterfaceCustomizationFrame->SetParent(this->GetPagesParentWidget());
this->InterfaceCustomizationFrame->Create();
this->InterfaceCustomizationFrame->SetLabelText(
ks_("Application Settings|Drag & Drop Settings"));
tk_cmd << "pack " << this->InterfaceCustomizationFrame->GetWidgetName()
<< " -side top -anchor nw -fill x -padx 2 -pady 2 "
<< " -in " << page->GetWidgetName() << endl;
frame = this->InterfaceCustomizationFrame->GetFrame();
// --------------------------------------------------------------
// Interface customization : Drag & Drop : Reset
if (!this->ResetDragAndDropButton)
{
this->ResetDragAndDropButton = vtkKWPushButton::New();
}
this->ResetDragAndDropButton->SetParent(frame);
this->ResetDragAndDropButton->Create();
this->ResetDragAndDropButton->SetText(
ks_("Application Settings|Reset Interface To Default State"));
this->ResetDragAndDropButton->SetCommand(this, "ResetDragAndDropCallback");
this->ResetDragAndDropButton->SetBalloonHelpString(
k_("You can drag & drop elements of the "
"interface within the same panel or from one panel to the other. "
"To do so, drag the title of a labeled frame to reposition it within "
"a panel, or drop it on another tab to move it to a different panel. "
"Press this button to reset the placement of all user interface "
"elements to their default position. You will need to restart the "
"application for the interface to be reset."));
tk_cmd << "pack " << this->ResetDragAndDropButton->GetWidgetName()
<< " -side top -anchor w -expand y -fill x -padx 2 -pady 2"
<< endl;
// --------------------------------------------------------------
// Toolbar settings : main frame
if (!this->ToolbarSettingsFrame)
{
this->ToolbarSettingsFrame = vtkKWFrameWithLabel::New();
}
this->ToolbarSettingsFrame->SetParent(this->GetPagesParentWidget());
this->ToolbarSettingsFrame->Create();
this->ToolbarSettingsFrame->SetLabelText(
ks_("Application Settings|Toolbar Settings"));
tk_cmd << "pack " << this->ToolbarSettingsFrame->GetWidgetName()
<< " -side top -anchor nw -fill x -padx 2 -pady 2 "
<< " -in " << page->GetWidgetName() << endl;
frame = this->ToolbarSettingsFrame->GetFrame();
// --------------------------------------------------------------
// Toolbar settings : flat frame
if (!this->FlatToolbarsCheckButton)
{
this->FlatToolbarsCheckButton = vtkKWCheckButton::New();
}
this->FlatToolbarsCheckButton->SetParent(frame);
this->FlatToolbarsCheckButton->Create();
this->FlatToolbarsCheckButton->SetText(
ks_("Application Settings|Toolbar Settings|Flat frame"));
this->FlatToolbarsCheckButton->SetCommand(this, "FlatToolbarsCallback");
this->FlatToolbarsCheckButton->SetBalloonHelpString(
k_("Display the toolbar frames using a flat aspect."));
tk_cmd << "pack " << this->FlatToolbarsCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
// --------------------------------------------------------------
// Toolbar settings : flat buttons
if (!this->FlatToolbarWidgetsCheckButton)
{
this->FlatToolbarWidgetsCheckButton = vtkKWCheckButton::New();
}
this->FlatToolbarWidgetsCheckButton->SetParent(frame);
this->FlatToolbarWidgetsCheckButton->Create();
this->FlatToolbarWidgetsCheckButton->SetText(
ks_("Application Settings|Toolbar Settings|Flat buttons"));
this->FlatToolbarWidgetsCheckButton->SetCommand(this, "FlatToolbarWidgetsCallback");
this->FlatToolbarWidgetsCheckButton->SetBalloonHelpString(
k_("Display the toolbar buttons using a flat aspect."));
tk_cmd << "pack " << this->FlatToolbarWidgetsCheckButton->GetWidgetName()
<< " -side top -anchor w -expand no -fill none" << endl;
// --------------------------------------------------------------
// Print settings : main frame
if (!this->PrintSettingsFrame)
{
this->PrintSettingsFrame = vtkKWFrameWithLabel::New();
}
this->PrintSettingsFrame->SetParent(this->GetPagesParentWidget());
this->PrintSettingsFrame->Create();
this->PrintSettingsFrame->SetLabelText(
ks_("Application Settings|Print Settings"));
tk_cmd << "pack " << this->PrintSettingsFrame->GetWidgetName()
<< " -side top -anchor nw -fill x -padx 2 -pady 2 "
<< " -in " << page->GetWidgetName() << endl;
frame = this->PrintSettingsFrame->GetFrame();
// --------------------------------------------------------------
// Print settings : DPI
if (!this->DPIOptionMenu)
{
this->DPIOptionMenu = vtkKWMenuButtonWithLabel::New();
}
this->DPIOptionMenu->SetParent(frame);
this->DPIOptionMenu->Create();
this->DPIOptionMenu->GetLabel()->SetText(
ks_("Application Settings|Print Settings|DPI:"));
double dpis[] = { 100.0, 150.0, 300.0, 600.0 };
for (unsigned int i = 0; i < sizeof(dpis) / sizeof(double); i++)
{
char label[128], command[128];
sprintf(command, "DPICallback %lf", dpis[i]);
sprintf(label, VTK_KW_APPLICATION_SETTINGS_DPI_FORMAT, dpis[i]);
this->DPIOptionMenu->GetWidget()->GetMenu()->AddRadioButton(
label, this, command);
}
tk_cmd << "pack " << this->DPIOptionMenu->GetWidgetName()
<< " -side top -anchor w -padx 2 -pady 2" << endl;
// --------------------------------------------------------------
// Pack
this->Script(tk_cmd.str().c_str());
// Update
this->Update();
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::Update()
{
this->Superclass::Update();
if (!this->IsCreated() || !this->Window)
{
return;
}
// Interface settings : Prompt before exit ?
if (this->PromptBeforeExitCheckButton)
{
this->PromptBeforeExitCheckButton->SetSelectedState(
vtkKWMessageDialog::RestoreMessageDialogResponseFromRegistry(
this->GetApplication(), vtkKWApplication::ExitDialogName) ? 0 : 1);
}
// Interface settings : Prompt before exit ?
if (this->SendErrorLogBeforeExitCheckButton)
{
this->SendErrorLogBeforeExitCheckButton->SetSelectedState(
vtkKWMessageDialog::RestoreMessageDialogResponseFromRegistry(
this->GetApplication(), vtkKWApplication::SendErrorLogDialogName)?0:1);
}
// Interface settings : Save application geometry on exit ?
if (this->SaveUserInterfaceGeometryCheckButton)
{
this->SaveUserInterfaceGeometryCheckButton->SetSelectedState(
this->GetApplication()->GetSaveUserInterfaceGeometry());
}
// Interface settings : Show splash screen ?
if (this->SplashScreenVisibilityCheckButton)
{
this->SplashScreenVisibilityCheckButton->SetSelectedState(
this->GetApplication()->GetSplashScreenVisibility());
}
// Interface settings : Show balloon help ?
if (this->BalloonHelpVisibilityCheckButton)
{
vtkKWBalloonHelpManager *mgr =
this->GetApplication()->GetBalloonHelpManager();
if (mgr)
{
this->BalloonHelpVisibilityCheckButton->SetSelectedState(
mgr->GetVisibility());
}
}
// Interface settings : View Panel Position
if (this->ViewPanelPositionOptionMenu &&
this->ViewPanelPositionOptionMenu->GetWidget() && this->Window)
{
if (this->Window->GetViewPanelPosition() ==
vtkKWWindow::ViewPanelPositionLeft)
{
this->ViewPanelPositionOptionMenu->GetWidget()->SetValue(
ks_("Position|Left"));
}
else if (this->Window->GetViewPanelPosition() ==
vtkKWWindow::ViewPanelPositionRight)
{
this->ViewPanelPositionOptionMenu->GetWidget()->SetValue(
ks_("Position|Right"));
}
}
// Interface customization : Drag & Drop : Enable
// Instead of disabling, we hide the D&D section alltogether if it's not
// supported in order not to confuse the user about this 'missing' feature.
vtkKWUserInterfaceManagerNotebook *uim_nb = NULL;
if (this->Window->HasMainUserInterfaceManager())
{
uim_nb = vtkKWUserInterfaceManagerNotebook::SafeDownCast(
this->Window->GetMainUserInterfaceManager());
}
if (this->InterfaceCustomizationFrame)
{
if (!uim_nb || !uim_nb->GetEnableDragAndDrop())
{
this->Script(
"pack forget %s", this->InterfaceCustomizationFrame->GetWidgetName());
if (this->ResetDragAndDropButton)
{
this->ResetDragAndDropButton->SetEnabled(0);
}
}
else
{
this->Script(
"pack %s -side top -anchor nw -fill x -padx 2 -pady 2 -in %s ",
this->InterfaceCustomizationFrame->GetWidgetName(),
this->GetPageWidget(this->GetName())->GetWidgetName());
}
}
// Toolbar settings : flat frame
if (this->FlatToolbarsCheckButton)
{
switch (vtkKWToolbar::GetGlobalToolbarAspect())
{
case vtkKWToolbar::ToolbarAspectFlat:
this->FlatToolbarsCheckButton->SetSelectedState(1);
break;
case vtkKWToolbar::ToolbarAspectRelief:
this->FlatToolbarsCheckButton->SetSelectedState(0);
break;
}
this->FlatToolbarsCheckButton->SetEnabled(
(vtkKWToolbar::GetGlobalToolbarAspect() ==
vtkKWToolbar::ToolbarAspectUnChanged) ? 0 : this->GetEnabled());
}
// Toolbar settings : flat buttons
if (this->FlatToolbarWidgetsCheckButton)
{
switch (vtkKWToolbar::GetGlobalWidgetsAspect())
{
case vtkKWToolbar::WidgetsAspectFlat:
this->FlatToolbarWidgetsCheckButton->SetSelectedState(1);
break;
case vtkKWToolbar::WidgetsAspectRelief:
this->FlatToolbarWidgetsCheckButton->SetSelectedState(0);
break;
}
this->FlatToolbarWidgetsCheckButton->SetEnabled(
(vtkKWToolbar::GetGlobalWidgetsAspect() ==
vtkKWToolbar::WidgetsAspectUnChanged) ? 0 : this->GetEnabled());
}
// Print settings
if (this->DPIOptionMenu && this->DPIOptionMenu->GetWidget() && this->Window)
{
char buffer[128];
sprintf(buffer, VTK_KW_APPLICATION_SETTINGS_DPI_FORMAT,
this->GetApplication()->GetPrintTargetDPI());
this->DPIOptionMenu->GetWidget()->SetValue(buffer);
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::PromptBeforeExitCallback(int state)
{
vtkKWMessageDialog::SaveMessageDialogResponseToRegistry(
this->GetApplication(),
vtkKWApplication::ExitDialogName,
state ? 0 : 1);
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::SendErrorLogBeforeExitCallback(
int state)
{
vtkKWMessageDialog::SaveMessageDialogResponseToRegistry(
this->GetApplication(),
vtkKWApplication::SendErrorLogDialogName,
state ? 0 : -1);
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::SaveUserInterfaceGeometryCallback(
int state)
{
this->GetApplication()->SetSaveUserInterfaceGeometry(state ? 1 : 0);
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::SplashScreenVisibilityCallback(
int state)
{
this->GetApplication()->SetSplashScreenVisibility(state ? 1 : 0);
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::BalloonHelpVisibilityCallback(
int state)
{
vtkKWBalloonHelpManager *mgr =
this->GetApplication()->GetBalloonHelpManager();
if (mgr)
{
mgr->SetVisibility(state ? 1 : 0);
}
}
//---------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::ViewPanelPositionCallback()
{
if (this->ViewPanelPositionOptionMenu &&
this->ViewPanelPositionOptionMenu->GetWidget() && this->Window)
{
const char *pos =
this->ViewPanelPositionOptionMenu->GetWidget()->GetValue();
if (pos)
{
if (!strcmp(pos, ks_("Position|Left")))
{
this->Window->SetViewPanelPositionToLeft();
}
else if (!strcmp(pos, ks_("Position|Right")))
{
this->Window->SetViewPanelPositionToRight();
}
}
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::ResetDragAndDropCallback()
{
if (!this->Window || !this->IsCreated())
{
return;
}
vtkKWMessageDialog::PopupMessage(
this->GetApplication(), this->Window,
ks_("Application Settings|Reset Interface"),
k_("All Drag & Drop events performed so far will be discarded. "
"Note that the interface will be reset the next time you "
"start this application."),
vtkKWMessageDialog::WarningIcon);
if (this->Window->HasMainUserInterfaceManager())
{
vtkKWUserInterfaceManagerNotebook *uim_nb =
vtkKWUserInterfaceManagerNotebook::SafeDownCast(
this->Window->GetMainUserInterfaceManager());
if (uim_nb)
{
uim_nb->DeleteAllDragAndDropEntries();
}
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::FlatToolbarsCallback(int state)
{
vtkKWToolbar::SetGlobalToolbarAspect(
state ? vtkKWToolbar::ToolbarAspectFlat :
vtkKWToolbar::ToolbarAspectRelief);
if (this->Window)
{
this->Window->UpdateToolbarState();
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::FlatToolbarWidgetsCallback(int state)
{
vtkKWToolbar::SetGlobalWidgetsAspect(
state ? vtkKWToolbar::WidgetsAspectFlat :
vtkKWToolbar::WidgetsAspectRelief);
if (this->Window)
{
this->Window->UpdateToolbarState();
}
}
//---------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::DPICallback(double dpi)
{
if (this->GetApplication())
{
this->GetApplication()->SetPrintTargetDPI(dpi);
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::UpdateEnableState()
{
this->Superclass::UpdateEnableState();
// Interface settings
if (this->InterfaceSettingsFrame)
{
this->InterfaceSettingsFrame->SetEnabled(this->GetEnabled());
}
if (this->PromptBeforeExitCheckButton)
{
this->PromptBeforeExitCheckButton->SetEnabled(this->GetEnabled());
}
if (this->SendErrorLogBeforeExitCheckButton)
{
this->SendErrorLogBeforeExitCheckButton->SetEnabled(this->GetEnabled());
}
if (this->SaveUserInterfaceGeometryCheckButton)
{
this->SaveUserInterfaceGeometryCheckButton->SetEnabled(this->GetEnabled());
}
if (this->SplashScreenVisibilityCheckButton)
{
this->SplashScreenVisibilityCheckButton->SetEnabled(this->GetEnabled());
}
if (this->BalloonHelpVisibilityCheckButton)
{
this->BalloonHelpVisibilityCheckButton->SetEnabled(this->GetEnabled());
}
if (this->ViewPanelPositionOptionMenu)
{
this->ViewPanelPositionOptionMenu->SetEnabled(this->GetEnabled());
}
// Interface customization
if (this->InterfaceCustomizationFrame)
{
this->InterfaceCustomizationFrame->SetEnabled(this->GetEnabled());
}
if (this->ResetDragAndDropButton)
{
this->ResetDragAndDropButton->SetEnabled(this->GetEnabled());
}
// Toolbar settings
if (this->ToolbarSettingsFrame)
{
this->ToolbarSettingsFrame->SetEnabled(this->GetEnabled());
}
if (this->FlatToolbarsCheckButton)
{
this->FlatToolbarsCheckButton->SetEnabled(this->GetEnabled());
}
if (this->FlatToolbarWidgetsCheckButton)
{
this->FlatToolbarWidgetsCheckButton->SetEnabled(this->GetEnabled());
}
// Print settings
if (this->PrintSettingsFrame)
{
this->PrintSettingsFrame->SetEnabled(this->GetEnabled());
}
if (this->DPIOptionMenu)
{
this->DPIOptionMenu->SetEnabled(this->GetEnabled());
}
}
//----------------------------------------------------------------------------
void vtkKWApplicationSettingsInterface::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Window: " << this->Window << endl;
}
|