1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: QtxPagePrefMgr.h
21 // Author: Sergey TELKOV
23 #ifndef QTXPAGEPREFMGR_H
24 #define QTXPAGEPREFMGR_H
26 #include "QtxPreferenceMgr.h"
28 #include "QtxPathEdit.h"
29 #include "QtxPathListEdit.h"
42 class QtxShortcutEdit;
43 class QtxShortcutTree;
44 class QtxBackgroundTool;
59 class QTX_EXPORT QtxPagePrefMgr : public QFrame, public QtxPreferenceMgr
64 QtxPagePrefMgr( QtxResourceMgr*, QWidget* = 0 );
65 virtual ~QtxPagePrefMgr();
67 virtual QSize sizeHint() const;
68 virtual QSize minimumSizeHint() const;
70 virtual void updateContents();
73 void resourceChanged( int );
74 void resourceChanged( QString&, QString& );
75 void resourcesChanged( const QMap<int, QString>& );
78 virtual void setVisible( bool );
81 virtual void itemAdded( QtxPreferenceItem* );
82 virtual void itemRemoved( QtxPreferenceItem* );
83 virtual void itemChanged( QtxPreferenceItem* );
85 virtual QVariant optionValue( const QString& ) const;
86 virtual void setOptionValue( const QString&, const QVariant& );
89 void initialize() const;
90 void initialize( QtxPreferenceItem* );
97 class QTX_EXPORT QtxPagePrefItem : public QtxPreferenceItem
102 QtxPagePrefItem( const QString&, QtxPreferenceItem* = 0,
103 const QString& = QString(), const QString& = QString() );
104 virtual ~QtxPagePrefItem();
106 QWidget* widget() const;
108 virtual void activate();
111 void setWidget( QWidget* );
113 virtual void itemAdded( QtxPreferenceItem* );
114 virtual void itemRemoved( QtxPreferenceItem* );
115 virtual void itemChanged( QtxPreferenceItem* );
117 void pageChildItems( QList<QtxPagePrefItem*>&, const bool = false ) const;
119 virtual void store();
120 virtual void retrieve();
122 virtual void widgetShown();
123 virtual void widgetHided();
125 virtual void ensureVisible( QtxPreferenceItem* );
128 virtual void contentChanged();
131 QPointer<QWidget> myWidget;
132 Listener* myListener;
135 class QTX_EXPORT QtxPageNamedPrefItem : public QtxPagePrefItem
138 QtxPageNamedPrefItem( const QString&, QtxPreferenceItem* = 0,
139 const QString& = QString(), const QString& = QString() );
140 virtual ~QtxPageNamedPrefItem();
142 virtual void setTitle( const QString& );
144 static void adjustLabels( QtxPagePrefItem* );
147 QLabel* label() const;
148 QWidget* control() const;
150 void setControl( QWidget* );
153 QPointer<QLabel> myLabel;
154 QPointer<QWidget> myControl;
157 class QTX_EXPORT QtxPagePrefListItem : public QObject, public QtxPagePrefItem
162 QtxPagePrefListItem( const QString&, QtxPreferenceItem* = 0,
163 const QString& = QString(), const QString& = QString() );
164 virtual ~QtxPagePrefListItem();
166 virtual void updateContents();
168 QString emptyInfo() const;
169 void setEmptyInfo( const QString& );
171 bool isFixedSize() const;
172 void setFixedSize( const bool );
175 void onItemSelectionChanged();
178 virtual QVariant optionValue( const QString& ) const;
179 virtual void setOptionValue( const QString&, const QVariant& );
180 virtual void ensureVisible( QtxPreferenceItem* );
182 virtual void widgetShown();
188 void updateVisible();
190 int selected() const;
191 QtxPagePrefItem* selectedItem() const;
192 void setSelected( const int );
197 QStackedWidget* myStack;
203 class QTX_EXPORT QtxPagePrefToolBoxItem : public QtxPagePrefItem
206 QtxPagePrefToolBoxItem( const QString&, QtxPreferenceItem* = 0,
207 const QString& = QString(), const QString& = QString() );
208 virtual ~QtxPagePrefToolBoxItem();
210 virtual void updateContents();
213 virtual void ensureVisible( QtxPreferenceItem* );
216 void updateToolBox();
222 class QTX_EXPORT QtxPagePrefTabsItem : public QtxPagePrefItem
225 QtxPagePrefTabsItem( const QString&, QtxPreferenceItem* = 0,
226 const QString& = QString(), const QString& = QString() );
227 virtual ~QtxPagePrefTabsItem();
229 virtual void updateContents();
231 int tabPosition() const;
232 void setTabPosition( const int );
234 int tabShape() const;
235 void setTabShape( const int );
237 QSize tabIconSize() const;
238 void setTabIconSize( const QSize& );
241 virtual QVariant optionValue( const QString& ) const;
242 virtual void setOptionValue( const QString&, const QVariant& );
243 virtual void ensureVisible( QtxPreferenceItem* );
252 class QTX_EXPORT QtxPagePrefFrameItem : public QtxPagePrefItem
255 QtxPagePrefFrameItem( const QString&, QtxPreferenceItem* = 0,
256 const QString& = QString(), const QString& = QString(), const bool = false );
257 virtual ~QtxPagePrefFrameItem();
259 virtual void updateContents();
261 bool stretch() const;
262 void setStretch( const bool );
265 void setMargin( const int );
268 void setSpacing( const int );
271 void setColumns( const int );
273 Qt::Orientation orientation() const;
274 void setOrientation( const Qt::Orientation );
277 virtual QVariant optionValue( const QString& ) const;
278 virtual void setOptionValue( const QString&, const QVariant& );
280 virtual void widgetShown();
289 class QTX_EXPORT QtxPagePrefGroupItem : public QtxPagePrefItem
292 QtxPagePrefGroupItem( const QString&, QtxPreferenceItem* = 0,
293 const QString& = QString(), const QString& = QString() );
294 QtxPagePrefGroupItem( const int, const QString&, QtxPreferenceItem* = 0,
295 const QString& = QString(), const QString& = QString() );
296 virtual ~QtxPagePrefGroupItem();
298 virtual void updateContents();
301 void setMargin( const int );
304 void setSpacing( const int );
307 void setColumns( const int );
309 Qt::Orientation orientation() const;
310 void setOrientation( const Qt::Orientation );
313 void setFlat( const bool );
315 virtual void setResource( const QString&, const QString& );
317 virtual void store();
318 virtual void retrieve();
320 QtxGridBox* gridBox() const;
323 virtual QVariant optionValue( const QString& ) const;
324 virtual void setOptionValue( const QString&, const QVariant& );
326 virtual void widgetShown();
334 QtxGroupBox* myGroup;
337 class QTX_EXPORT QtxPagePrefLabelItem : public QtxPagePrefItem
340 QtxPagePrefLabelItem( const QString&, QtxPreferenceItem* = 0 );
341 QtxPagePrefLabelItem( Qt::Alignment, const QString&, QtxPreferenceItem* = 0 );
342 virtual ~QtxPagePrefLabelItem();
344 virtual void setTitle( const QString& );
346 Qt::Alignment alignment() const;
347 void setAlignment( Qt::Alignment );
350 virtual QVariant optionValue( const QString& ) const;
351 virtual void setOptionValue( const QString&, const QVariant& );
354 QPointer<QLabel> myLabel;
357 class QTX_EXPORT QtxPagePrefSpaceItem : public QtxPagePrefItem
360 QtxPagePrefSpaceItem( QtxPreferenceItem* = 0 );
361 QtxPagePrefSpaceItem( Qt::Orientation, QtxPreferenceItem* = 0 );
362 QtxPagePrefSpaceItem( const int, const int, QtxPreferenceItem* = 0 );
363 virtual ~QtxPagePrefSpaceItem();
365 int size( Qt::Orientation ) const;
366 void setSize( Qt::Orientation, const int );
368 int stretch( Qt::Orientation ) const;
369 void setStretch( Qt::Orientation, const int );
372 virtual QVariant optionValue( const QString& ) const;
373 virtual void setOptionValue( const QString&, const QVariant& );
376 void initialize( const int, const int, const int, const int );
379 class QTX_EXPORT QtxPagePrefCheckItem : public QtxPagePrefItem
382 QtxPagePrefCheckItem( const QString&, QtxPreferenceItem* = 0,
383 const QString& = QString(), const QString& = QString() );
384 virtual ~QtxPagePrefCheckItem();
386 virtual void setTitle( const QString& );
388 virtual void store();
389 virtual void retrieve();
395 class QTX_EXPORT QtxPagePrefEditItem : public QtxPageNamedPrefItem
398 typedef enum { String, Integer, Double } InputType;
401 QtxPagePrefEditItem( const QString&, QtxPreferenceItem* = 0,
402 const QString& = QString(), const QString& = QString() );
403 QtxPagePrefEditItem( const int, const QString&, QtxPreferenceItem* = 0,
404 const QString& = QString(), const QString& = QString() );
405 virtual ~QtxPagePrefEditItem();
407 int inputType() const;
408 void setInputType( const int );
410 int decimals() const;
411 void setDecimals( const int );
413 int echoMode() const;
414 void setEchoMode( const int );
416 virtual void store();
417 virtual void retrieve();
420 virtual QVariant optionValue( const QString& ) const;
421 virtual void setOptionValue( const QString&, const QVariant& );
433 class QTX_EXPORT QtxPagePrefSliderItem : public QObject,public QtxPageNamedPrefItem
438 QtxPagePrefSliderItem( const QString&, QtxPreferenceItem* = 0,
439 const QString& = QString(), const QString& = QString() );
440 virtual ~QtxPagePrefSliderItem();
442 int singleStep() const;
443 int pageStep() const;
446 QList<QIcon> icons() const;
448 void setSingleStep( const int& );
449 void setPageStep( const int& );
450 void setMinimum( const int& );
451 void setMaximum( const int& );
452 void setIcons( const QList<QIcon>& );
454 virtual void store();
455 virtual void retrieve();
458 virtual QVariant optionValue( const QString& ) const;
459 virtual void setOptionValue( const QString&, const QVariant& );
466 void setIcons( const QVariant& );
471 QList<QIcon> myIcons;
474 class QTX_EXPORT QtxPagePrefSelectItem : public QtxPageNamedPrefItem
477 typedef enum { NoInput, String, Integer, Double } InputType;
480 QtxPagePrefSelectItem( const QString&, QtxPreferenceItem* = 0,
481 const QString& = QString(), const QString& = QString() );
482 QtxPagePrefSelectItem( const int, const QString&, QtxPreferenceItem* = 0,
483 const QString& = QString(), const QString& = QString() );
484 virtual ~QtxPagePrefSelectItem();
486 int inputType() const;
487 void setInputType( const int );
489 QStringList strings() const;
490 QList<QVariant> numbers() const;
491 QList<QIcon> icons() const;
493 void setStrings( const QStringList& );
494 void setNumbers( const QList<QVariant>& );
495 void setIcons( const QList<QIcon>& );
497 virtual void store();
498 virtual void retrieve();
501 virtual QVariant optionValue( const QString& ) const;
502 virtual void setOptionValue( const QString&, const QVariant& );
505 void updateSelector();
506 void setStrings( const QVariant& );
507 void setNumbers( const QVariant& );
508 void setIcons( const QVariant& );
512 QtxComboBox* mySelector;
515 class QTX_EXPORT QtxPagePrefSpinItem : public QtxPageNamedPrefItem
518 typedef enum { Integer, Double } InputType;
521 QtxPagePrefSpinItem( const QString&, QtxPreferenceItem* = 0,
522 const QString& = QString(), const QString& = QString() );
523 QtxPagePrefSpinItem( const int, const QString&, QtxPreferenceItem* = 0,
524 const QString& = QString(), const QString& = QString() );
525 virtual ~QtxPagePrefSpinItem();
527 QVariant step() const;
528 QVariant precision() const;
529 QVariant minimum() const;
530 QVariant maximum() const;
532 QString prefix() const;
533 QString suffix() const;
534 QString specialValueText() const;
536 void setStep( const QVariant& );
537 void setPrecision( const QVariant& );
538 void setMinimum( const QVariant& );
539 void setMaximum( const QVariant& );
541 void setPrefix( const QString& );
542 void setSuffix( const QString& );
543 void setSpecialValueText( const QString& );
545 int inputType() const;
546 void setInputType( const int );
548 virtual void store();
549 virtual void retrieve();
552 virtual QVariant optionValue( const QString& ) const;
553 virtual void setOptionValue( const QString&, const QVariant& );
556 void updateSpinBox();
562 class QTX_EXPORT QtxPagePrefTextItem : public QtxPageNamedPrefItem
565 QtxPagePrefTextItem( QtxPreferenceItem* = 0,
566 const QString& = QString(), const QString& = QString() );
567 QtxPagePrefTextItem( const QString&, QtxPreferenceItem* = 0,
568 const QString& = QString(), const QString& = QString() );
569 virtual ~QtxPagePrefTextItem();
571 virtual void store();
572 virtual void retrieve();
578 class QTX_EXPORT QtxPagePrefColorItem : public QtxPageNamedPrefItem
581 QtxPagePrefColorItem( const QString&, QtxPreferenceItem* = 0,
582 const QString& = QString(), const QString& = QString() );
583 virtual ~QtxPagePrefColorItem();
585 virtual void store();
586 virtual void retrieve();
589 QtxColorButton* myColor;
592 class QTX_EXPORT QtxPagePrefBiColorItem : public QtxPageNamedPrefItem
595 QtxPagePrefBiColorItem( const QString&, QtxPreferenceItem* = 0,
596 const QString& = QString(), const QString& = QString() );
597 virtual ~QtxPagePrefBiColorItem();
599 virtual QString text() const;
600 virtual void setText( const QString& );
602 virtual void store();
603 virtual void retrieve();
606 virtual QVariant optionValue( const QString& ) const;
607 virtual void setOptionValue( const QString&, const QVariant& );
610 QtxBiColorTool* myColors;
613 class QTX_EXPORT QtxPagePrefFontItem : public QObject, public QtxPageNamedPrefItem
618 QtxPagePrefFontItem( const int, const QString&, QtxPreferenceItem* = 0,
619 const QString& = QString(), const QString& = QString() );
620 QtxPagePrefFontItem( const QString&, QtxPreferenceItem* = 0,
621 const QString& = QString(), const QString& = QString() );
622 virtual ~QtxPagePrefFontItem();
624 int features() const;
625 void setFeatures( const int );
627 void setMode( const int );
630 void setFonts( const QStringList& );
631 QStringList fonts() const;
633 void setSizes( const QList<int>& = QList<int>() );
634 QList<int> sizes() const;
636 virtual void store();
637 virtual void retrieve();
640 virtual QVariant optionValue( const QString& ) const;
641 virtual void setOptionValue( const QString&, const QVariant& );
647 class QTX_EXPORT QtxPagePrefPathItem : public QtxPageNamedPrefItem
650 QtxPagePrefPathItem( const Qtx::PathType, const QString&, QtxPreferenceItem* = 0,
651 const QString& = QString(), const QString& = QString() );
652 QtxPagePrefPathItem( const QString&, QtxPreferenceItem* = 0,
653 const QString& = QString(), const QString& = QString() );
654 virtual ~QtxPagePrefPathItem();
656 Qtx::PathType pathType() const;
657 void setPathType( const Qtx::PathType );
659 QString pathFilter() const;
660 void setPathFilter( const QString& );
662 virtual void store();
663 virtual void retrieve();
666 virtual QVariant optionValue( const QString& ) const;
667 virtual void setOptionValue( const QString&, const QVariant& );
673 class QTX_EXPORT QtxPagePrefPathListItem : public QtxPageNamedPrefItem
676 QtxPagePrefPathListItem( QtxPreferenceItem* = 0,
677 const QString& = QString(), const QString& = QString() );
678 QtxPagePrefPathListItem( const QString&, QtxPreferenceItem* = 0,
679 const QString& = QString(), const QString& = QString() );
680 QtxPagePrefPathListItem( const Qtx::PathType, const QString&, QtxPreferenceItem* = 0,
681 const QString& = QString(), const QString& = QString() );
682 virtual ~QtxPagePrefPathListItem();
684 Qtx::PathType pathType() const;
685 void setPathType( const Qtx::PathType );
687 virtual void store();
688 virtual void retrieve();
691 virtual QVariant optionValue( const QString& ) const;
692 virtual void setOptionValue( const QString&, const QVariant& );
695 QtxPathListEdit* myPaths;
698 class QTX_EXPORT QtxPagePrefDateTimeItem : public QtxPageNamedPrefItem
701 typedef enum { Date, Time, DateTime } InputType;
704 QtxPagePrefDateTimeItem( const QString&, QtxPreferenceItem* = 0,
705 const QString& = QString(), const QString& = QString() );
706 QtxPagePrefDateTimeItem( const int, const QString&, QtxPreferenceItem* = 0,
707 const QString& = QString(), const QString& = QString() );
708 virtual ~QtxPagePrefDateTimeItem();
710 int inputType() const;
711 void setInputType( const int );
713 bool calendar() const;
714 void setCalendar( const bool );
716 QDate maximumDate() const;
717 QTime maximumTime() const;
718 QDate minimumDate() const;
719 QTime minimumTime() const;
721 void setMaximumDate( const QDate& );
722 void setMaximumTime( const QTime& );
723 void setMinimumDate( const QDate& );
724 void setMinimumTime( const QTime& );
726 virtual void store();
727 virtual void retrieve();
730 virtual QVariant optionValue( const QString& ) const;
731 virtual void setOptionValue( const QString&, const QVariant& );
734 void updateDateTime();
738 QDateTimeEdit* myDateTime;
741 class QTX_EXPORT QtxPagePrefShortcutBtnsItem : public QtxPageNamedPrefItem
744 QtxPagePrefShortcutBtnsItem( const QString&, QtxPreferenceItem* = 0,
745 const QString& = QString(), const QString& = QString() );
746 virtual ~QtxPagePrefShortcutBtnsItem();
747 virtual void store();
748 virtual void retrieve();
751 QtxShortcutEdit* myShortcut;
754 class QTX_EXPORT QtxPagePrefShortcutTreeItem : public QtxPageNamedPrefItem
757 QtxPagePrefShortcutTreeItem( const QString&, QtxPreferenceItem* = 0,
758 const QString& = QString(), const QString& = QString() );
759 virtual ~QtxPagePrefShortcutTreeItem();
760 virtual void store();
761 virtual void retrieve();
764 QtxShortcutTree* myShortcutTree;
768 class QTX_EXPORT QtxPagePrefBackgroundItem : public QObject, public QtxPageNamedPrefItem
773 QtxPagePrefBackgroundItem( const QString&, QtxPreferenceItem* = 0,
774 const QString& = QString(), const QString& = QString() );
775 virtual ~QtxPagePrefBackgroundItem();
777 void gradients( QStringList&, QIntList& ) const;
778 void setGradients( const QStringList&, const QIntList& = QIntList() );
780 bool isModeAllowed( Qtx::BackgroundMode ) const;
781 void setModeAllowed( Qtx::BackgroundMode, bool );
783 bool isTextureModeAllowed( Qtx::TextureMode ) const;
784 void setTextureModeAllowed( Qtx::TextureMode, bool );
786 bool isTextureAllowed() const;
787 void setTextureAllowed( bool );
789 QString imageFormats() const;
790 void setImageFormats( const QString& );
792 Qt::Orientation orientation() const;
793 void setOrientation( Qt::Orientation );
795 virtual void store();
796 virtual void retrieve();
799 virtual QVariant optionValue( const QString& ) const;
800 virtual void setOptionValue( const QString&, const QVariant& );
803 QtxBackgroundTool* myBgTool;
806 class QtxUserDefinedContent: public QWidget
809 QtxUserDefinedContent(QWidget* parent = 0, Qt::WindowFlags f = 0 ):QWidget(parent, f) {};
810 virtual void store(QtxResourceMgr* theRes, QtxPreferenceMgr* thePref) = 0;
811 virtual void retrieve(QtxResourceMgr* theRes, QtxPreferenceMgr* thePref) = 0;
815 class QTX_EXPORT QtxUserDefinedItem : public QtxPageNamedPrefItem
818 QtxUserDefinedItem( QtxPreferenceItem* parent );
820 void setContent( QtxUserDefinedContent* theContent );
822 virtual void store();
823 virtual void retrieve();
826 virtual QVariant optionValue( const QString& theName ) const;
827 virtual void setOptionValue( const QString& theName, const QVariant& theVal );
830 QtxUserDefinedContent* myContent;