From 7bc57326e69b9c3f0eaeda63e4a49b67ba611426 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 8 Jun 2024 15:05:55 +0900 Subject: Rename style nt* related files to equivalent tq* Signed-off-by: Michele Calgaro --- src/kernel/ntqnamespace.h | 4 +- src/kernel/ntqstyle.h | 1243 ----------------- src/kernel/ntqstylesheet.h | 253 ---- src/kernel/ntqt.h | 10 +- src/kernel/qapplication.cpp | 4 +- src/kernel/qapplication_x11.cpp | 2 +- src/kernel/qrichtext.cpp | 4 +- src/kernel/qrichtext_p.h | 2 +- src/kernel/qsizegrip.cpp | 2 +- src/kernel/qstyle.cpp | 2911 --------------------------------------- src/kernel/qstylesheet.cpp | 1623 ---------------------- src/kernel/qt_kernel.pri | 8 +- src/kernel/qt_pch.h | 2 +- src/kernel/tqobject.cpp | 2 +- src/kernel/tqstyle.cpp | 2911 +++++++++++++++++++++++++++++++++++++++ src/kernel/tqstyle.h | 1243 +++++++++++++++++ src/kernel/tqstylesheet.cpp | 1623 ++++++++++++++++++++++ src/kernel/tqstylesheet.h | 253 ++++ src/kernel/tqwidget.cpp | 4 +- 19 files changed, 6052 insertions(+), 6052 deletions(-) delete mode 100644 src/kernel/ntqstyle.h delete mode 100644 src/kernel/ntqstylesheet.h delete mode 100644 src/kernel/qstyle.cpp delete mode 100644 src/kernel/qstylesheet.cpp create mode 100644 src/kernel/tqstyle.cpp create mode 100644 src/kernel/tqstyle.h create mode 100644 src/kernel/tqstylesheet.cpp create mode 100644 src/kernel/tqstylesheet.h (limited to 'src/kernel') diff --git a/src/kernel/ntqnamespace.h b/src/kernel/ntqnamespace.h index 03c58309c..052fea171 100644 --- a/src/kernel/ntqnamespace.h +++ b/src/kernel/ntqnamespace.h @@ -317,7 +317,7 @@ public: }; #endif - // documented in qstyle.cpp + // documented in tqstyle.cpp #ifdef TQT_NO_COMPAT enum GUIStyle { WindowsStyle = 1, // ### TQt 4.0: either remove the obsolete enums or clean up compat vs. @@ -856,7 +856,7 @@ public: WV_CE_based = 0x0f00 }; - // documented in qstyle.cpp + // documented in tqstyle.cpp enum UIEffect { UI_General, UI_AnimateMenu, diff --git a/src/kernel/ntqstyle.h b/src/kernel/ntqstyle.h deleted file mode 100644 index 6fc61b456..000000000 --- a/src/kernel/ntqstyle.h +++ /dev/null @@ -1,1243 +0,0 @@ -/**************************************************************************** -** -** Definition of TQStyle class -** -** Created : 980616 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ -#ifndef TQSTYLE_H -#define TQSTYLE_H - -#ifndef QT_H -#include "tqobject.h" -#include "ntqpixmap.h" -#include "ntqcolor.h" -#include "tqiconset.h" -#include "ntqtabbar.h" -#include "ntqtoolbutton.h" -#endif // QT_H - - -#ifndef TQT_NO_STYLE - -class TQPopupMenu; -class TQStylePrivate; -class TQMenuItem; -class TQTab; -class TQListViewItem; -class TQCheckListItem; - -class TQ_EXPORT TQStyleOption { -public: - enum StyleOptionDefault { Default }; - - TQStyleOption(StyleOptionDefault=Default); - TQStyleOption(int in1); - TQStyleOption(int in1, int in2); - TQStyleOption(int in1, int in2, int in3, int in4); - TQStyleOption(TQMenuItem* m); - TQStyleOption(TQMenuItem* m, int in1); - TQStyleOption(TQMenuItem* m, int in1, int in2); - TQStyleOption(const TQColor& c); - TQStyleOption(TQTab* t); - TQStyleOption(TQListViewItem* i); - TQStyleOption(TQCheckListItem* i); - TQStyleOption(TQt::ArrowType a); - TQStyleOption(const TQRect& r); - TQStyleOption(TQWidget *w); - - bool isDefault() const { return def; } - - int day() const { return i1; } - - int lineWidth() const { return i1; } - int midLineWidth() const { return i2; } - int frameShape() const { return i3; } - int frameShadow() const { return i4; } - - int headerSection() const { return i1; } - TQMenuItem* menuItem() const { return mi; } - int maxIconWidth() const { return i1; } - int tabWidth() const { return i2; } - - const TQColor& color() const { return *cl; } - - TQTab* tab() const { return tb; } - - TQCheckListItem* checkListItem() const { return cli; } - TQListViewItem* listViewItem() const { return li; } - - TQt::ArrowType arrowType() const { return (TQt::ArrowType)i1; } - TQRect rect() const { return TQRect( i1, i2, i3, i4 ); } - TQWidget* widget() const { return (TQWidget*)p1; } - - TQStyleOption(TQTab* t, TQTab* h) : def(FALSE), tb(t), cli(NULL), tbh(h) {} - TQTab* hoverTab() const { return tbh; } - -private: - // NOTE: none of these components have constructors. - bool def; - bool b1,b2,b3; // reserved - TQMenuItem* mi; - TQTab* tb; - TQListViewItem* li; - const TQColor* cl; - int i1, i2, i3, i4; - int i5, i6; // reserved - TQCheckListItem* cli; - void *p1, *p2, *p3, *p4; // reserved - TQTab* tbh; - // (padded to 64 bytes on some architectures) -}; - -class TQStyleHintReturn; // not defined yet - -typedef TQMap DialogButtonSizeMap; -typedef TQMap TabIdentifierIndexMap; - -class TQStyleControlElementGenericWidgetData; - -class TQStyleControlElementPopupMenuData { - public: - // -}; - -class TQStyleControlElementCheckListItemData { - public: - bool dataValid; - bool enabled; - bool hasParent; - int height; -}; - -class TQStyleControlElementListViewData { - public: - bool rootDecorated; - int itemMargin; -}; - -class TQStyleControlElementSpinWidgetData { - public: - TQ_UINT32 buttonSymbols; - TQRect upRect; - TQRect downRect; - bool upEnabled; - bool downEnabled; -}; - -class TQStyleControlElementTitleBarData { - public: - bool hasWindow; - bool usesActiveColor; - int windowState; - TQString visibleText; -}; - -class TQStyleControlElementDockWidgetData { - public: - bool hasDockArea; - bool closeEnabled; - TQt::Orientation areaOrientation; -}; - -class TQStyleControlElementToolBarWidgetData { - public: - TQt::Orientation orientation; -}; - -class TQStyleControlElementGenericWidgetData { - public: - TQStringList widgetObjectTypes; - bool allDataPopulated; - TQt::WFlags wflags; - TQt::WindowState windowState; - TQPixmap bgPixmap; - TQBrush bgBrush; - TQColor bgColor; - TQPoint bgOffset; - TQt::BackgroundMode backgroundMode; - TQColor fgColor; - TQColorGroup colorGroup; - TQRect geometry; - TQRect rect; - TQPoint pos; - TQPixmap icon; - TQPalette palette; - TQFont font; - TQColor paletteBgColor; - TQString name; - TQString caption; -}; - -class TQStyleControlElementTabBarData { - public: - int tabCount; - int currentTabIndex; - TQTabBar::Shape shape; - TabIdentifierIndexMap identIndexMap; -#ifdef Q_QDOC -#else - TQStyleControlElementGenericWidgetData cornerWidgets[4]; -#endif - - enum CornerWidgetLocation { - CWL_TopLeft = 0, - CWL_TopRight = 1, - CWL_BottomLeft = 2, - CWL_BottomRight = 3 - }; -}; - -class TQ_EXPORT TQStyleControlElementData { - public: - TQStyleControlElementData(); - ~TQStyleControlElementData(); - - public: - bool isNull; - TQStringList widgetObjectTypes; - bool allDataPopulated; - TQt::WFlags wflags; - TQt::WindowState windowState; - TQPixmap bgPixmap; - TQBrush bgBrush; - TQColor bgColor; - TQPoint bgOffset; - TQt::BackgroundMode backgroundMode; - TQPixmap fgPixmap; - TQColor fgColor; - TQColorGroup colorGroup; - TQRect geometry; - TQRect rect; - TQPoint pos; - TQPixmap icon; - TQIconSet iconSet; - TQString text; - TQt::Orientation orientation; - TQColor activeItemPaletteBgColor; - TQPalette palette; - int totalSteps; - int currentStep; - TQ_UINT32 tickMarkSetting; - int tickInterval; - int minSteps; - int maxSteps; - int startStep; - int pageStep; - int lineStep; - int dlgVisibleButtons; - DialogButtonSizeMap dlgVisibleSizeHints; - TQString progressText; - TQString textLabel; - TQFont font; - int percentageVisible; - TQStyleControlElementDockWidgetData dwData; - TQToolButton::TextPosition toolButtonTextPosition; - int popupDelay; - TQStyleControlElementTitleBarData titleBarData; - TQStyleControlElementSpinWidgetData spinWidgetData; - TQStyleControlElementGenericWidgetData parentWidgetData; - TQStyleControlElementGenericWidgetData viewportData; - TQStyleControlElementListViewData listViewData; - TQStyleControlElementTabBarData tabBarData; - TQStyleControlElementCheckListItemData checkListItemData; - TQ_UINT32 comboBoxLineEditFlags; - TQ_UINT32 frameStyle; - TQRect sliderRect; - TQPainter* activePainter; - TQStyleControlElementToolBarWidgetData toolBarData; - TQ_UINT32 comboBoxListBoxFlags; - TQColor paletteBgColor; - TQ_UINT32 parentWidgetFlags; - TQString name; - TQString caption; - TQStyleControlElementGenericWidgetData topLevelWidgetData; - TQ_UINT32 topLevelWidgetFlags; - TQPixmap paletteBgPixmap; - -#ifdef ENABLE_TQSTYLECONTROLELEMENTDATA_SLOW_COPY - public: - TQStyleControlElementData(const TQStyleControlElementData&); -#else - private: - // Disable copy constructor - TQStyleControlElementData(const TQStyleControlElementData&); -#endif - -}; - -class TQ_EXPORT TQStyleWidgetActionRequestData { - public: - TQStyleWidgetActionRequestData(); - TQStyleWidgetActionRequestData(int metric1, int metric2=0); - TQStyleWidgetActionRequestData(TQPalette palette, bool informWidgets = FALSE, const char* className = 0); - TQStyleWidgetActionRequestData(TQFont font, bool informWidgets = FALSE, const char* className = 0); - TQStyleWidgetActionRequestData(TQRect rect); - TQStyleWidgetActionRequestData(TQPaintEvent* paintEvent); - ~TQStyleWidgetActionRequestData(); - public: - bool bool1; - bool bool2; - int metric1; - int metric2; - TQPalette palette; - TQFont font; - TQRect rect; - const char * cstr; - TQString string; - TQPaintEvent * paintEvent; -}; - -typedef TQStyleWidgetActionRequestData TQStyleApplicationActionRequestData; - -class TQ_EXPORT TQStyle: public TQObject -{ - TQ_OBJECT - -public: - TQStyle(); - virtual ~TQStyle(); - - enum ControlElementFlags { - CEF_None = 0x00000000, - CEF_IsDefault = 0x00000001, - CEF_AutoDefault = 0x00000002, - CEF_IsActive = 0x00000004, - CEF_IsDown = 0x00000008, - CEF_IsOn = 0x00000010, - CEF_IsEnabled = 0x00000020, - CEF_BiState = 0x00000040, - CEF_HasFocus = 0x00000080, - CEF_IsMenuWidget = 0x00000100, - CEF_IsContainerEmpty = 0x00000200, - CEF_CenterIndicator = 0x00000400, - CEF_IndicatorFollowsStyle = 0x00000800, - CEF_UsesTextLabel = 0x00001000, - CEF_UsesBigPixmap = 0x00002000, - CEF_UseGenericParameters = 0x00004000, - CEF_HasParentWidget = 0x00008000, - CEF_HasPopupMenu = 0x00010000, - CEF_IsCheckable = 0x00020000, - CEF_HasFocusProxy = 0x00040000, - CEF_IsEditable = 0x00080000, - CEF_IsFlat = 0x00100000, - CEF_IsActiveWindow = 0x00200000, - CEF_IsTopLevel = 0x00400000, - CEF_IsVisible = 0x00800000, - CEF_IsShown = 0x01000000, - CEF_HasMouse = 0x02000000 - }; - - // New TQStyle API - most of these should probably be pure virtual - - // Old API - // DEPRECATED - virtual void polish( TQWidget * ); - - // New API - virtual void polish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); - - // Old API - // DEPRECATED - virtual void unPolish( TQWidget * ); - - // New API - virtual void unPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); - - // Old API - // DEPRECATED - virtual void polish( TQApplication * ); - - // New API - virtual void applicationPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); - - // Old API - // DEPRECATED - virtual void unPolish( TQApplication * ); - - // New API - virtual void applicationUnPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); - - virtual void polish( TQPalette & ); - - // Old API - // DEPRECATED - virtual void polishPopupMenu( TQPopupMenu* ); - - // New API - virtual void polishPopupMenu( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ) = 0; - - virtual TQRect itemRect( TQPainter *p, const TQRect &r, - int flags, bool enabled, - const TQPixmap *pixmap, - const TQString &text, int len = -1 ) const; - - virtual void drawItem( TQPainter *p, const TQRect &r, - int flags, const TQColorGroup &g, bool enabled, - const TQPixmap *pixmap, const TQString &text, - int len = -1, const TQColor *penColor = 0 ) const; - - enum PrimitiveElement { - PE_ButtonCommand, - PE_ButtonDefault, - PE_ButtonBevel, - PE_ButtonTool, - PE_ButtonDropDown, - - PE_FocusRect, - - PE_ArrowUp, - PE_ArrowDown, - PE_ArrowRight, - PE_ArrowLeft, - - PE_SpinWidgetUp, - PE_SpinWidgetDown, - PE_SpinWidgetPlus, - PE_SpinWidgetMinus, - - PE_Indicator, - PE_IndicatorMask, - PE_ExclusiveIndicator, - PE_ExclusiveIndicatorMask, - - PE_DockWindowHandle, - PE_DockWindowSeparator, - PE_DockWindowResizeHandle, - - PE_Splitter, - - PE_Panel, - PE_PanelPopup, - PE_PanelMenuBar, - PE_PanelDockWindow, - - PE_TabBarBase, - - PE_HeaderSection, - PE_HeaderArrow, - PE_StatusBarSection, - - PE_GroupBoxFrame, - - PE_Separator, - - PE_SizeGrip, - - PE_CheckMark, - - PE_ScrollBarAddLine, - PE_ScrollBarSubLine, - PE_ScrollBarAddPage, - PE_ScrollBarSubPage, - PE_ScrollBarSlider, - PE_ScrollBarFirst, - PE_ScrollBarLast, - - PE_ProgressBarChunk, - - PE_PanelLineEdit, - PE_PanelTabWidget, - - PE_WindowFrame, - - PE_CheckListController, - PE_CheckListIndicator, - PE_CheckListExclusiveIndicator, - - PE_PanelGroupBox, - PE_RubberBand, - - PE_HeaderSectionMenu, - - PE_PanelScrollBar, - PE_MenuItemIndicatorFrame, - PE_MenuItemIndicatorIconFrame, - PE_MenuItemIndicatorCheck, - - PE_ScrollBarTrough, - - // do not add any values below/greater this - PE_CustomBase = 0xf000000 - }; - - enum StyleFlags { - Style_Default = 0x00000000, - Style_Enabled = 0x00000001, - Style_Raised = 0x00000002, - Style_Sunken = 0x00000004, - Style_Off = 0x00000008, - Style_NoChange = 0x00000010, - Style_On = 0x00000020, - Style_Down = 0x00000040, - Style_Horizontal = 0x00000080, - Style_HasFocus = 0x00000100, - Style_Top = 0x00000200, - Style_Bottom = 0x00000400, - Style_FocusAtBorder = 0x00000800, - Style_AutoRaise = 0x00001000, - Style_MouseOver = 0x00002000, - Style_Up = 0x00004000, - Style_Selected = 0x00008000, - Style_Active = 0x00010000, - Style_ButtonDefault = 0x00020000 - }; - typedef uint SFlags; - - // Old API - // DEPRECATED - virtual void drawPrimitive( PrimitiveElement pe, - TQPainter *p, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; - - // New API - virtual void drawPrimitive( PrimitiveElement pe, - TQPainter *p, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const = 0; - - - enum ControlElement { - CE_PushButton, - CE_PushButtonLabel, - - CE_CheckBox, - CE_CheckBoxLabel, - - CE_RadioButton, - CE_RadioButtonLabel, - - CE_TabBarTab, - CE_TabBarLabel, - - CE_ProgressBarGroove, - CE_ProgressBarContents, - CE_ProgressBarLabel, - - CE_PopupMenuItem, - CE_MenuBarItem, - - CE_ToolButtonLabel, - CE_MenuBarEmptyArea, - CE_PopupMenuScroller, - CE_DockWindowEmptyArea, - CE_PopupMenuVerticalExtra, - CE_PopupMenuHorizontalExtra, - - CE_ToolBoxTab, - CE_HeaderLabel, - - // do not add any values below/greater than this - CE_CustomBase = 0xf0000000 - }; - - // Old API - // DEPRECATED - virtual void drawControl( ControlElement element, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags how = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; - - // New API - virtual void drawControl( ControlElement element, - TQPainter *p, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQRect &r, - const TQColorGroup &cg, - SFlags how = Style_Default, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 /* compat, will likely go away */ ) const = 0; - - // Old API - // DEPRECATED - virtual void drawControlMask( ControlElement element, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; - - // New API - virtual void drawControlMask( ControlElement element, - TQPainter *p, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQRect &r, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 /* compat, will likely go away */ ) const = 0; - - enum SubRect { - SR_PushButtonContents, - SR_PushButtonFocusRect, - - SR_CheckBoxIndicator, - SR_CheckBoxContents, - SR_CheckBoxFocusRect, - - SR_RadioButtonIndicator, - SR_RadioButtonContents, - SR_RadioButtonFocusRect, - - SR_ComboBoxFocusRect, - - SR_SliderFocusRect, - - SR_DockWindowHandleRect, - - SR_ProgressBarGroove, - SR_ProgressBarContents, - SR_ProgressBarLabel, - - SR_ToolButtonContents, - - SR_DialogButtonAccept, - SR_DialogButtonReject, - SR_DialogButtonApply, - SR_DialogButtonHelp, - SR_DialogButtonAll, - SR_DialogButtonAbort, - SR_DialogButtonIgnore, - SR_DialogButtonRetry, - SR_DialogButtonCustom, - - SR_ToolBoxTabContents, - - // do not add any values below/greater than this - SR_CustomBase = 0xf0000000 - }; - - // Old API - // DEPRECATED - virtual TQRect subRect( SubRect r, const TQWidget *widget ) const; - - // New API - virtual TQRect subRect( SubRect r, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const = 0; - - - enum ComplexControl{ - CC_SpinWidget, - CC_ComboBox, - CC_ScrollBar, - CC_Slider, - CC_ToolButton, - CC_TitleBar, - CC_ListView, - - // do not add any values below/greater than this - CC_CustomBase = 0xf0000000 - }; - - enum SubControl { - SC_None = 0x00000000, - - SC_ScrollBarAddLine = 0x00000001, - SC_ScrollBarSubLine = 0x00000002, - SC_ScrollBarAddPage = 0x00000004, - SC_ScrollBarSubPage = 0x00000008, - SC_ScrollBarFirst = 0x00000010, - SC_ScrollBarLast = 0x00000020, - SC_ScrollBarSlider = 0x00000040, - SC_ScrollBarGroove = 0x00000080, - - SC_SpinWidgetUp = 0x00000001, - SC_SpinWidgetDown = 0x00000002, - SC_SpinWidgetFrame = 0x00000004, - SC_SpinWidgetEditField = 0x00000008, - SC_SpinWidgetButtonField = 0x00000010, - - SC_ComboBoxFrame = 0x00000001, - SC_ComboBoxEditField = 0x00000002, - SC_ComboBoxArrow = 0x00000004, - SC_ComboBoxListBoxPopup = 0x00000008, - - SC_SliderGroove = 0x00000001, - SC_SliderHandle = 0x00000002, - SC_SliderTickmarks = 0x00000004, - - SC_ToolButton = 0x00000001, - SC_ToolButtonMenu = 0x00000002, - - SC_TitleBarLabel = 0x00000001, - SC_TitleBarSysMenu = 0x00000002, - SC_TitleBarMinButton = 0x00000004, - SC_TitleBarMaxButton = 0x00000008, - SC_TitleBarCloseButton = 0x00000010, - SC_TitleBarNormalButton = 0x00000020, - SC_TitleBarShadeButton = 0x00000040, - SC_TitleBarUnshadeButton = 0x00000080, - - SC_ListView = 0x00000001, - SC_ListViewBranch = 0x00000002, - SC_ListViewExpand = 0x00000004, - - SC_All = 0xffffffff - }; - typedef uint SCFlags; - - - // Old API - // DEPRECATED - virtual void drawComplexControl( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags how = Style_Default, -#ifdef Q_QDOC - SCFlags sub = SC_All, -#else - SCFlags sub = (uint)SC_All, -#endif - SCFlags subActive = SC_None, - const TQStyleOption& = TQStyleOption::Default ) const; - - virtual void drawComplexControl( ComplexControl control, - TQPainter *p, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQRect &r, - const TQColorGroup &cg, - SFlags how = Style_Default, -#ifdef Q_QDOC - SCFlags sub = SC_All, -#else - SCFlags sub = (uint)SC_All, -#endif - SCFlags subActive = SC_None, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 ) const = 0; - - // Old API - // DEPRECATED - virtual void drawComplexControlMask( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; - - // New API - virtual void drawComplexControlMask( ComplexControl control, - TQPainter *p, - const TQStyleControlElementData &ceData, - const ControlElementFlags elementFlags, - const TQRect &r, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 ) const = 0; - - // Old API - // DEPRECATED - virtual TQRect querySubControlMetrics( ComplexControl control, - const TQWidget *widget, - SubControl sc, - const TQStyleOption& = TQStyleOption::Default ) const; - - // New API - virtual TQRect querySubControlMetrics( ComplexControl control, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - SubControl sc, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 ) const = 0; - - // Old API - // DEPRECATED - virtual SubControl querySubControl( ComplexControl control, - const TQWidget *widget, - const TQPoint &pos, - const TQStyleOption& = TQStyleOption::Default ) const; - - // New API - virtual SubControl querySubControl( ComplexControl control, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQPoint &pos, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 ) const = 0; - - - enum PixelMetric { - PM_ButtonMargin, - PM_ButtonDefaultIndicator, - PM_MenuButtonIndicator, - PM_ButtonShiftHorizontal, - PM_ButtonShiftVertical, - - PM_DefaultFrameWidth, - PM_SpinBoxFrameWidth, - - PM_MaximumDragDistance, - - PM_ScrollBarExtent, - PM_ScrollBarSliderMin, - - PM_SliderThickness, // total slider thickness - PM_SliderControlThickness, // thickness of the business part - PM_SliderLength, // total length of slider - PM_SliderTickmarkOffset, // - PM_SliderSpaceAvailable, // available space for slider to move - - PM_DockWindowSeparatorExtent, - PM_DockWindowHandleExtent, - PM_DockWindowFrameWidth, - - PM_MenuBarFrameWidth, - - PM_TabBarTabOverlap, - PM_TabBarTabHSpace, - PM_TabBarTabVSpace, - PM_TabBarBaseHeight, - PM_TabBarBaseOverlap, - - PM_ProgressBarChunkWidth, - - PM_SplitterWidth, - PM_TitleBarHeight, - - PM_IndicatorWidth, - PM_IndicatorHeight, - PM_ExclusiveIndicatorWidth, - PM_ExclusiveIndicatorHeight, - PM_PopupMenuScrollerHeight, - PM_CheckListButtonSize, - PM_CheckListControllerSize, - PM_PopupMenuFrameHorizontalExtra, - PM_PopupMenuFrameVerticalExtra, - - PM_DialogButtonsSeparator, - PM_DialogButtonsButtonWidth, - PM_DialogButtonsButtonHeight, - - PM_MDIFrameWidth, - PM_MDIMinimizedWidth, - PM_HeaderMargin, - PM_HeaderMarkSize, - PM_HeaderGripMargin, - PM_TabBarTabShiftHorizontal, - PM_TabBarTabShiftVertical, - PM_TabBarScrollButtonWidth, - - PM_MenuBarItemSpacing, - PM_ToolBarItemSpacing, - - PM_MenuIndicatorFrameHBorder, - PM_MenuIndicatorFrameVBorder, - PM_MenuIconIndicatorFrameHBorder, - PM_MenuIconIndicatorFrameVBorder, - - PM_ArrowSize, - - // do not add any values below/greater than this - PM_CustomBase = 0xf0000000 - }; - - // Old API - // DEPRECATED - virtual int pixelMetric( PixelMetric metric, - const TQWidget *widget = 0 ) const; - - // New API - virtual int pixelMetric( PixelMetric metric, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQWidget *widget = 0 ) const = 0; - - - enum ContentsType { - CT_PushButton, - CT_CheckBox, - CT_RadioButton, - CT_ToolButton, - CT_ComboBox, - CT_Splitter, - CT_DockWindow, - CT_ProgressBar, - CT_PopupMenuItem, - CT_TabBarTab, - CT_Slider, - CT_Header, - CT_LineEdit, - CT_MenuBar, - CT_SpinBox, - CT_SizeGrip, - CT_TabWidget, - CT_DialogButtons, - - // do not add any values below/greater than this - CT_CustomBase = 0xf0000000 - }; - - // Old API - // DEPRECATED - virtual TQSize sizeFromContents( ContentsType contents, - const TQWidget *widget, - const TQSize &contentsSize, - const TQStyleOption& = TQStyleOption::Default ) const; - - virtual TQSize sizeFromContents( ContentsType contents, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQSize &contentsSize, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 ) const = 0; - - enum StyleHint { - // ... - // the general hints - // ... - // disabled text should be etched, ala Windows - SH_EtchDisabledText, - - // the GUI style enum, argh! - SH_GUIStyle, - - // ... - // widget specific hints - // ... - SH_ScrollBar_BackgroundMode, - SH_ScrollBar_MiddleClickAbsolutePosition, - SH_ScrollBar_ScrollWhenPointerLeavesControl, - - // TQEvent::Type - which mouse event to select a tab - SH_TabBar_SelectMouseType, - - SH_TabBar_Alignment, - - SH_Header_ArrowAlignment, - - // bool - sliders snap to values while moving, ala Windows - SH_Slider_SnapToValue, - - // bool - key presses handled in a sloppy manner - ie. left on a vertical - // slider subtracts a line - SH_Slider_SloppyKeyEvents, - - // bool - center button on progress dialogs, ala Motif, else right aligned - // perhaps this should be a TQt::Alignment value - SH_ProgressDialog_CenterCancelButton, - - // TQt::AlignmentFlags - text label alignment in progress dialogs - // Center on windows, Auto|VCenter otherwize - SH_ProgressDialog_TextLabelAlignment, - - // bool - right align buttons on print dialog, ala Windows - SH_PrintDialog_RightAlignButtons, - - // bool - 1 or 2 pixel space between the menubar and the dockarea, ala Windows - // this *REALLY* needs a better name - SH_MainWindow_SpaceBelowMenuBar, - - // bool - select the text in the line edit about the listbox when selecting - // an item from the listbox, or when the line edit receives focus, ala Windows - SH_FontDialog_SelectAssociatedText, - - // bool - allows disabled menu items to be active - SH_PopupMenu_AllowActiveAndDisabled, - - // bool - pressing space activates item, ala Motif - SH_PopupMenu_SpaceActivatesItem, - - // int - number of milliseconds to wait before opening a submenu - // 256 on windows, 96 on motif - SH_PopupMenu_SubMenuPopupDelay, - - // bool - should scrollviews draw their frame only around contents (ala Motif), - // or around contents, scrollbars and corner widgets (ala Windows) ? - SH_ScrollView_FrameOnlyAroundContents, - - // bool - menubars items are navigatable by pressing alt, followed by using - // the arrow keys to select the desired item - SH_MenuBar_AltKeyNavigation, - - // bool - mouse tracking in combobox dropdown lists - SH_ComboBox_ListMouseTracking, - - // bool - mouse tracking in popupmenus - SH_PopupMenu_MouseTracking, - - // bool - mouse tracking in menubars - SH_MenuBar_MouseTracking, - - // bool - gray out selected items when loosing focus - SH_ItemView_ChangeHighlightOnFocus, - - // bool - supports shared activation among modeless widgets - SH_Widget_ShareActivation, - - // bool - workspace should just maximize the client area - SH_Workspace_FillSpaceOnMaximize, - - // bool - supports popup menu comboboxes - SH_ComboBox_Popup, - - // bool - titlebar has no border - SH_TitleBar_NoBorder, - - // bool - stop scrollbar at mouse - SH_ScrollBar_StopMouseOverSlider, - - //bool - blink cursort with selected text - SH_BlinkCursorWhenTextSelected, - - //bool - richtext selections extend the full width of the docuemnt - SH_RichText_FullWidthSelection, - - //bool - popupmenu supports scrolling instead of multicolumn mode - SH_PopupMenu_Scrollable, - - // TQt::AlignmentFlags - text label vertical alignment in groupboxes - // Center on windows, Auto|VCenter otherwize - SH_GroupBox_TextLabelVerticalAlignment, - - // TQt::TQRgb - text label color in groupboxes - SH_GroupBox_TextLabelColor, - - // bool - popupmenu supports sloppy submenus - SH_PopupMenu_SloppySubMenus, - - // TQt::TQRgb - table grid color - SH_Table_GridLineColor, - - // TQChar - Unicode character for password char - SH_LineEdit_PasswordCharacter, - - // TQDialogButtons::Button - default button - SH_DialogButtons_DefaultButton, - - // TQToolBox - Boldness of the selected page title - SH_ToolBox_SelectedPageTitleBold, - - //bool - if a tabbar prefers not to have scroller arrows - SH_TabBar_PreferNoArrows, - - //bool - if left button should cause an absolute position - SH_ScrollBar_LeftClickAbsolutePosition, - - // TQEvent::Type - which mouse event to select a list view expansion - SH_ListViewExpand_SelectMouseType, - - //bool - if underline for accelerators - SH_UnderlineAccelerator, - - // bool - TQToolButton - if tool buttons should use a 3D frame - // when the mouse is over the button - SH_ToolButton_Uses3D, - - // bool - hide underlined accelerators uless Alt key is currently down - SH_HideUnderlineAcceleratorWhenAltUp, - - // int - width of menu check column - SH_MenuIndicatorColumnWidth, - - // bool - whether or not the lower two button drawing areas should be combined into one - SH_ScrollBar_CombineAddLineRegionDrawingAreas, - - // bool - whether or not the upper two button drawing areas should be combined into one - SH_ScrollBar_CombineSubLineRegionDrawingAreas, - - // TQt::TQRgb - color of the popup menu arrow (active, menuitem enabled) - SH_PopupMenu_SubMenuArrowColorActiveEnabled, - - // TQt::TQRgb - color of the popup menu arrow (active, menuitem disabled) - SH_PopupMenu_SubMenuArrowColorActiveDisabled, - - // TQt::TQRgb - color of the popup menu arrow (inactive, menuitem enabled) - SH_PopupMenu_SubMenuArrowColorInactiveEnabled, - - // TQt::TQRgb - color of the popup menu arrow (active, menuitem disabled) - SH_PopupMenu_SubMenuArrowColorInactiveDisabled, - - // do not add any values below/greater than this - SH_CustomBase = 0xf0000000 - }; - - // Old API - // DEPRECATED - virtual int styleHint( StyleHint stylehint, - const TQWidget *widget = 0, - const TQStyleOption& = TQStyleOption::Default, - TQStyleHintReturn* returnData = 0 - ) const; - - // New API - virtual int styleHint( StyleHint stylehint, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQStyleOption& = TQStyleOption::Default, - TQStyleHintReturn* returnData = 0, - const TQWidget *widget = 0 - ) const = 0; - - - enum StylePixmap { - SP_TitleBarMinButton, - SP_TitleBarMaxButton, - SP_TitleBarCloseButton, - SP_TitleBarNormalButton, - SP_TitleBarShadeButton, - SP_TitleBarUnshadeButton, - SP_DockWindowCloseButton, - SP_MessageBoxInformation, - SP_MessageBoxWarning, - SP_MessageBoxCritical, - SP_MessageBoxQuestion, - - // do not add any values below/greater than this - SP_CustomBase = 0xf0000000 - }; - - // Old API - // DEPRECATED - virtual TQPixmap stylePixmap( StylePixmap stylepixmap, - const TQWidget *widget = 0, - const TQStyleOption& = TQStyleOption::Default ) const; - - virtual TQPixmap stylePixmap( StylePixmap stylepixmap, - const TQStyleControlElementData &ceData, - ControlElementFlags elementFlags, - const TQStyleOption& = TQStyleOption::Default, - const TQWidget *widget = 0 ) const = 0; - - - // Old API - // DEPRECATED - static TQRect visualRect( const TQRect &logical, const TQWidget *w ); - - // New API - static TQRect visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ); - - static TQRect visualRect( const TQRect &logical, const TQRect &bounding ); - - - // Object event handling API - typedef TQMap ObjectEventSourceToHandlerMap; - typedef TQMap ObjectEventSourceDataToHandlerMap; - typedef TQMap ObjectEventSourceFlagsToHandlerMap; - typedef bool (*EventHandlerInstallationHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler); - typedef bool (*EventHandlerRemovalHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler); - void installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); - void removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); - void setEventHandlerInstallationHook( EventHandlerInstallationHook ); - void setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); - virtual bool objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); - - enum WidgetActionRequest { - WAR_Repaint, - WAR_RepaintRect, - WAR_EnableMouseTracking, - WAR_DisableMouseTracking, - WAR_SetAutoMask, - WAR_UnSetAutoMask, - WAR_SetCheckable, - WAR_UnSetCheckable, - WAR_FrameSetStyle, - WAR_FrameSetLineWidth, - WAR_SetLayoutMargin, - WAR_SetPalette, - WAR_SetBackgroundMode, - WAR_SetBackgroundOrigin, - WAR_SetFont, - WAR_RepaintAllAccelerators, - WAR_SetDefault, - WAR_UnSetDefault, - WAR_SendPaintEvent - }; - - typedef bool (*WidgetActionRequestHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData); - void setWidgetActionRequestHook( WidgetActionRequestHook ); - virtual bool widgetActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData = TQStyleWidgetActionRequestData() ); - - enum ApplicationActionRequest { - AAR_SetPalette, - AAR_SetFont - }; - - typedef bool (*ApplicationActionRequestHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData); - void setApplicationActionRequestHook( ApplicationActionRequestHook ); - virtual bool applicationActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData = TQStyleApplicationActionRequestData() ); - - // Old 2.x TQStyle API - -#ifndef TQT_NO_COMPAT - int defaultFrameWidth() const; - void tabbarMetrics( const TQWidget* t, int& hf, int& vf, int& ov ) const; - TQSize scrollBarExtent() const; -#endif - -public: - virtual bool eventFilter( TQObject *, TQEvent * ); - bool acceleratorsShown() const; - -protected: - void acceleratorKeypressEventMonitor( TQObject *, TQEvent * ); - -private: - TQStylePrivate * d; - -#if defined(TQ_DISABLE_COPY) - TQStyle( const TQStyle & ); - TQStyle& operator=( const TQStyle & ); -#endif - - EventHandlerInstallationHook m_eventHandlerInstallationHook; - EventHandlerRemovalHook m_eventHandlerRemovalHook; - WidgetActionRequestHook m_widgetActionRequestHook; - ApplicationActionRequestHook m_applicationActionRequestHook; - ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap; - ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap; - ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap; - bool conditionalAcceleratorsEnabled; -}; - -inline TQStyle::ControlElementFlags operator|(const TQStyle::ControlElementFlags a, const TQStyle::ControlElementFlags b) { return static_cast(static_cast(a) | static_cast(b)); } -// inline TQStyle::ControlElementFlags operator|=(TQStyle::ControlElementFlags &a, const TQStyle::ControlElementFlags b) { a = static_cast(static_cast(a) | static_cast(b)); return a; } - -TQ_EXPORT const TQStyleControlElementData &populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields=true); -TQ_EXPORT const TQStyleControlElementData &populateControlElementDataFromApplication(const TQApplication* app, const TQStyleOption& opt, bool populateReliantFields=true); -TQ_EXPORT TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, const TQStyleOption& opt, bool populateReliantFields=true); -TQ_EXPORT TQStringList getObjectTypeListForObject(const TQObject* object); -TQ_EXPORT const TQStyleControlElementData &populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields); - -#endif // TQT_NO_STYLE -#endif // TQSTYLE_H diff --git a/src/kernel/ntqstylesheet.h b/src/kernel/ntqstylesheet.h deleted file mode 100644 index 1c12775cc..000000000 --- a/src/kernel/ntqstylesheet.h +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Definition of the TQStyleSheet class -** -** Created : 990101 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#ifndef TQSTYLESHEET_H -#define TQSTYLESHEET_H - -#ifndef QT_H -#include "tqstring.h" -#include "tqvaluelist.h" -#include "tqptrvector.h" -#include "ntqdict.h" -#include "tqobject.h" -#endif // QT_H - -#ifndef TQT_NO_RICHTEXT - -class TQStyleSheet; -class TQTextDocument; -template class TQMap; -class TQStyleSheetItemData; - -class TQ_EXPORT TQStyleSheetItem : public TQt -{ -public: - TQStyleSheetItem( TQStyleSheet* parent, const TQString& name ); - TQStyleSheetItem( const TQStyleSheetItem & ); - ~TQStyleSheetItem(); - - TQStyleSheetItem& operator=( const TQStyleSheetItem& other ); - - TQString name() const; - - TQStyleSheet* styleSheet(); - const TQStyleSheet* styleSheet() const; - - enum AdditionalStyleValues { Undefined = - 1}; - - enum DisplayMode { - DisplayBlock, - DisplayInline, - DisplayListItem, - DisplayNone -#ifndef Q_QDOC - , DisplayModeUndefined = -1 -#endif - }; - - DisplayMode displayMode() const; - void setDisplayMode(DisplayMode m); - - int alignment() const; - void setAlignment( int f); - - enum VerticalAlignment { - VAlignBaseline, - VAlignSub, - VAlignSuper - }; - - VerticalAlignment verticalAlignment() const; - void setVerticalAlignment( VerticalAlignment valign ); - - int fontWeight() const; - void setFontWeight(int w); - - int logicalFontSize() const; - void setLogicalFontSize(int s); - - int logicalFontSizeStep() const; - void setLogicalFontSizeStep( int s ); - - int fontSize() const; - void setFontSize(int s); - - TQString fontFamily() const; - void setFontFamily( const TQString& ); - - int numberOfColumns() const; - void setNumberOfColumns(int ncols); - - TQColor color() const; - void setColor( const TQColor &); - - bool fontItalic() const; - void setFontItalic( bool ); - bool definesFontItalic() const; - - bool fontUnderline() const; - void setFontUnderline( bool ); - bool definesFontUnderline() const; - - bool fontStrikeOut() const; - void setFontStrikeOut( bool ); - bool definesFontStrikeOut() const; - - bool isAnchor() const; - void setAnchor(bool anc); - - enum WhiteSpaceMode { - WhiteSpaceNormal, - WhiteSpacePre, - WhiteSpaceNoWrap -#ifndef Q_QDOC - , WhiteSpaceModeUndefined = -1 -#endif - }; - WhiteSpaceMode whiteSpaceMode() const; - void setWhiteSpaceMode(WhiteSpaceMode m); - - enum Margin { - MarginLeft, - MarginRight, - MarginTop, - MarginBottom, - MarginFirstLine, - MarginAll, - MarginVertical, - MarginHorizontal -#ifndef Q_QDOC - , MarginUndefined = -1 -#endif - }; - - int margin( Margin m) const; - void setMargin( Margin, int); - - enum ListStyle { - ListDisc, - ListCircle, - ListSquare, - ListDecimal, - ListLowerAlpha, - ListUpperAlpha -#ifndef Q_QDOC - , ListStyleUndefined = -1 -#endif - }; - - ListStyle listStyle() const; - void setListStyle( ListStyle ); - - TQString contexts() const; - void setContexts( const TQString& ); - bool allowedInContext( const TQStyleSheetItem* ) const; - - bool selfNesting() const; - void setSelfNesting( bool ); - - void setLineSpacing( int ls ); - int lineSpacing() const; - -private: - void init(); - TQStyleSheetItemData* d; -}; - - -#if defined(Q_TEMPLATEDLL) -// MOC_SKIP_BEGIN -Q_TEMPLATE_EXTERN template class TQ_EXPORT TQDict; -Q_TEMPLATE_EXTERN template class TQ_EXPORT TQValueList< TQPtrVector >; -Q_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrVector; -Q_TEMPLATE_EXTERN template class TQ_EXPORT TQValueList; -// MOC_SKIP_END -#endif - -#ifndef TQT_NO_TEXTCUSTOMITEM -class TQTextCustomItem; -#endif - -class TQ_EXPORT TQStyleSheet : public TQObject -{ - TQ_OBJECT -public: - TQStyleSheet( TQObject *parent=0, const char *name=0 ); - virtual ~TQStyleSheet(); - - static TQStyleSheet* defaultSheet(); - static void setDefaultSheet( TQStyleSheet* ); - - - TQStyleSheetItem* item( const TQString& name); - const TQStyleSheetItem* item( const TQString& name) const; - - void insert( TQStyleSheetItem* item); - -#ifndef TQT_NO_TEXTCUSTOMITEM - virtual TQTextCustomItem* tag( const TQString& name, - const TQMap &attr, - const TQString& context, - const TQMimeSourceFactory& factory, - bool emptyTag, TQTextDocument *doc ) const; -#endif - static TQString escape( const TQString& ); - static TQString convertFromPlainText( const TQString&, - TQStyleSheetItem::WhiteSpaceMode mode = TQStyleSheetItem::WhiteSpacePre ); - static bool mightBeRichText( const TQString& ); - - virtual void scaleFont( TQFont& font, int logicalSize ) const; - - virtual void error( const TQString& ) const; - -private: - void init(); - TQDict styles; - TQStyleSheetItem* nullstyle; -private: // Disabled copy constructor and operator= -#if defined(TQ_DISABLE_COPY) - TQStyleSheet( const TQStyleSheet & ); - TQStyleSheet &operator=( const TQStyleSheet & ); -#endif -}; - -#endif // TQT_NO_RICHTEXT - -#endif // TQSTYLESHEET_H diff --git a/src/kernel/ntqt.h b/src/kernel/ntqt.h index 78ce0ca55..46dd439d1 100644 --- a/src/kernel/ntqt.h +++ b/src/kernel/ntqt.h @@ -71,7 +71,7 @@ #include "tqiconset.h" #include "ntqbutton.h" #include -#include "ntqstyle.h" +#include "tqstyle.h" #include "ntqframe.h" #include "ntqfile.h" #include "ntqfileinfo.h" @@ -168,7 +168,7 @@ #include #include #include -#include "ntqstylesheet.h" +#include "tqstylesheet.h" #include #include #include @@ -222,8 +222,8 @@ #include "ntqtranslator.h" #include #include -#include -#include +#include +#include #include "tqtextedit.h" #include #include @@ -291,7 +291,7 @@ #include "private/tqsqlmanager_p.h" #include "private/qlock_p.h" #include "private/qcomponentfactory_p.h" -#include "private/qstyleinterface_p.h" +#include "private/tqstyleinterface_p.h" #include "private/qrichtext_p.h" #include "private/qsvgdevice_p.h" #include "private/qfontcodecs_p.h" diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index baf5ba495..5ba5f5b21 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -54,8 +54,8 @@ #include "ntqdragobject.h" #include "ntqclipboard.h" #include "ntqcursor.h" -#include "ntqstyle.h" -#include "ntqstylefactory.h" +#include "tqstyle.h" +#include "tqstylefactory.h" #include "ntqfile.h" #include "ntqmessagebox.h" #include "ntqdir.h" diff --git a/src/kernel/qapplication_x11.cpp b/src/kernel/qapplication_x11.cpp index 0cfd812c2..0a1d62cf8 100644 --- a/src/kernel/qapplication_x11.cpp +++ b/src/kernel/qapplication_x11.cpp @@ -85,7 +85,7 @@ #include "ntqclipboard.h" #include "ntqwhatsthis.h" // ######## dependency #include "ntqsettings.h" -#include "ntqstylefactory.h" +#include "tqstylefactory.h" #include "ntqfileinfo.h" // Input method stuff - UNFINISHED diff --git a/src/kernel/qrichtext.cpp b/src/kernel/qrichtext.cpp index cd4c31055..1d9626426 100644 --- a/src/kernel/qrichtext.cpp +++ b/src/kernel/qrichtext.cpp @@ -50,7 +50,7 @@ #include "ntqapplication.h" #include "tqmap.h" #include "ntqfileinfo.h" -#include "ntqstylesheet.h" +#include "tqstylesheet.h" #include "ntqmime.h" #include "tqimage.h" #include "ntqdragobject.h" @@ -60,7 +60,7 @@ #include "ntqcursor.h" #include "tqptrstack.h" #include "tqptrdict.h" -#include "ntqstyle.h" +#include "tqstyle.h" #include "ntqcleanuphandler.h" #include "tqtextengine_p.h" #include diff --git a/src/kernel/qrichtext_p.h b/src/kernel/qrichtext_p.h index 58fed9826..f30c29149 100644 --- a/src/kernel/qrichtext_p.h +++ b/src/kernel/qrichtext_p.h @@ -69,7 +69,7 @@ #include "tqobject.h" #include "ntqdict.h" #include "ntqpixmap.h" -#include "ntqstylesheet.h" +#include "tqstylesheet.h" #include "tqptrvector.h" #include "ntqpainter.h" #include "ntqlayout.h" diff --git a/src/kernel/qsizegrip.cpp b/src/kernel/qsizegrip.cpp index a6629ecf6..f4528c3b9 100644 --- a/src/kernel/qsizegrip.cpp +++ b/src/kernel/qsizegrip.cpp @@ -44,7 +44,7 @@ #include "ntqpainter.h" #include "ntqapplication.h" -#include "ntqstyle.h" +#include "tqstyle.h" #if defined(TQ_WS_X11) #include "qt_x11_p.h" diff --git a/src/kernel/qstyle.cpp b/src/kernel/qstyle.cpp deleted file mode 100644 index d45540bb8..000000000 --- a/src/kernel/qstyle.cpp +++ /dev/null @@ -1,2911 +0,0 @@ -/**************************************************************************** -** -** Implementation of TQStyle class -** -** Created : 981231 -** -** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqstyle.h" -#ifndef TQT_NO_STYLE -#include "ntqapplication.h" -#include "ntqpainter.h" -#include "ntqbitmap.h" -#include "ntqpixmapcache.h" -#include "ntqframe.h" -#include "ntqlayout.h" -#include "ntqlistview.h" -#include "ntqpopupmenu.h" -#include "ntqpushbutton.h" -#include "tqobjectlist.h" -#include "tqwidgetlist.h" - -#include - -class TQStylePrivate -{ -public: - TQStylePrivate() - { - } -}; - -TQStyleOption::TQStyleOption(StyleOptionDefault) : - def(TRUE), - tb(NULL), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(int in1) : - def(FALSE), - tb(NULL), - i1(in1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(int in1, int in2) : - def(FALSE), - tb(NULL), - i1(in1), - i2(in2), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(int in1, int in2, int in3, int in4) : - def(FALSE), - tb(NULL), - i1(in1), - i2(in2), - i3(in3), - i4(in4), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQMenuItem* m) : - def(FALSE), - mi(m), - tb(NULL), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQMenuItem* m, int in1) : - def(FALSE), - mi(m), - tb(NULL), - i1(in1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQMenuItem* m, int in1, int in2) : - def(FALSE), - mi(m), - tb(NULL), - i1(in1), - i2(in2), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(const TQColor& c) : - def(FALSE), - tb(NULL), - cl(&c), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQTab* t) : - def(FALSE), - tb(t), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQListViewItem* i) : - def(FALSE), - tb(NULL), - li(i), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQCheckListItem* i) : - def(FALSE), - tb(NULL), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(i), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQt::ArrowType a) : - def(FALSE), - tb(NULL), - i1((int)a), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(const TQRect& r) : - def(FALSE), - tb(NULL), - i1(r.x()), - i2(r.y()), - i3(r.width()), - i4(r.height()), - i5(-1), - cli(NULL), - tbh(NULL) { - // -} - -TQStyleOption::TQStyleOption(TQWidget *w) : - def(FALSE), - tb(NULL), - i1(-1), - i2(-1), - i3(-1), - i4(-1), - i5(-1), - cli(NULL), - p1((void*)w), - tbh(NULL) { - // -} - -/*! - \class TQStyleOption ntqstyle.h - \brief The TQStyleOption class specifies optional parameters for TQStyle functions. - \ingroup appearance - - Some TQStyle functions take an optional argument specifying extra - information that is required for a paritical primitive or control. - So that the TQStyle class can be extended, TQStyleOption is used to - provide a variable-argument for these options. - - The TQStyleOption class has constructors for each type of optional - argument, and this set of constructors may be extended in future - TQt releases. There are also corresponding access functions that - return the optional arguments: these too may be extended. - - For each constructor, you should refer to the documentation of the - TQStyle functions to see the meaning of the arguments. - - When calling TQStyle functions from your own widgets, you must only - pass the default TQStyleOption or the argument that TQStyle is - documented to accept. For example, if the function expects - TQStyleOption(TQMenuItem *, int), passing TQStyleOption(TQMenuItem *) - leaves the optional integer argument uninitialized. - - When subclassing TQStyle, you must similarly only expect the - default or documented arguments. The other arguments will have - uninitialized values. - - If you make your own TQStyle subclasses and your own widgets, you - can make a subclass of TQStyleOption to pass additional arguments - to your TQStyle subclass. You will need to cast the "const - TQStyleOption&" argument to your subclass, so be sure your style - has been called from your widget. -*/ - -/*! - \enum TQStyleOption::StyleOptionDefault - - This enum value can be passed as the optional argument to any - TQStyle function. - - \value Default -*/ - -/*! - \fn TQStyleOption::TQStyleOption(StyleOptionDefault) - - The default option. This can always be passed as the optional - argument to TQStyle functions. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(int) - - Pass one integer, \a in1. For example, headerSection. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(int, int) - - Pass two integers, \a in1 and \a in2. For example, linewidth and - midlinewidth. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(int, int, int, int) - - Pass four integers, \a in1, \a in2, \a in3 and \a in4. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQMenuItem*) - - Pass a menu item, \a m. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQMenuItem*, int) - - Pass a menu item and an integer, \a m and \a in1. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQMenuItem*, int, int) - - Pass a menu item and two integers, \a m, \a in1 and \a in2. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(const TQColor&) - - Pass a color, \a c. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQTab*) - - Pass a TQTab, \a t. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQListViewItem*) - - Pass a TQListViewItem, \a i. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQt::ArrowType) - - Pass an TQt::ArrowType, \a a. -*/ - -/*! - \fn TQStyleOption::TQStyleOption(TQCheckListItem* i) - - Pass a TQCheckListItem, \a i. -*/ - -/*! - \fn TQStyleOption::TQStyleOption( const TQRect &r ) - - Pass a TQRect, \a r. -*/ - -/*! - \fn TQStyleOption::TQStyleOption( TQWidget *w ) - - Pass a TQWidget, \a w. -*/ - -/*! - \fn bool TQStyleOption::isDefault() const - - Returns TRUE if the option was constructed with the default - constructor; otherwise returns FALSE. -*/ - -/*! - \fn int TQStyleOption::day() const - - Returns the index of the day in the month if the appropriate - constructor was called; otherwise the return value is undefined. -*/ - -/*! - \fn int TQStyleOption::lineWidth() const - - Returns the line width if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \fn int TQStyleOption::midLineWidth() const - - Returns the mid-line width if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn int TQStyleOption::frameShape() const - - Returns a TQFrame::Shape value if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn int TQStyleOption::frameShadow() const - - Returns a TQFrame::Shadow value if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn TQMenuItem* TQStyleOption::menuItem() const - - Returns a menu item if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \fn int TQStyleOption::maxIconWidth() const - - Returns the maximum width of the menu item check area if the - appropriate constructor was called; otherwise the return value is - undefined. -*/ - -/*! - \fn int TQStyleOption::tabWidth() const - - Returns the tab indent width if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn int TQStyleOption::headerSection() const - - Returns the header section if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn const TQColor& TQStyleOption::color() const - - Returns a color if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \fn TQTab* TQStyleOption::tab() const - - Returns a TQTabBar tab if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \fn TQListViewItem* TQStyleOption::listViewItem() const - - Returns a TQListView item if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn TQt::ArrowType TQStyleOption::arrowType() const - - Returns an arrow type if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \fn TQCheckListItem* TQStyleOption::checkListItem() const - - Returns a check list item if the appropriate constructor was - called; otherwise the return value is undefined. -*/ - -/*! - \fn TQRect TQStyleOption::rect() const - - Returns a rectangle if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \fn TQWidget* TQStyleOption::widget() const - - Returns a pointer to a widget if the appropriate constructor was called; - otherwise the return value is undefined. -*/ - -/*! - \class TQStyle ntqstyle.h - \brief The TQStyle class specifies the look and feel of a GUI. - \ingroup appearance - - A large number of GUI elements are common to many widgets. The - TQStyle class allows the look of these elements to be modified - across all widgets that use the TQStyle functions. It also - provides two feel options: Motif and Windows. - - Although it is not possible to fully enumerate the look of - graphical elements and the feel of widgets in a GUI, TQStyle - provides a considerable amount of control and customisability. - - In TQt 1.x the look and feel option for widgets was specified by a - single value: the GUIStyle. Starting with TQt 2.0, this notion was - expanded to allow the look to be specified by virtual drawing - functions. - - Derived classes may reimplement some or all of the drawing - functions to modify the look of all widgets that use those - functions. - - Languages written from right to left (such as Arabic and Hebrew) - usually also mirror the whole layout of widgets. If you design a - style, you should take special care when drawing asymmetric - elements to make sure that they also look correct in a mirrored - layout. You can start your application with \c -reverse to check - the mirrored layout. Also notice, that for a reversed layout, the - light usually comes from top right instead of top left. - - The actual reverse layout is performed automatically when - possible. However, for the sake of flexibility, the translation - cannot be performed everywhere. The documentation for each - function in the TQStyle API states whether the function - expects/returns logical or screen coordinates. Using logical - coordinates (in ComplexControls, for example) provides great - flexibility in controlling the look of a widget. Use visualRect() - when necessary to translate logical coordinates into screen - coordinates for drawing. - - In TQt versions prior to 3.0, if you wanted a low level route into - changing the appearance of a widget, you would reimplement - polish(). With the new 3.0 style engine the recommended approach - is to reimplement the draw functions, for example drawItem(), - drawPrimitive(), drawControl(), drawControlMask(), - drawComplexControl() and drawComplexControlMask(). Each of these - functions is called with a range of parameters that provide - information that you can use to determine how to draw them, e.g. - style flags, rectangle, color group, etc. - - For information on changing elements of an existing style or - creating your own style see the \link customstyles.html Style - overview\endlink. - - Styles can also be created as \link plugins-howto.html - plugins\endlink. -*/ - -/*! - \enum TQt::GUIStyle - - \obsolete - - \value WindowsStyle - \value MotifStyle - \value MacStyle - \value Win3Style - \value PMStyle -*/ - -/*! - \enum TQt::UIEffect - - \value UI_General - \value UI_AnimateMenu - \value UI_FadeMenu - \value UI_AnimateCombo - \value UI_AnimateTooltip - \value UI_FadeTooltip - \value UI_AnimateToolBox Reserved -*/ - -/*! - Constructs a TQStyle. -*/ -TQStyle::TQStyle() -{ - m_eventHandlerInstallationHook = NULL; - m_eventHandlerRemovalHook = NULL; - m_widgetActionRequestHook = NULL; - m_applicationActionRequestHook = NULL; - conditionalAcceleratorsEnabled = false; - d = new TQStylePrivate; -} - -/*! - Destroys the style and frees all allocated resources. -*/ -TQStyle::~TQStyle() -{ - delete d; - d = 0; -} - -/* - \fn GUIStyle TQStyle::guiStyle() const - \obsolete - - Returns an indicator to the additional "feel" component of a - style. Current supported values are TQt::WindowsStyle and TQt::MotifStyle. -*/ - -/*! - Initializes the appearance of a widget. - - This function is called for every widget at some point after it - has been fully created but just \e before it is shown the very - first time. - - Reasonable actions in this function might be to call - TQWidget::setBackgroundMode() for the widget. An example of highly - unreasonable use would be setting the geometry! Reimplementing - this function gives you a back-door through which you can change - the appearance of a widget. With TQt 3.0's style engine you will - rarely need to write your own polish(); instead reimplement - drawItem(), drawPrimitive(), etc. - - The TQWidget::inherits() function may provide enough information to - allow class-specific customizations. But be careful not to - hard-code things too much because new TQStyle subclasses are - expected to work reasonably with all current and \e future - widgets. - - \sa unPolish() -*/ -void TQStyle::polish( TQWidget *widget ) { - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - polish(ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); -} - -/*! - Undoes the initialization of a widget's appearance. - - This function is the counterpart to polish. It is called for every - polished widget when the style is dynamically changed. The former - style has to unpolish its settings before the new style can polish - them again. - - \sa polish() -*/ -void TQStyle::unPolish( TQWidget *widget ) { - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - unPolish(ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); -} - -/*! - Initializes the appearance of a widget. - - This function is called for every widget at some point after it - has been fully created but just \e before it is shown the very - first time. - - Reasonable actions in this function might be to install a widget - event handler for the style. An example of highly unreasonable - use would be setting the geometry! With TQt 3.0's style engine - you will rarely need to write your own polish(); instead reimplement - drawItem(), drawPrimitive(), etc. - - The \a objectTypes object may provide enough information to - allow class-specific customizations. But be careful not to - hard-code things too much because new TQStyle subclasses are - expected to work reasonably with all current and \e future - widgets. - - You may specify either a TQWidget pointer or a custom pointer. - If a custom pointer is specified, you must be careful to intercept any event - handler installation/removal calls via setEventHandlerInstallationHook and - setEventHandlerRemovalHook. - - \sa unPolish() -*/ -void TQStyle::polish( const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr ) { - if (ceData.widgetObjectTypes.contains("TQWidget")) { - // Enable dynamic hide/show of accelerator shortcuts - TQWidget* widget = reinterpret_cast(ptr); - widget->installEventFilter(this); - } -} - -/*! - Undoes the initialization of a widget's appearance. - - This function is the counterpart to polish. It is called for every - polished widget when the style is dynamically changed. The former - style has to unpolish its settings before the new style can polish - them again. - - \sa polish() -*/ -void TQStyle::unPolish( const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr ) { - if (ceData.widgetObjectTypes.contains("TQWidget")) { - // Disable dynamic hide/show of accelerator shortcuts - TQWidget* widget = reinterpret_cast(ptr); - widget->installEventFilter(this); - } -} - -/*! - \overload - Late initialization of the TQApplication object. - - \sa unPolish() -*/ -void TQStyle::polish( TQApplication *app ) { - const TQStyleControlElementData &ceData = populateControlElementDataFromApplication(app, TQStyleOption()); - applicationPolish(ceData, getControlElementFlagsForObject(app, TQStyleOption()), app); -} - -/*! - \overload - - Undoes the application polish. - - \sa polish() -*/ -void TQStyle::unPolish( TQApplication *app ) { - const TQStyleControlElementData &ceData = populateControlElementDataFromApplication(app, TQStyleOption()); - applicationUnPolish(ceData, getControlElementFlagsForObject(app, TQStyleOption()), app); -} - -/*! - \overload - Late initialization of the TQApplication object or other global application object. - - You may specify either a TQApplication pointer or a custom pointer. - If a custom pointer is specified, you must be careful to intercept any event - handler installation/removal calls via setEventHandlerInstallationHook and - setEventHandlerRemovalHook. - - \sa unPolish() -*/ -void TQStyle::applicationPolish( const TQStyleControlElementData&, ControlElementFlags, void * ) { - // -} - -/*! - \overload - - Undoes the application polish. - - You may specify either a TQApplication pointer or a custom pointer. - If a custom pointer is specified, you must be careful to intercept any event - handler installation/removal calls via setEventHandlerInstallationHook and - setEventHandlerRemovalHook. - - \sa polish() -*/ -void TQStyle::applicationUnPolish( const TQStyleControlElementData&, ControlElementFlags, void * ) { - // -} - -/*! - \overload - - The style may have certain requirements for color palettes. In - this function it has the chance to change the palette according to - these requirements. - - \sa TQPalette, TQApplication::setPalette() -*/ -void TQStyle::polish( TQPalette&) -{ -} - -/*! - Polishes the popup menu according to the GUI style. This usually - means setting the mouse tracking - (\l{TQPopupMenu::setMouseTracking()}) and whether the menu is - checkable by default (\l{TQPopupMenu::setCheckable()}). -*/ -void TQStyle::polishPopupMenu( TQPopupMenu *pm ) { - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(pm, TQStyleOption()); - polish(ceData, getControlElementFlagsForObject(pm, TQStyleOption()), pm); -} - -/*! - Polishes the popup menu according to the GUI style. This usually - means setting the mouse tracking - (\l{TQPopupMenu::setMouseTracking()}) and whether the menu is - checkable by default (\l{TQPopupMenu::setCheckable()}). -*/ -void TQStyle::polishPopupMenu( const TQStyleControlElementData&, ControlElementFlags, void * ) -{ -} - -/*! - Returns the appropriate area (see below) within rectangle \a r in - which to draw the \a text or \a pixmap using painter \a p. If \a - len is -1 (the default) all the \a text is drawn; otherwise only - the first \a len characters of \a text are drawn. The text is - aligned in accordance with the alignment \a flags (see - \l{TQt::AlignmentFlags}). The \a enabled bool indicates whether or - not the item is enabled. - - If \a r is larger than the area needed to render the \a text the - rectangle that is returned will be offset within \a r in - accordance with the alignment \a flags. For example if \a flags is - \c AlignCenter the returned rectangle will be centered within \a - r. If \a r is smaller than the area needed the rectangle that is - returned will be \e larger than \a r (the smallest rectangle large - enough to render the \a text or \a pixmap). - - By default, if both the text and the pixmap are not null, the - pixmap is drawn and the text is ignored. -*/ -TQRect TQStyle::itemRect( TQPainter *p, const TQRect &r, - int flags, bool enabled, const TQPixmap *pixmap, - const TQString& text, int len ) const -{ - TQRect result; - int x = r.x(); - int y = r.y(); - int w = r.width(); - int h = r.height(); - GUIStyle gs = (GUIStyle)styleHint( SH_GUIStyle ); - - if ( pixmap ) { - if ( (flags & TQt::AlignVCenter) == TQt::AlignVCenter ) - y += h/2 - pixmap->height()/2; - else if ( (flags & TQt::AlignBottom) == TQt::AlignBottom) - y += h - pixmap->height(); - if ( (flags & TQt::AlignRight) == TQt::AlignRight ) - x += w - pixmap->width(); - else if ( (flags & TQt::AlignHCenter) == TQt::AlignHCenter ) - x += w/2 - pixmap->width()/2; - else if ( (flags & TQt::AlignLeft) != TQt::AlignLeft && TQApplication::reverseLayout() ) - x += w - pixmap->width(); - result = TQRect(x, y, pixmap->width(), pixmap->height()); - } else if ( !text.isNull() && p ) { - result = p->boundingRect( x, y, w, h, flags, text, len ); - if ( gs == TQt::WindowsStyle && !enabled ) { - result.setWidth(result.width()+1); - result.setHeight(result.height()+1); - } - } else { - result = TQRect(x, y, w, h); - } - - return result; -} - - -/*! - Draws the \a text or \a pixmap in rectangle \a r using painter \a - p and color group \a g. The pen color is specified with \a - penColor. The \a enabled bool indicates whether or not the item is - enabled; when reimplementing this bool should influence how the - item is drawn. If \a len is -1 (the default) all the \a text is - drawn; otherwise only the first \a len characters of \a text are - drawn. The text is aligned and wrapped according to the alignment - \a flags (see \l{TQt::AlignmentFlags}). - - By default, if both the text and the pixmap are not null, the - pixmap is drawn and the text is ignored. -*/ -void TQStyle::drawItem( TQPainter *p, const TQRect &r, - int flags, const TQColorGroup &g, bool enabled, - const TQPixmap *pixmap, const TQString& text, int len, - const TQColor* penColor ) const -{ - int x = r.x(); - int y = r.y(); - int w = r.width(); - int h = r.height(); - GUIStyle gs = (GUIStyle)styleHint( SH_GUIStyle ); - - p->setPen( penColor?*penColor:g.foreground() ); - if ( pixmap ) { - TQPixmap pm( *pixmap ); - bool clip = (flags & TQt::DontClip) == 0; - if ( clip ) { - if ( pm.width() < w && pm.height() < h ) { - clip = FALSE; - } else { - p->save(); - TQRegion cr = TQRect(x, y, w, h); - if (p->hasClipping()) - cr &= p->clipRegion(TQPainter::CoordPainter); - p->setClipRegion(cr); - } - } - if ( (flags & TQt::AlignVCenter) == TQt::AlignVCenter ) - y += h/2 - pm.height()/2; - else if ( (flags & TQt::AlignBottom) == TQt::AlignBottom) - y += h - pm.height(); - if ( (flags & TQt::AlignRight) == TQt::AlignRight ) - x += w - pm.width(); - else if ( (flags & TQt::AlignHCenter) == TQt::AlignHCenter ) - x += w/2 - pm.width()/2; - else if ( ((flags & TQt::AlignLeft) != TQt::AlignLeft) && TQApplication::reverseLayout() ) // AlignAuto && rightToLeft - x += w - pm.width(); - - if ( !enabled ) { - if ( pm.mask() ) { // pixmap with a mask - if ( !pm.selfMask() ) { // mask is not pixmap itself - TQPixmap pmm( *pm.mask() ); - pmm.setMask( *((TQBitmap *)&pmm) ); - pm = pmm; - } - } else if ( pm.depth() == 1 ) { // monochrome pixmap, no mask - pm.setMask( *((TQBitmap *)&pm) ); -#ifndef TQT_NO_IMAGE_HEURISTIC_MASK - } else { // color pixmap, no mask - TQString k; - k.sprintf( "$qt-drawitem-%x", pm.serialNumber() ); - TQPixmap *mask = TQPixmapCache::find(k); - bool del=FALSE; - if ( !mask ) { - mask = new TQPixmap( pm.createHeuristicMask() ); - mask->setMask( *((TQBitmap*)mask) ); - del = !TQPixmapCache::insert( k, mask ); - } - pm = *mask; - if (del) delete mask; -#endif - } - if ( gs == TQt::WindowsStyle ) { - p->setPen( g.light() ); - p->drawPixmap( x+1, y+1, pm ); - p->setPen( g.text() ); - } - } - p->drawPixmap( x, y, pm ); - if ( clip ) - p->restore(); - } else if ( !text.isNull() ) { - if ( gs == TQt::WindowsStyle && !enabled ) { - p->setPen( g.light() ); - p->drawText( x+1, y+1, w, h, flags, text, len ); - p->setPen( g.text() ); - } - p->drawText( x, y, w, h, flags, text, len ); - } -} - -/*! - \enum TQStyle::PrimitiveElement - - This enum represents the PrimitiveElements of a style. A - PrimitiveElement is a common GUI element, such as a checkbox - indicator or pushbutton bevel. - - \value PE_ButtonCommand button used to initiate an action, for - example, a TQPushButton. - \value PE_ButtonDefault this button is the default button, e.g. - in a dialog. - \value PE_ButtonBevel generic button bevel. - \value PE_ButtonTool tool button, for example, a TQToolButton. - \value PE_ButtonDropDown drop down button, for example, a tool - button that displays a popup menu, for example, TQPopupMenu. - - - \value PE_FocusRect generic focus indicator. - - - \value PE_ArrowUp up arrow. - \value PE_ArrowDown down arrow. - \value PE_ArrowRight right arrow. - \value PE_ArrowLeft left arrow. - - - \value PE_SpinWidgetUp up symbol for a spin widget, for example a - TQSpinBox. - \value PE_SpinWidgetDown down symbol for a spin widget. - \value PE_SpinWidgetPlus increase symbol for a spin widget. - \value PE_SpinWidgetMinus decrease symbol for a spin widget. - - - \value PE_Indicator on/off indicator, for example, a TQCheckBox. - \value PE_IndicatorMask bitmap mask for an indicator. - \value PE_ExclusiveIndicator exclusive on/off indicator, for - example, a TQRadioButton. - \value PE_ExclusiveIndicatorMask bitmap mask for an exclusive indicator. - - - \value PE_DockWindowHandle tear off handle for dock windows and - toolbars, for example \l{TQDockWindow}s and \l{TQToolBar}s. - \value PE_DockWindowSeparator item separator for dock window and - toolbar contents. - \value PE_DockWindowResizeHandle resize handle for dock windows. - - \value PE_Splitter splitter handle; see also TQSplitter. - - - \value PE_Panel generic panel frame; see also TQFrame. - \value PE_PanelPopup panel frame for popup windows/menus; see also - TQPopupMenu. - \value PE_PanelMenuBar panel frame for menu bars. - \value PE_PanelDockWindow panel frame for dock windows and toolbars. - \value PE_PanelTabWidget panel frame for tab widgets. - \value PE_PanelLineEdit panel frame for line edits. - \value PE_PanelGroupBox panel frame for group boxes. - - \value PE_TabBarBase area below tabs in a tab widget, for example, - TQTab. - - - \value PE_HeaderSection section of a list or table header; see also - TQHeader. - \value PE_HeaderArrow arrow used to indicate sorting on a list or table - header - \value PE_StatusBarSection section of a status bar; see also - TQStatusBar. - - - \value PE_GroupBoxFrame frame around a group box; see also - TQGroupBox. - \value PE_WindowFrame frame around a MDI window or a docking window - - - \value PE_Separator generic separator. - - - \value PE_SizeGrip window resize handle; see also TQSizeGrip. - - - \value PE_CheckMark generic check mark; see also TQCheckBox. - - - \value PE_ScrollBarAddLine scrollbar line increase indicator - (i.e. scroll down); see also TQScrollBar. - \value PE_ScrollBarSubLine scrollbar line decrease indicator (i.e. scroll up). - \value PE_ScrollBarAddPage scolllbar page increase indicator (i.e. page down). - \value PE_ScrollBarSubPage scrollbar page decrease indicator (i.e. page up). - \value PE_ScrollBarSlider scrollbar slider - \value PE_ScrollBarFirst scrollbar first line indicator (i.e. home). - \value PE_ScrollBarLast scrollbar last line indicator (i.e. end). - - - \value PE_ProgressBarChunk section of a progress bar indicator; see - also TQProgressBar. - - \value PE_CheckListController controller part of a listview item - \value PE_CheckListIndicator checkbox part of a listview item - \value PE_CheckListExclusiveIndicator radiobutton part of a listview item - \value PE_RubberBand rubber band used in such things as iconview - - \value PE_CustomBase base value for custom PrimitiveElements. - All values above this are reserved for custom use. Custom - values must be greater than this value. - - \sa drawPrimitive() -*/ -/*! \enum TQStyle::SFlags - \internal -*/ -/*! \enum TQStyle::SCFlags - \internal -*/ - -/*! - \enum TQStyle::StyleFlags - - This enum represents flags for drawing PrimitiveElements. Not all - primitives use all of these flags. Note that these flags may mean - different things to different primitives. For an explanation of - the relationship between primitives and their flags, as well as - the different meanings of the flags, see the \link - customstyles.html Style overview\endlink. - - \value Style_Default - \value Style_Enabled - \value Style_Raised - \value Style_Sunken - \value Style_Off - \value Style_NoChange - \value Style_On - \value Style_Down - \value Style_Horizontal - \value Style_HasFocus - \value Style_Top - \value Style_Bottom - \value Style_FocusAtBorder - \value Style_AutoRaise - \value Style_MouseOver - \value Style_Up - \value Style_Selected - \value Style_HasFocus - \value Style_Active - \value Style_ButtonDefault - - \sa drawPrimitive() -*/ - -/*! - \fn void TQStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption& opt) const - - Draws the style PrimitiveElement \a pe using the painter \a p in - the area \a r. Colors are used from the color group \a cg. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The rect \a r should be in screen coordinates. - - The \a flags argument is used to control how the PrimitiveElement - is drawn. Multiple flags can be OR'ed together. - - For example, a pressed button would be drawn with the flags \c - Style_Enabled and \c Style_Down. - - The \a opt argument can be used to control how various - PrimitiveElements are drawn. Note that \a opt may be the default - value even for PrimitiveElements that make use of extra options. - When \a opt is non-default, it is used as follows: - - \table - \header \i PrimitiveElement \i Options \i Notes - \row \i \l PE_FocusRect - \i \l TQStyleOption ( const \l TQColor & bg ) - \list - \i opt.\link TQStyleOption::color() color\endlink() - \endlist - \i \e bg is the background color on which the focus rect is being drawn. - \row \i12 \l PE_Panel - \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) - \list - \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() - \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() - \endlist - \i \e linewidth is the line width for drawing the panel. - \row \i \e midlinewidth is the mid-line width for drawing the panel. - \row \i12 \l PE_PanelPopup - \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) - \list - \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() - \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() - \endlist - \i \e linewidth is the line width for drawing the panel. - \row \i \e midlinewidth is the mid-line width for drawing the panel. - \row \i12 \l PE_PanelMenuBar - \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) - \list - \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() - \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() - \endlist - \i \e linewidth is the line width for drawing the panel. - \row \i \e midlinewidth is the mid-line width for drawing the panel. - \row \i12 \l PE_PanelDockWindow - \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) - \list - \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() - \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() - \endlist - \i \e linewidth is the line width for drawing the panel. - \row \i \e midlinewidth is the mid-line width for drawing the panel. - \row \i14 \l PE_GroupBoxFrame - \i14 \l TQStyleOption ( int linewidth, int midlinewidth, int shape, int shadow ) - \list - \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() - \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() - \i opt.\link TQStyleOption::frameShape() frameShape\endlink() - \i opt.\link TQStyleOption::frameShadow() frameShadow\endlink() - \endlist - \i \e linewidth is the line width for the group box. - \row \i \e midlinewidth is the mid-line width for the group box. - \row \i \e shape is the \link TQFrame::frameShape frame shape \endlink - for the group box. - \row \i \e shadow is the \link TQFrame::frameShadow frame shadow \endlink - for the group box. - \endtable - - - For all other \link TQStyle::PrimitiveElement - PrimitiveElements\endlink, \a opt is unused. - - \sa StyleFlags -*/ - -/*! - \enum TQStyle::ControlElement - - This enum represents a ControlElement. A ControlElement is part of - a widget that performs some action or displays information to the - user. - - \value CE_PushButton the bevel and default indicator of a TQPushButton. - \value CE_PushButtonLabel the label (iconset with text or pixmap) - of a TQPushButton. - - \value CE_CheckBox the indicator of a TQCheckBox. - \value CE_CheckBoxLabel the label (text or pixmap) of a TQCheckBox. - - \value CE_RadioButton the indicator of a TQRadioButton. - \value CE_RadioButtonLabel the label (text or pixmap) of a TQRadioButton. - - \value CE_TabBarTab the tab within a TQTabBar (a TQTab). - \value CE_TabBarLabel the label within a TQTab. - - \value CE_ProgressBarGroove the groove where the progress - indicator is drawn in a TQProgressBar. - \value CE_ProgressBarContents the progress indicator of a TQProgressBar. - \value CE_ProgressBarLabel the text label of a TQProgressBar. - - \value CE_PopupMenuItem a menu item in a TQPopupMenu. - \value CE_PopupMenuScroller scrolling areas in a popumenu when the - style supports scrolling. - \value CE_PopupMenuHorizontalExtra extra frame area set aside with PM_PopupMenuFrameHorizontalExtra - \value CE_PopupMenuVerticalExtra extra frame area set aside with PM_PopupMenuFrameVerticalExtra - - \value CE_MenuBarItem a menu item in a TQMenuBar. - - \value CE_ToolButtonLabel a tool button's label. - - \value CE_MenuBarEmptyArea the empty area of a TQMenuBar. - \value CE_DockWindowEmptyArea the empty area of a TQDockWindow. - - \value CE_ToolBoxTab the toolbox's tab area - \value CE_HeaderLabel the header's label - - \value CE_CustomBase base value for custom ControlElements. All values above - this are reserved for custom use. Therefore, custom values must be - greater than this value. - - \sa drawControl() -*/ - -/*! - \fn void TQStyle::drawControl( ControlElement element, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, const TQStyleOption& opt, const TQWidget *widget) const - - Draws the ControlElement \a element using the painter \a p in the - area \a r. Colors are used from the color group \a cg. - - The rect \a r should be in screen coordinates. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a how argument is used to control how the ControlElement is - drawn. Multiple flags can be OR'ed together. See the table below - for an explanation of which flags are used with the various - ControlElements. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. Note that usage of the widget argument is deprecated - in favor of specifying widget parameters via \a ceData and \a elementFlags. - The widget can be cast to the appropriate type based - on the value of \a element. The \a opt argument can be used to - pass extra information required when drawing the ControlElement. - Note that \a opt may be the default value even for ControlElements - that can make use of the extra options. See the table below for - the appropriate \a widget and \a opt usage: - - \table - \header \i ControlElement
\& Widget Cast - \i Style Flags - \i Notes - \i Options - \i Notes - - \row \i16 \l{CE_PushButton}(const \l TQPushButton *) - - and - - \l{CE_PushButtonLabel}(const \l TQPushButton *) - \i \l Style_Enabled \i Set if the button is enabled. - \i16 Unused. - \i16   - \row \i \l Style_HasFocus \i Set if the button has input focus. - \row \i \l Style_Raised \i Set if the button is not down, not on and not flat. - \row \i \l Style_On \i Set if the button is a toggle button and toggled on. - \row \i \l Style_Down \i Set if the button is down (i.e., the mouse button or - space bar is pressed on the button). - \row \i \l Style_ButtonDefault \i Set if the button is a default button. - - \row \i16 \l{CE_CheckBox}(const \l TQCheckBox *) - - and - - \l{CE_CheckBoxLabel}(const \l TQCheckBox *) - - \i \l Style_Enabled \i Set if the checkbox is enabled. - \i16 Unused. - \i16   - \row \i \l Style_HasFocus \i Set if the checkbox has input focus. - \row \i \l Style_On \i Set if the checkbox is checked. - \row \i \l Style_Off \i Set if the checkbox is not checked. - \row \i \l Style_NoChange \i Set if the checkbox is in the NoChange state. - \row \i \l Style_Down \i Set if the checkbox is down (i.e., the mouse button or - space bar is pressed on the button). - - \row \i15 \l{CE_RadioButton}(const TQRadioButton *) - - and - - \l{CE_RadioButtonLabel}(const TQRadioButton *) - \i \l Style_Enabled \i Set if the radiobutton is enabled. - \i15 Unused. - \i15   - \row \i \l Style_HasFocus \i Set if the radiobutton has input focus. - \row \i \l Style_On \i Set if the radiobutton is checked. - \row \i \l Style_Off \i Set if the radiobutton is not checked. - \row \i \l Style_Down \i Set if the radiobutton is down (i.e., the mouse - button or space bar is pressed on the radiobutton). - - \row \i12 \l{CE_TabBarTab}(const \l TQTabBar *) - - and - - \l{CE_TabBarLabel}(const \l TQTabBar *) - - \i \l Style_Enabled \i Set if the tabbar and tab is enabled. - \i12 \l TQStyleOption ( \l TQTab *t ) - \list - \i opt.\link TQStyleOption::tab() tab\endlink() - \endlist - \i12 \e t is the TQTab being drawn. - \row \i \l Style_Selected \i Set if the tab is the current tab. - - \row \i12 \l{CE_ProgressBarGroove}(const TQProgressBar *) - - and - - \l{CE_ProgressBarContents}(const TQProgressBar *) - - and - - \l{CE_ProgressBarLabel}(const TQProgressBar *) - - \i \l Style_Enabled \i Set if the progressbar is enabled. - \i12 Unused. - \i12   - \row \i \l Style_HasFocus \i Set if the progressbar has input focus. - - \row \i13 \l{CE_PopupMenuItem}(const \l TQPopupMenu *) - \i \l Style_Enabled \i Set if the menuitem is enabled. - \i13 \l TQStyleOption ( TQMenuItem *mi, int tabwidth, int maxpmwidth ) - \list - \i opt.\link TQStyleOption::menuItem() menuItem\endlink() - \i opt.\link TQStyleOption::tabWidth() tabWidth\endlink() - \i opt.\link TQStyleOption::maxIconWidth() maxIconWidth\endlink() - \endlist - \i \e mi is the menu item being drawn. TQMenuItem is currently an - internal class. - \row \i \l Style_Active \i Set if the menuitem is the current item. - \i \e tabwidth is the width of the tab column where key accelerators - are drawn. - \row \i \l Style_Down \i Set if the menuitem is down (i.e., the mouse button - or space bar is pressed). - \i \e maxpmwidth is the maximum width of the check column where - checkmarks and iconsets are drawn. - - \row \i14 \l{CE_MenuBarItem}(const \l TQMenuBar *) - \i \l Style_Enabled \i Set if the menuitem is enabled - \i14 \l TQStyleOption ( TQMenuItem *mi ) - \list - \i opt.\link TQStyleOption::menuItem() menuItem\endlink() - \endlist - \i14 \e mi is the menu item being drawn. - \row \i \l Style_Active \i Set if the menuitem is the current item. - \row \i \l Style_Down \i Set if the menuitem is down (i.e., a mouse button or - the space bar is pressed). - \row \i \l Style_HasFocus \i Set if the menubar has input focus. - - \row \i17 \l{CE_ToolButtonLabel}(const \l TQToolButton *) - \i \l Style_Enabled \i Set if the toolbutton is enabled. - \i17 \l TQStyleOption ( \l ArrowType t ) - \list - \i opt.\link TQStyleOption::arrowType() arrowType\endlink() - \endlist - \i17 When the tool button only contains an arrow, \e t is the - arrow's type. - \row \i \l Style_HasFocus \i Set if the toolbutton has input focus. - \row \i \l Style_Down \i Set if the toolbutton is down (i.e., a - mouse button or the space is pressed). - \row \i \l Style_On \i Set if the toolbutton is a toggle button - and is toggled on. - \row \i \l Style_AutoRaise \i Set if the toolbutton has auto-raise enabled. - \row \i \l Style_MouseOver \i Set if the mouse pointer is over the toolbutton. - \row \i \l Style_Raised \i Set if the button is not down, not on and doesn't - contain the mouse when auto-raise is enabled. - \endtable - - \sa ControlElement, StyleFlags -*/ - -/*! - \fn void TQStyle::drawControlMask( ControlElement element, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQStyleOption& opt, const TQWidget *widget) const - - Draw a bitmask for the ControlElement \a element using the painter - \a p in the area \a r. See drawControl() for an explanation of the - use of the \a widget and \a opt arguments. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The rect \a r should be in screen coordinates. - - \a widget is deprecated and should not be used. - - \sa drawControl(), ControlElement -*/ - -/*! - \enum TQStyle::SubRect - - This enum represents a sub-area of a widget. Style implementations - would use these areas to draw the different parts of a widget. - - \value SR_PushButtonContents area containing the label (iconset - with text or pixmap). - \value SR_PushButtonFocusRect area for the focus rect (usually - larger than the contents rect). - - \value SR_CheckBoxIndicator area for the state indicator (e.g. check mark). - \value SR_CheckBoxContents area for the label (text or pixmap). - \value SR_CheckBoxFocusRect area for the focus indicator. - - - \value SR_RadioButtonIndicator area for the state indicator. - \value SR_RadioButtonContents area for the label. - \value SR_RadioButtonFocusRect area for the focus indicator. - - - \value SR_ComboBoxFocusRect area for the focus indicator. - - - \value SR_SliderFocusRect area for the focus indicator. - - - \value SR_DockWindowHandleRect area for the tear-off handle. - - - \value SR_ProgressBarGroove area for the groove. - \value SR_ProgressBarContents area for the progress indicator. - \value SR_ProgressBarLabel area for the text label. - - - \value SR_ToolButtonContents area for the tool button's label. - - \value SR_DialogButtonAccept area for a dialog's accept button. - \value SR_DialogButtonReject area for a dialog's reject button. - \value SR_DialogButtonApply area for a dialog's apply button. - \value SR_DialogButtonHelp area for a dialog's help button. - \value SR_DialogButtonAll area for a dialog's all button. - \value SR_DialogButtonRetry area for a dialog's retry button. - \value SR_DialogButtonAbort area for a dialog's abort button. - \value SR_DialogButtonIgnore area for a dialog's ignore button. - \value SR_DialogButtonCustom area for a dialog's custom widget area (in button row). - - \value SR_ToolBoxTabContents area for a toolbox tab's icon and label - - \value SR_CustomBase base value for custom ControlElements. All values above - this are reserved for custom use. Therefore, custom values must be - greater than this value. - - \sa subRect() -*/ - -/*! - \fn TQRect TQStyle::subRect( SubRect subrect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const; - - Returns the sub-area \a subrect for the \a widget in logical - coordinates. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. Note that usage of \a widget is deprecated in favor - of \a ceData and \a elementFlags. The widget can be cast to the - appropriate type based on the value of \a subrect. See the table - below for the appropriate \a widget casts: - - \table - \header \i SubRect \i Widget Cast - \row \i \l SR_PushButtonContents \i (const \l TQPushButton *) - \row \i \l SR_PushButtonFocusRect \i (const \l TQPushButton *) - \row \i \l SR_CheckBoxIndicator \i (const \l TQCheckBox *) - \row \i \l SR_CheckBoxContents \i (const \l TQCheckBox *) - \row \i \l SR_CheckBoxFocusRect \i (const \l TQCheckBox *) - \row \i \l SR_RadioButtonIndicator \i (const \l TQRadioButton *) - \row \i \l SR_RadioButtonContents \i (const \l TQRadioButton *) - \row \i \l SR_RadioButtonFocusRect \i (const \l TQRadioButton *) - \row \i \l SR_ComboBoxFocusRect \i (const \l TQComboBox *) - \row \i \l SR_DockWindowHandleRect \i (const \l TQWidget *) - \row \i \l SR_ProgressBarGroove \i (const \l TQProgressBar *) - \row \i \l SR_ProgressBarContents \i (const \l TQProgressBar *) - \row \i \l SR_ProgressBarLabel \i (const \l TQProgressBar *) - \endtable - - The tear-off handle (SR_DockWindowHandleRect) for TQDockWindow - is a private class. Use TQWidget::parentWidget() to access the - TQDockWindow: - - \code - if ( !widget->parentWidget() ) - return; - const TQDockWindow *dw = (const TQDockWindow *) widget->parentWidget(); - \endcode - - \sa SubRect -*/ - -/*! - \enum TQStyle::ComplexControl - - This enum represents a ComplexControl. ComplexControls have - different behaviour depending upon where the user clicks on them - or which keys are pressed. - - \value CC_SpinWidget - \value CC_ComboBox - \value CC_ScrollBar - \value CC_Slider - \value CC_ToolButton - \value CC_TitleBar - \value CC_ListView - - - \value CC_CustomBase base value for custom ControlElements. All - values above this are reserved for custom use. Therefore, - custom values must be greater than this value. - - \sa SubControl drawComplexControl() -*/ - -/*! - \enum TQStyle::SubControl - - This enum represents a SubControl within a ComplexControl. - - \value SC_None special value that matches no other SubControl. - - - \value SC_ScrollBarAddLine scrollbar add line (i.e. down/right - arrow); see also TQScrollbar. - \value SC_ScrollBarSubLine scrollbar sub line (i.e. up/left arrow). - \value SC_ScrollBarAddPage scrollbar add page (i.e. page down). - \value SC_ScrollBarSubPage scrollbar sub page (i.e. page up). - \value SC_ScrollBarFirst scrollbar first line (i.e. home). - \value SC_ScrollBarLast scrollbar last line (i.e. end). - \value SC_ScrollBarSlider scrollbar slider handle. - \value SC_ScrollBarGroove special subcontrol which contains the - area in which the slider handle may move. - - - \value SC_SpinWidgetUp spinwidget up/increase; see also TQSpinBox. - \value SC_SpinWidgetDown spinwidget down/decrease. - \value SC_SpinWidgetFrame spinwidget frame. - \value SC_SpinWidgetEditField spinwidget edit field. - \value SC_SpinWidgetButtonField spinwidget button field. - - - \value SC_ComboBoxEditField combobox edit field; see also TQComboBox. - \value SC_ComboBoxArrow combobox arrow - \value SC_ComboBoxFrame combobox frame - \value SC_ComboBoxListBoxPopup combobox list box - - \value SC_SliderGroove special subcontrol which contains the area - in which the slider handle may move. - \value SC_SliderHandle slider handle. - \value SC_SliderTickmarks slider tickmarks. - - - \value SC_ToolButton tool button; see also TQToolbutton. - \value SC_ToolButtonMenu subcontrol for opening a popup menu in a - tool button; see also TQPopupMenu. - - - \value SC_TitleBarSysMenu system menu button (i.e. restore, close, etc.). - \value SC_TitleBarMinButton minimize button. - \value SC_TitleBarMaxButton maximize button. - \value SC_TitleBarCloseButton close button. - \value SC_TitleBarLabel window title label. - \value SC_TitleBarNormalButton normal (restore) button. - \value SC_TitleBarShadeButton shade button. - \value SC_TitleBarUnshadeButton unshade button. - - - \value SC_ListView the list view area. - \value SC_ListViewBranch (internal) - \value SC_ListViewExpand expand item (i.e. show/hide child items). - - - \value SC_All special value that matches all SubControls. - - - \sa ComplexControl -*/ - -/*! - \fn void TQStyle::drawComplexControl( ComplexControl control, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const TQStyleOption& opt, const TQWidget *widget ) const - - Draws the ComplexControl \a control using the painter \a p in the - area \a r. Colors are used from the color group \a cg. The \a sub - argument specifies which SubControls to draw. Multiple SubControls - can be OR'ed together. The \a subActive argument specifies which - SubControl is active. - - The rect \a r should be in logical coordinates. Reimplementations - of this function should use visualRect() to change the logical - coordinates into screen coordinates when using drawPrimitive() and - drawControl(). - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a how argument is used to control how the ComplexControl is - drawn. Multiple flags can OR'ed together. See the table below for - an explanation of which flags are used with the various - ComplexControls. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a control. Note that usage of \a widget is - deprecated in favor of \a ceData and \a elementFlags. The \a opt - argument can be used to pass extra information required when - drawing the ComplexControl. Note that \a opt may be the default - value even for ComplexControls that can make use of the extra - options. See the table below for the appropriate \a widget and - \a opt usage: - - \table - \header \i ComplexControl
\& Widget Cast - \i Style Flags - \i Notes - \i Options - \i Notes - - \row \i12 \l{CC_SpinWidget}(const TQSpinWidget *) - \i \l Style_Enabled \i Set if the spinwidget is enabled. - \i12 Unused. - \i12   - \row \i \l Style_HasFocus \i Set if the spinwidget has input focus. - - \row \i12 \l{CC_ComboBox}(const \l TQComboBox *) - \i \l Style_Enabled \i Set if the combobox is enabled. - \i12 Unused. - \i12   - \row \i \l Style_HasFocus \i Set if the combobox has input focus. - - \row \i12 \l{CC_ScrollBar}(const \l TQScrollBar *) - \i \l Style_Enabled \i Set if the scrollbar is enabled. - \i12 Unused. - \i12   - \row \i \l Style_HasFocus \i Set if the scrollbar has input focus. - - \row \i12 \l{CC_Slider}(const \l TQSlider *) - \i \l Style_Enabled \i Set if the slider is enabled. - \i12 Unused. - \i12   - - \row \i \l Style_HasFocus \i Set if the slider has input focus. - - \row \i16 \l{CC_ToolButton}(const \l TQToolButton *) - \i \l Style_Enabled \i Set if the toolbutton is enabled. - \i16 \l TQStyleOption ( \l ArrowType t ) - \list - \i opt.\link TQStyleOption::arrowType() arrowType\endlink() - \endlist - \i16 When the tool button only contains an arrow, \e t is the - arrow's type. - \row \i \l Style_HasFocus \i Set if the toolbutton has input focus. - \row \i \l Style_Down \i Set if the toolbutton is down (ie. mouse - button or space pressed). - \row \i \l Style_On \i Set if the toolbutton is a toggle button - and is toggled on. - \row \i \l Style_AutoRaise \i Set if the toolbutton has auto-raise enabled. - \row \i \l Style_Raised \i Set if the button is not down, not on and doesn't - contain the mouse when auto-raise is enabled. - - \row \i \l{CC_TitleBar}(const \l TQWidget *) - \i \l Style_Enabled \i Set if the titlebar is enabled. - \i Unused. - \i   - - \row \i \l{CC_ListView}(const \l TQListView *) - \i \l Style_Enabled \i Set if the titlebar is enabled. - \i \l TQStyleOption ( \l TQListViewItem *item ) - \list - \i opt.\link TQStyleOption::listViewItem() listViewItem\endlink() - \endlist - \i \e item is the item that needs branches drawn - \endtable - - \sa ComplexControl, SubControl -*/ - -/*! - \fn void TQStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQRect &r, const TQStyleOption& opt, const TQWidget *widget) const - - Draw a bitmask for the ComplexControl \a control using the painter - \a p in the area \a r. See drawComplexControl() for an explanation - of the use of the \a widget and \a opt arguments. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The rect \a r should be in logical coordinates. Reimplementations - of this function should use visualRect() to change the logical - corrdinates into screen coordinates when using drawPrimitive() and - drawControl(). - - Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. - - \sa drawComplexControl() ComplexControl -*/ - -/*! - \fn TQRect TQStyle::querySubControlMetrics( ComplexControl control, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, SubControl subcontrol, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - - Returns the rect for the SubControl \a subcontrol for \a widget in - logical coordinates. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a control. The \a opt argument can be used to - pass extra information required when drawing the ComplexControl. - Note that \a opt may be the default value even for ComplexControls - that can make use of the extra options. See drawComplexControl() - for an explanation of the \a widget and \a opt arguments. - - Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. - - \sa drawComplexControl(), ComplexControl, SubControl -*/ - -/*! - \fn SubControl TQStyle::querySubControl( ComplexControl control, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQPoint &pos, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - - Returns the SubControl for \a widget at the point \a pos. The \a - widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a control. The \a opt argument can be used to - pass extra information required when drawing the ComplexControl. - Note that \a opt may be the default value even for ComplexControls - that can make use of the extra options. See drawComplexControl() - for an explanation of the \a widget and \a opt arguments. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - Note that \a pos is passed in screen coordinates. When using - querySubControlMetrics() to check for hits and misses, use - visualRect() to change the logical coordinates into screen - coordinates. - - Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. - - \sa drawComplexControl(), ComplexControl, SubControl, querySubControlMetrics() -*/ - -/*! - \enum TQStyle::PixelMetric - - This enum represents a PixelMetric. A PixelMetric is a style - dependent size represented as a single pixel value. - - \value PM_ButtonMargin amount of whitespace between pushbutton - labels and the frame. - \value PM_ButtonDefaultIndicator width of the default-button indicator frame. - \value PM_MenuButtonIndicator width of the menu button indicator - proportional to the widget height. - \value PM_ButtonShiftHorizontal horizontal contents shift of a - button when the button is down. - \value PM_ButtonShiftVertical vertical contents shift of a button when the - button is down. - - \value PM_DefaultFrameWidth default frame width, usually 2. - \value PM_SpinBoxFrameWidth frame width of a spin box. - \value PM_MDIFrameWidth frame width of an MDI window. - \value PM_MDIMinimizedWidth width of a minimized MSI window. - - \value PM_MaximumDragDistance Some feels require the scrollbar or - other sliders to jump back to the original position when the - mouse pointer is too far away while dragging. A value of -1 - disables this behavior. - - \value PM_ScrollBarExtent width of a vertical scrollbar and the - height of a horizontal scrollbar. - \value PM_ScrollBarSliderMin the minimum height of a vertical - scrollbar's slider and the minimum width of a horiztonal - scrollbar slider. - - \value PM_SliderThickness total slider thickness. - \value PM_SliderControlThickness thickness of the slider handle. - \value PM_SliderLength length of the slider. - \value PM_SliderTickmarkOffset the offset between the tickmarks - and the slider. - \value PM_SliderSpaceAvailable the available space for the slider to move. - - \value PM_DockWindowSeparatorExtent width of a separator in a - horiztonal dock window and the height of a separator in a - vertical dock window. - \value PM_DockWindowHandleExtent width of the handle in a - horizontal dock window and the height of the handle in a - vertical dock window. - \value PM_DockWindowFrameWidth frame width of a dock window. - - \value PM_MenuBarFrameWidth frame width of a menubar. - - \value PM_MenuBarItemSpacing spacing between menubar items. - \value PM_ToolBarItemSpacing spacing between toolbar items. - - \value PM_TabBarTabOverlap number of pixels the tabs should overlap. - \value PM_TabBarTabHSpace extra space added to the tab width. - \value PM_TabBarTabVSpace extra space added to the tab height. - \value PM_TabBarBaseHeight height of the area between the tab bar - and the tab pages. - \value PM_TabBarBaseOverlap number of pixels the tab bar overlaps - the tab bar base. - \value PM_TabBarScrollButtonWidth - \value PM_TabBarTabShiftHorizontal horizontal pixel shift when a - tab is selected. - \value PM_TabBarTabShiftVertical vertical pixel shift when a - tab is selected. - - \value PM_ProgressBarChunkWidth width of a chunk in a progress bar indicator. - - \value PM_SplitterWidth width of a splitter. - - \value PM_TitleBarHeight height of the title bar. - \value PM_PopupMenuFrameHorizontalExtra additional border, e.g. for panels - \value PM_PopupMenuFrameVerticalExtra additional border, e.g. for panels - - \value PM_IndicatorWidth width of a check box indicator. - \value PM_IndicatorHeight height of a checkbox indicator. - \value PM_ExclusiveIndicatorWidth width of a radio button indicator. - \value PM_ExclusiveIndicatorHeight height of a radio button indicator. - - \value PM_PopupMenuScrollerHeight height of the scroller area in a popupmenu. - \value PM_PopupMenuScrollerHeight height of the scroller area in a popupmenu. - \value PM_CheckListButtonSize area (width/height) of the - checkbox/radiobutton in a TQCheckListItem - \value PM_CheckListControllerSize area (width/height) of the - controller in a TQCheckListItem - - \value PM_DialogButtonsSeparator distance between buttons in a dialog buttons widget. - \value PM_DialogButtonsButtonWidth minimum width of a button in a dialog buttons widget. - \value PM_DialogButtonsButtonHeight minimum height of a button in a dialog buttons widget. - - \value PM_HeaderMarkSize - \value PM_HeaderGripMargin - \value PM_HeaderMargin - - \value PM_CustomBase base value for custom ControlElements. All - values above this are reserved for custom use. Therefore, - custom values must be greater than this value. - - - \sa pixelMetric() -*/ - -/*! - \fn int TQStyle::pixelMetric( PixelMetric metric, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const; - - Returns the pixel metric for \a metric. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a metric. Note that \a widget may be zero even - for PixelMetrics that can make use of \a widget. Note also that - usage of \a widget is deprecated in favor of \a ceData and - \a elementFlags. See the table below for the appropriate - \a widget casts: - - \table - \header \i PixelMetric \i Widget Cast - \row \i \l PM_SliderControlThickness \i (const \l TQSlider *) - \row \i \l PM_SliderLength \i (const \l TQSlider *) - \row \i \l PM_SliderTickmarkOffset \i (const \l TQSlider *) - \row \i \l PM_SliderSpaceAvailable \i (const \l TQSlider *) - \row \i \l PM_TabBarTabOverlap \i (const \l TQTabBar *) - \row \i \l PM_TabBarTabHSpace \i (const \l TQTabBar *) - \row \i \l PM_TabBarTabVSpace \i (const \l TQTabBar *) - \row \i \l PM_TabBarBaseHeight \i (const \l TQTabBar *) - \row \i \l PM_TabBarBaseOverlap \i (const \l TQTabBar *) - \endtable -*/ - -/*! - \enum TQStyle::ContentsType - - This enum represents a ContentsType. It is used to calculate sizes - for the contents of various widgets. - - \value CT_PushButton - \value CT_CheckBox - \value CT_RadioButton - \value CT_ToolButton - \value CT_ComboBox - \value CT_Splitter - \value CT_DockWindow - \value CT_ProgressBar - \value CT_PopupMenuItem - \value CT_TabBarTab - \value CT_Slider - \value CT_Header - \value CT_LineEdit - \value CT_MenuBar - \value CT_SpinBox - \value CT_SizeGrip - \value CT_TabWidget - \value CT_DialogButtons - - \value CT_CustomBase base value for custom ControlElements. All - values above this are reserved for custom use. Custom values - must be greater than this value. - - \sa sizeFromContents() -*/ - -/*! - \fn TQSize TQStyle::sizeFromContents( ContentsType contents, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQSize &contentsSize, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - - Returns the size of \a widget based on the contents size \a - contentsSize. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a contents. The \a opt argument can be used to - pass extra information required when calculating the size. Note - that \a opt may be the default value even for ContentsTypes that - can make use of the extra options. Note that usage of \a widget - is deprecated in favor of \a ceData and \a elementFlags. See the - table below for the appropriate \a widget and \a opt usage: - - \table - \header \i ContentsType \i Widget Cast \i Options \i Notes - \row \i \l CT_PushButton \i (const \l TQPushButton *) \i Unused. \i   - \row \i \l CT_CheckBox \i (const \l TQCheckBox *) \i Unused. \i   - \row \i \l CT_RadioButton \i (const \l TQRadioButton *) \i Unused. \i   - \row \i \l CT_ToolButton \i (const \l TQToolButton *) \i Unused. \i   - \row \i \l CT_ComboBox \i (const \l TQComboBox *) \i Unused. \i   - \row \i \l CT_Splitter \i (const \l TQSplitter *) \i Unused. \i   - \row \i \l CT_DockWindow \i (const \l TQDockWindow *) \i Unused. \i   - \row \i \l CT_ProgressBar \i (const \l TQProgressBar *) \i Unused. \i   - \row \i \l CT_PopupMenuItem \i (const TQPopupMenu *) - \i \l TQStyleOption ( TQMenuItem *mi ) - \list - \i opt.\link TQStyleOption::menuItem() menuItem\endlink() - \endlist - \i \e mi is the menu item to use when calculating the size. - TQMenuItem is currently an internal class. - \endtable -*/ - -/*! - \enum TQStyle::StyleHint - - This enum represents a StyleHint. A StyleHint is a general look - and/or feel hint. - - \value SH_EtchDisabledText disabled text is "etched" like Windows. - - \value SH_GUIStyle the GUI style to use. - - \value SH_ScrollBar_BackgroundMode the background mode for a - TQScrollBar. Possible values are any of those in the \link - TQt::BackgroundMode BackgroundMode\endlink enum. - - \value SH_ScrollBar_MiddleClickAbsolutePosition a boolean value. - If TRUE, middle clicking on a scrollbar causes the slider to - jump to that position. If FALSE, the middle clicking is - ignored. - - \value SH_ScrollBar_LeftClickAbsolutePosition a boolean value. - If TRUE, left clicking on a scrollbar causes the slider to - jump to that position. If FALSE, the left clicking will - behave as appropriate for each control. - - \value SH_ScrollBar_ScrollWhenPointerLeavesControl a boolean - value. If TRUE, when clicking a scrollbar SubControl, holding - the mouse button down and moving the pointer outside the - SubControl, the scrollbar continues to scroll. If FALSE, the - scollbar stops scrolling when the pointer leaves the - SubControl. - - \value SH_TabBar_Alignment the alignment for tabs in a - TQTabWidget. Possible values are \c TQt::AlignLeft, \c - TQt::AlignCenter and \c TQt::AlignRight. - - \value SH_Header_ArrowAlignment the placement of the sorting - indicator may appear in list or table headers. Possible values - are \c TQt::Left or \c TQt::Right. - - \value SH_Slider_SnapToValue sliders snap to values while moving, - like Windows - - \value SH_Slider_SloppyKeyEvents key presses handled in a sloppy - manner, i.e. left on a vertical slider subtracts a line. - - \value SH_ProgressDialog_CenterCancelButton center button on - progress dialogs, like Motif, otherwise right aligned. - - \value SH_ProgressDialog_TextLabelAlignment TQt::AlignmentFlags -- - text label alignment in progress dialogs; Center on windows, - Auto|VCenter otherwise. - - \value SH_PrintDialog_RightAlignButtons right align buttons in - the print dialog, like Windows. - - \value SH_MainWindow_SpaceBelowMenuBar 1 or 2 pixel space between - the menubar and the dockarea, like Windows. - - \value SH_FontDialog_SelectAssociatedText select the text in the - line edit, or when selecting an item from the listbox, or when - the line edit receives focus, like Windows. - - \value SH_PopupMenu_AllowActiveAndDisabled allows disabled menu - items to be active. - - \value SH_PopupMenu_SpaceActivatesItem pressing Space activates - the item, like Motif. - - \value SH_PopupMenu_SubMenuPopupDelay the number of milliseconds - to wait before opening a submenu; 256 on windows, 96 on Motif. - - \value SH_PopupMenu_Scrollable whether popupmenu's must support - scrolling. - - \value SH_PopupMenu_SloppySubMenus whether popupmenu's must support - sloppy submenu; as implemented on Mac OS. - - \value SH_ScrollView_FrameOnlyAroundContents whether scrollviews - draw their frame only around contents (like Motif), or around - contents, scrollbars and corner widgets (like Windows). - - \value SH_MenuBar_AltKeyNavigation menubars items are navigable - by pressing Alt, followed by using the arrow keys to select - the desired item. - - \value SH_ComboBox_ListMouseTracking mouse tracking in combobox - dropdown lists. - - \value SH_PopupMenu_MouseTracking mouse tracking in popup menus. - - \value SH_MenuBar_MouseTracking mouse tracking in menubars. - - \value SH_ItemView_ChangeHighlightOnFocus gray out selected items - when losing focus. - - \value SH_Widget_ShareActivation turn on sharing activation with - floating modeless dialogs. - - \value SH_TabBar_SelectMouseType which type of mouse event should - cause a tab to be selected. - - \value SH_ListViewExpand_SelectMouseType which type of mouse event should - cause a listview expansion to be selected. - - \value SH_TabBar_PreferNoArrows whether a tabbar should suggest a size - to prevent scoll arrows. - - \value SH_ComboBox_Popup allows popups as a combobox dropdown - menu. - - \value SH_Workspace_FillSpaceOnMaximize the workspace should - maximize the client area. - - \value SH_TitleBar_NoBorder the titlebar has no border - - \value SH_ScrollBar_StopMouseOverSlider stops autorepeat when - slider reaches mouse - - \value SH_BlinkCursorWhenTextSelected whether cursor should blink - when text is selected - - \value SH_RichText_FullWidthSelection whether richtext selections - should extend the full width of the document. - - \value SH_GroupBox_TextLabelVerticalAlignment how to vertically align a - groupbox's text label. - - \value SH_GroupBox_TextLabelColor how to paint a groupbox's text label. - - \value SH_DialogButtons_DefaultButton which buttons gets the - default status in a dialog's button widget. - - \value SH_CustomBase base value for custom ControlElements. All - values above this are reserved for custom use. Therefore, - custom values must be greater than this value. - - \value SH_ToolButton_Uses3D indicates whether TQToolButtons should - use a 3D frame when the mouse is over them - - \value SH_ToolBox_SelectedPageTitleBold Boldness of the selected - page title in a TQToolBox. - - \value SH_LineEdit_PasswordCharacter The TQChar Unicode character - to be used for passwords. - - \value SH_Table_GridLineColor - - \value SH_UnderlineAccelerator whether accelerators are underlined - - \sa styleHint() -*/ - -/*! - \fn int TQStyle::styleHint( StyleHint stylehint, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQStyleOption &opt = TQStyleOption::Default, TQStyleHintReturn *returnData = 0, const TQWidget *widget = 0 ) const; - - Returns the style hint \a stylehint for \a widget. Currently, \a - widget, \a opt, and \a returnData are unused; they're included to - allow for future enhancements. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - Note that usage of \a widget is deprecated in favor of \a ceData - and \a elementFlags. - - For an explanation of the return value see \l StyleHint. -*/ - -/*! - \enum TQStyle::StylePixmap - - This enum represents a StylePixmap. A StylePixmap is a pixmap that - can follow some existing GUI style or guideline. - - - \value SP_TitleBarMinButton minimize button on titlebars. For - example, in a TQWorkspace. - \value SP_TitleBarMaxButton maximize button on titlebars. - \value SP_TitleBarCloseButton close button on titlebars. - \value SP_TitleBarNormalButton normal (restore) button on titlebars. - \value SP_TitleBarShadeButton shade button on titlebars. - \value SP_TitleBarUnshadeButton unshade button on titlebars. - \value SP_MessageBoxInformation the 'information' icon. - \value SP_MessageBoxWarning the 'warning' icon. - \value SP_MessageBoxCritical the 'critical' icon. - \value SP_MessageBoxQuestion the 'question' icon. - - - \value SP_DockWindowCloseButton close button on dock windows; - see also TQDockWindow. - - - \value SP_CustomBase base value for custom ControlElements. All - values above this are reserved for custom use. Therefore, - custom values must be greater than this value. - - \sa stylePixmap() -*/ - -/*! - \fn TQPixmap TQStyle::stylePixmap( StylePixmap stylepixmap, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - - Returns a pixmap for \a stylepixmap. - - \a ceData and \a elementFlags provide additional information about - the widget for which the PrimitiveElement is being drawn. - - The \a opt argument can be used to pass extra information required - when drawing the ControlElement. Note that \a opt may be the - default value even for StylePixmaps that can make use of the extra - options. Currently, the \a opt argument is unused. - - The \a widget argument is a pointer to a TQWidget or one of its - subclasses. The widget can be cast to the appropriate type based - on the value of \a stylepixmap. Note that usage of \a widget is - deprecated in favor of \a ceData and \a elementFlags.See the table - below for the appropriate \a widget casts: - - \table - \header \i StylePixmap \i Widget Cast - \row \i \l SP_TitleBarMinButton \i (const \l TQWidget *) - \row \i \l SP_TitleBarMaxButton \i (const \l TQWidget *) - \row \i \l SP_TitleBarCloseButton \i (const \l TQWidget *) - \row \i \l SP_TitleBarNormalButton \i (const \l TQWidget *) - \row \i \l SP_TitleBarShadeButton \i (const \l TQWidget *) - \row \i \l SP_TitleBarUnshadeButton \i (const \l TQWidget *) - \row \i \l SP_DockWindowCloseButton \i (const \l TQDockWindow *) - \endtable - - \sa StylePixmap -*/ - -/*! - \fn TQRect TQStyle::visualRect( const TQRect &logical, const TQWidget *w ); - - Returns the rect \a logical in screen coordinates. The bounding - rect for widget \a w is used to perform the translation. This - function is provided to aid style implementors in supporting - right-to-left mode. - - Note that this function is deprecated in favor of visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ); - - \sa TQApplication::reverseLayout() -*/ -TQRect TQStyle::visualRect( const TQRect &logical, const TQWidget *w ) -{ - TQStyleControlElementData ceData; - ceData.rect = w->rect(); - return visualRect(logical, ceData, CEF_None); -} - -/*! - \fn TQRect TQStyle::visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ); - - Returns the rect \a logical in screen coordinates. The bounding - rect for the widget described by \a ceData and \a elementFlags - is used to perform the translation. This function is provided to - aid style implementors in supporting - right-to-left mode. - - \sa TQApplication::reverseLayout() -*/ -TQRect TQStyle::visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ) -{ - Q_UNUSED(elementFlags) - - TQRect boundingRect = ceData.rect; - TQRect r = logical; - if ( TQApplication::reverseLayout() ) - r.moveBy( 2*(boundingRect.right() - logical.right()) + - logical.width() - boundingRect.width(), 0 ); - return r; -} - -/*! - \overload TQRect TQStyle::visualRect( const TQRect &logical, const TQRect &bounding ); - - Returns the rect \a logical in screen coordinates. The rect \a - bounding is used to perform the translation. This function is - provided to aid style implementors in supporting right-to-left - mode. - - \sa TQApplication::reverseLayout() -*/ -TQRect TQStyle::visualRect( const TQRect &logical, const TQRect &boundingRect ) -{ - TQRect r = logical; - if ( TQApplication::reverseLayout() ) - r.moveBy( 2*(boundingRect.right() - logical.right()) + - logical.width() - boundingRect.width(), 0 ); - return r; -} - -/*! - \fn void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); - - Intercepts events generated by \a source and sends them to \a handler via - the bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) virtual method. - - \sa void TQStyle::removeObjectEventHandler( TQObject* source, TQStyle* handler ) - \sa bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) -*/ -void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) { - bool cbret = false; - if (m_eventHandlerInstallationHook) { - cbret = (*m_eventHandlerInstallationHook)(ceData, elementFlags, source, handler); - } - if (!cbret) { - if (ceData.widgetObjectTypes.contains("TQObject")) { - TQObject* o = reinterpret_cast(source); - o->installEventFilter(this); - m_objectEventSourceToHandlerMap[source] = handler; - m_objectEventSourceDataToHandlerMap[source] = ceData; - m_objectEventSourceFlagsToHandlerMap[source] = elementFlags; - } - } -} - -/*! - \fn void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); - - Stops intercepting events generated by \a source. - - \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) -*/ -void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) { - bool cbret = false; - if (m_eventHandlerRemovalHook) { - cbret = (*m_eventHandlerRemovalHook)(ceData, elementFlags, source, handler); - } - if (!cbret) { - if (ceData.widgetObjectTypes.contains("TQObject")) { - TQObject* o = reinterpret_cast(source); - m_objectEventSourceToHandlerMap.remove(source); - m_objectEventSourceDataToHandlerMap.remove(source); - m_objectEventSourceFlagsToHandlerMap.remove(source); - o->removeEventFilter(this); - } - } -} - -/*! - \fn void TQStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ); - - Sets a callback function \a hook which will be called whenever a new intercept request - is made via the TQStyle::installObjectEventHandler method. The callback function must - use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). - - \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) -*/ -void TQStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ) { - m_eventHandlerInstallationHook = hook; -} - -/*! - \fn void TQStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); - - Sets a callback function \a hook which will be called whenever a new intercept deactivation request - is made via the TQStyle::removeObjectEventHandler method. The callback function must - use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). - - \sa void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) -*/ -void TQStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ) { - m_eventHandlerRemovalHook = hook; -} - -/*! - \fn bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); - - Override this virtual function to intercept events requested by a previous call to - TQStyle::installObjectEventHandler. - - \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) - \sa void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) -*/ -bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) { - Q_UNUSED(ceData); - Q_UNUSED(elementFlags); - Q_UNUSED(source); - Q_UNUSED(e); - return false; -} - -/*! - \fn bool TQStyle::eventFilter(TQObject *o, TQEvent *e); - \internal -*/ -bool TQStyle::eventFilter(TQObject *o, TQEvent *e) { - acceleratorKeypressEventMonitor(o, e); - - if (m_objectEventSourceToHandlerMap.contains(o)) { - TQStyle* handler = m_objectEventSourceToHandlerMap[o]; - const TQStyleControlElementData &ceData = m_objectEventSourceDataToHandlerMap[o]; - ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; - bool ret; - TQWidget* w = dynamic_cast(o); - if (w) { - // Update ceData as widget parameters may have changed - // If not done glitches may appear such as those present in Bug 1816 - populateControlElementDataFromWidget(w, TQStyleOption()); - const TQStyleControlElementData &widgetCEData = *(w->controlElementDataObject()); - if (e->type() == TQEvent::Paint) { - TQPainter p(w); - TQPainter* activePainterOrig = widgetCEData.activePainter; - const_cast(widgetCEData).activePainter = &p; - ret = handler->objectEventHandler(widgetCEData, elementFlags, o, e); - const_cast(widgetCEData).activePainter = activePainterOrig; - } - else { - ret = handler->objectEventHandler(widgetCEData, elementFlags, o, e); - } - } - else { - ret = handler->objectEventHandler(ceData, elementFlags, o, e); - } - if (ret) { - return ret; - } - else { - return TQObject::eventFilter(o, e); - } - } - else { - return TQObject::eventFilter(o, e); - } -} - -/*! - \fn void TQStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ); - - Sets a callback function \a hook which will be called whenever a new widget action request - is made via the TQStyle::installObjectEventHandler method. The callback function must - use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). - - \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) -*/ -void TQStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ) { - m_widgetActionRequestHook = hook; -} - -/*! - \fn bool widgetActionRequestHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request ); - - Handles widget action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. -*/ -bool TQStyle::widgetActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData ) { - bool cbret = false; - if (m_widgetActionRequestHook) { - cbret = (*m_widgetActionRequestHook)(ceData, elementFlags, source, request, requestData); - } - if (!cbret) { - if (ceData.widgetObjectTypes.contains("TQWidget")) { - TQWidget* widget = reinterpret_cast(source); - if (request == WAR_Repaint) { - widget->repaint(FALSE); - } - else if (request == WAR_RepaintRect) { - widget->repaint(requestData.rect, FALSE); - } - else if (request == WAR_EnableMouseTracking) { - widget->setMouseTracking(TRUE); - } - else if (request == WAR_DisableMouseTracking) { - widget->setMouseTracking(FALSE); - } - else if (request == WAR_SetAutoMask) { - widget->setAutoMask(TRUE); - } - else if (request == WAR_UnSetAutoMask) { - widget->setAutoMask(FALSE); - } - else if (request == WAR_SetCheckable) { - TQPopupMenu *pm = dynamic_cast(widget); - if (pm) { - pm->setCheckable(TRUE); - } - } - else if (request == WAR_UnSetCheckable) { - TQPopupMenu *pm = dynamic_cast(widget); - if (pm) { - pm->setCheckable(FALSE); - } - } - else if (request == WAR_FrameSetStyle) { - TQFrame* frame = dynamic_cast(widget); - if (frame) { - frame->setFrameStyle(requestData.metric1); - } - } - else if (request == WAR_FrameSetLineWidth) { - TQFrame* frame = dynamic_cast(widget); - if (frame) { - frame->setLineWidth(requestData.metric1); - } - } - else if (request == WAR_SetLayoutMargin) { - TQLayout* layout = widget->layout(); - if (layout) { - layout->setMargin(requestData.metric1); - } - } - else if (request == WAR_SetPalette) { - widget->setPalette(requestData.palette); - } - else if (request == WAR_SetBackgroundMode) { - widget->setBackgroundMode((TQt::BackgroundMode)requestData.metric1); - } - else if (request == WAR_SetBackgroundOrigin) { - widget->setBackgroundOrigin((TQWidget::BackgroundOrigin)requestData.metric1); - } - else if (request == WAR_SetFont) { - widget->setFont(requestData.font); - } - else if (request == WAR_RepaintAllAccelerators) { - TQWidgetList *list = TQApplication::topLevelWidgets(); - TQWidgetListIt it( *list ); - TQWidget * widget; - while ((widget=it.current()) != 0) { - ++it; - - TQObjectList *l = widget->queryList("TQWidget"); - TQObjectListIt it2( *l ); - TQWidget *w; - while ( (w = (TQWidget*)it2.current()) != 0 ) { - ++it2; - if (w->isTopLevel() || !w->isVisible() || w->style().styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, w)) { - l->removeRef(w); - } - } - - // Repaint all relevant widgets - it2.toFirst(); - while ( (w = (TQWidget*)it2.current()) != 0 ) { - ++it2; - w->repaint(FALSE); - } - delete l; - } - delete list; - } - else if (request == WAR_SetDefault) { - TQPushButton *button = dynamic_cast(widget); - if (button) { - button->setDefault(TRUE); - } - } - else if (request == WAR_UnSetDefault) { - TQPushButton *button = dynamic_cast(widget); - if (button) { - button->setDefault(FALSE); - } - } - else if (request == WAR_SendPaintEvent) { - static_cast(widget)->event(requestData.paintEvent); - } - return true; - } - } - return true; -} - -/*! - \fn void TQStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ); - - Sets a callback function \a hook which will be called whenever a new application action request - is made via the TQStyle::installObjectEventHandler method. The callback function must - use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). - - \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) -*/ -void TQStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ) { - m_applicationActionRequestHook = hook; -} - -/*! - \fn bool applicationActionRequestHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request ); - - Handles application action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. -*/ -bool TQStyle::applicationActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData ) { - bool cbret = false; - if (m_applicationActionRequestHook) { - cbret = (*m_applicationActionRequestHook)(ceData, elementFlags, source, request, requestData); - } - if (!cbret) { - if (ceData.widgetObjectTypes.contains("TQApplication")) { - TQApplication* application = reinterpret_cast(source); - if (request == AAR_SetPalette) { - application->setPalette(requestData.palette, requestData.bool1, requestData.cstr); - } - else if (request == AAR_SetFont) { - application->setFont(requestData.font, requestData.bool1, requestData.cstr); - } - return true; - } - } - return true; -} - -void TQStyle::acceleratorKeypressEventMonitor( TQObject *o, TQEvent *e ) { - if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { - TQWidget *widget = dynamic_cast(o); - if (widget) { - switch(e->type()) { - case TQEvent::KeyPress: - if (((TQKeyEvent*)e)->key() == Key_Alt) { - conditionalAcceleratorsEnabled = true; - widgetActionRequest(TQStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); - } - break; - case TQEvent::KeyRelease: - if (((TQKeyEvent*)e)->key() == Key_Alt) { - conditionalAcceleratorsEnabled = false; - widgetActionRequest(TQStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); - } - break; - default: - break; - } - } - } - else { - conditionalAcceleratorsEnabled = false; - } -} - -bool TQStyle::acceleratorsShown() const { - if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { - return conditionalAcceleratorsEnabled; - } - else { - return true; - } -} - -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData() { - // -} -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(int param1, int param2) { - metric1 = param1; - metric2 = param2; -} - -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPalette param, bool informWidgets, const char* className) { - palette = param; - bool1 = informWidgets; - cstr = className; -} - -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQFont param, bool informWidgets, const char* className) { - font = param; - bool1 = informWidgets; - cstr = className; -} - -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQRect param) { - rect = param; -} - -TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPaintEvent* param) { - paintEvent = param; -} - -TQStyleWidgetActionRequestData::~TQStyleWidgetActionRequestData() { - // -} - -// ============================================================================================ -// Interface methods -// ============================================================================================ - -void TQStyle::drawPrimitive( PrimitiveElement pe, - TQPainter *p, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption& opt ) const -{ - const TQWidget* widget = 0; - - // Determine if the request needs widget information and set widget appropriately - // FIXME - if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { - TQCheckListItem *item = opt.checkListItem(); - if (item) { - TQListView *lv = item->listView(); - widget = dynamic_cast(lv); - } - } - - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, cg, flags, opt); -} - -void TQStyle::drawControl( ControlElement element, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - const TQStyleOption& opt ) const -{ -#if defined(QT_CHECK_STATE) - if (!widget) { - tqWarning("TQStyle::drawControl: widget parameter cannot be zero!"); - return; - } -#endif - - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - drawControl(element, p, ceData, getControlElementFlagsForObject(widget, opt), r, cg, flags, opt, widget); -} - -void TQStyle::drawControlMask( ControlElement control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& opt ) const -{ - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, opt), r, opt, widget); -} - -TQRect TQStyle::subRect(SubRect r, const TQWidget *widget) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQStyle::subRect: widget parameter cannot be zero!"); - return TQRect(); - } -#endif - - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); - return subRect(r, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); -} - -void TQStyle::drawComplexControl( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQColorGroup &cg, - SFlags flags, - SCFlags controls, - SCFlags active, - const TQStyleOption& opt ) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQStyle::drawComplexControl: widget parameter cannot be zero!"); - return; - } -#endif - - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, cg, flags, controls, active, opt, widget); -} - -void TQStyle::drawComplexControlMask( ComplexControl control, - TQPainter *p, - const TQWidget *widget, - const TQRect &r, - const TQStyleOption& opt ) const -{ - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, opt, widget); -} - -TQRect TQStyle::querySubControlMetrics( ComplexControl control, - const TQWidget *widget, - SubControl sc, - const TQStyleOption &opt ) const -{ -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQStyle::querySubControlMetrics: widget parameter cannot be zero!"); - return TQRect(); - } -#endif - - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt, false); - return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), sc, opt, widget); -} - -TQStyle::SubControl TQStyle::querySubControl(ComplexControl control, - const TQWidget *widget, - const TQPoint &pos, - const TQStyleOption& opt ) const -{ - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - return querySubControl(control, ceData, getControlElementFlagsForObject(widget, opt), pos, opt, widget); -} - -int TQStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const -{ - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption(), false); - return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); -} - -TQSize TQStyle::sizeFromContents(ContentsType contents, - const TQWidget *widget, - const TQSize &contentsSize, - const TQStyleOption& opt ) const -{ - TQSize sz(contentsSize); - -#if defined(QT_CHECK_STATE) - if (! widget) { - tqWarning("TQStyle::sizeFromContents: widget parameter cannot be zero!"); - return sz; - } -#endif - - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); - return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), contentsSize, opt, widget); -} - -int TQStyle::styleHint(StyleHint sh, const TQWidget * w, const TQStyleOption &so, TQStyleHintReturn *shr) const -{ - bool ceDataNotNeeded = false; - if (sh == SH_Widget_ShareActivation) { - ceDataNotNeeded = true; - } - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(w, so, false, ceDataNotNeeded); - return styleHint(sh, ceData, getControlElementFlagsForObject(w, TQStyleOption(), false), so, shr, w); -} - -TQPixmap TQStyle::stylePixmap(StylePixmap sp, const TQWidget *w, const TQStyleOption &so) const -{ - const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(w, so); - return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, TQStyleOption()), so, w); -} - -/*! - \fn int TQStyle::defaultFrameWidth() const - \obsolete -*/ - -/*! - \fn void TQStyle::tabbarMetrics( const TQWidget *, int &, int &, int & ) const - \obsolete -*/ - -/*! - \fn TQSize TQStyle::scrollBarExtent() const - \obsolete -*/ - -#ifndef TQT_NO_COMPAT -int TQStyle::defaultFrameWidth() const -{ - TQStyleControlElementData ceData; - return pixelMetric( PM_DefaultFrameWidth, ceData, CEF_None ); -} - -void TQStyle::tabbarMetrics( const TQWidget* t, int& hf, int& vf, int& ov ) const -{ - TQStyleControlElementData ceData; - hf = pixelMetric( PM_TabBarTabHSpace, ceData, CEF_None, t ); - vf = pixelMetric( PM_TabBarTabVSpace, ceData, CEF_None, t ); - ov = pixelMetric( PM_TabBarBaseOverlap, ceData, CEF_None, t ); -} - -TQSize TQStyle::scrollBarExtent() const -{ - TQStyleControlElementData ceData; - ceData.orientation = TQt::Horizontal; - return TQSize(pixelMetric(PM_ScrollBarExtent, ceData, CEF_None), - pixelMetric(PM_ScrollBarExtent, ceData, CEF_None)); -} -#endif - -TQStyleControlElementData::TQStyleControlElementData() { - isNull = true; - activePainter = 0; - tickMarkSetting = 0; - comboBoxLineEditFlags = 0; - frameStyle = 0; - comboBoxListBoxFlags = 0; - parentWidgetFlags = 0; - topLevelWidgetFlags = 0; -} - -TQStyleControlElementData::~TQStyleControlElementData() { - // -} - -TQStyleControlElementData::TQStyleControlElementData(const TQStyleControlElementData& orig) { - isNull = orig.isNull; - widgetObjectTypes = orig.widgetObjectTypes; - allDataPopulated = orig.allDataPopulated; - wflags = orig.wflags; - windowState = orig.windowState; - bgPixmap = orig.bgPixmap; - bgBrush = orig.bgBrush; - bgColor = orig.bgColor; - bgOffset = orig.bgOffset; - backgroundMode = orig.backgroundMode; - fgPixmap = orig.fgPixmap; - fgColor = orig.fgColor; - colorGroup = orig.colorGroup; - geometry = orig.geometry; - rect = orig.rect; - pos = orig.pos; - icon = orig.icon; - iconSet = orig.iconSet; - text = orig.text; - orientation = orig.orientation; - activeItemPaletteBgColor = orig.activeItemPaletteBgColor; - palette = orig.palette; - totalSteps = orig.totalSteps; - currentStep = orig.currentStep; - tickMarkSetting = orig.tickMarkSetting; - tickInterval = orig.tickInterval; - minSteps = orig.minSteps; - maxSteps = orig.maxSteps; - startStep = orig.startStep; - pageStep = orig.pageStep; - lineStep = orig.lineStep; - dlgVisibleButtons = orig.dlgVisibleButtons; - dlgVisibleSizeHints = orig.dlgVisibleSizeHints; - progressText = orig.progressText; - textLabel = orig.textLabel; - font = orig.font; - percentageVisible = orig.percentageVisible; - dwData = orig.dwData; - toolButtonTextPosition = orig.toolButtonTextPosition; - popupDelay = orig.popupDelay; - titleBarData = orig.titleBarData; - spinWidgetData = orig.spinWidgetData; - parentWidgetData = orig.parentWidgetData; - viewportData = orig.viewportData; - listViewData = orig.listViewData; - tabBarData = orig.tabBarData; - checkListItemData = orig.checkListItemData; - comboBoxLineEditFlags = orig.comboBoxLineEditFlags; - frameStyle = orig.frameStyle; - sliderRect = orig.sliderRect; - activePainter = orig.activePainter; - toolBarData = orig.toolBarData; - comboBoxListBoxFlags = orig.comboBoxListBoxFlags; - paletteBgColor = orig.paletteBgColor; - parentWidgetFlags = orig.parentWidgetFlags; - name = orig.name; - caption = orig.caption; - topLevelWidgetData = orig.topLevelWidgetData; - topLevelWidgetFlags = orig.topLevelWidgetFlags; - paletteBgPixmap = orig.paletteBgPixmap; -} - -#endif // TQT_NO_STYLE diff --git a/src/kernel/qstylesheet.cpp b/src/kernel/qstylesheet.cpp deleted file mode 100644 index b1e9ac795..000000000 --- a/src/kernel/qstylesheet.cpp +++ /dev/null @@ -1,1623 +0,0 @@ -/**************************************************************************** -** -** Implementation of the TQStyleSheet class -** -** Created : 990101 -** -** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. -** -** This file is part of the kernel module of the TQt GUI Toolkit. -** -** This file may be used under the terms of the GNU General -** Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the files LICENSE.GPL2 -** and LICENSE.GPL3 included in the packaging of this file. -** Alternatively you may (at your option) use any later version -** of the GNU General Public License if such license has been -** publicly approved by Trolltech ASA (or its successors, if any) -** and the KDE Free TQt Foundation. -** -** Please review the following information to ensure GNU General -** Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/. -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** This file may be used under the terms of the Q Public License as -** defined by Trolltech ASA and appearing in the file LICENSE.TQPL -** included in the packaging of this file. Licensees holding valid TQt -** Commercial licenses may use this file in accordance with the TQt -** Commercial License Agreement provided with the Software. -** -** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, -** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted -** herein. -** -**********************************************************************/ - -#include "ntqstylesheet.h" - -#ifndef TQT_NO_RICHTEXT - -#include "private/qrichtext_p.h" -#include "ntqlayout.h" -#include "ntqpainter.h" -#include "ntqcleanuphandler.h" - -#include - -class TQStyleSheetItemData -{ -public: - TQStyleSheetItem::DisplayMode disp; - int fontitalic; - int fontunderline; - int fontstrikeout; - int fontweight; - int fontsize; - int fontsizelog; - int fontsizestep; - int lineSpacing; - TQString fontfamily; - TQStyleSheetItem *parentstyle; - TQString stylename; - int ncolumns; - TQColor col; - bool anchor; - int align; - TQStyleSheetItem::VerticalAlignment valign; - int margin[5]; - TQStyleSheetItem::ListStyle list; - TQStyleSheetItem::WhiteSpaceMode whitespacemode; - TQString contxt; - bool selfnest; - TQStyleSheet* sheet; -}; - -/*! - \class TQStyleSheetItem ntqstylesheet.h - \brief The TQStyleSheetItem class provides an encapsulation of a set of text styles. - - \ingroup text - - A style sheet item consists of a name and a set of attributes that - specifiy its font, color, etc. When used in a \link TQStyleSheet - style sheet\endlink (see styleSheet()), items define the name() of - a rich text tag and the display property changes associated with - it. - - The \link TQStyleSheetItem::DisplayMode display mode\endlink - attribute indicates whether the item is a block, an inline element - or a list element; see setDisplayMode(). The treatment of - whitespace is controlled by the \link - TQStyleSheetItem::WhiteSpaceMode white space mode\endlink; see - setWhiteSpaceMode(). An item's margins are set with setMargin(), - In the case of list items, the list style is set with - setListStyle(). An item may be a hypertext link anchor; see - setAnchor(). Other attributes are set with setAlignment(), - setVerticalAlignment(), setFontFamily(), setFontSize(), - setFontWeight(), setFontItalic(), setFontUnderline(), - setFontStrikeOut and setColor(). -*/ - -/*! \enum TQStyleSheetItem::AdditionalStyleValues - \internal -*/ - -/*! - \enum TQStyleSheetItem::WhiteSpaceMode - - This enum defines the ways in which TQStyleSheet can treat - whitespace. - - \value WhiteSpaceNormal any sequence of whitespace (including - line-breaks) is equivalent to a single space. - - \value WhiteSpacePre whitespace must be output exactly as given - in the input. - - \value WhiteSpaceNoWrap multiple spaces are collapsed as with - WhiteSpaceNormal, but no automatic line-breaks occur. To break - lines manually, use the \c{
} tag. - -*/ - -/*! - \enum TQStyleSheetItem::Margin - - \value MarginLeft left margin - \value MarginRight right margin - \value MarginTop top margin - \value MarginBottom bottom margin - \value MarginAll all margins (left, right, top and bottom) - \value MarginVertical top and bottom margins - \value MarginHorizontal left and right margins - \value MarginFirstLine margin (indentation) of the first line of - a paragarph (in addition to the MarginLeft of the paragraph) -*/ - -/*! - Constructs a new style called \a name for the stylesheet \a - parent. - - All properties in TQStyleSheetItem are initially in the "do not - change" state, except \link TQStyleSheetItem::DisplayMode display - mode\endlink, which defaults to \c DisplayInline. -*/ -TQStyleSheetItem::TQStyleSheetItem( TQStyleSheet* parent, const TQString& name ) -{ - d = new TQStyleSheetItemData; - d->stylename = name.lower(); - d->sheet = parent; - init(); - if (parent) - parent->insert( this ); -} - -/*! - Copy constructor. Constructs a copy of \a other that is not bound - to any style sheet. -*/ -TQStyleSheetItem::TQStyleSheetItem( const TQStyleSheetItem & other ) -{ - d = new TQStyleSheetItemData; - *d = *other.d; -} - - -/*! - Destroys the style. Note that TQStyleSheetItem objects become - owned by TQStyleSheet when they are created. -*/ -TQStyleSheetItem::~TQStyleSheetItem() -{ - delete d; -} - -/*! - Assignment. Assings a copy of \a other that is not bound to any style sheet. - Unbounds first from previous style sheet. - */ -TQStyleSheetItem& TQStyleSheetItem::operator=( const TQStyleSheetItem& other ) -{ - if ( &other == this ) - return *this; - delete d; - d = new TQStyleSheetItemData; - *d = *other.d; - return *this; -} - -/*! - Returns the style sheet this item is in. -*/ -TQStyleSheet* TQStyleSheetItem::styleSheet() -{ - return d->sheet; -} - -/*! - \overload - - Returns the style sheet this item is in. -*/ -const TQStyleSheet* TQStyleSheetItem::styleSheet() const -{ - return d->sheet; -} - -/*! - \internal - Internal initialization - */ -void TQStyleSheetItem::init() -{ - d->disp = DisplayInline; - - d->fontitalic = Undefined; - d->fontunderline = Undefined; - d->fontstrikeout = Undefined; - d->fontweight = Undefined; - d->fontsize = Undefined; - d->fontsizelog = Undefined; - d->fontsizestep = 0; - d->ncolumns = Undefined; - d->col = TQColor(); // !isValid() - d->anchor = FALSE; - d->align = Undefined; - d->valign = VAlignBaseline; - d->margin[0] = Undefined; - d->margin[1] = Undefined; - d->margin[2] = Undefined; - d->margin[3] = Undefined; - d->margin[4] = Undefined; - d->list = ListStyleUndefined; - d->whitespacemode = WhiteSpaceModeUndefined; - d->selfnest = TRUE; - d->lineSpacing = Undefined; -} - -/*! - Returns the name of the style item. -*/ -TQString TQStyleSheetItem::name() const -{ - return d->stylename; -} - -/*! - Returns the \link TQStyleSheetItem::DisplayMode display - mode\endlink of the style. - - \sa setDisplayMode() -*/ -TQStyleSheetItem::DisplayMode TQStyleSheetItem::displayMode() const -{ - return d->disp; -} - -/*! - \enum TQStyleSheetItem::DisplayMode - - This enum type defines the way adjacent elements are displayed. - - \value DisplayBlock elements are displayed as a rectangular block - (e.g. \c{

...

}). - - \value DisplayInline elements are displayed in a horizontally - flowing sequence (e.g. \c{...}). - - \value DisplayListItem elements are displayed in a vertical - sequence (e.g. \c{
  • ...
  • }). - - \value DisplayNone elements are not displayed at all. -*/ - -/*! - Sets the display mode of the style to \a m. - - \sa displayMode() - */ -void TQStyleSheetItem::setDisplayMode(DisplayMode m) -{ - d->disp=m; -} - - -/*! - Returns the alignment of this style. Possible values are \c - AlignAuto, \c AlignLeft, \c AlignRight, \c AlignCenter or \c - AlignJustify. - - \sa setAlignment(), TQt::AlignmentFlags -*/ -int TQStyleSheetItem::alignment() const -{ - return d->align; -} - -/*! - Sets the alignment to \a f. This only makes sense for styles with - a \link TQStyleSheetItem::DisplayMode display mode\endlink of - DisplayBlock. Possible values are \c AlignAuto, \c AlignLeft, - \c AlignRight, \c AlignCenter or \c AlignJustify. - - \sa alignment(), displayMode(), TQt::AlignmentFlags -*/ -void TQStyleSheetItem::setAlignment( int f ) -{ - d->align = f; -} - - -/*! - Returns the vertical alignment of the style. Possible values are - \c VAlignBaseline, \c VAlignSub or \c VAlignSuper. - - \sa setVerticalAlignment() -*/ -TQStyleSheetItem::VerticalAlignment TQStyleSheetItem::verticalAlignment() const -{ - return d->valign; -} - -/*! - \enum TQStyleSheetItem::VerticalAlignment - - This enum type defines the way elements are aligned vertically. - This is only supported for text elements. - - \value VAlignBaseline align the baseline of the element (or the - bottom, if the element doesn't have a baseline) with the - baseline of the parent - - \value VAlignSub subscript the element - - \value VAlignSuper superscript the element - -*/ - - -/*! - Sets the vertical alignment to \a valign. Possible values are - \c VAlignBaseline, \c VAlignSub or \c VAlignSuper. - - The vertical alignment property is not inherited. - - \sa verticalAlignment() -*/ -void TQStyleSheetItem::setVerticalAlignment( VerticalAlignment valign ) -{ - d->valign = valign; -} - - -/*! - Returns TRUE if the style sets an italic font; otherwise returns - FALSE. - - \sa setFontItalic(), definesFontItalic() -*/ -bool TQStyleSheetItem::fontItalic() const -{ - return d->fontitalic > 0; -} - -/*! - If \a italic is TRUE sets italic for the style; otherwise sets - upright. - - \sa fontItalic(), definesFontItalic() -*/ -void TQStyleSheetItem::setFontItalic(bool italic) -{ - d->fontitalic = italic?1:0; -} - -/*! - Returns TRUE if the style defines a font shape; otherwise returns - FALSE. A style does not define any shape until setFontItalic() is - called. - - \sa setFontItalic(), fontItalic() -*/ -bool TQStyleSheetItem::definesFontItalic() const -{ - return d->fontitalic != Undefined; -} - -/*! - Returns TRUE if the style sets an underlined font; otherwise - returns FALSE. - - \sa setFontUnderline(), definesFontUnderline() -*/ -bool TQStyleSheetItem::fontUnderline() const -{ - return d->fontunderline > 0; -} - -/*! - If \a underline is TRUE, sets underline for the style; otherwise - sets no underline. - - \sa fontUnderline(), definesFontUnderline() -*/ -void TQStyleSheetItem::setFontUnderline(bool underline) -{ - d->fontunderline = underline?1:0; -} - -/*! - Returns TRUE if the style defines a setting for the underline - property of the font; otherwise returns FALSE. A style does not - define this until setFontUnderline() is called. - - \sa setFontUnderline(), fontUnderline() -*/ -bool TQStyleSheetItem::definesFontUnderline() const -{ - return d->fontunderline != Undefined; -} - - -/*! - Returns TRUE if the style sets a strike out font; otherwise - returns FALSE. - - \sa setFontStrikeOut(), definesFontStrikeOut() -*/ -bool TQStyleSheetItem::fontStrikeOut() const -{ - return d->fontstrikeout > 0; -} - -/*! - If \a strikeOut is TRUE, sets strike out for the style; otherwise - sets no strike out. - - \sa fontStrikeOut(), definesFontStrikeOut() -*/ -void TQStyleSheetItem::setFontStrikeOut(bool strikeOut) -{ - d->fontstrikeout = strikeOut?1:0; -} - -/*! - Returns TRUE if the style defines a setting for the strikeOut - property of the font; otherwise returns FALSE. A style does not - define this until setFontStrikeOut() is called. - - \sa setFontStrikeOut(), fontStrikeOut() -*/ -bool TQStyleSheetItem::definesFontStrikeOut() const -{ - return d->fontstrikeout != Undefined; -} - - -/*! - Returns the font weight setting of the style. This is either a - valid \c TQFont::Weight or the value \c TQStyleSheetItem::Undefined. - - \sa setFontWeight(), TQFont -*/ -int TQStyleSheetItem::fontWeight() const -{ - return d->fontweight; -} - -/*! - Sets the font weight setting of the style to \a w. Valid values - are those defined by \c TQFont::Weight. - - \sa TQFont, fontWeight() -*/ -void TQStyleSheetItem::setFontWeight(int w) -{ - d->fontweight = w; -} - -/*! - Returns the logical font size setting of the style. This is either - a valid size between 1 and 7 or \c TQStyleSheetItem::Undefined. - - \sa setLogicalFontSize(), setLogicalFontSizeStep(), TQFont::pointSize(), TQFont::setPointSize() -*/ -int TQStyleSheetItem::logicalFontSize() const -{ - return d->fontsizelog; -} - - -/*! - Sets the logical font size setting of the style to \a s. Valid - logical sizes are 1 to 7. - - \sa logicalFontSize(), TQFont::pointSize(), TQFont::setPointSize() -*/ -void TQStyleSheetItem::setLogicalFontSize(int s) -{ - d->fontsizelog = s; -} - -/*! - Returns the logical font size step of this style. - - The default is 0. Tags such as \c big define \c +1; \c small - defines \c -1. - - \sa setLogicalFontSizeStep() -*/ -int TQStyleSheetItem::logicalFontSizeStep() const -{ - return d->fontsizestep; -} - -/*! - Sets the logical font size step of this style to \a s. - - \sa logicalFontSizeStep() -*/ -void TQStyleSheetItem::setLogicalFontSizeStep( int s ) -{ - d->fontsizestep = s; -} - - - -/*! - Sets the font size setting of the style to \a s points. - - \sa fontSize(), TQFont::pointSize(), TQFont::setPointSize() -*/ -void TQStyleSheetItem::setFontSize(int s) -{ - d->fontsize = s; -} - -/*! - Returns the font size setting of the style. This is either a valid - point size or \c TQStyleSheetItem::Undefined. - - \sa setFontSize(), TQFont::pointSize(), TQFont::setPointSize() -*/ -int TQStyleSheetItem::fontSize() const -{ - return d->fontsize; -} - - -/*! - Returns the font family setting of the style. This is either a - valid font family or TQString::null if no family has been set. - - \sa setFontFamily(), TQFont::family(), TQFont::setFamily() -*/ -TQString TQStyleSheetItem::fontFamily() const -{ - return d->fontfamily; -} - -/*! - Sets the font family setting of the style to \a fam. - - \sa fontFamily(), TQFont::family(), TQFont::setFamily() -*/ -void TQStyleSheetItem::setFontFamily( const TQString& fam) -{ - d->fontfamily = fam; -} - - -/*!\obsolete - Returns the number of columns for this style. - - \sa setNumberOfColumns(), displayMode(), setDisplayMode() - - */ -int TQStyleSheetItem::numberOfColumns() const -{ - return d->ncolumns; -} - - -/*!\obsolete - Sets the number of columns for this style. Elements in the style - are divided into columns. - - This makes sense only if the style uses a block display mode - (see TQStyleSheetItem::DisplayMode). - - \sa numberOfColumns() - */ -void TQStyleSheetItem::setNumberOfColumns(int ncols) -{ - if (ncols > 0) - d->ncolumns = ncols; -} - - -/*! - Returns the text color of this style or an invalid color if no - color has been set. - - \sa setColor() TQColor::isValid() -*/ -TQColor TQStyleSheetItem::color() const -{ - return d->col; -} - -/*! - Sets the text color of this style to \a c. - - \sa color() -*/ -void TQStyleSheetItem::setColor( const TQColor &c) -{ - d->col = c; -} - -/*! - Returns whether this style is an anchor. - - \sa setAnchor() -*/ -bool TQStyleSheetItem::isAnchor() const -{ - return d->anchor; -} - -/*! - If \a anc is TRUE, sets this style to be an anchor (hypertext - link); otherwise sets it to not be an anchor. Elements in this - style link to other documents or anchors. - - \sa isAnchor() -*/ -void TQStyleSheetItem::setAnchor(bool anc) -{ - d->anchor = anc; -} - - -/*! - Returns the whitespace mode. - - \sa setWhiteSpaceMode() WhiteSpaceMode -*/ -TQStyleSheetItem::WhiteSpaceMode TQStyleSheetItem::whiteSpaceMode() const -{ - return d->whitespacemode; -} - -/*! - Sets the whitespace mode to \a m. - - \sa WhiteSpaceMode -*/ -void TQStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) -{ - d->whitespacemode = m; -} - - -/*! - Returns the width of margin \a m in pixels. - - The margin, \a m, can be \c MarginLeft, \c MarginRight, \c - MarginTop, \c MarginBottom, or \c MarginFirstLine. - - \sa setMargin() Margin -*/ -int TQStyleSheetItem::margin(Margin m) const -{ - if (m == MarginAll ) { - return d->margin[MarginLeft]; - } else if (m == MarginVertical) { - return d->margin[MarginTop]; - } else if (m == MarginHorizontal) { - return d->margin[MarginLeft]; - } else { - return d->margin[m]; - } -} - - -/*! - Sets the width of margin \a m to \a v pixels. - - The margin, \a m, can be \c MarginLeft, \c MarginRight, \c - MarginTop, \c MarginBottom, \c MarginFirstLine, \c MarginAll, - \c MarginVertical or \c MarginHorizontal. The value \a v must - be >= 0. - - \sa margin() -*/ -void TQStyleSheetItem::setMargin(Margin m, int v) -{ - if (m == MarginAll) { - d->margin[MarginLeft] = v; - d->margin[MarginRight] = v; - d->margin[MarginTop] = v; - d->margin[MarginBottom] = v; - } else if (m == MarginVertical ) { - d->margin[MarginTop] = v; - d->margin[MarginBottom] = v; - } else if (m == MarginHorizontal ) { - d->margin[MarginLeft] = v; - d->margin[MarginRight] = v; - } else { - d->margin[m] = v; - } -} - - -/*! - Returns the list style of the style. - - \sa setListStyle() ListStyle - */ -TQStyleSheetItem::ListStyle TQStyleSheetItem::listStyle() const -{ - return d->list; -} - -/*! - \enum TQStyleSheetItem::ListStyle - - This enum type defines how the items in a list are prefixed when - displayed. - - \value ListDisc a filled circle (i.e. a bullet) - \value ListCircle an unfilled circle - \value ListSquare a filled square - \value ListDecimal an integer in base 10: \e 1, \e 2, \e 3, ... - \value ListLowerAlpha a lowercase letter: \e a, \e b, \e c, ... - \value ListUpperAlpha an uppercase letter: \e A, \e B, \e C, ... -*/ - -/*! - Sets the list style of the style to \a s. - - This is used by nested elements that have a display mode of \c - DisplayListItem. - - \sa listStyle() DisplayMode ListStyle -*/ -void TQStyleSheetItem::setListStyle(ListStyle s) -{ - d->list=s; -} - - -/*! - Returns a space-separated list of names of styles that may contain - elements of this style. If nothing has been set, contexts() - returns an empty string, which indicates that this style can be - nested everywhere. - - \sa setContexts() -*/ -TQString TQStyleSheetItem::contexts() const -{ - return d->contxt; -} - -/*! - Sets a space-separated list of names of styles that may contain - elements of this style. If \a c is empty, the style can be nested - everywhere. - - \sa contexts() -*/ -void TQStyleSheetItem::setContexts( const TQString& c) -{ - d->contxt = TQChar(' ') + c + TQChar(' '); -} - -/*! - Returns TRUE if this style can be nested into an element of style - \a s; otherwise returns FALSE. - - \sa contexts(), setContexts() -*/ -bool TQStyleSheetItem::allowedInContext( const TQStyleSheetItem* s) const -{ - if ( d->contxt.isEmpty() ) - return TRUE; - return d->contxt.find( TQChar(' ')+s->name()+TQChar(' ')) != -1; -} - - -/*! - Returns TRUE if this style has self-nesting enabled; otherwise - returns FALSE. - - \sa setSelfNesting() -*/ -bool TQStyleSheetItem::selfNesting() const -{ - return d->selfnest; -} - -/*! - Sets the self-nesting property for this style to \a nesting. - - In order to support "dirty" HTML, paragraphs \c{

    } and list - items \c{

  • } are not self-nesting. This means that starting a - new paragraph or list item automatically closes the previous one. - - \sa selfNesting() -*/ -void TQStyleSheetItem::setSelfNesting( bool nesting ) -{ - d->selfnest = nesting; -} - -/*! - \internal - Sets the linespacing to be at least \a ls pixels. - - For compatibility with previous TQt releases, small values get - treated differently: If \a ls is smaller than the default font - line spacing in pixels at parse time, the resulting line spacing - is the sum of the default line spacing plus \a ls. We recommend - not relying on this behavior. -*/ - -void TQStyleSheetItem::setLineSpacing( int ls ) -{ - d->lineSpacing = ls; -} - -/*! - \obsolete - - Returns the linespacing -*/ - -int TQStyleSheetItem::lineSpacing() const -{ - return d->lineSpacing; -} - -//************************************************************************ - - - - -//************************************************************************ - - -/*! - \class TQStyleSheet ntqstylesheet.h - \ingroup text - \brief The TQStyleSheet class is a collection of styles for rich text - rendering and a generator of tags. - - \ingroup graphics - \ingroup helpsystem - - By creating TQStyleSheetItem objects for a style sheet you build a - definition of a set of tags. This definition will be used by the - internal rich text rendering system to parse and display text - documents to which the style sheet applies. Rich text is normally - visualized in a TQTextEdit or a TQTextBrowser. However, TQLabel, - TQWhatsThis and TQMessageBox also support it, and other classes are - likely to follow. With TQSimpleRichText it is possible to use the - rich text renderer for custom widgets as well. - - The default TQStyleSheet object has the following style bindings, - sorted by structuring bindings, anchors, character style bindings - (i.e. inline styles), special elements such as horizontal lines or - images, and other tags. In addition, rich text supports simple - HTML tables. - - The structuring tags are - \table - \header \i Structuring tags \i Notes - \row \i \c{}...\c{} - \i A TQt rich text document. It understands the following - attributes: - \list - \i \c title -- The caption of the document. This attribute is - easily accessible with TQTextEdit::documentTitle(). - \i \c type -- The type of the document. The default type is \c - page. It indicates that the document is displayed in a - page of its own. Another style is \c detail, which can be - used to explain certain expressions in more detail in a - few sentences. For \c detail, TQTextBrowser will then keep - the current page and display the new document in a small - popup similar to TQWhatsThis. Note that links will not work - in documents with \c{...}. - \i \c bgcolor -- The background color, for example \c - bgcolor="yellow" or \c bgcolor="#0000FF". - \i \c background -- The background pixmap, for example \c - background="granite.xpm". The pixmap name will be resolved - by a TQMimeSourceFactory(). - \i \c text -- The default text color, for example \c text="red". - \i \c link -- The link color, for example \c link="green". - \endlist - \row \i \c{

    ...

    } - \i A top-level heading. - \row \i \c{

    ...

    } - \i A sublevel heading. - \row \i \c{

    ...

    } - \i A sub-sublevel heading. - \row \i \c{

    ...

    } \c{
    ...
    } - \i Headings of lesser importance. - \row \i \c{

    ...

    } - \i A left-aligned paragraph. Adjust the alignment with the \c - align attribute. Possible values are \c left, \c right and - \c center. - \row \i \c{
    ...}
    \c{
    } - \i A centered paragraph. - \row \i \c{
    ...}
    \c{
    } - \i An indented paragraph that is useful for quotes. - \row \i \c{
      ...
    } - \i An unordered list. You can also pass a type argument to - define the bullet style. The default is \c type=disc; - other types are \c circle and \c square. - \row \i \c{
      ...
    } - \i An ordered list. You can also pass a type argument to - define the enumeration label style. The default is \c - type="1"; other types are \c "a" and \c "A". - \row \i \c{
  • ...
  • } - \i A list item. This tag can be used only within the context - of \c{
      } or \c{
        }. - \row \i \c{
        ...
        } - \i A list of definitions, consisting of terms and descriptions. - \row \i \c{
        ...
        } - \i A term in a list of definitions. This tag can be used only - in the context of \c{
        ...
        }. - \row \i \c{
        ...
        } - \i A description in a list of definitions. This tag can be - used only in the context of \c{
        ...
        }. - \row \i \c{
        ...
        } - \i For larger chunks of code. Whitespaces in the contents are - preserved. For small bits of code use the inline-style \c - code. - \row \i \c{
        ...
        } and \c{...} - \i Block grouping elements. These are used to structure the - document, and are often used to provide hints about the - intended presentation of the document. - \endtable - - Anchors and links are done with a single tag: - \table - \header \i Anchor tags \i Notes - \row \i \c{...} - \i An anchor or link. - \list - \i A link is created by using an \c href - attribute, for example -
        \c{Link Text}. Links to - targets within a document are achieved in the same way - as for HTML, e.g. -
        \c{Link Text}. - \i A target is created by using a \c name - attribute, for example -
        \c{

        Sub Title

        }. - \endlist - \endtable - - The default character style bindings are - \table - \header \i Style tags \i Notes - \row \i \c{...} - \i Emphasized. By default this is the same as \c{...} - (italic). - \row \i \c{...} - \i Strong. By default this is the same as \c{...} - (bold). - \row \i \c{...} - \i Italic font style. - \row \i \c{...} - \i Bold font style. - \row \i \c{...} - \i Underlined font style. - \row \i \c{...} - \i Strike out font style. - \row \i \c{...} - \i A larger font size. - \row \i \c{...} - \i A smaller font size. - \row \i \c{...} - \i Subscripted text - \row \i \c{...} - \i Superscripted text - \row \i \c{...} - \i Indicates code. By default this is the same as - \c{...} (typewriter). For larger chunks of code - use the block-tag \c{<}\c{pre>}. - \row \i \c{...} - \i Typewriter font style. - \row \i \c{...} - \i Customizes the font size, family and text color. The tag - understands the following attributes: - \list - \i \c color -- The text color, for example \c color="red" or - \c color="#FF0000". - \i \c size -- The logical size of the font. Logical sizes 1 - to 7 are supported. The value may either be absolute - (for example, \c size=3) or relative (\c size=-2). In - the latter case the sizes are simply added. - \i \c face -- The family of the font, for example \c face=times. - \endlist - \endtable - - Special elements are: - \table - \header \i Special tags \i Notes - \row \i \c{} - \i An image. The image name for the mime source factory is - given in the source attribute, for example - \c{} The image tag also understands the - attributes \c width and \c height that determine the size - of the image. If the pixmap does not fit the specified - size it will be scaled automatically (by using - TQImage::smoothScale()). -
        - The \c align attribute determines where the image is - placed. By default, an image is placed inline just like a - normal character. Specify \c left or \c right to place the - image at the respective side. - \row \i \c{
        } - \i A horizontal line. - \row \i \c{
        } - \i A line break. - \row \i \c{...} - \i No break. Prevents word wrap. - \endtable - - In addition, rich text supports simple HTML tables. A table - consists of one or more rows each of which contains one or more - cells. Cells are either data cells or header cells, depending on - their content. Cells which span rows and columns are supported. - - \table - \header \i Table tags \i Notes - \row \i \c{...
        } - \i A table. Tables support the following attributes: - \list - \i \c bgcolor -- The background color. - \i \c width -- The table width. This is either an absolute - pixel width or a relative percentage of the table's - width, for example \c width=80%. - \i \c border -- The width of the table border. The default is - 0 (= no border). - \i \c cellspacing -- Additional space around the table cells. - The default is 2. - \i \c cellpadding -- Additional space around the contents of - table cells. The default is 1. - \endlist - \row \i \c{...} - \i A table row. This is only valid within a \c table. Rows - support the following attribute: - \list - \i \c bgcolor -- The background color. - \endlist - \row \i \c{...} - \i A table header cell. Similar to \c td, but defaults to - center alignment and a bold font. - \row \i \c{...} - \i A table data cell. This is only valid within a \c tr. - Cells support the following attributes: - \list - \i \c bgcolor -- The background color. - \i \c width -- The cell width. This is either an absolute - pixel width or a relative percentage of table's width, - for example \c width=50%. - \i \c colspan -- Specifies how many columns this cell spans. - The default is 1. - \i \c rowspan -- Specifies how many rows this cell spans. The - default is 1. - \i \c align -- Alignment; possible values are \c left, \c - right, and \c center. The default is \c left. - \i \c valign -- Vertical alignment; possible values are \c - top, \c middle, and \c bottom. The default is \c middle. - \endlist - \endtable -*/ - -/*! - Creates a style sheet called \a name, with parent \a parent. Like - any TQObject it will be deleted when its parent is destroyed (if - the child still exists). - - By default the style sheet has the tag definitions defined above. -*/ -TQStyleSheet::TQStyleSheet( TQObject *parent, const char *name ) - : TQObject( parent, name ) -{ - init(); -} - -/*! - Destroys the style sheet. All styles inserted into the style sheet - will be deleted. -*/ -TQStyleSheet::~TQStyleSheet() -{ -} - -/*! - \internal - Initialized the style sheet to the basic TQt style. -*/ -void TQStyleSheet::init() -{ - styles.setAutoDelete( TRUE ); - - nullstyle = new TQStyleSheetItem( this, - TQString::fromLatin1("") ); - - TQStyleSheetItem* style; - - style = new TQStyleSheetItem( this, "qml" ); // compatibility - style->setDisplayMode( TQStyleSheetItem::DisplayBlock ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("qt") ); - style->setDisplayMode( TQStyleSheetItem::DisplayBlock ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("a") ); - style->setAnchor( TRUE ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("em") ); - style->setFontItalic( TRUE ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("i") ); - style->setFontItalic( TRUE ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("big") ); - style->setLogicalFontSizeStep( 1 ); - style = new TQStyleSheetItem( this, TQString::fromLatin1("large") ); // compatibility - style->setLogicalFontSizeStep( 1 ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("small") ); - style->setLogicalFontSizeStep( -1 ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("strong") ); - style->setFontWeight( TQFont::Bold); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("b") ); - style->setFontWeight( TQFont::Bold); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("h1") ); - style->setFontWeight( TQFont::Bold); - style->setLogicalFontSize(6); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style-> setMargin(TQStyleSheetItem::MarginTop, 18); - style-> setMargin(TQStyleSheetItem::MarginBottom, 12); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("h2") ); - style->setFontWeight( TQFont::Bold); - style->setLogicalFontSize(5); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style-> setMargin(TQStyleSheetItem::MarginTop, 16); - style-> setMargin(TQStyleSheetItem::MarginBottom, 12); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("h3") ); - style->setFontWeight( TQFont::Bold); - style->setLogicalFontSize(4); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style-> setMargin(TQStyleSheetItem::MarginTop, 14); - style-> setMargin(TQStyleSheetItem::MarginBottom, 12); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("h4") ); - style->setFontWeight( TQFont::Bold); - style->setLogicalFontSize(3); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style-> setMargin(TQStyleSheetItem::MarginVertical, 12); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("h5") ); - style->setFontWeight( TQFont::Bold); - style->setLogicalFontSize(2); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style-> setMargin(TQStyleSheetItem::MarginTop, 12); - style-> setMargin(TQStyleSheetItem::MarginBottom, 4); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("p") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style-> setMargin(TQStyleSheetItem::MarginVertical, 12); - style->setSelfNesting( FALSE ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("center") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setAlignment( AlignCenter ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("twocolumn") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setNumberOfColumns( 2 ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("multicol") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - (void) new TQStyleSheetItem( this, TQString::fromLatin1("font") ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("ul") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setListStyle( TQStyleSheetItem::ListDisc ); - style-> setMargin(TQStyleSheetItem::MarginVertical, 12); - style->setMargin( TQStyleSheetItem::MarginLeft, 40 ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("ol") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setListStyle( TQStyleSheetItem::ListDecimal ); - style-> setMargin(TQStyleSheetItem::MarginVertical, 12); - style->setMargin( TQStyleSheetItem::MarginLeft, 40 ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("li") ); - style->setDisplayMode(TQStyleSheetItem::DisplayListItem); - style->setSelfNesting( FALSE ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("code") ); - style->setFontFamily( TQString::fromLatin1("Courier New,courier") ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("tt") ); - style->setFontFamily( TQString::fromLatin1("Courier New,courier") ); - - new TQStyleSheetItem(this, TQString::fromLatin1("img")); - new TQStyleSheetItem(this, TQString::fromLatin1("br")); - new TQStyleSheetItem(this, TQString::fromLatin1("hr")); - - style = new TQStyleSheetItem(this, TQString::fromLatin1("sub")); - style->setVerticalAlignment( TQStyleSheetItem::VAlignSub ); - style = new TQStyleSheetItem(this, TQString::fromLatin1("sup")); - style->setVerticalAlignment( TQStyleSheetItem::VAlignSuper ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("pre") ); - style->setFontFamily( TQString::fromLatin1("Courier New,courier") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setWhiteSpaceMode(TQStyleSheetItem::WhiteSpacePre); - style-> setMargin(TQStyleSheetItem::MarginVertical, 12); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("blockquote") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setMargin(TQStyleSheetItem::MarginHorizontal, 40 ); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("head") ); - style->setDisplayMode(TQStyleSheetItem::DisplayNone); - style = new TQStyleSheetItem( this, TQString::fromLatin1("body") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style = new TQStyleSheetItem( this, TQString::fromLatin1("div") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock) ; - style = new TQStyleSheetItem( this, TQString::fromLatin1("span") ); - style = new TQStyleSheetItem( this, TQString::fromLatin1("dl") ); - style-> setMargin(TQStyleSheetItem::MarginVertical, 8); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style = new TQStyleSheetItem( this, TQString::fromLatin1("dt") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setContexts(TQString::fromLatin1("dl") ); - style = new TQStyleSheetItem( this, TQString::fromLatin1("dd") ); - style->setDisplayMode(TQStyleSheetItem::DisplayBlock); - style->setMargin(TQStyleSheetItem::MarginLeft, 30); - style->setContexts(TQString::fromLatin1("dt dl") ); - style = new TQStyleSheetItem( this, TQString::fromLatin1("u") ); - style->setFontUnderline( TRUE); - style = new TQStyleSheetItem( this, TQString::fromLatin1("s") ); - style->setFontStrikeOut( TRUE); - style = new TQStyleSheetItem( this, TQString::fromLatin1("nobr") ); - style->setWhiteSpaceMode( TQStyleSheetItem::WhiteSpaceNoWrap ); - - // compatibily with some minor 3.0.x TQt versions that had an - // undocumented tag. ### Remove 3.1 - style = new TQStyleSheetItem( this, TQString::fromLatin1("wsp") ); - style->setWhiteSpaceMode( TQStyleSheetItem::WhiteSpacePre ); - - // tables - style = new TQStyleSheetItem( this, TQString::fromLatin1("table") ); - style = new TQStyleSheetItem( this, TQString::fromLatin1("tr") ); - style->setContexts(TQString::fromLatin1("table")); - style = new TQStyleSheetItem( this, TQString::fromLatin1("td") ); - style->setContexts(TQString::fromLatin1("tr")); - style = new TQStyleSheetItem( this, TQString::fromLatin1("th") ); - style->setFontWeight( TQFont::Bold ); - style->setAlignment( TQt::AlignCenter ); - style->setContexts(TQString::fromLatin1("tr")); - - style = new TQStyleSheetItem( this, TQString::fromLatin1("html") ); -} - - - -static TQStyleSheet* defaultsheet = 0; -static TQSingleCleanupHandler tqt_cleanup_stylesheet; - -/*! - Returns the application-wide default style sheet. This style sheet - is used by rich text rendering classes such as TQSimpleRichText, - TQWhatsThis and TQMessageBox to define the rendering style and - available tags within rich text documents. It also serves as the - initial style sheet for the more complex render widgets, TQTextEdit - and TQTextBrowser. - - \sa setDefaultSheet() -*/ -TQStyleSheet* TQStyleSheet::defaultSheet() -{ - if (!defaultsheet) { - defaultsheet = new TQStyleSheet(); - tqt_cleanup_stylesheet.set( &defaultsheet ); - } - return defaultsheet; -} - -/*! - Sets the application-wide default style sheet to \a sheet, - deleting any style sheet previously set. The ownership is - transferred to TQStyleSheet. - - \sa defaultSheet() -*/ -void TQStyleSheet::setDefaultSheet( TQStyleSheet* sheet) -{ - if ( defaultsheet != sheet ) { - if ( defaultsheet ) - tqt_cleanup_stylesheet.reset(); - delete defaultsheet; - } - defaultsheet = sheet; - if ( defaultsheet ) - tqt_cleanup_stylesheet.set( &defaultsheet ); -} - -/*!\internal - Inserts \a style. Any tags generated after this time will be - bound to this style. Note that \a style becomes owned by the - style sheet and will be deleted when the style sheet is destroyed. -*/ -void TQStyleSheet::insert( TQStyleSheetItem* style ) -{ - styles.insert(style->name(), style); -} - - -/*! - Returns the style called \a name or 0 if there is no such style. -*/ -TQStyleSheetItem* TQStyleSheet::item( const TQString& name) -{ - if ( name.isNull() ) - return 0; - return styles[name]; -} - -/*! - \overload - - Returns the style called \a name or 0 if there is no such style - (const version) -*/ -const TQStyleSheetItem* TQStyleSheet::item( const TQString& name) const -{ - if ( name.isNull() ) - return 0; - return styles[name]; -} - - -/*! - \preliminary - - Generates an internal object for the tag called \a name, given the - attributes \a attr, and using additional information provided by - the mime source factory \a factory. - - \a context is the optional context of the document, i.e. the path - to look for relative links. This becomes important if the text - contains relative references, for example within image tags. - TQSimpleRichText always uses the default mime source factory (see - \l{TQMimeSourceFactory::defaultFactory()}) to resolve these - references. The context will then be used to calculate the - absolute path. See TQMimeSourceFactory::makeAbsolute() for details. - - \a emptyTag and \a doc are for internal use only. - - This function should not be used in application code. -*/ -#ifndef TQT_NO_TEXTCUSTOMITEM -TQTextCustomItem* TQStyleSheet::tag( const TQString& name, - const TQMap &attr, - const TQString& context, - const TQMimeSourceFactory& factory, - bool /*emptyTag */, TQTextDocument *doc ) const -{ - const TQStyleSheetItem* style = item( name ); - // first some known tags - if ( !style ) - return 0; - if ( style->name() == "img" ) - return new TQTextImage( doc, attr, context, (TQMimeSourceFactory&)factory ); - if ( style->name() == "hr" ) - return new TQTextHorizontalLine( doc, attr, context, (TQMimeSourceFactory&)factory ); - return 0; -} -#endif - - -/*! Auxiliary function. Converts the plain text string \a plain to a - rich text formatted paragraph while preserving most of its look. - - \a mode defines the whitespace mode. Possible values are \c - TQStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces - preserved) and \c TQStyleSheetItem::WhiteSpaceNormal (wrapping, - simplified whitespaces). - - \sa escape() -*/ -TQString TQStyleSheet::convertFromPlainText( const TQString& plain, TQStyleSheetItem::WhiteSpaceMode mode ) -{ - int col = 0; - TQString rich; - rich += "

        "; - for ( int i = 0; i < int(plain.length()); ++i ) { - if ( plain[i] == '\n' ){ - int c = 1; - while ( i+1 < int(plain.length()) && plain[i+1] == '\n' ) { - i++; - c++; - } - if ( c == 1) - rich += "
        \n"; - else { - rich += "

        \n"; - while ( --c > 1 ) - rich += "
        \n"; - rich += "

        "; - } - col = 0; - } else { - if ( mode == TQStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){ - rich += 0x00a0U; - ++col; - while ( col % 8 ) { - rich += 0x00a0U; - ++col; - } - } - else if ( mode == TQStyleSheetItem::WhiteSpacePre && plain[i].isSpace() ) - rich += 0x00a0U; - else if ( plain[i] == '<' ) - rich +="<"; - else if ( plain[i] == '>' ) - rich +=">"; - else if ( plain[i] == '&' ) - rich +="&"; - else - rich += plain[i]; - ++col; - } - } - if ( col != 0 ) - rich += "

        "; - return rich; -} - -/*! - Auxiliary function. Converts the plain text string \a plain to a - rich text formatted string with any HTML meta-characters escaped. - - \sa convertFromPlainText() -*/ -TQString TQStyleSheet::escape( const TQString& plain) -{ - TQString rich; - for ( int i = 0; i < int(plain.length()); ++i ) { - if ( plain[i] == '<' ) - rich +="<"; - else if ( plain[i] == '>' ) - rich +=">"; - else if ( plain[i] == '&' ) - rich +="&"; - else - rich += plain[i]; - } - return rich; -} - -// Must doc this enum somewhere, and it is logically related to TQStyleSheet - -/*! - \enum TQt::TextFormat - - This enum is used in widgets that can display both plain text and - rich text, e.g. TQLabel. It is used for deciding whether a text - string should be interpreted as one or the other. This is normally - done by passing one of the enum values to a setTextFormat() - function. - - \value PlainText The text string is interpreted as a plain text - string. - - \value RichText The text string is interpreted as a rich text - string using the current TQStyleSheet::defaultSheet(). - - \value AutoText The text string is interpreted as for \c RichText - if TQStyleSheet::mightBeRichText() returns TRUE, otherwise as - \c PlainText. - - \value LogText A special, limited text format which is only used - by TQTextEdit in an optimized mode. -*/ - -/*! - Returns TRUE if the string \a text is likely to be rich text; - otherwise returns FALSE. - - This function uses a fast and therefore simple heuristic. It - mainly checks whether there is something that looks like a tag - before the first line break. Although the result may be correct - for common cases, there is no guarantee. -*/ -bool TQStyleSheet::mightBeRichText( const TQString& text) -{ - if ( text.isEmpty() ) - return FALSE; - int start = 0; - - while ( start < int(text.length()) && text[start].isSpace() ) - ++start; - if ( text.mid( start, 5 ).lower() == " - ++open; - } - if ( open < (int)text.length() && text[open] == '<' ) { - int close = text.find('>', open); - if ( close > -1 ) { - TQString tag; - for (int i = open+1; i < close; ++i) { - if ( text[i].isDigit() || text[i].isLetter() ) - tag += text[i]; - else if ( !tag.isEmpty() && text[i].isSpace() ) - break; - else if ( !text[i].isSpace() && (!tag.isEmpty() || text[i] != '!' ) ) - return FALSE; // that's not a tag - } - return defaultSheet()->item( tag.lower() ) != 0; - } - } - return FALSE; -} - - -/*! - \fn void TQStyleSheet::error( const TQString& msg) const - - This virtual function is called when an error occurs when - processing rich text. Reimplement it if you need to catch error - messages. - - Errors might occur if some rich text strings contain tags that are - not understood by the stylesheet, if some tags are nested - incorrectly, or if tags are not closed properly. - - \a msg is the error message. -*/ -void TQStyleSheet::error( const TQString& ) const -{ -} - - -/*! - Scales the font \a font to the appropriate physical point size - corresponding to the logical font size \a logicalSize. - - When calling this function, \a font has a point size corresponding - to the logical font size 3. - - Logical font sizes range from 1 to 7, with 1 being the smallest. - - \sa TQStyleSheetItem::logicalFontSize(), TQStyleSheetItem::logicalFontSizeStep(), TQFont::setPointSize() - */ -void TQStyleSheet::scaleFont( TQFont& font, int logicalSize ) const -{ - if ( logicalSize < 1 ) - logicalSize = 1; - if ( logicalSize > 7 ) - logicalSize = 7; - int baseSize = font.pointSize(); - bool pixel = FALSE; - if ( baseSize == -1 ) { - baseSize = font.pixelSize(); - pixel = TRUE; - } - int s; - switch ( logicalSize ) { - case 1: - s = 7*baseSize/10; - break; - case 2: - s = (8 * baseSize) / 10; - break; - case 4: - s = (12 * baseSize) / 10; - break; - case 5: - s = (15 * baseSize) / 10; - break; - case 6: - s = 2 * baseSize; - break; - case 7: - s = (24 * baseSize) / 10; - break; - default: - s = baseSize; - } - if ( pixel ) - font.setPixelSize( s ); - else - font.setPointSize( s ); -} - -#endif // TQT_NO_RICHTEXT diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri index a021a33fe..d22498131 100644 --- a/src/kernel/qt_kernel.pri +++ b/src/kernel/qt_kernel.pri @@ -75,8 +75,8 @@ kernel { $$KERNEL_H/ntqsizepolicy.h \ $$KERNEL_H/ntqsocketnotifier.h \ $$KERNEL_H/ntqsound.h \ - $$KERNEL_H/ntqstyle.h \ - $$KERNEL_H/ntqstylesheet.h \ + $$KERNEL_H/tqstyle.h \ + $$KERNEL_H/tqstylesheet.h \ $$KERNEL_H/ntqthread.h \ $$KERNEL_H/ntqtimer.h \ $$KERNEL_H/ntqurl.h \ @@ -245,10 +245,10 @@ kernel { $$KERNEL_CPP/qsignalmapper.cpp \ $$KERNEL_CPP/qsize.cpp \ $$KERNEL_CPP/qsizegrip.cpp \ - $$KERNEL_CPP/qstyle.cpp \ + $$KERNEL_CPP/tqstyle.cpp \ $$KERNEL_CPP/qsocketnotifier.cpp \ $$KERNEL_CPP/qsound.cpp \ - $$KERNEL_CPP/qstylesheet.cpp \ + $$KERNEL_CPP/tqstylesheet.cpp \ $$KERNEL_CPP/qthread.cpp \ $$KERNEL_CPP/qtimer.cpp \ $$KERNEL_CPP/qurl.cpp \ diff --git a/src/kernel/qt_pch.h b/src/kernel/qt_pch.h index 4041d1847..a4655ff25 100644 --- a/src/kernel/qt_pch.h +++ b/src/kernel/qt_pch.h @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/kernel/tqobject.cpp b/src/kernel/tqobject.cpp index b87fd8d07..d50b48e85 100644 --- a/src/kernel/tqobject.cpp +++ b/src/kernel/tqobject.cpp @@ -50,7 +50,7 @@ #include "tqptrvector.h" // TQStyleControlElementData -#include "ntqstyle.h" +#include "tqstyle.h" #ifdef TQT_THREAD_SUPPORT #include "ntqmutex.h" diff --git a/src/kernel/tqstyle.cpp b/src/kernel/tqstyle.cpp new file mode 100644 index 000000000..f0c0524d6 --- /dev/null +++ b/src/kernel/tqstyle.cpp @@ -0,0 +1,2911 @@ +/**************************************************************************** +** +** Implementation of TQStyle class +** +** Created : 981231 +** +** Copyright (C) 1998-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqstyle.h" +#ifndef TQT_NO_STYLE +#include "ntqapplication.h" +#include "ntqpainter.h" +#include "ntqbitmap.h" +#include "ntqpixmapcache.h" +#include "ntqframe.h" +#include "ntqlayout.h" +#include "ntqlistview.h" +#include "ntqpopupmenu.h" +#include "ntqpushbutton.h" +#include "tqobjectlist.h" +#include "tqwidgetlist.h" + +#include + +class TQStylePrivate +{ +public: + TQStylePrivate() + { + } +}; + +TQStyleOption::TQStyleOption(StyleOptionDefault) : + def(TRUE), + tb(NULL), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(int in1) : + def(FALSE), + tb(NULL), + i1(in1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(int in1, int in2) : + def(FALSE), + tb(NULL), + i1(in1), + i2(in2), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(int in1, int in2, int in3, int in4) : + def(FALSE), + tb(NULL), + i1(in1), + i2(in2), + i3(in3), + i4(in4), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQMenuItem* m) : + def(FALSE), + mi(m), + tb(NULL), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQMenuItem* m, int in1) : + def(FALSE), + mi(m), + tb(NULL), + i1(in1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQMenuItem* m, int in1, int in2) : + def(FALSE), + mi(m), + tb(NULL), + i1(in1), + i2(in2), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(const TQColor& c) : + def(FALSE), + tb(NULL), + cl(&c), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQTab* t) : + def(FALSE), + tb(t), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQListViewItem* i) : + def(FALSE), + tb(NULL), + li(i), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQCheckListItem* i) : + def(FALSE), + tb(NULL), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(i), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQt::ArrowType a) : + def(FALSE), + tb(NULL), + i1((int)a), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(const TQRect& r) : + def(FALSE), + tb(NULL), + i1(r.x()), + i2(r.y()), + i3(r.width()), + i4(r.height()), + i5(-1), + cli(NULL), + tbh(NULL) { + // +} + +TQStyleOption::TQStyleOption(TQWidget *w) : + def(FALSE), + tb(NULL), + i1(-1), + i2(-1), + i3(-1), + i4(-1), + i5(-1), + cli(NULL), + p1((void*)w), + tbh(NULL) { + // +} + +/*! + \class TQStyleOption tqstyle.h + \brief The TQStyleOption class specifies optional parameters for TQStyle functions. + \ingroup appearance + + Some TQStyle functions take an optional argument specifying extra + information that is required for a paritical primitive or control. + So that the TQStyle class can be extended, TQStyleOption is used to + provide a variable-argument for these options. + + The TQStyleOption class has constructors for each type of optional + argument, and this set of constructors may be extended in future + TQt releases. There are also corresponding access functions that + return the optional arguments: these too may be extended. + + For each constructor, you should refer to the documentation of the + TQStyle functions to see the meaning of the arguments. + + When calling TQStyle functions from your own widgets, you must only + pass the default TQStyleOption or the argument that TQStyle is + documented to accept. For example, if the function expects + TQStyleOption(TQMenuItem *, int), passing TQStyleOption(TQMenuItem *) + leaves the optional integer argument uninitialized. + + When subclassing TQStyle, you must similarly only expect the + default or documented arguments. The other arguments will have + uninitialized values. + + If you make your own TQStyle subclasses and your own widgets, you + can make a subclass of TQStyleOption to pass additional arguments + to your TQStyle subclass. You will need to cast the "const + TQStyleOption&" argument to your subclass, so be sure your style + has been called from your widget. +*/ + +/*! + \enum TQStyleOption::StyleOptionDefault + + This enum value can be passed as the optional argument to any + TQStyle function. + + \value Default +*/ + +/*! + \fn TQStyleOption::TQStyleOption(StyleOptionDefault) + + The default option. This can always be passed as the optional + argument to TQStyle functions. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(int) + + Pass one integer, \a in1. For example, headerSection. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(int, int) + + Pass two integers, \a in1 and \a in2. For example, linewidth and + midlinewidth. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(int, int, int, int) + + Pass four integers, \a in1, \a in2, \a in3 and \a in4. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQMenuItem*) + + Pass a menu item, \a m. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQMenuItem*, int) + + Pass a menu item and an integer, \a m and \a in1. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQMenuItem*, int, int) + + Pass a menu item and two integers, \a m, \a in1 and \a in2. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(const TQColor&) + + Pass a color, \a c. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQTab*) + + Pass a TQTab, \a t. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQListViewItem*) + + Pass a TQListViewItem, \a i. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQt::ArrowType) + + Pass an TQt::ArrowType, \a a. +*/ + +/*! + \fn TQStyleOption::TQStyleOption(TQCheckListItem* i) + + Pass a TQCheckListItem, \a i. +*/ + +/*! + \fn TQStyleOption::TQStyleOption( const TQRect &r ) + + Pass a TQRect, \a r. +*/ + +/*! + \fn TQStyleOption::TQStyleOption( TQWidget *w ) + + Pass a TQWidget, \a w. +*/ + +/*! + \fn bool TQStyleOption::isDefault() const + + Returns TRUE if the option was constructed with the default + constructor; otherwise returns FALSE. +*/ + +/*! + \fn int TQStyleOption::day() const + + Returns the index of the day in the month if the appropriate + constructor was called; otherwise the return value is undefined. +*/ + +/*! + \fn int TQStyleOption::lineWidth() const + + Returns the line width if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \fn int TQStyleOption::midLineWidth() const + + Returns the mid-line width if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn int TQStyleOption::frameShape() const + + Returns a TQFrame::Shape value if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn int TQStyleOption::frameShadow() const + + Returns a TQFrame::Shadow value if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn TQMenuItem* TQStyleOption::menuItem() const + + Returns a menu item if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \fn int TQStyleOption::maxIconWidth() const + + Returns the maximum width of the menu item check area if the + appropriate constructor was called; otherwise the return value is + undefined. +*/ + +/*! + \fn int TQStyleOption::tabWidth() const + + Returns the tab indent width if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn int TQStyleOption::headerSection() const + + Returns the header section if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn const TQColor& TQStyleOption::color() const + + Returns a color if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \fn TQTab* TQStyleOption::tab() const + + Returns a TQTabBar tab if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \fn TQListViewItem* TQStyleOption::listViewItem() const + + Returns a TQListView item if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn TQt::ArrowType TQStyleOption::arrowType() const + + Returns an arrow type if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \fn TQCheckListItem* TQStyleOption::checkListItem() const + + Returns a check list item if the appropriate constructor was + called; otherwise the return value is undefined. +*/ + +/*! + \fn TQRect TQStyleOption::rect() const + + Returns a rectangle if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \fn TQWidget* TQStyleOption::widget() const + + Returns a pointer to a widget if the appropriate constructor was called; + otherwise the return value is undefined. +*/ + +/*! + \class TQStyle tqstyle.h + \brief The TQStyle class specifies the look and feel of a GUI. + \ingroup appearance + + A large number of GUI elements are common to many widgets. The + TQStyle class allows the look of these elements to be modified + across all widgets that use the TQStyle functions. It also + provides two feel options: Motif and Windows. + + Although it is not possible to fully enumerate the look of + graphical elements and the feel of widgets in a GUI, TQStyle + provides a considerable amount of control and customisability. + + In TQt 1.x the look and feel option for widgets was specified by a + single value: the GUIStyle. Starting with TQt 2.0, this notion was + expanded to allow the look to be specified by virtual drawing + functions. + + Derived classes may reimplement some or all of the drawing + functions to modify the look of all widgets that use those + functions. + + Languages written from right to left (such as Arabic and Hebrew) + usually also mirror the whole layout of widgets. If you design a + style, you should take special care when drawing asymmetric + elements to make sure that they also look correct in a mirrored + layout. You can start your application with \c -reverse to check + the mirrored layout. Also notice, that for a reversed layout, the + light usually comes from top right instead of top left. + + The actual reverse layout is performed automatically when + possible. However, for the sake of flexibility, the translation + cannot be performed everywhere. The documentation for each + function in the TQStyle API states whether the function + expects/returns logical or screen coordinates. Using logical + coordinates (in ComplexControls, for example) provides great + flexibility in controlling the look of a widget. Use visualRect() + when necessary to translate logical coordinates into screen + coordinates for drawing. + + In TQt versions prior to 3.0, if you wanted a low level route into + changing the appearance of a widget, you would reimplement + polish(). With the new 3.0 style engine the recommended approach + is to reimplement the draw functions, for example drawItem(), + drawPrimitive(), drawControl(), drawControlMask(), + drawComplexControl() and drawComplexControlMask(). Each of these + functions is called with a range of parameters that provide + information that you can use to determine how to draw them, e.g. + style flags, rectangle, color group, etc. + + For information on changing elements of an existing style or + creating your own style see the \link customstyles.html Style + overview\endlink. + + Styles can also be created as \link plugins-howto.html + plugins\endlink. +*/ + +/*! + \enum TQt::GUIStyle + + \obsolete + + \value WindowsStyle + \value MotifStyle + \value MacStyle + \value Win3Style + \value PMStyle +*/ + +/*! + \enum TQt::UIEffect + + \value UI_General + \value UI_AnimateMenu + \value UI_FadeMenu + \value UI_AnimateCombo + \value UI_AnimateTooltip + \value UI_FadeTooltip + \value UI_AnimateToolBox Reserved +*/ + +/*! + Constructs a TQStyle. +*/ +TQStyle::TQStyle() +{ + m_eventHandlerInstallationHook = NULL; + m_eventHandlerRemovalHook = NULL; + m_widgetActionRequestHook = NULL; + m_applicationActionRequestHook = NULL; + conditionalAcceleratorsEnabled = false; + d = new TQStylePrivate; +} + +/*! + Destroys the style and frees all allocated resources. +*/ +TQStyle::~TQStyle() +{ + delete d; + d = 0; +} + +/* + \fn GUIStyle TQStyle::guiStyle() const + \obsolete + + Returns an indicator to the additional "feel" component of a + style. Current supported values are TQt::WindowsStyle and TQt::MotifStyle. +*/ + +/*! + Initializes the appearance of a widget. + + This function is called for every widget at some point after it + has been fully created but just \e before it is shown the very + first time. + + Reasonable actions in this function might be to call + TQWidget::setBackgroundMode() for the widget. An example of highly + unreasonable use would be setting the geometry! Reimplementing + this function gives you a back-door through which you can change + the appearance of a widget. With TQt 3.0's style engine you will + rarely need to write your own polish(); instead reimplement + drawItem(), drawPrimitive(), etc. + + The TQWidget::inherits() function may provide enough information to + allow class-specific customizations. But be careful not to + hard-code things too much because new TQStyle subclasses are + expected to work reasonably with all current and \e future + widgets. + + \sa unPolish() +*/ +void TQStyle::polish( TQWidget *widget ) { + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + polish(ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); +} + +/*! + Undoes the initialization of a widget's appearance. + + This function is the counterpart to polish. It is called for every + polished widget when the style is dynamically changed. The former + style has to unpolish its settings before the new style can polish + them again. + + \sa polish() +*/ +void TQStyle::unPolish( TQWidget *widget ) { + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + unPolish(ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); +} + +/*! + Initializes the appearance of a widget. + + This function is called for every widget at some point after it + has been fully created but just \e before it is shown the very + first time. + + Reasonable actions in this function might be to install a widget + event handler for the style. An example of highly unreasonable + use would be setting the geometry! With TQt 3.0's style engine + you will rarely need to write your own polish(); instead reimplement + drawItem(), drawPrimitive(), etc. + + The \a objectTypes object may provide enough information to + allow class-specific customizations. But be careful not to + hard-code things too much because new TQStyle subclasses are + expected to work reasonably with all current and \e future + widgets. + + You may specify either a TQWidget pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void TQStyle::polish( const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { + // Enable dynamic hide/show of accelerator shortcuts + TQWidget* widget = reinterpret_cast(ptr); + widget->installEventFilter(this); + } +} + +/*! + Undoes the initialization of a widget's appearance. + + This function is the counterpart to polish. It is called for every + polished widget when the style is dynamically changed. The former + style has to unpolish its settings before the new style can polish + them again. + + \sa polish() +*/ +void TQStyle::unPolish( const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr ) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { + // Disable dynamic hide/show of accelerator shortcuts + TQWidget* widget = reinterpret_cast(ptr); + widget->installEventFilter(this); + } +} + +/*! + \overload + Late initialization of the TQApplication object. + + \sa unPolish() +*/ +void TQStyle::polish( TQApplication *app ) { + const TQStyleControlElementData &ceData = populateControlElementDataFromApplication(app, TQStyleOption()); + applicationPolish(ceData, getControlElementFlagsForObject(app, TQStyleOption()), app); +} + +/*! + \overload + + Undoes the application polish. + + \sa polish() +*/ +void TQStyle::unPolish( TQApplication *app ) { + const TQStyleControlElementData &ceData = populateControlElementDataFromApplication(app, TQStyleOption()); + applicationUnPolish(ceData, getControlElementFlagsForObject(app, TQStyleOption()), app); +} + +/*! + \overload + Late initialization of the TQApplication object or other global application object. + + You may specify either a TQApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa unPolish() +*/ +void TQStyle::applicationPolish( const TQStyleControlElementData&, ControlElementFlags, void * ) { + // +} + +/*! + \overload + + Undoes the application polish. + + You may specify either a TQApplication pointer or a custom pointer. + If a custom pointer is specified, you must be careful to intercept any event + handler installation/removal calls via setEventHandlerInstallationHook and + setEventHandlerRemovalHook. + + \sa polish() +*/ +void TQStyle::applicationUnPolish( const TQStyleControlElementData&, ControlElementFlags, void * ) { + // +} + +/*! + \overload + + The style may have certain requirements for color palettes. In + this function it has the chance to change the palette according to + these requirements. + + \sa TQPalette, TQApplication::setPalette() +*/ +void TQStyle::polish( TQPalette&) +{ +} + +/*! + Polishes the popup menu according to the GUI style. This usually + means setting the mouse tracking + (\l{TQPopupMenu::setMouseTracking()}) and whether the menu is + checkable by default (\l{TQPopupMenu::setCheckable()}). +*/ +void TQStyle::polishPopupMenu( TQPopupMenu *pm ) { + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(pm, TQStyleOption()); + polish(ceData, getControlElementFlagsForObject(pm, TQStyleOption()), pm); +} + +/*! + Polishes the popup menu according to the GUI style. This usually + means setting the mouse tracking + (\l{TQPopupMenu::setMouseTracking()}) and whether the menu is + checkable by default (\l{TQPopupMenu::setCheckable()}). +*/ +void TQStyle::polishPopupMenu( const TQStyleControlElementData&, ControlElementFlags, void * ) +{ +} + +/*! + Returns the appropriate area (see below) within rectangle \a r in + which to draw the \a text or \a pixmap using painter \a p. If \a + len is -1 (the default) all the \a text is drawn; otherwise only + the first \a len characters of \a text are drawn. The text is + aligned in accordance with the alignment \a flags (see + \l{TQt::AlignmentFlags}). The \a enabled bool indicates whether or + not the item is enabled. + + If \a r is larger than the area needed to render the \a text the + rectangle that is returned will be offset within \a r in + accordance with the alignment \a flags. For example if \a flags is + \c AlignCenter the returned rectangle will be centered within \a + r. If \a r is smaller than the area needed the rectangle that is + returned will be \e larger than \a r (the smallest rectangle large + enough to render the \a text or \a pixmap). + + By default, if both the text and the pixmap are not null, the + pixmap is drawn and the text is ignored. +*/ +TQRect TQStyle::itemRect( TQPainter *p, const TQRect &r, + int flags, bool enabled, const TQPixmap *pixmap, + const TQString& text, int len ) const +{ + TQRect result; + int x = r.x(); + int y = r.y(); + int w = r.width(); + int h = r.height(); + GUIStyle gs = (GUIStyle)styleHint( SH_GUIStyle ); + + if ( pixmap ) { + if ( (flags & TQt::AlignVCenter) == TQt::AlignVCenter ) + y += h/2 - pixmap->height()/2; + else if ( (flags & TQt::AlignBottom) == TQt::AlignBottom) + y += h - pixmap->height(); + if ( (flags & TQt::AlignRight) == TQt::AlignRight ) + x += w - pixmap->width(); + else if ( (flags & TQt::AlignHCenter) == TQt::AlignHCenter ) + x += w/2 - pixmap->width()/2; + else if ( (flags & TQt::AlignLeft) != TQt::AlignLeft && TQApplication::reverseLayout() ) + x += w - pixmap->width(); + result = TQRect(x, y, pixmap->width(), pixmap->height()); + } else if ( !text.isNull() && p ) { + result = p->boundingRect( x, y, w, h, flags, text, len ); + if ( gs == TQt::WindowsStyle && !enabled ) { + result.setWidth(result.width()+1); + result.setHeight(result.height()+1); + } + } else { + result = TQRect(x, y, w, h); + } + + return result; +} + + +/*! + Draws the \a text or \a pixmap in rectangle \a r using painter \a + p and color group \a g. The pen color is specified with \a + penColor. The \a enabled bool indicates whether or not the item is + enabled; when reimplementing this bool should influence how the + item is drawn. If \a len is -1 (the default) all the \a text is + drawn; otherwise only the first \a len characters of \a text are + drawn. The text is aligned and wrapped according to the alignment + \a flags (see \l{TQt::AlignmentFlags}). + + By default, if both the text and the pixmap are not null, the + pixmap is drawn and the text is ignored. +*/ +void TQStyle::drawItem( TQPainter *p, const TQRect &r, + int flags, const TQColorGroup &g, bool enabled, + const TQPixmap *pixmap, const TQString& text, int len, + const TQColor* penColor ) const +{ + int x = r.x(); + int y = r.y(); + int w = r.width(); + int h = r.height(); + GUIStyle gs = (GUIStyle)styleHint( SH_GUIStyle ); + + p->setPen( penColor?*penColor:g.foreground() ); + if ( pixmap ) { + TQPixmap pm( *pixmap ); + bool clip = (flags & TQt::DontClip) == 0; + if ( clip ) { + if ( pm.width() < w && pm.height() < h ) { + clip = FALSE; + } else { + p->save(); + TQRegion cr = TQRect(x, y, w, h); + if (p->hasClipping()) + cr &= p->clipRegion(TQPainter::CoordPainter); + p->setClipRegion(cr); + } + } + if ( (flags & TQt::AlignVCenter) == TQt::AlignVCenter ) + y += h/2 - pm.height()/2; + else if ( (flags & TQt::AlignBottom) == TQt::AlignBottom) + y += h - pm.height(); + if ( (flags & TQt::AlignRight) == TQt::AlignRight ) + x += w - pm.width(); + else if ( (flags & TQt::AlignHCenter) == TQt::AlignHCenter ) + x += w/2 - pm.width()/2; + else if ( ((flags & TQt::AlignLeft) != TQt::AlignLeft) && TQApplication::reverseLayout() ) // AlignAuto && rightToLeft + x += w - pm.width(); + + if ( !enabled ) { + if ( pm.mask() ) { // pixmap with a mask + if ( !pm.selfMask() ) { // mask is not pixmap itself + TQPixmap pmm( *pm.mask() ); + pmm.setMask( *((TQBitmap *)&pmm) ); + pm = pmm; + } + } else if ( pm.depth() == 1 ) { // monochrome pixmap, no mask + pm.setMask( *((TQBitmap *)&pm) ); +#ifndef TQT_NO_IMAGE_HEURISTIC_MASK + } else { // color pixmap, no mask + TQString k; + k.sprintf( "$qt-drawitem-%x", pm.serialNumber() ); + TQPixmap *mask = TQPixmapCache::find(k); + bool del=FALSE; + if ( !mask ) { + mask = new TQPixmap( pm.createHeuristicMask() ); + mask->setMask( *((TQBitmap*)mask) ); + del = !TQPixmapCache::insert( k, mask ); + } + pm = *mask; + if (del) delete mask; +#endif + } + if ( gs == TQt::WindowsStyle ) { + p->setPen( g.light() ); + p->drawPixmap( x+1, y+1, pm ); + p->setPen( g.text() ); + } + } + p->drawPixmap( x, y, pm ); + if ( clip ) + p->restore(); + } else if ( !text.isNull() ) { + if ( gs == TQt::WindowsStyle && !enabled ) { + p->setPen( g.light() ); + p->drawText( x+1, y+1, w, h, flags, text, len ); + p->setPen( g.text() ); + } + p->drawText( x, y, w, h, flags, text, len ); + } +} + +/*! + \enum TQStyle::PrimitiveElement + + This enum represents the PrimitiveElements of a style. A + PrimitiveElement is a common GUI element, such as a checkbox + indicator or pushbutton bevel. + + \value PE_ButtonCommand button used to initiate an action, for + example, a TQPushButton. + \value PE_ButtonDefault this button is the default button, e.g. + in a dialog. + \value PE_ButtonBevel generic button bevel. + \value PE_ButtonTool tool button, for example, a TQToolButton. + \value PE_ButtonDropDown drop down button, for example, a tool + button that displays a popup menu, for example, TQPopupMenu. + + + \value PE_FocusRect generic focus indicator. + + + \value PE_ArrowUp up arrow. + \value PE_ArrowDown down arrow. + \value PE_ArrowRight right arrow. + \value PE_ArrowLeft left arrow. + + + \value PE_SpinWidgetUp up symbol for a spin widget, for example a + TQSpinBox. + \value PE_SpinWidgetDown down symbol for a spin widget. + \value PE_SpinWidgetPlus increase symbol for a spin widget. + \value PE_SpinWidgetMinus decrease symbol for a spin widget. + + + \value PE_Indicator on/off indicator, for example, a TQCheckBox. + \value PE_IndicatorMask bitmap mask for an indicator. + \value PE_ExclusiveIndicator exclusive on/off indicator, for + example, a TQRadioButton. + \value PE_ExclusiveIndicatorMask bitmap mask for an exclusive indicator. + + + \value PE_DockWindowHandle tear off handle for dock windows and + toolbars, for example \l{TQDockWindow}s and \l{TQToolBar}s. + \value PE_DockWindowSeparator item separator for dock window and + toolbar contents. + \value PE_DockWindowResizeHandle resize handle for dock windows. + + \value PE_Splitter splitter handle; see also TQSplitter. + + + \value PE_Panel generic panel frame; see also TQFrame. + \value PE_PanelPopup panel frame for popup windows/menus; see also + TQPopupMenu. + \value PE_PanelMenuBar panel frame for menu bars. + \value PE_PanelDockWindow panel frame for dock windows and toolbars. + \value PE_PanelTabWidget panel frame for tab widgets. + \value PE_PanelLineEdit panel frame for line edits. + \value PE_PanelGroupBox panel frame for group boxes. + + \value PE_TabBarBase area below tabs in a tab widget, for example, + TQTab. + + + \value PE_HeaderSection section of a list or table header; see also + TQHeader. + \value PE_HeaderArrow arrow used to indicate sorting on a list or table + header + \value PE_StatusBarSection section of a status bar; see also + TQStatusBar. + + + \value PE_GroupBoxFrame frame around a group box; see also + TQGroupBox. + \value PE_WindowFrame frame around a MDI window or a docking window + + + \value PE_Separator generic separator. + + + \value PE_SizeGrip window resize handle; see also TQSizeGrip. + + + \value PE_CheckMark generic check mark; see also TQCheckBox. + + + \value PE_ScrollBarAddLine scrollbar line increase indicator + (i.e. scroll down); see also TQScrollBar. + \value PE_ScrollBarSubLine scrollbar line decrease indicator (i.e. scroll up). + \value PE_ScrollBarAddPage scolllbar page increase indicator (i.e. page down). + \value PE_ScrollBarSubPage scrollbar page decrease indicator (i.e. page up). + \value PE_ScrollBarSlider scrollbar slider + \value PE_ScrollBarFirst scrollbar first line indicator (i.e. home). + \value PE_ScrollBarLast scrollbar last line indicator (i.e. end). + + + \value PE_ProgressBarChunk section of a progress bar indicator; see + also TQProgressBar. + + \value PE_CheckListController controller part of a listview item + \value PE_CheckListIndicator checkbox part of a listview item + \value PE_CheckListExclusiveIndicator radiobutton part of a listview item + \value PE_RubberBand rubber band used in such things as iconview + + \value PE_CustomBase base value for custom PrimitiveElements. + All values above this are reserved for custom use. Custom + values must be greater than this value. + + \sa drawPrimitive() +*/ +/*! \enum TQStyle::SFlags + \internal +*/ +/*! \enum TQStyle::SCFlags + \internal +*/ + +/*! + \enum TQStyle::StyleFlags + + This enum represents flags for drawing PrimitiveElements. Not all + primitives use all of these flags. Note that these flags may mean + different things to different primitives. For an explanation of + the relationship between primitives and their flags, as well as + the different meanings of the flags, see the \link + customstyles.html Style overview\endlink. + + \value Style_Default + \value Style_Enabled + \value Style_Raised + \value Style_Sunken + \value Style_Off + \value Style_NoChange + \value Style_On + \value Style_Down + \value Style_Horizontal + \value Style_HasFocus + \value Style_Top + \value Style_Bottom + \value Style_FocusAtBorder + \value Style_AutoRaise + \value Style_MouseOver + \value Style_Up + \value Style_Selected + \value Style_HasFocus + \value Style_Active + \value Style_ButtonDefault + + \sa drawPrimitive() +*/ + +/*! + \fn void TQStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption& opt) const + + Draws the style PrimitiveElement \a pe using the painter \a p in + the area \a r. Colors are used from the color group \a cg. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The rect \a r should be in screen coordinates. + + The \a flags argument is used to control how the PrimitiveElement + is drawn. Multiple flags can be OR'ed together. + + For example, a pressed button would be drawn with the flags \c + Style_Enabled and \c Style_Down. + + The \a opt argument can be used to control how various + PrimitiveElements are drawn. Note that \a opt may be the default + value even for PrimitiveElements that make use of extra options. + When \a opt is non-default, it is used as follows: + + \table + \header \i PrimitiveElement \i Options \i Notes + \row \i \l PE_FocusRect + \i \l TQStyleOption ( const \l TQColor & bg ) + \list + \i opt.\link TQStyleOption::color() color\endlink() + \endlist + \i \e bg is the background color on which the focus rect is being drawn. + \row \i12 \l PE_Panel + \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) + \list + \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() + \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() + \endlist + \i \e linewidth is the line width for drawing the panel. + \row \i \e midlinewidth is the mid-line width for drawing the panel. + \row \i12 \l PE_PanelPopup + \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) + \list + \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() + \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() + \endlist + \i \e linewidth is the line width for drawing the panel. + \row \i \e midlinewidth is the mid-line width for drawing the panel. + \row \i12 \l PE_PanelMenuBar + \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) + \list + \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() + \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() + \endlist + \i \e linewidth is the line width for drawing the panel. + \row \i \e midlinewidth is the mid-line width for drawing the panel. + \row \i12 \l PE_PanelDockWindow + \i12 \l TQStyleOption ( int linewidth, int midlinewidth ) + \list + \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() + \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() + \endlist + \i \e linewidth is the line width for drawing the panel. + \row \i \e midlinewidth is the mid-line width for drawing the panel. + \row \i14 \l PE_GroupBoxFrame + \i14 \l TQStyleOption ( int linewidth, int midlinewidth, int shape, int shadow ) + \list + \i opt.\link TQStyleOption::lineWidth() lineWidth\endlink() + \i opt.\link TQStyleOption::midLineWidth() midLineWidth\endlink() + \i opt.\link TQStyleOption::frameShape() frameShape\endlink() + \i opt.\link TQStyleOption::frameShadow() frameShadow\endlink() + \endlist + \i \e linewidth is the line width for the group box. + \row \i \e midlinewidth is the mid-line width for the group box. + \row \i \e shape is the \link TQFrame::frameShape frame shape \endlink + for the group box. + \row \i \e shadow is the \link TQFrame::frameShadow frame shadow \endlink + for the group box. + \endtable + + + For all other \link TQStyle::PrimitiveElement + PrimitiveElements\endlink, \a opt is unused. + + \sa StyleFlags +*/ + +/*! + \enum TQStyle::ControlElement + + This enum represents a ControlElement. A ControlElement is part of + a widget that performs some action or displays information to the + user. + + \value CE_PushButton the bevel and default indicator of a TQPushButton. + \value CE_PushButtonLabel the label (iconset with text or pixmap) + of a TQPushButton. + + \value CE_CheckBox the indicator of a TQCheckBox. + \value CE_CheckBoxLabel the label (text or pixmap) of a TQCheckBox. + + \value CE_RadioButton the indicator of a TQRadioButton. + \value CE_RadioButtonLabel the label (text or pixmap) of a TQRadioButton. + + \value CE_TabBarTab the tab within a TQTabBar (a TQTab). + \value CE_TabBarLabel the label within a TQTab. + + \value CE_ProgressBarGroove the groove where the progress + indicator is drawn in a TQProgressBar. + \value CE_ProgressBarContents the progress indicator of a TQProgressBar. + \value CE_ProgressBarLabel the text label of a TQProgressBar. + + \value CE_PopupMenuItem a menu item in a TQPopupMenu. + \value CE_PopupMenuScroller scrolling areas in a popumenu when the + style supports scrolling. + \value CE_PopupMenuHorizontalExtra extra frame area set aside with PM_PopupMenuFrameHorizontalExtra + \value CE_PopupMenuVerticalExtra extra frame area set aside with PM_PopupMenuFrameVerticalExtra + + \value CE_MenuBarItem a menu item in a TQMenuBar. + + \value CE_ToolButtonLabel a tool button's label. + + \value CE_MenuBarEmptyArea the empty area of a TQMenuBar. + \value CE_DockWindowEmptyArea the empty area of a TQDockWindow. + + \value CE_ToolBoxTab the toolbox's tab area + \value CE_HeaderLabel the header's label + + \value CE_CustomBase base value for custom ControlElements. All values above + this are reserved for custom use. Therefore, custom values must be + greater than this value. + + \sa drawControl() +*/ + +/*! + \fn void TQStyle::drawControl( ControlElement element, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, const TQStyleOption& opt, const TQWidget *widget) const + + Draws the ControlElement \a element using the painter \a p in the + area \a r. Colors are used from the color group \a cg. + + The rect \a r should be in screen coordinates. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a how argument is used to control how the ControlElement is + drawn. Multiple flags can be OR'ed together. See the table below + for an explanation of which flags are used with the various + ControlElements. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. Note that usage of the widget argument is deprecated + in favor of specifying widget parameters via \a ceData and \a elementFlags. + The widget can be cast to the appropriate type based + on the value of \a element. The \a opt argument can be used to + pass extra information required when drawing the ControlElement. + Note that \a opt may be the default value even for ControlElements + that can make use of the extra options. See the table below for + the appropriate \a widget and \a opt usage: + + \table + \header \i ControlElement
        \& Widget Cast + \i Style Flags + \i Notes + \i Options + \i Notes + + \row \i16 \l{CE_PushButton}(const \l TQPushButton *) + + and + + \l{CE_PushButtonLabel}(const \l TQPushButton *) + \i \l Style_Enabled \i Set if the button is enabled. + \i16 Unused. + \i16   + \row \i \l Style_HasFocus \i Set if the button has input focus. + \row \i \l Style_Raised \i Set if the button is not down, not on and not flat. + \row \i \l Style_On \i Set if the button is a toggle button and toggled on. + \row \i \l Style_Down \i Set if the button is down (i.e., the mouse button or + space bar is pressed on the button). + \row \i \l Style_ButtonDefault \i Set if the button is a default button. + + \row \i16 \l{CE_CheckBox}(const \l TQCheckBox *) + + and + + \l{CE_CheckBoxLabel}(const \l TQCheckBox *) + + \i \l Style_Enabled \i Set if the checkbox is enabled. + \i16 Unused. + \i16   + \row \i \l Style_HasFocus \i Set if the checkbox has input focus. + \row \i \l Style_On \i Set if the checkbox is checked. + \row \i \l Style_Off \i Set if the checkbox is not checked. + \row \i \l Style_NoChange \i Set if the checkbox is in the NoChange state. + \row \i \l Style_Down \i Set if the checkbox is down (i.e., the mouse button or + space bar is pressed on the button). + + \row \i15 \l{CE_RadioButton}(const TQRadioButton *) + + and + + \l{CE_RadioButtonLabel}(const TQRadioButton *) + \i \l Style_Enabled \i Set if the radiobutton is enabled. + \i15 Unused. + \i15   + \row \i \l Style_HasFocus \i Set if the radiobutton has input focus. + \row \i \l Style_On \i Set if the radiobutton is checked. + \row \i \l Style_Off \i Set if the radiobutton is not checked. + \row \i \l Style_Down \i Set if the radiobutton is down (i.e., the mouse + button or space bar is pressed on the radiobutton). + + \row \i12 \l{CE_TabBarTab}(const \l TQTabBar *) + + and + + \l{CE_TabBarLabel}(const \l TQTabBar *) + + \i \l Style_Enabled \i Set if the tabbar and tab is enabled. + \i12 \l TQStyleOption ( \l TQTab *t ) + \list + \i opt.\link TQStyleOption::tab() tab\endlink() + \endlist + \i12 \e t is the TQTab being drawn. + \row \i \l Style_Selected \i Set if the tab is the current tab. + + \row \i12 \l{CE_ProgressBarGroove}(const TQProgressBar *) + + and + + \l{CE_ProgressBarContents}(const TQProgressBar *) + + and + + \l{CE_ProgressBarLabel}(const TQProgressBar *) + + \i \l Style_Enabled \i Set if the progressbar is enabled. + \i12 Unused. + \i12   + \row \i \l Style_HasFocus \i Set if the progressbar has input focus. + + \row \i13 \l{CE_PopupMenuItem}(const \l TQPopupMenu *) + \i \l Style_Enabled \i Set if the menuitem is enabled. + \i13 \l TQStyleOption ( TQMenuItem *mi, int tabwidth, int maxpmwidth ) + \list + \i opt.\link TQStyleOption::menuItem() menuItem\endlink() + \i opt.\link TQStyleOption::tabWidth() tabWidth\endlink() + \i opt.\link TQStyleOption::maxIconWidth() maxIconWidth\endlink() + \endlist + \i \e mi is the menu item being drawn. TQMenuItem is currently an + internal class. + \row \i \l Style_Active \i Set if the menuitem is the current item. + \i \e tabwidth is the width of the tab column where key accelerators + are drawn. + \row \i \l Style_Down \i Set if the menuitem is down (i.e., the mouse button + or space bar is pressed). + \i \e maxpmwidth is the maximum width of the check column where + checkmarks and iconsets are drawn. + + \row \i14 \l{CE_MenuBarItem}(const \l TQMenuBar *) + \i \l Style_Enabled \i Set if the menuitem is enabled + \i14 \l TQStyleOption ( TQMenuItem *mi ) + \list + \i opt.\link TQStyleOption::menuItem() menuItem\endlink() + \endlist + \i14 \e mi is the menu item being drawn. + \row \i \l Style_Active \i Set if the menuitem is the current item. + \row \i \l Style_Down \i Set if the menuitem is down (i.e., a mouse button or + the space bar is pressed). + \row \i \l Style_HasFocus \i Set if the menubar has input focus. + + \row \i17 \l{CE_ToolButtonLabel}(const \l TQToolButton *) + \i \l Style_Enabled \i Set if the toolbutton is enabled. + \i17 \l TQStyleOption ( \l ArrowType t ) + \list + \i opt.\link TQStyleOption::arrowType() arrowType\endlink() + \endlist + \i17 When the tool button only contains an arrow, \e t is the + arrow's type. + \row \i \l Style_HasFocus \i Set if the toolbutton has input focus. + \row \i \l Style_Down \i Set if the toolbutton is down (i.e., a + mouse button or the space is pressed). + \row \i \l Style_On \i Set if the toolbutton is a toggle button + and is toggled on. + \row \i \l Style_AutoRaise \i Set if the toolbutton has auto-raise enabled. + \row \i \l Style_MouseOver \i Set if the mouse pointer is over the toolbutton. + \row \i \l Style_Raised \i Set if the button is not down, not on and doesn't + contain the mouse when auto-raise is enabled. + \endtable + + \sa ControlElement, StyleFlags +*/ + +/*! + \fn void TQStyle::drawControlMask( ControlElement element, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQStyleOption& opt, const TQWidget *widget) const + + Draw a bitmask for the ControlElement \a element using the painter + \a p in the area \a r. See drawControl() for an explanation of the + use of the \a widget and \a opt arguments. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The rect \a r should be in screen coordinates. + + \a widget is deprecated and should not be used. + + \sa drawControl(), ControlElement +*/ + +/*! + \enum TQStyle::SubRect + + This enum represents a sub-area of a widget. Style implementations + would use these areas to draw the different parts of a widget. + + \value SR_PushButtonContents area containing the label (iconset + with text or pixmap). + \value SR_PushButtonFocusRect area for the focus rect (usually + larger than the contents rect). + + \value SR_CheckBoxIndicator area for the state indicator (e.g. check mark). + \value SR_CheckBoxContents area for the label (text or pixmap). + \value SR_CheckBoxFocusRect area for the focus indicator. + + + \value SR_RadioButtonIndicator area for the state indicator. + \value SR_RadioButtonContents area for the label. + \value SR_RadioButtonFocusRect area for the focus indicator. + + + \value SR_ComboBoxFocusRect area for the focus indicator. + + + \value SR_SliderFocusRect area for the focus indicator. + + + \value SR_DockWindowHandleRect area for the tear-off handle. + + + \value SR_ProgressBarGroove area for the groove. + \value SR_ProgressBarContents area for the progress indicator. + \value SR_ProgressBarLabel area for the text label. + + + \value SR_ToolButtonContents area for the tool button's label. + + \value SR_DialogButtonAccept area for a dialog's accept button. + \value SR_DialogButtonReject area for a dialog's reject button. + \value SR_DialogButtonApply area for a dialog's apply button. + \value SR_DialogButtonHelp area for a dialog's help button. + \value SR_DialogButtonAll area for a dialog's all button. + \value SR_DialogButtonRetry area for a dialog's retry button. + \value SR_DialogButtonAbort area for a dialog's abort button. + \value SR_DialogButtonIgnore area for a dialog's ignore button. + \value SR_DialogButtonCustom area for a dialog's custom widget area (in button row). + + \value SR_ToolBoxTabContents area for a toolbox tab's icon and label + + \value SR_CustomBase base value for custom ControlElements. All values above + this are reserved for custom use. Therefore, custom values must be + greater than this value. + + \sa subRect() +*/ + +/*! + \fn TQRect TQStyle::subRect( SubRect subrect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const; + + Returns the sub-area \a subrect for the \a widget in logical + coordinates. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. Note that usage of \a widget is deprecated in favor + of \a ceData and \a elementFlags. The widget can be cast to the + appropriate type based on the value of \a subrect. See the table + below for the appropriate \a widget casts: + + \table + \header \i SubRect \i Widget Cast + \row \i \l SR_PushButtonContents \i (const \l TQPushButton *) + \row \i \l SR_PushButtonFocusRect \i (const \l TQPushButton *) + \row \i \l SR_CheckBoxIndicator \i (const \l TQCheckBox *) + \row \i \l SR_CheckBoxContents \i (const \l TQCheckBox *) + \row \i \l SR_CheckBoxFocusRect \i (const \l TQCheckBox *) + \row \i \l SR_RadioButtonIndicator \i (const \l TQRadioButton *) + \row \i \l SR_RadioButtonContents \i (const \l TQRadioButton *) + \row \i \l SR_RadioButtonFocusRect \i (const \l TQRadioButton *) + \row \i \l SR_ComboBoxFocusRect \i (const \l TQComboBox *) + \row \i \l SR_DockWindowHandleRect \i (const \l TQWidget *) + \row \i \l SR_ProgressBarGroove \i (const \l TQProgressBar *) + \row \i \l SR_ProgressBarContents \i (const \l TQProgressBar *) + \row \i \l SR_ProgressBarLabel \i (const \l TQProgressBar *) + \endtable + + The tear-off handle (SR_DockWindowHandleRect) for TQDockWindow + is a private class. Use TQWidget::parentWidget() to access the + TQDockWindow: + + \code + if ( !widget->parentWidget() ) + return; + const TQDockWindow *dw = (const TQDockWindow *) widget->parentWidget(); + \endcode + + \sa SubRect +*/ + +/*! + \enum TQStyle::ComplexControl + + This enum represents a ComplexControl. ComplexControls have + different behaviour depending upon where the user clicks on them + or which keys are pressed. + + \value CC_SpinWidget + \value CC_ComboBox + \value CC_ScrollBar + \value CC_Slider + \value CC_ToolButton + \value CC_TitleBar + \value CC_ListView + + + \value CC_CustomBase base value for custom ControlElements. All + values above this are reserved for custom use. Therefore, + custom values must be greater than this value. + + \sa SubControl drawComplexControl() +*/ + +/*! + \enum TQStyle::SubControl + + This enum represents a SubControl within a ComplexControl. + + \value SC_None special value that matches no other SubControl. + + + \value SC_ScrollBarAddLine scrollbar add line (i.e. down/right + arrow); see also TQScrollbar. + \value SC_ScrollBarSubLine scrollbar sub line (i.e. up/left arrow). + \value SC_ScrollBarAddPage scrollbar add page (i.e. page down). + \value SC_ScrollBarSubPage scrollbar sub page (i.e. page up). + \value SC_ScrollBarFirst scrollbar first line (i.e. home). + \value SC_ScrollBarLast scrollbar last line (i.e. end). + \value SC_ScrollBarSlider scrollbar slider handle. + \value SC_ScrollBarGroove special subcontrol which contains the + area in which the slider handle may move. + + + \value SC_SpinWidgetUp spinwidget up/increase; see also TQSpinBox. + \value SC_SpinWidgetDown spinwidget down/decrease. + \value SC_SpinWidgetFrame spinwidget frame. + \value SC_SpinWidgetEditField spinwidget edit field. + \value SC_SpinWidgetButtonField spinwidget button field. + + + \value SC_ComboBoxEditField combobox edit field; see also TQComboBox. + \value SC_ComboBoxArrow combobox arrow + \value SC_ComboBoxFrame combobox frame + \value SC_ComboBoxListBoxPopup combobox list box + + \value SC_SliderGroove special subcontrol which contains the area + in which the slider handle may move. + \value SC_SliderHandle slider handle. + \value SC_SliderTickmarks slider tickmarks. + + + \value SC_ToolButton tool button; see also TQToolbutton. + \value SC_ToolButtonMenu subcontrol for opening a popup menu in a + tool button; see also TQPopupMenu. + + + \value SC_TitleBarSysMenu system menu button (i.e. restore, close, etc.). + \value SC_TitleBarMinButton minimize button. + \value SC_TitleBarMaxButton maximize button. + \value SC_TitleBarCloseButton close button. + \value SC_TitleBarLabel window title label. + \value SC_TitleBarNormalButton normal (restore) button. + \value SC_TitleBarShadeButton shade button. + \value SC_TitleBarUnshadeButton unshade button. + + + \value SC_ListView the list view area. + \value SC_ListViewBranch (internal) + \value SC_ListViewExpand expand item (i.e. show/hide child items). + + + \value SC_All special value that matches all SubControls. + + + \sa ComplexControl +*/ + +/*! + \fn void TQStyle::drawComplexControl( ComplexControl control, TQPainter *p, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags how, SCFlags sub, SCFlags subActive, const TQStyleOption& opt, const TQWidget *widget ) const + + Draws the ComplexControl \a control using the painter \a p in the + area \a r. Colors are used from the color group \a cg. The \a sub + argument specifies which SubControls to draw. Multiple SubControls + can be OR'ed together. The \a subActive argument specifies which + SubControl is active. + + The rect \a r should be in logical coordinates. Reimplementations + of this function should use visualRect() to change the logical + coordinates into screen coordinates when using drawPrimitive() and + drawControl(). + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a how argument is used to control how the ComplexControl is + drawn. Multiple flags can OR'ed together. See the table below for + an explanation of which flags are used with the various + ComplexControls. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a control. Note that usage of \a widget is + deprecated in favor of \a ceData and \a elementFlags. The \a opt + argument can be used to pass extra information required when + drawing the ComplexControl. Note that \a opt may be the default + value even for ComplexControls that can make use of the extra + options. See the table below for the appropriate \a widget and + \a opt usage: + + \table + \header \i ComplexControl
        \& Widget Cast + \i Style Flags + \i Notes + \i Options + \i Notes + + \row \i12 \l{CC_SpinWidget}(const TQSpinWidget *) + \i \l Style_Enabled \i Set if the spinwidget is enabled. + \i12 Unused. + \i12   + \row \i \l Style_HasFocus \i Set if the spinwidget has input focus. + + \row \i12 \l{CC_ComboBox}(const \l TQComboBox *) + \i \l Style_Enabled \i Set if the combobox is enabled. + \i12 Unused. + \i12   + \row \i \l Style_HasFocus \i Set if the combobox has input focus. + + \row \i12 \l{CC_ScrollBar}(const \l TQScrollBar *) + \i \l Style_Enabled \i Set if the scrollbar is enabled. + \i12 Unused. + \i12   + \row \i \l Style_HasFocus \i Set if the scrollbar has input focus. + + \row \i12 \l{CC_Slider}(const \l TQSlider *) + \i \l Style_Enabled \i Set if the slider is enabled. + \i12 Unused. + \i12   + + \row \i \l Style_HasFocus \i Set if the slider has input focus. + + \row \i16 \l{CC_ToolButton}(const \l TQToolButton *) + \i \l Style_Enabled \i Set if the toolbutton is enabled. + \i16 \l TQStyleOption ( \l ArrowType t ) + \list + \i opt.\link TQStyleOption::arrowType() arrowType\endlink() + \endlist + \i16 When the tool button only contains an arrow, \e t is the + arrow's type. + \row \i \l Style_HasFocus \i Set if the toolbutton has input focus. + \row \i \l Style_Down \i Set if the toolbutton is down (ie. mouse + button or space pressed). + \row \i \l Style_On \i Set if the toolbutton is a toggle button + and is toggled on. + \row \i \l Style_AutoRaise \i Set if the toolbutton has auto-raise enabled. + \row \i \l Style_Raised \i Set if the button is not down, not on and doesn't + contain the mouse when auto-raise is enabled. + + \row \i \l{CC_TitleBar}(const \l TQWidget *) + \i \l Style_Enabled \i Set if the titlebar is enabled. + \i Unused. + \i   + + \row \i \l{CC_ListView}(const \l TQListView *) + \i \l Style_Enabled \i Set if the titlebar is enabled. + \i \l TQStyleOption ( \l TQListViewItem *item ) + \list + \i opt.\link TQStyleOption::listViewItem() listViewItem\endlink() + \endlist + \i \e item is the item that needs branches drawn + \endtable + + \sa ComplexControl, SubControl +*/ + +/*! + \fn void TQStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQRect &r, const TQStyleOption& opt, const TQWidget *widget) const + + Draw a bitmask for the ComplexControl \a control using the painter + \a p in the area \a r. See drawComplexControl() for an explanation + of the use of the \a widget and \a opt arguments. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The rect \a r should be in logical coordinates. Reimplementations + of this function should use visualRect() to change the logical + corrdinates into screen coordinates when using drawPrimitive() and + drawControl(). + + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + + \sa drawComplexControl() ComplexControl +*/ + +/*! + \fn TQRect TQStyle::querySubControlMetrics( ComplexControl control, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, SubControl subcontrol, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; + + Returns the rect for the SubControl \a subcontrol for \a widget in + logical coordinates. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a control. The \a opt argument can be used to + pass extra information required when drawing the ComplexControl. + Note that \a opt may be the default value even for ComplexControls + that can make use of the extra options. See drawComplexControl() + for an explanation of the \a widget and \a opt arguments. + + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + + \sa drawComplexControl(), ComplexControl, SubControl +*/ + +/*! + \fn SubControl TQStyle::querySubControl( ComplexControl control, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQPoint &pos, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; + + Returns the SubControl for \a widget at the point \a pos. The \a + widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a control. The \a opt argument can be used to + pass extra information required when drawing the ComplexControl. + Note that \a opt may be the default value even for ComplexControls + that can make use of the extra options. See drawComplexControl() + for an explanation of the \a widget and \a opt arguments. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + Note that \a pos is passed in screen coordinates. When using + querySubControlMetrics() to check for hits and misses, use + visualRect() to change the logical coordinates into screen + coordinates. + + Note that usage of \a widget is deprecated in favor of \a ceData and \a elementFlags. + + \sa drawComplexControl(), ComplexControl, SubControl, querySubControlMetrics() +*/ + +/*! + \enum TQStyle::PixelMetric + + This enum represents a PixelMetric. A PixelMetric is a style + dependent size represented as a single pixel value. + + \value PM_ButtonMargin amount of whitespace between pushbutton + labels and the frame. + \value PM_ButtonDefaultIndicator width of the default-button indicator frame. + \value PM_MenuButtonIndicator width of the menu button indicator + proportional to the widget height. + \value PM_ButtonShiftHorizontal horizontal contents shift of a + button when the button is down. + \value PM_ButtonShiftVertical vertical contents shift of a button when the + button is down. + + \value PM_DefaultFrameWidth default frame width, usually 2. + \value PM_SpinBoxFrameWidth frame width of a spin box. + \value PM_MDIFrameWidth frame width of an MDI window. + \value PM_MDIMinimizedWidth width of a minimized MSI window. + + \value PM_MaximumDragDistance Some feels require the scrollbar or + other sliders to jump back to the original position when the + mouse pointer is too far away while dragging. A value of -1 + disables this behavior. + + \value PM_ScrollBarExtent width of a vertical scrollbar and the + height of a horizontal scrollbar. + \value PM_ScrollBarSliderMin the minimum height of a vertical + scrollbar's slider and the minimum width of a horiztonal + scrollbar slider. + + \value PM_SliderThickness total slider thickness. + \value PM_SliderControlThickness thickness of the slider handle. + \value PM_SliderLength length of the slider. + \value PM_SliderTickmarkOffset the offset between the tickmarks + and the slider. + \value PM_SliderSpaceAvailable the available space for the slider to move. + + \value PM_DockWindowSeparatorExtent width of a separator in a + horiztonal dock window and the height of a separator in a + vertical dock window. + \value PM_DockWindowHandleExtent width of the handle in a + horizontal dock window and the height of the handle in a + vertical dock window. + \value PM_DockWindowFrameWidth frame width of a dock window. + + \value PM_MenuBarFrameWidth frame width of a menubar. + + \value PM_MenuBarItemSpacing spacing between menubar items. + \value PM_ToolBarItemSpacing spacing between toolbar items. + + \value PM_TabBarTabOverlap number of pixels the tabs should overlap. + \value PM_TabBarTabHSpace extra space added to the tab width. + \value PM_TabBarTabVSpace extra space added to the tab height. + \value PM_TabBarBaseHeight height of the area between the tab bar + and the tab pages. + \value PM_TabBarBaseOverlap number of pixels the tab bar overlaps + the tab bar base. + \value PM_TabBarScrollButtonWidth + \value PM_TabBarTabShiftHorizontal horizontal pixel shift when a + tab is selected. + \value PM_TabBarTabShiftVertical vertical pixel shift when a + tab is selected. + + \value PM_ProgressBarChunkWidth width of a chunk in a progress bar indicator. + + \value PM_SplitterWidth width of a splitter. + + \value PM_TitleBarHeight height of the title bar. + \value PM_PopupMenuFrameHorizontalExtra additional border, e.g. for panels + \value PM_PopupMenuFrameVerticalExtra additional border, e.g. for panels + + \value PM_IndicatorWidth width of a check box indicator. + \value PM_IndicatorHeight height of a checkbox indicator. + \value PM_ExclusiveIndicatorWidth width of a radio button indicator. + \value PM_ExclusiveIndicatorHeight height of a radio button indicator. + + \value PM_PopupMenuScrollerHeight height of the scroller area in a popupmenu. + \value PM_PopupMenuScrollerHeight height of the scroller area in a popupmenu. + \value PM_CheckListButtonSize area (width/height) of the + checkbox/radiobutton in a TQCheckListItem + \value PM_CheckListControllerSize area (width/height) of the + controller in a TQCheckListItem + + \value PM_DialogButtonsSeparator distance between buttons in a dialog buttons widget. + \value PM_DialogButtonsButtonWidth minimum width of a button in a dialog buttons widget. + \value PM_DialogButtonsButtonHeight minimum height of a button in a dialog buttons widget. + + \value PM_HeaderMarkSize + \value PM_HeaderGripMargin + \value PM_HeaderMargin + + \value PM_CustomBase base value for custom ControlElements. All + values above this are reserved for custom use. Therefore, + custom values must be greater than this value. + + + \sa pixelMetric() +*/ + +/*! + \fn int TQStyle::pixelMetric( PixelMetric metric, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const; + + Returns the pixel metric for \a metric. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a metric. Note that \a widget may be zero even + for PixelMetrics that can make use of \a widget. Note also that + usage of \a widget is deprecated in favor of \a ceData and + \a elementFlags. See the table below for the appropriate + \a widget casts: + + \table + \header \i PixelMetric \i Widget Cast + \row \i \l PM_SliderControlThickness \i (const \l TQSlider *) + \row \i \l PM_SliderLength \i (const \l TQSlider *) + \row \i \l PM_SliderTickmarkOffset \i (const \l TQSlider *) + \row \i \l PM_SliderSpaceAvailable \i (const \l TQSlider *) + \row \i \l PM_TabBarTabOverlap \i (const \l TQTabBar *) + \row \i \l PM_TabBarTabHSpace \i (const \l TQTabBar *) + \row \i \l PM_TabBarTabVSpace \i (const \l TQTabBar *) + \row \i \l PM_TabBarBaseHeight \i (const \l TQTabBar *) + \row \i \l PM_TabBarBaseOverlap \i (const \l TQTabBar *) + \endtable +*/ + +/*! + \enum TQStyle::ContentsType + + This enum represents a ContentsType. It is used to calculate sizes + for the contents of various widgets. + + \value CT_PushButton + \value CT_CheckBox + \value CT_RadioButton + \value CT_ToolButton + \value CT_ComboBox + \value CT_Splitter + \value CT_DockWindow + \value CT_ProgressBar + \value CT_PopupMenuItem + \value CT_TabBarTab + \value CT_Slider + \value CT_Header + \value CT_LineEdit + \value CT_MenuBar + \value CT_SpinBox + \value CT_SizeGrip + \value CT_TabWidget + \value CT_DialogButtons + + \value CT_CustomBase base value for custom ControlElements. All + values above this are reserved for custom use. Custom values + must be greater than this value. + + \sa sizeFromContents() +*/ + +/*! + \fn TQSize TQStyle::sizeFromContents( ContentsType contents, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQSize &contentsSize, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; + + Returns the size of \a widget based on the contents size \a + contentsSize. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a contents. The \a opt argument can be used to + pass extra information required when calculating the size. Note + that \a opt may be the default value even for ContentsTypes that + can make use of the extra options. Note that usage of \a widget + is deprecated in favor of \a ceData and \a elementFlags. See the + table below for the appropriate \a widget and \a opt usage: + + \table + \header \i ContentsType \i Widget Cast \i Options \i Notes + \row \i \l CT_PushButton \i (const \l TQPushButton *) \i Unused. \i   + \row \i \l CT_CheckBox \i (const \l TQCheckBox *) \i Unused. \i   + \row \i \l CT_RadioButton \i (const \l TQRadioButton *) \i Unused. \i   + \row \i \l CT_ToolButton \i (const \l TQToolButton *) \i Unused. \i   + \row \i \l CT_ComboBox \i (const \l TQComboBox *) \i Unused. \i   + \row \i \l CT_Splitter \i (const \l TQSplitter *) \i Unused. \i   + \row \i \l CT_DockWindow \i (const \l TQDockWindow *) \i Unused. \i   + \row \i \l CT_ProgressBar \i (const \l TQProgressBar *) \i Unused. \i   + \row \i \l CT_PopupMenuItem \i (const TQPopupMenu *) + \i \l TQStyleOption ( TQMenuItem *mi ) + \list + \i opt.\link TQStyleOption::menuItem() menuItem\endlink() + \endlist + \i \e mi is the menu item to use when calculating the size. + TQMenuItem is currently an internal class. + \endtable +*/ + +/*! + \enum TQStyle::StyleHint + + This enum represents a StyleHint. A StyleHint is a general look + and/or feel hint. + + \value SH_EtchDisabledText disabled text is "etched" like Windows. + + \value SH_GUIStyle the GUI style to use. + + \value SH_ScrollBar_BackgroundMode the background mode for a + TQScrollBar. Possible values are any of those in the \link + TQt::BackgroundMode BackgroundMode\endlink enum. + + \value SH_ScrollBar_MiddleClickAbsolutePosition a boolean value. + If TRUE, middle clicking on a scrollbar causes the slider to + jump to that position. If FALSE, the middle clicking is + ignored. + + \value SH_ScrollBar_LeftClickAbsolutePosition a boolean value. + If TRUE, left clicking on a scrollbar causes the slider to + jump to that position. If FALSE, the left clicking will + behave as appropriate for each control. + + \value SH_ScrollBar_ScrollWhenPointerLeavesControl a boolean + value. If TRUE, when clicking a scrollbar SubControl, holding + the mouse button down and moving the pointer outside the + SubControl, the scrollbar continues to scroll. If FALSE, the + scollbar stops scrolling when the pointer leaves the + SubControl. + + \value SH_TabBar_Alignment the alignment for tabs in a + TQTabWidget. Possible values are \c TQt::AlignLeft, \c + TQt::AlignCenter and \c TQt::AlignRight. + + \value SH_Header_ArrowAlignment the placement of the sorting + indicator may appear in list or table headers. Possible values + are \c TQt::Left or \c TQt::Right. + + \value SH_Slider_SnapToValue sliders snap to values while moving, + like Windows + + \value SH_Slider_SloppyKeyEvents key presses handled in a sloppy + manner, i.e. left on a vertical slider subtracts a line. + + \value SH_ProgressDialog_CenterCancelButton center button on + progress dialogs, like Motif, otherwise right aligned. + + \value SH_ProgressDialog_TextLabelAlignment TQt::AlignmentFlags -- + text label alignment in progress dialogs; Center on windows, + Auto|VCenter otherwise. + + \value SH_PrintDialog_RightAlignButtons right align buttons in + the print dialog, like Windows. + + \value SH_MainWindow_SpaceBelowMenuBar 1 or 2 pixel space between + the menubar and the dockarea, like Windows. + + \value SH_FontDialog_SelectAssociatedText select the text in the + line edit, or when selecting an item from the listbox, or when + the line edit receives focus, like Windows. + + \value SH_PopupMenu_AllowActiveAndDisabled allows disabled menu + items to be active. + + \value SH_PopupMenu_SpaceActivatesItem pressing Space activates + the item, like Motif. + + \value SH_PopupMenu_SubMenuPopupDelay the number of milliseconds + to wait before opening a submenu; 256 on windows, 96 on Motif. + + \value SH_PopupMenu_Scrollable whether popupmenu's must support + scrolling. + + \value SH_PopupMenu_SloppySubMenus whether popupmenu's must support + sloppy submenu; as implemented on Mac OS. + + \value SH_ScrollView_FrameOnlyAroundContents whether scrollviews + draw their frame only around contents (like Motif), or around + contents, scrollbars and corner widgets (like Windows). + + \value SH_MenuBar_AltKeyNavigation menubars items are navigable + by pressing Alt, followed by using the arrow keys to select + the desired item. + + \value SH_ComboBox_ListMouseTracking mouse tracking in combobox + dropdown lists. + + \value SH_PopupMenu_MouseTracking mouse tracking in popup menus. + + \value SH_MenuBar_MouseTracking mouse tracking in menubars. + + \value SH_ItemView_ChangeHighlightOnFocus gray out selected items + when losing focus. + + \value SH_Widget_ShareActivation turn on sharing activation with + floating modeless dialogs. + + \value SH_TabBar_SelectMouseType which type of mouse event should + cause a tab to be selected. + + \value SH_ListViewExpand_SelectMouseType which type of mouse event should + cause a listview expansion to be selected. + + \value SH_TabBar_PreferNoArrows whether a tabbar should suggest a size + to prevent scoll arrows. + + \value SH_ComboBox_Popup allows popups as a combobox dropdown + menu. + + \value SH_Workspace_FillSpaceOnMaximize the workspace should + maximize the client area. + + \value SH_TitleBar_NoBorder the titlebar has no border + + \value SH_ScrollBar_StopMouseOverSlider stops autorepeat when + slider reaches mouse + + \value SH_BlinkCursorWhenTextSelected whether cursor should blink + when text is selected + + \value SH_RichText_FullWidthSelection whether richtext selections + should extend the full width of the document. + + \value SH_GroupBox_TextLabelVerticalAlignment how to vertically align a + groupbox's text label. + + \value SH_GroupBox_TextLabelColor how to paint a groupbox's text label. + + \value SH_DialogButtons_DefaultButton which buttons gets the + default status in a dialog's button widget. + + \value SH_CustomBase base value for custom ControlElements. All + values above this are reserved for custom use. Therefore, + custom values must be greater than this value. + + \value SH_ToolButton_Uses3D indicates whether TQToolButtons should + use a 3D frame when the mouse is over them + + \value SH_ToolBox_SelectedPageTitleBold Boldness of the selected + page title in a TQToolBox. + + \value SH_LineEdit_PasswordCharacter The TQChar Unicode character + to be used for passwords. + + \value SH_Table_GridLineColor + + \value SH_UnderlineAccelerator whether accelerators are underlined + + \sa styleHint() +*/ + +/*! + \fn int TQStyle::styleHint( StyleHint stylehint, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQStyleOption &opt = TQStyleOption::Default, TQStyleHintReturn *returnData = 0, const TQWidget *widget = 0 ) const; + + Returns the style hint \a stylehint for \a widget. Currently, \a + widget, \a opt, and \a returnData are unused; they're included to + allow for future enhancements. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + Note that usage of \a widget is deprecated in favor of \a ceData + and \a elementFlags. + + For an explanation of the return value see \l StyleHint. +*/ + +/*! + \enum TQStyle::StylePixmap + + This enum represents a StylePixmap. A StylePixmap is a pixmap that + can follow some existing GUI style or guideline. + + + \value SP_TitleBarMinButton minimize button on titlebars. For + example, in a TQWorkspace. + \value SP_TitleBarMaxButton maximize button on titlebars. + \value SP_TitleBarCloseButton close button on titlebars. + \value SP_TitleBarNormalButton normal (restore) button on titlebars. + \value SP_TitleBarShadeButton shade button on titlebars. + \value SP_TitleBarUnshadeButton unshade button on titlebars. + \value SP_MessageBoxInformation the 'information' icon. + \value SP_MessageBoxWarning the 'warning' icon. + \value SP_MessageBoxCritical the 'critical' icon. + \value SP_MessageBoxQuestion the 'question' icon. + + + \value SP_DockWindowCloseButton close button on dock windows; + see also TQDockWindow. + + + \value SP_CustomBase base value for custom ControlElements. All + values above this are reserved for custom use. Therefore, + custom values must be greater than this value. + + \sa stylePixmap() +*/ + +/*! + \fn TQPixmap TQStyle::stylePixmap( StylePixmap stylepixmap, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQStyleOption& opt = TQStyleOption::Default, const TQWidget *widget = 0 ) const; + + Returns a pixmap for \a stylepixmap. + + \a ceData and \a elementFlags provide additional information about + the widget for which the PrimitiveElement is being drawn. + + The \a opt argument can be used to pass extra information required + when drawing the ControlElement. Note that \a opt may be the + default value even for StylePixmaps that can make use of the extra + options. Currently, the \a opt argument is unused. + + The \a widget argument is a pointer to a TQWidget or one of its + subclasses. The widget can be cast to the appropriate type based + on the value of \a stylepixmap. Note that usage of \a widget is + deprecated in favor of \a ceData and \a elementFlags.See the table + below for the appropriate \a widget casts: + + \table + \header \i StylePixmap \i Widget Cast + \row \i \l SP_TitleBarMinButton \i (const \l TQWidget *) + \row \i \l SP_TitleBarMaxButton \i (const \l TQWidget *) + \row \i \l SP_TitleBarCloseButton \i (const \l TQWidget *) + \row \i \l SP_TitleBarNormalButton \i (const \l TQWidget *) + \row \i \l SP_TitleBarShadeButton \i (const \l TQWidget *) + \row \i \l SP_TitleBarUnshadeButton \i (const \l TQWidget *) + \row \i \l SP_DockWindowCloseButton \i (const \l TQDockWindow *) + \endtable + + \sa StylePixmap +*/ + +/*! + \fn TQRect TQStyle::visualRect( const TQRect &logical, const TQWidget *w ); + + Returns the rect \a logical in screen coordinates. The bounding + rect for widget \a w is used to perform the translation. This + function is provided to aid style implementors in supporting + right-to-left mode. + + Note that this function is deprecated in favor of visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ); + + \sa TQApplication::reverseLayout() +*/ +TQRect TQStyle::visualRect( const TQRect &logical, const TQWidget *w ) +{ + TQStyleControlElementData ceData; + ceData.rect = w->rect(); + return visualRect(logical, ceData, CEF_None); +} + +/*! + \fn TQRect TQStyle::visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ); + + Returns the rect \a logical in screen coordinates. The bounding + rect for the widget described by \a ceData and \a elementFlags + is used to perform the translation. This function is provided to + aid style implementors in supporting + right-to-left mode. + + \sa TQApplication::reverseLayout() +*/ +TQRect TQStyle::visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ) +{ + Q_UNUSED(elementFlags) + + TQRect boundingRect = ceData.rect; + TQRect r = logical; + if ( TQApplication::reverseLayout() ) + r.moveBy( 2*(boundingRect.right() - logical.right()) + + logical.width() - boundingRect.width(), 0 ); + return r; +} + +/*! + \overload TQRect TQStyle::visualRect( const TQRect &logical, const TQRect &bounding ); + + Returns the rect \a logical in screen coordinates. The rect \a + bounding is used to perform the translation. This function is + provided to aid style implementors in supporting right-to-left + mode. + + \sa TQApplication::reverseLayout() +*/ +TQRect TQStyle::visualRect( const TQRect &logical, const TQRect &boundingRect ) +{ + TQRect r = logical; + if ( TQApplication::reverseLayout() ) + r.moveBy( 2*(boundingRect.right() - logical.right()) + + logical.width() - boundingRect.width(), 0 ); + return r; +} + +/*! + \fn void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + + Intercepts events generated by \a source and sends them to \a handler via + the bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) virtual method. + + \sa void TQStyle::removeObjectEventHandler( TQObject* source, TQStyle* handler ) + \sa bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) +*/ +void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) { + bool cbret = false; + if (m_eventHandlerInstallationHook) { + cbret = (*m_eventHandlerInstallationHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQObject")) { + TQObject* o = reinterpret_cast(source); + o->installEventFilter(this); + m_objectEventSourceToHandlerMap[source] = handler; + m_objectEventSourceDataToHandlerMap[source] = ceData; + m_objectEventSourceFlagsToHandlerMap[source] = elementFlags; + } + } +} + +/*! + \fn void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + + Stops intercepting events generated by \a source. + + \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) { + bool cbret = false; + if (m_eventHandlerRemovalHook) { + cbret = (*m_eventHandlerRemovalHook)(ceData, elementFlags, source, handler); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQObject")) { + TQObject* o = reinterpret_cast(source); + m_objectEventSourceToHandlerMap.remove(source); + m_objectEventSourceDataToHandlerMap.remove(source); + m_objectEventSourceFlagsToHandlerMap.remove(source); + o->removeEventFilter(this); + } + } +} + +/*! + \fn void TQStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept request + is made via the TQStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setEventHandlerInstallationHook( EventHandlerInstallationHook hook ) { + m_eventHandlerInstallationHook = hook; +} + +/*! + \fn void TQStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + + Sets a callback function \a hook which will be called whenever a new intercept deactivation request + is made via the TQStyle::removeObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setEventHandlerRemovalHook( EventHandlerRemovalHook hook ) { + m_eventHandlerRemovalHook = hook; +} + +/*! + \fn bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); + + Override this virtual function to intercept events requested by a previous call to + TQStyle::installObjectEventHandler. + + \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) + \sa void TQStyle::removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +bool TQStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) { + Q_UNUSED(ceData); + Q_UNUSED(elementFlags); + Q_UNUSED(source); + Q_UNUSED(e); + return false; +} + +/*! + \fn bool TQStyle::eventFilter(TQObject *o, TQEvent *e); + \internal +*/ +bool TQStyle::eventFilter(TQObject *o, TQEvent *e) { + acceleratorKeypressEventMonitor(o, e); + + if (m_objectEventSourceToHandlerMap.contains(o)) { + TQStyle* handler = m_objectEventSourceToHandlerMap[o]; + const TQStyleControlElementData &ceData = m_objectEventSourceDataToHandlerMap[o]; + ControlElementFlags elementFlags = m_objectEventSourceFlagsToHandlerMap[o]; + bool ret; + TQWidget* w = dynamic_cast(o); + if (w) { + // Update ceData as widget parameters may have changed + // If not done glitches may appear such as those present in Bug 1816 + populateControlElementDataFromWidget(w, TQStyleOption()); + const TQStyleControlElementData &widgetCEData = *(w->controlElementDataObject()); + if (e->type() == TQEvent::Paint) { + TQPainter p(w); + TQPainter* activePainterOrig = widgetCEData.activePainter; + const_cast(widgetCEData).activePainter = &p; + ret = handler->objectEventHandler(widgetCEData, elementFlags, o, e); + const_cast(widgetCEData).activePainter = activePainterOrig; + } + else { + ret = handler->objectEventHandler(widgetCEData, elementFlags, o, e); + } + } + else { + ret = handler->objectEventHandler(ceData, elementFlags, o, e); + } + if (ret) { + return ret; + } + else { + return TQObject::eventFilter(o, e); + } + } + else { + return TQObject::eventFilter(o, e); + } +} + +/*! + \fn void TQStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ); + + Sets a callback function \a hook which will be called whenever a new widget action request + is made via the TQStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setWidgetActionRequestHook( WidgetActionRequestHook hook ) { + m_widgetActionRequestHook = hook; +} + +/*! + \fn bool widgetActionRequestHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request ); + + Handles widget action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. +*/ +bool TQStyle::widgetActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData ) { + bool cbret = false; + if (m_widgetActionRequestHook) { + cbret = (*m_widgetActionRequestHook)(ceData, elementFlags, source, request, requestData); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { + TQWidget* widget = reinterpret_cast(source); + if (request == WAR_Repaint) { + widget->repaint(FALSE); + } + else if (request == WAR_RepaintRect) { + widget->repaint(requestData.rect, FALSE); + } + else if (request == WAR_EnableMouseTracking) { + widget->setMouseTracking(TRUE); + } + else if (request == WAR_DisableMouseTracking) { + widget->setMouseTracking(FALSE); + } + else if (request == WAR_SetAutoMask) { + widget->setAutoMask(TRUE); + } + else if (request == WAR_UnSetAutoMask) { + widget->setAutoMask(FALSE); + } + else if (request == WAR_SetCheckable) { + TQPopupMenu *pm = dynamic_cast(widget); + if (pm) { + pm->setCheckable(TRUE); + } + } + else if (request == WAR_UnSetCheckable) { + TQPopupMenu *pm = dynamic_cast(widget); + if (pm) { + pm->setCheckable(FALSE); + } + } + else if (request == WAR_FrameSetStyle) { + TQFrame* frame = dynamic_cast(widget); + if (frame) { + frame->setFrameStyle(requestData.metric1); + } + } + else if (request == WAR_FrameSetLineWidth) { + TQFrame* frame = dynamic_cast(widget); + if (frame) { + frame->setLineWidth(requestData.metric1); + } + } + else if (request == WAR_SetLayoutMargin) { + TQLayout* layout = widget->layout(); + if (layout) { + layout->setMargin(requestData.metric1); + } + } + else if (request == WAR_SetPalette) { + widget->setPalette(requestData.palette); + } + else if (request == WAR_SetBackgroundMode) { + widget->setBackgroundMode((TQt::BackgroundMode)requestData.metric1); + } + else if (request == WAR_SetBackgroundOrigin) { + widget->setBackgroundOrigin((TQWidget::BackgroundOrigin)requestData.metric1); + } + else if (request == WAR_SetFont) { + widget->setFont(requestData.font); + } + else if (request == WAR_RepaintAllAccelerators) { + TQWidgetList *list = TQApplication::topLevelWidgets(); + TQWidgetListIt it( *list ); + TQWidget * widget; + while ((widget=it.current()) != 0) { + ++it; + + TQObjectList *l = widget->queryList("TQWidget"); + TQObjectListIt it2( *l ); + TQWidget *w; + while ( (w = (TQWidget*)it2.current()) != 0 ) { + ++it2; + if (w->isTopLevel() || !w->isVisible() || w->style().styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, w)) { + l->removeRef(w); + } + } + + // Repaint all relevant widgets + it2.toFirst(); + while ( (w = (TQWidget*)it2.current()) != 0 ) { + ++it2; + w->repaint(FALSE); + } + delete l; + } + delete list; + } + else if (request == WAR_SetDefault) { + TQPushButton *button = dynamic_cast(widget); + if (button) { + button->setDefault(TRUE); + } + } + else if (request == WAR_UnSetDefault) { + TQPushButton *button = dynamic_cast(widget); + if (button) { + button->setDefault(FALSE); + } + } + else if (request == WAR_SendPaintEvent) { + static_cast(widget)->event(requestData.paintEvent); + } + return true; + } + } + return true; +} + +/*! + \fn void TQStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ); + + Sets a callback function \a hook which will be called whenever a new application action request + is made via the TQStyle::installObjectEventHandler method. The callback function must + use this definition: bool callbackFunction( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ). + + \sa void TQStyle::installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ) +*/ +void TQStyle::setApplicationActionRequestHook( ApplicationActionRequestHook hook ) { + m_applicationActionRequestHook = hook; +} + +/*! + \fn bool applicationActionRequestHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request ); + + Handles application action requests. Return FALSE to continue processing in base classes, TRUE to eat the request and halt processing. +*/ +bool TQStyle::applicationActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData ) { + bool cbret = false; + if (m_applicationActionRequestHook) { + cbret = (*m_applicationActionRequestHook)(ceData, elementFlags, source, request, requestData); + } + if (!cbret) { + if (ceData.widgetObjectTypes.contains("TQApplication")) { + TQApplication* application = reinterpret_cast(source); + if (request == AAR_SetPalette) { + application->setPalette(requestData.palette, requestData.bool1, requestData.cstr); + } + else if (request == AAR_SetFont) { + application->setFont(requestData.font, requestData.bool1, requestData.cstr); + } + return true; + } + } + return true; +} + +void TQStyle::acceleratorKeypressEventMonitor( TQObject *o, TQEvent *e ) { + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { + TQWidget *widget = dynamic_cast(o); + if (widget) { + switch(e->type()) { + case TQEvent::KeyPress: + if (((TQKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = true; + widgetActionRequest(TQStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + case TQEvent::KeyRelease: + if (((TQKeyEvent*)e)->key() == Key_Alt) { + conditionalAcceleratorsEnabled = false; + widgetActionRequest(TQStyleControlElementData(), CEF_None, o, WAR_RepaintAllAccelerators); + } + break; + default: + break; + } + } + } + else { + conditionalAcceleratorsEnabled = false; + } +} + +bool TQStyle::acceleratorsShown() const { + if (styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, TQStyleOption::Default, NULL, NULL) != 0) { + return conditionalAcceleratorsEnabled; + } + else { + return true; + } +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData() { + // +} +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(int param1, int param2) { + metric1 = param1; + metric2 = param2; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPalette param, bool informWidgets, const char* className) { + palette = param; + bool1 = informWidgets; + cstr = className; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQFont param, bool informWidgets, const char* className) { + font = param; + bool1 = informWidgets; + cstr = className; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQRect param) { + rect = param; +} + +TQStyleWidgetActionRequestData::TQStyleWidgetActionRequestData(TQPaintEvent* param) { + paintEvent = param; +} + +TQStyleWidgetActionRequestData::~TQStyleWidgetActionRequestData() { + // +} + +// ============================================================================================ +// Interface methods +// ============================================================================================ + +void TQStyle::drawPrimitive( PrimitiveElement pe, + TQPainter *p, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption& opt ) const +{ + const TQWidget* widget = 0; + + // Determine if the request needs widget information and set widget appropriately + // FIXME + if ((pe == PE_CheckListController) || (pe == PE_CheckListExclusiveIndicator) || (pe == PE_CheckListIndicator)) { + TQCheckListItem *item = opt.checkListItem(); + if (item) { + TQListView *lv = item->listView(); + widget = dynamic_cast(lv); + } + } + + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawPrimitive(pe, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, cg, flags, opt); +} + +void TQStyle::drawControl( ControlElement element, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (!widget) { + tqWarning("TQStyle::drawControl: widget parameter cannot be zero!"); + return; + } +#endif + + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawControl(element, p, ceData, getControlElementFlagsForObject(widget, opt), r, cg, flags, opt, widget); +} + +void TQStyle::drawControlMask( ControlElement control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQStyleOption& opt ) const +{ + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawControlMask(control, p, ceData, getControlElementFlagsForObject(widget, opt), r, opt, widget); +} + +TQRect TQStyle::subRect(SubRect r, const TQWidget *widget) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::subRect: widget parameter cannot be zero!"); + return TQRect(); + } +#endif + + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + return subRect(r, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); +} + +void TQStyle::drawComplexControl( ComplexControl control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + SCFlags controls, + SCFlags active, + const TQStyleOption& opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::drawComplexControl: widget parameter cannot be zero!"); + return; + } +#endif + + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawComplexControl(control, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, cg, flags, controls, active, opt, widget); +} + +void TQStyle::drawComplexControlMask( ComplexControl control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQStyleOption& opt ) const +{ + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + drawComplexControlMask(control, p, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), r, opt, widget); +} + +TQRect TQStyle::querySubControlMetrics( ComplexControl control, + const TQWidget *widget, + SubControl sc, + const TQStyleOption &opt ) const +{ +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::querySubControlMetrics: widget parameter cannot be zero!"); + return TQRect(); + } +#endif + + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt, false); + return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), sc, opt, widget); +} + +TQStyle::SubControl TQStyle::querySubControl(ComplexControl control, + const TQWidget *widget, + const TQPoint &pos, + const TQStyleOption& opt ) const +{ + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + return querySubControl(control, ceData, getControlElementFlagsForObject(widget, opt), pos, opt, widget); +} + +int TQStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const +{ + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, TQStyleOption(), false); + return pixelMetric(m, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), widget); +} + +TQSize TQStyle::sizeFromContents(ContentsType contents, + const TQWidget *widget, + const TQSize &contentsSize, + const TQStyleOption& opt ) const +{ + TQSize sz(contentsSize); + +#if defined(QT_CHECK_STATE) + if (! widget) { + tqWarning("TQStyle::sizeFromContents: widget parameter cannot be zero!"); + return sz; + } +#endif + + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(widget, opt); + return sizeFromContents(contents, ceData, getControlElementFlagsForObject(widget, TQStyleOption()), contentsSize, opt, widget); +} + +int TQStyle::styleHint(StyleHint sh, const TQWidget * w, const TQStyleOption &so, TQStyleHintReturn *shr) const +{ + bool ceDataNotNeeded = false; + if (sh == SH_Widget_ShareActivation) { + ceDataNotNeeded = true; + } + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(w, so, false, ceDataNotNeeded); + return styleHint(sh, ceData, getControlElementFlagsForObject(w, TQStyleOption(), false), so, shr, w); +} + +TQPixmap TQStyle::stylePixmap(StylePixmap sp, const TQWidget *w, const TQStyleOption &so) const +{ + const TQStyleControlElementData &ceData = populateControlElementDataFromWidget(w, so); + return stylePixmap(sp, ceData, getControlElementFlagsForObject(w, TQStyleOption()), so, w); +} + +/*! + \fn int TQStyle::defaultFrameWidth() const + \obsolete +*/ + +/*! + \fn void TQStyle::tabbarMetrics( const TQWidget *, int &, int &, int & ) const + \obsolete +*/ + +/*! + \fn TQSize TQStyle::scrollBarExtent() const + \obsolete +*/ + +#ifndef TQT_NO_COMPAT +int TQStyle::defaultFrameWidth() const +{ + TQStyleControlElementData ceData; + return pixelMetric( PM_DefaultFrameWidth, ceData, CEF_None ); +} + +void TQStyle::tabbarMetrics( const TQWidget* t, int& hf, int& vf, int& ov ) const +{ + TQStyleControlElementData ceData; + hf = pixelMetric( PM_TabBarTabHSpace, ceData, CEF_None, t ); + vf = pixelMetric( PM_TabBarTabVSpace, ceData, CEF_None, t ); + ov = pixelMetric( PM_TabBarBaseOverlap, ceData, CEF_None, t ); +} + +TQSize TQStyle::scrollBarExtent() const +{ + TQStyleControlElementData ceData; + ceData.orientation = TQt::Horizontal; + return TQSize(pixelMetric(PM_ScrollBarExtent, ceData, CEF_None), + pixelMetric(PM_ScrollBarExtent, ceData, CEF_None)); +} +#endif + +TQStyleControlElementData::TQStyleControlElementData() { + isNull = true; + activePainter = 0; + tickMarkSetting = 0; + comboBoxLineEditFlags = 0; + frameStyle = 0; + comboBoxListBoxFlags = 0; + parentWidgetFlags = 0; + topLevelWidgetFlags = 0; +} + +TQStyleControlElementData::~TQStyleControlElementData() { + // +} + +TQStyleControlElementData::TQStyleControlElementData(const TQStyleControlElementData& orig) { + isNull = orig.isNull; + widgetObjectTypes = orig.widgetObjectTypes; + allDataPopulated = orig.allDataPopulated; + wflags = orig.wflags; + windowState = orig.windowState; + bgPixmap = orig.bgPixmap; + bgBrush = orig.bgBrush; + bgColor = orig.bgColor; + bgOffset = orig.bgOffset; + backgroundMode = orig.backgroundMode; + fgPixmap = orig.fgPixmap; + fgColor = orig.fgColor; + colorGroup = orig.colorGroup; + geometry = orig.geometry; + rect = orig.rect; + pos = orig.pos; + icon = orig.icon; + iconSet = orig.iconSet; + text = orig.text; + orientation = orig.orientation; + activeItemPaletteBgColor = orig.activeItemPaletteBgColor; + palette = orig.palette; + totalSteps = orig.totalSteps; + currentStep = orig.currentStep; + tickMarkSetting = orig.tickMarkSetting; + tickInterval = orig.tickInterval; + minSteps = orig.minSteps; + maxSteps = orig.maxSteps; + startStep = orig.startStep; + pageStep = orig.pageStep; + lineStep = orig.lineStep; + dlgVisibleButtons = orig.dlgVisibleButtons; + dlgVisibleSizeHints = orig.dlgVisibleSizeHints; + progressText = orig.progressText; + textLabel = orig.textLabel; + font = orig.font; + percentageVisible = orig.percentageVisible; + dwData = orig.dwData; + toolButtonTextPosition = orig.toolButtonTextPosition; + popupDelay = orig.popupDelay; + titleBarData = orig.titleBarData; + spinWidgetData = orig.spinWidgetData; + parentWidgetData = orig.parentWidgetData; + viewportData = orig.viewportData; + listViewData = orig.listViewData; + tabBarData = orig.tabBarData; + checkListItemData = orig.checkListItemData; + comboBoxLineEditFlags = orig.comboBoxLineEditFlags; + frameStyle = orig.frameStyle; + sliderRect = orig.sliderRect; + activePainter = orig.activePainter; + toolBarData = orig.toolBarData; + comboBoxListBoxFlags = orig.comboBoxListBoxFlags; + paletteBgColor = orig.paletteBgColor; + parentWidgetFlags = orig.parentWidgetFlags; + name = orig.name; + caption = orig.caption; + topLevelWidgetData = orig.topLevelWidgetData; + topLevelWidgetFlags = orig.topLevelWidgetFlags; + paletteBgPixmap = orig.paletteBgPixmap; +} + +#endif // TQT_NO_STYLE diff --git a/src/kernel/tqstyle.h b/src/kernel/tqstyle.h new file mode 100644 index 000000000..6fc61b456 --- /dev/null +++ b/src/kernel/tqstyle.h @@ -0,0 +1,1243 @@ +/**************************************************************************** +** +** Definition of TQStyle class +** +** Created : 980616 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ +#ifndef TQSTYLE_H +#define TQSTYLE_H + +#ifndef QT_H +#include "tqobject.h" +#include "ntqpixmap.h" +#include "ntqcolor.h" +#include "tqiconset.h" +#include "ntqtabbar.h" +#include "ntqtoolbutton.h" +#endif // QT_H + + +#ifndef TQT_NO_STYLE + +class TQPopupMenu; +class TQStylePrivate; +class TQMenuItem; +class TQTab; +class TQListViewItem; +class TQCheckListItem; + +class TQ_EXPORT TQStyleOption { +public: + enum StyleOptionDefault { Default }; + + TQStyleOption(StyleOptionDefault=Default); + TQStyleOption(int in1); + TQStyleOption(int in1, int in2); + TQStyleOption(int in1, int in2, int in3, int in4); + TQStyleOption(TQMenuItem* m); + TQStyleOption(TQMenuItem* m, int in1); + TQStyleOption(TQMenuItem* m, int in1, int in2); + TQStyleOption(const TQColor& c); + TQStyleOption(TQTab* t); + TQStyleOption(TQListViewItem* i); + TQStyleOption(TQCheckListItem* i); + TQStyleOption(TQt::ArrowType a); + TQStyleOption(const TQRect& r); + TQStyleOption(TQWidget *w); + + bool isDefault() const { return def; } + + int day() const { return i1; } + + int lineWidth() const { return i1; } + int midLineWidth() const { return i2; } + int frameShape() const { return i3; } + int frameShadow() const { return i4; } + + int headerSection() const { return i1; } + TQMenuItem* menuItem() const { return mi; } + int maxIconWidth() const { return i1; } + int tabWidth() const { return i2; } + + const TQColor& color() const { return *cl; } + + TQTab* tab() const { return tb; } + + TQCheckListItem* checkListItem() const { return cli; } + TQListViewItem* listViewItem() const { return li; } + + TQt::ArrowType arrowType() const { return (TQt::ArrowType)i1; } + TQRect rect() const { return TQRect( i1, i2, i3, i4 ); } + TQWidget* widget() const { return (TQWidget*)p1; } + + TQStyleOption(TQTab* t, TQTab* h) : def(FALSE), tb(t), cli(NULL), tbh(h) {} + TQTab* hoverTab() const { return tbh; } + +private: + // NOTE: none of these components have constructors. + bool def; + bool b1,b2,b3; // reserved + TQMenuItem* mi; + TQTab* tb; + TQListViewItem* li; + const TQColor* cl; + int i1, i2, i3, i4; + int i5, i6; // reserved + TQCheckListItem* cli; + void *p1, *p2, *p3, *p4; // reserved + TQTab* tbh; + // (padded to 64 bytes on some architectures) +}; + +class TQStyleHintReturn; // not defined yet + +typedef TQMap DialogButtonSizeMap; +typedef TQMap TabIdentifierIndexMap; + +class TQStyleControlElementGenericWidgetData; + +class TQStyleControlElementPopupMenuData { + public: + // +}; + +class TQStyleControlElementCheckListItemData { + public: + bool dataValid; + bool enabled; + bool hasParent; + int height; +}; + +class TQStyleControlElementListViewData { + public: + bool rootDecorated; + int itemMargin; +}; + +class TQStyleControlElementSpinWidgetData { + public: + TQ_UINT32 buttonSymbols; + TQRect upRect; + TQRect downRect; + bool upEnabled; + bool downEnabled; +}; + +class TQStyleControlElementTitleBarData { + public: + bool hasWindow; + bool usesActiveColor; + int windowState; + TQString visibleText; +}; + +class TQStyleControlElementDockWidgetData { + public: + bool hasDockArea; + bool closeEnabled; + TQt::Orientation areaOrientation; +}; + +class TQStyleControlElementToolBarWidgetData { + public: + TQt::Orientation orientation; +}; + +class TQStyleControlElementGenericWidgetData { + public: + TQStringList widgetObjectTypes; + bool allDataPopulated; + TQt::WFlags wflags; + TQt::WindowState windowState; + TQPixmap bgPixmap; + TQBrush bgBrush; + TQColor bgColor; + TQPoint bgOffset; + TQt::BackgroundMode backgroundMode; + TQColor fgColor; + TQColorGroup colorGroup; + TQRect geometry; + TQRect rect; + TQPoint pos; + TQPixmap icon; + TQPalette palette; + TQFont font; + TQColor paletteBgColor; + TQString name; + TQString caption; +}; + +class TQStyleControlElementTabBarData { + public: + int tabCount; + int currentTabIndex; + TQTabBar::Shape shape; + TabIdentifierIndexMap identIndexMap; +#ifdef Q_QDOC +#else + TQStyleControlElementGenericWidgetData cornerWidgets[4]; +#endif + + enum CornerWidgetLocation { + CWL_TopLeft = 0, + CWL_TopRight = 1, + CWL_BottomLeft = 2, + CWL_BottomRight = 3 + }; +}; + +class TQ_EXPORT TQStyleControlElementData { + public: + TQStyleControlElementData(); + ~TQStyleControlElementData(); + + public: + bool isNull; + TQStringList widgetObjectTypes; + bool allDataPopulated; + TQt::WFlags wflags; + TQt::WindowState windowState; + TQPixmap bgPixmap; + TQBrush bgBrush; + TQColor bgColor; + TQPoint bgOffset; + TQt::BackgroundMode backgroundMode; + TQPixmap fgPixmap; + TQColor fgColor; + TQColorGroup colorGroup; + TQRect geometry; + TQRect rect; + TQPoint pos; + TQPixmap icon; + TQIconSet iconSet; + TQString text; + TQt::Orientation orientation; + TQColor activeItemPaletteBgColor; + TQPalette palette; + int totalSteps; + int currentStep; + TQ_UINT32 tickMarkSetting; + int tickInterval; + int minSteps; + int maxSteps; + int startStep; + int pageStep; + int lineStep; + int dlgVisibleButtons; + DialogButtonSizeMap dlgVisibleSizeHints; + TQString progressText; + TQString textLabel; + TQFont font; + int percentageVisible; + TQStyleControlElementDockWidgetData dwData; + TQToolButton::TextPosition toolButtonTextPosition; + int popupDelay; + TQStyleControlElementTitleBarData titleBarData; + TQStyleControlElementSpinWidgetData spinWidgetData; + TQStyleControlElementGenericWidgetData parentWidgetData; + TQStyleControlElementGenericWidgetData viewportData; + TQStyleControlElementListViewData listViewData; + TQStyleControlElementTabBarData tabBarData; + TQStyleControlElementCheckListItemData checkListItemData; + TQ_UINT32 comboBoxLineEditFlags; + TQ_UINT32 frameStyle; + TQRect sliderRect; + TQPainter* activePainter; + TQStyleControlElementToolBarWidgetData toolBarData; + TQ_UINT32 comboBoxListBoxFlags; + TQColor paletteBgColor; + TQ_UINT32 parentWidgetFlags; + TQString name; + TQString caption; + TQStyleControlElementGenericWidgetData topLevelWidgetData; + TQ_UINT32 topLevelWidgetFlags; + TQPixmap paletteBgPixmap; + +#ifdef ENABLE_TQSTYLECONTROLELEMENTDATA_SLOW_COPY + public: + TQStyleControlElementData(const TQStyleControlElementData&); +#else + private: + // Disable copy constructor + TQStyleControlElementData(const TQStyleControlElementData&); +#endif + +}; + +class TQ_EXPORT TQStyleWidgetActionRequestData { + public: + TQStyleWidgetActionRequestData(); + TQStyleWidgetActionRequestData(int metric1, int metric2=0); + TQStyleWidgetActionRequestData(TQPalette palette, bool informWidgets = FALSE, const char* className = 0); + TQStyleWidgetActionRequestData(TQFont font, bool informWidgets = FALSE, const char* className = 0); + TQStyleWidgetActionRequestData(TQRect rect); + TQStyleWidgetActionRequestData(TQPaintEvent* paintEvent); + ~TQStyleWidgetActionRequestData(); + public: + bool bool1; + bool bool2; + int metric1; + int metric2; + TQPalette palette; + TQFont font; + TQRect rect; + const char * cstr; + TQString string; + TQPaintEvent * paintEvent; +}; + +typedef TQStyleWidgetActionRequestData TQStyleApplicationActionRequestData; + +class TQ_EXPORT TQStyle: public TQObject +{ + TQ_OBJECT + +public: + TQStyle(); + virtual ~TQStyle(); + + enum ControlElementFlags { + CEF_None = 0x00000000, + CEF_IsDefault = 0x00000001, + CEF_AutoDefault = 0x00000002, + CEF_IsActive = 0x00000004, + CEF_IsDown = 0x00000008, + CEF_IsOn = 0x00000010, + CEF_IsEnabled = 0x00000020, + CEF_BiState = 0x00000040, + CEF_HasFocus = 0x00000080, + CEF_IsMenuWidget = 0x00000100, + CEF_IsContainerEmpty = 0x00000200, + CEF_CenterIndicator = 0x00000400, + CEF_IndicatorFollowsStyle = 0x00000800, + CEF_UsesTextLabel = 0x00001000, + CEF_UsesBigPixmap = 0x00002000, + CEF_UseGenericParameters = 0x00004000, + CEF_HasParentWidget = 0x00008000, + CEF_HasPopupMenu = 0x00010000, + CEF_IsCheckable = 0x00020000, + CEF_HasFocusProxy = 0x00040000, + CEF_IsEditable = 0x00080000, + CEF_IsFlat = 0x00100000, + CEF_IsActiveWindow = 0x00200000, + CEF_IsTopLevel = 0x00400000, + CEF_IsVisible = 0x00800000, + CEF_IsShown = 0x01000000, + CEF_HasMouse = 0x02000000 + }; + + // New TQStyle API - most of these should probably be pure virtual + + // Old API + // DEPRECATED + virtual void polish( TQWidget * ); + + // New API + virtual void polish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED + virtual void unPolish( TQWidget * ); + + // New API + virtual void unPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED + virtual void polish( TQApplication * ); + + // New API + virtual void applicationPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + + // Old API + // DEPRECATED + virtual void unPolish( TQApplication * ); + + // New API + virtual void applicationUnPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + + virtual void polish( TQPalette & ); + + // Old API + // DEPRECATED + virtual void polishPopupMenu( TQPopupMenu* ); + + // New API + virtual void polishPopupMenu( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ) = 0; + + virtual TQRect itemRect( TQPainter *p, const TQRect &r, + int flags, bool enabled, + const TQPixmap *pixmap, + const TQString &text, int len = -1 ) const; + + virtual void drawItem( TQPainter *p, const TQRect &r, + int flags, const TQColorGroup &g, bool enabled, + const TQPixmap *pixmap, const TQString &text, + int len = -1, const TQColor *penColor = 0 ) const; + + enum PrimitiveElement { + PE_ButtonCommand, + PE_ButtonDefault, + PE_ButtonBevel, + PE_ButtonTool, + PE_ButtonDropDown, + + PE_FocusRect, + + PE_ArrowUp, + PE_ArrowDown, + PE_ArrowRight, + PE_ArrowLeft, + + PE_SpinWidgetUp, + PE_SpinWidgetDown, + PE_SpinWidgetPlus, + PE_SpinWidgetMinus, + + PE_Indicator, + PE_IndicatorMask, + PE_ExclusiveIndicator, + PE_ExclusiveIndicatorMask, + + PE_DockWindowHandle, + PE_DockWindowSeparator, + PE_DockWindowResizeHandle, + + PE_Splitter, + + PE_Panel, + PE_PanelPopup, + PE_PanelMenuBar, + PE_PanelDockWindow, + + PE_TabBarBase, + + PE_HeaderSection, + PE_HeaderArrow, + PE_StatusBarSection, + + PE_GroupBoxFrame, + + PE_Separator, + + PE_SizeGrip, + + PE_CheckMark, + + PE_ScrollBarAddLine, + PE_ScrollBarSubLine, + PE_ScrollBarAddPage, + PE_ScrollBarSubPage, + PE_ScrollBarSlider, + PE_ScrollBarFirst, + PE_ScrollBarLast, + + PE_ProgressBarChunk, + + PE_PanelLineEdit, + PE_PanelTabWidget, + + PE_WindowFrame, + + PE_CheckListController, + PE_CheckListIndicator, + PE_CheckListExclusiveIndicator, + + PE_PanelGroupBox, + PE_RubberBand, + + PE_HeaderSectionMenu, + + PE_PanelScrollBar, + PE_MenuItemIndicatorFrame, + PE_MenuItemIndicatorIconFrame, + PE_MenuItemIndicatorCheck, + + PE_ScrollBarTrough, + + // do not add any values below/greater this + PE_CustomBase = 0xf000000 + }; + + enum StyleFlags { + Style_Default = 0x00000000, + Style_Enabled = 0x00000001, + Style_Raised = 0x00000002, + Style_Sunken = 0x00000004, + Style_Off = 0x00000008, + Style_NoChange = 0x00000010, + Style_On = 0x00000020, + Style_Down = 0x00000040, + Style_Horizontal = 0x00000080, + Style_HasFocus = 0x00000100, + Style_Top = 0x00000200, + Style_Bottom = 0x00000400, + Style_FocusAtBorder = 0x00000800, + Style_AutoRaise = 0x00001000, + Style_MouseOver = 0x00002000, + Style_Up = 0x00004000, + Style_Selected = 0x00008000, + Style_Active = 0x00010000, + Style_ButtonDefault = 0x00020000 + }; + typedef uint SFlags; + + // Old API + // DEPRECATED + virtual void drawPrimitive( PrimitiveElement pe, + TQPainter *p, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + const TQStyleOption& = TQStyleOption::Default ) const; + + // New API + virtual void drawPrimitive( PrimitiveElement pe, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + const TQStyleOption& = TQStyleOption::Default ) const = 0; + + + enum ControlElement { + CE_PushButton, + CE_PushButtonLabel, + + CE_CheckBox, + CE_CheckBoxLabel, + + CE_RadioButton, + CE_RadioButtonLabel, + + CE_TabBarTab, + CE_TabBarLabel, + + CE_ProgressBarGroove, + CE_ProgressBarContents, + CE_ProgressBarLabel, + + CE_PopupMenuItem, + CE_MenuBarItem, + + CE_ToolButtonLabel, + CE_MenuBarEmptyArea, + CE_PopupMenuScroller, + CE_DockWindowEmptyArea, + CE_PopupMenuVerticalExtra, + CE_PopupMenuHorizontalExtra, + + CE_ToolBoxTab, + CE_HeaderLabel, + + // do not add any values below/greater than this + CE_CustomBase = 0xf0000000 + }; + + // Old API + // DEPRECATED + virtual void drawControl( ControlElement element, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQColorGroup &cg, + SFlags how = Style_Default, + const TQStyleOption& = TQStyleOption::Default ) const; + + // New API + virtual void drawControl( ControlElement element, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags how = Style_Default, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + + // Old API + // DEPRECATED + virtual void drawControlMask( ControlElement element, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default ) const; + + // New API + virtual void drawControlMask( ControlElement element, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 /* compat, will likely go away */ ) const = 0; + + enum SubRect { + SR_PushButtonContents, + SR_PushButtonFocusRect, + + SR_CheckBoxIndicator, + SR_CheckBoxContents, + SR_CheckBoxFocusRect, + + SR_RadioButtonIndicator, + SR_RadioButtonContents, + SR_RadioButtonFocusRect, + + SR_ComboBoxFocusRect, + + SR_SliderFocusRect, + + SR_DockWindowHandleRect, + + SR_ProgressBarGroove, + SR_ProgressBarContents, + SR_ProgressBarLabel, + + SR_ToolButtonContents, + + SR_DialogButtonAccept, + SR_DialogButtonReject, + SR_DialogButtonApply, + SR_DialogButtonHelp, + SR_DialogButtonAll, + SR_DialogButtonAbort, + SR_DialogButtonIgnore, + SR_DialogButtonRetry, + SR_DialogButtonCustom, + + SR_ToolBoxTabContents, + + // do not add any values below/greater than this + SR_CustomBase = 0xf0000000 + }; + + // Old API + // DEPRECATED + virtual TQRect subRect( SubRect r, const TQWidget *widget ) const; + + // New API + virtual TQRect subRect( SubRect r, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const = 0; + + + enum ComplexControl{ + CC_SpinWidget, + CC_ComboBox, + CC_ScrollBar, + CC_Slider, + CC_ToolButton, + CC_TitleBar, + CC_ListView, + + // do not add any values below/greater than this + CC_CustomBase = 0xf0000000 + }; + + enum SubControl { + SC_None = 0x00000000, + + SC_ScrollBarAddLine = 0x00000001, + SC_ScrollBarSubLine = 0x00000002, + SC_ScrollBarAddPage = 0x00000004, + SC_ScrollBarSubPage = 0x00000008, + SC_ScrollBarFirst = 0x00000010, + SC_ScrollBarLast = 0x00000020, + SC_ScrollBarSlider = 0x00000040, + SC_ScrollBarGroove = 0x00000080, + + SC_SpinWidgetUp = 0x00000001, + SC_SpinWidgetDown = 0x00000002, + SC_SpinWidgetFrame = 0x00000004, + SC_SpinWidgetEditField = 0x00000008, + SC_SpinWidgetButtonField = 0x00000010, + + SC_ComboBoxFrame = 0x00000001, + SC_ComboBoxEditField = 0x00000002, + SC_ComboBoxArrow = 0x00000004, + SC_ComboBoxListBoxPopup = 0x00000008, + + SC_SliderGroove = 0x00000001, + SC_SliderHandle = 0x00000002, + SC_SliderTickmarks = 0x00000004, + + SC_ToolButton = 0x00000001, + SC_ToolButtonMenu = 0x00000002, + + SC_TitleBarLabel = 0x00000001, + SC_TitleBarSysMenu = 0x00000002, + SC_TitleBarMinButton = 0x00000004, + SC_TitleBarMaxButton = 0x00000008, + SC_TitleBarCloseButton = 0x00000010, + SC_TitleBarNormalButton = 0x00000020, + SC_TitleBarShadeButton = 0x00000040, + SC_TitleBarUnshadeButton = 0x00000080, + + SC_ListView = 0x00000001, + SC_ListViewBranch = 0x00000002, + SC_ListViewExpand = 0x00000004, + + SC_All = 0xffffffff + }; + typedef uint SCFlags; + + + // Old API + // DEPRECATED + virtual void drawComplexControl( ComplexControl control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQColorGroup &cg, + SFlags how = Style_Default, +#ifdef Q_QDOC + SCFlags sub = SC_All, +#else + SCFlags sub = (uint)SC_All, +#endif + SCFlags subActive = SC_None, + const TQStyleOption& = TQStyleOption::Default ) const; + + virtual void drawComplexControl( ComplexControl control, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags how = Style_Default, +#ifdef Q_QDOC + SCFlags sub = SC_All, +#else + SCFlags sub = (uint)SC_All, +#endif + SCFlags subActive = SC_None, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED + virtual void drawComplexControlMask( ComplexControl control, + TQPainter *p, + const TQWidget *widget, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default ) const; + + // New API + virtual void drawComplexControlMask( ComplexControl control, + TQPainter *p, + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED + virtual TQRect querySubControlMetrics( ComplexControl control, + const TQWidget *widget, + SubControl sc, + const TQStyleOption& = TQStyleOption::Default ) const; + + // New API + virtual TQRect querySubControlMetrics( ComplexControl control, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + SubControl sc, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + // Old API + // DEPRECATED + virtual SubControl querySubControl( ComplexControl control, + const TQWidget *widget, + const TQPoint &pos, + const TQStyleOption& = TQStyleOption::Default ) const; + + // New API + virtual SubControl querySubControl( ComplexControl control, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQPoint &pos, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + + enum PixelMetric { + PM_ButtonMargin, + PM_ButtonDefaultIndicator, + PM_MenuButtonIndicator, + PM_ButtonShiftHorizontal, + PM_ButtonShiftVertical, + + PM_DefaultFrameWidth, + PM_SpinBoxFrameWidth, + + PM_MaximumDragDistance, + + PM_ScrollBarExtent, + PM_ScrollBarSliderMin, + + PM_SliderThickness, // total slider thickness + PM_SliderControlThickness, // thickness of the business part + PM_SliderLength, // total length of slider + PM_SliderTickmarkOffset, // + PM_SliderSpaceAvailable, // available space for slider to move + + PM_DockWindowSeparatorExtent, + PM_DockWindowHandleExtent, + PM_DockWindowFrameWidth, + + PM_MenuBarFrameWidth, + + PM_TabBarTabOverlap, + PM_TabBarTabHSpace, + PM_TabBarTabVSpace, + PM_TabBarBaseHeight, + PM_TabBarBaseOverlap, + + PM_ProgressBarChunkWidth, + + PM_SplitterWidth, + PM_TitleBarHeight, + + PM_IndicatorWidth, + PM_IndicatorHeight, + PM_ExclusiveIndicatorWidth, + PM_ExclusiveIndicatorHeight, + PM_PopupMenuScrollerHeight, + PM_CheckListButtonSize, + PM_CheckListControllerSize, + PM_PopupMenuFrameHorizontalExtra, + PM_PopupMenuFrameVerticalExtra, + + PM_DialogButtonsSeparator, + PM_DialogButtonsButtonWidth, + PM_DialogButtonsButtonHeight, + + PM_MDIFrameWidth, + PM_MDIMinimizedWidth, + PM_HeaderMargin, + PM_HeaderMarkSize, + PM_HeaderGripMargin, + PM_TabBarTabShiftHorizontal, + PM_TabBarTabShiftVertical, + PM_TabBarScrollButtonWidth, + + PM_MenuBarItemSpacing, + PM_ToolBarItemSpacing, + + PM_MenuIndicatorFrameHBorder, + PM_MenuIndicatorFrameVBorder, + PM_MenuIconIndicatorFrameHBorder, + PM_MenuIconIndicatorFrameVBorder, + + PM_ArrowSize, + + // do not add any values below/greater than this + PM_CustomBase = 0xf0000000 + }; + + // Old API + // DEPRECATED + virtual int pixelMetric( PixelMetric metric, + const TQWidget *widget = 0 ) const; + + // New API + virtual int pixelMetric( PixelMetric metric, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQWidget *widget = 0 ) const = 0; + + + enum ContentsType { + CT_PushButton, + CT_CheckBox, + CT_RadioButton, + CT_ToolButton, + CT_ComboBox, + CT_Splitter, + CT_DockWindow, + CT_ProgressBar, + CT_PopupMenuItem, + CT_TabBarTab, + CT_Slider, + CT_Header, + CT_LineEdit, + CT_MenuBar, + CT_SpinBox, + CT_SizeGrip, + CT_TabWidget, + CT_DialogButtons, + + // do not add any values below/greater than this + CT_CustomBase = 0xf0000000 + }; + + // Old API + // DEPRECATED + virtual TQSize sizeFromContents( ContentsType contents, + const TQWidget *widget, + const TQSize &contentsSize, + const TQStyleOption& = TQStyleOption::Default ) const; + + virtual TQSize sizeFromContents( ContentsType contents, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQSize &contentsSize, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + enum StyleHint { + // ... + // the general hints + // ... + // disabled text should be etched, ala Windows + SH_EtchDisabledText, + + // the GUI style enum, argh! + SH_GUIStyle, + + // ... + // widget specific hints + // ... + SH_ScrollBar_BackgroundMode, + SH_ScrollBar_MiddleClickAbsolutePosition, + SH_ScrollBar_ScrollWhenPointerLeavesControl, + + // TQEvent::Type - which mouse event to select a tab + SH_TabBar_SelectMouseType, + + SH_TabBar_Alignment, + + SH_Header_ArrowAlignment, + + // bool - sliders snap to values while moving, ala Windows + SH_Slider_SnapToValue, + + // bool - key presses handled in a sloppy manner - ie. left on a vertical + // slider subtracts a line + SH_Slider_SloppyKeyEvents, + + // bool - center button on progress dialogs, ala Motif, else right aligned + // perhaps this should be a TQt::Alignment value + SH_ProgressDialog_CenterCancelButton, + + // TQt::AlignmentFlags - text label alignment in progress dialogs + // Center on windows, Auto|VCenter otherwize + SH_ProgressDialog_TextLabelAlignment, + + // bool - right align buttons on print dialog, ala Windows + SH_PrintDialog_RightAlignButtons, + + // bool - 1 or 2 pixel space between the menubar and the dockarea, ala Windows + // this *REALLY* needs a better name + SH_MainWindow_SpaceBelowMenuBar, + + // bool - select the text in the line edit about the listbox when selecting + // an item from the listbox, or when the line edit receives focus, ala Windows + SH_FontDialog_SelectAssociatedText, + + // bool - allows disabled menu items to be active + SH_PopupMenu_AllowActiveAndDisabled, + + // bool - pressing space activates item, ala Motif + SH_PopupMenu_SpaceActivatesItem, + + // int - number of milliseconds to wait before opening a submenu + // 256 on windows, 96 on motif + SH_PopupMenu_SubMenuPopupDelay, + + // bool - should scrollviews draw their frame only around contents (ala Motif), + // or around contents, scrollbars and corner widgets (ala Windows) ? + SH_ScrollView_FrameOnlyAroundContents, + + // bool - menubars items are navigatable by pressing alt, followed by using + // the arrow keys to select the desired item + SH_MenuBar_AltKeyNavigation, + + // bool - mouse tracking in combobox dropdown lists + SH_ComboBox_ListMouseTracking, + + // bool - mouse tracking in popupmenus + SH_PopupMenu_MouseTracking, + + // bool - mouse tracking in menubars + SH_MenuBar_MouseTracking, + + // bool - gray out selected items when loosing focus + SH_ItemView_ChangeHighlightOnFocus, + + // bool - supports shared activation among modeless widgets + SH_Widget_ShareActivation, + + // bool - workspace should just maximize the client area + SH_Workspace_FillSpaceOnMaximize, + + // bool - supports popup menu comboboxes + SH_ComboBox_Popup, + + // bool - titlebar has no border + SH_TitleBar_NoBorder, + + // bool - stop scrollbar at mouse + SH_ScrollBar_StopMouseOverSlider, + + //bool - blink cursort with selected text + SH_BlinkCursorWhenTextSelected, + + //bool - richtext selections extend the full width of the docuemnt + SH_RichText_FullWidthSelection, + + //bool - popupmenu supports scrolling instead of multicolumn mode + SH_PopupMenu_Scrollable, + + // TQt::AlignmentFlags - text label vertical alignment in groupboxes + // Center on windows, Auto|VCenter otherwize + SH_GroupBox_TextLabelVerticalAlignment, + + // TQt::TQRgb - text label color in groupboxes + SH_GroupBox_TextLabelColor, + + // bool - popupmenu supports sloppy submenus + SH_PopupMenu_SloppySubMenus, + + // TQt::TQRgb - table grid color + SH_Table_GridLineColor, + + // TQChar - Unicode character for password char + SH_LineEdit_PasswordCharacter, + + // TQDialogButtons::Button - default button + SH_DialogButtons_DefaultButton, + + // TQToolBox - Boldness of the selected page title + SH_ToolBox_SelectedPageTitleBold, + + //bool - if a tabbar prefers not to have scroller arrows + SH_TabBar_PreferNoArrows, + + //bool - if left button should cause an absolute position + SH_ScrollBar_LeftClickAbsolutePosition, + + // TQEvent::Type - which mouse event to select a list view expansion + SH_ListViewExpand_SelectMouseType, + + //bool - if underline for accelerators + SH_UnderlineAccelerator, + + // bool - TQToolButton - if tool buttons should use a 3D frame + // when the mouse is over the button + SH_ToolButton_Uses3D, + + // bool - hide underlined accelerators uless Alt key is currently down + SH_HideUnderlineAcceleratorWhenAltUp, + + // int - width of menu check column + SH_MenuIndicatorColumnWidth, + + // bool - whether or not the lower two button drawing areas should be combined into one + SH_ScrollBar_CombineAddLineRegionDrawingAreas, + + // bool - whether or not the upper two button drawing areas should be combined into one + SH_ScrollBar_CombineSubLineRegionDrawingAreas, + + // TQt::TQRgb - color of the popup menu arrow (active, menuitem enabled) + SH_PopupMenu_SubMenuArrowColorActiveEnabled, + + // TQt::TQRgb - color of the popup menu arrow (active, menuitem disabled) + SH_PopupMenu_SubMenuArrowColorActiveDisabled, + + // TQt::TQRgb - color of the popup menu arrow (inactive, menuitem enabled) + SH_PopupMenu_SubMenuArrowColorInactiveEnabled, + + // TQt::TQRgb - color of the popup menu arrow (active, menuitem disabled) + SH_PopupMenu_SubMenuArrowColorInactiveDisabled, + + // do not add any values below/greater than this + SH_CustomBase = 0xf0000000 + }; + + // Old API + // DEPRECATED + virtual int styleHint( StyleHint stylehint, + const TQWidget *widget = 0, + const TQStyleOption& = TQStyleOption::Default, + TQStyleHintReturn* returnData = 0 + ) const; + + // New API + virtual int styleHint( StyleHint stylehint, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQStyleOption& = TQStyleOption::Default, + TQStyleHintReturn* returnData = 0, + const TQWidget *widget = 0 + ) const = 0; + + + enum StylePixmap { + SP_TitleBarMinButton, + SP_TitleBarMaxButton, + SP_TitleBarCloseButton, + SP_TitleBarNormalButton, + SP_TitleBarShadeButton, + SP_TitleBarUnshadeButton, + SP_DockWindowCloseButton, + SP_MessageBoxInformation, + SP_MessageBoxWarning, + SP_MessageBoxCritical, + SP_MessageBoxQuestion, + + // do not add any values below/greater than this + SP_CustomBase = 0xf0000000 + }; + + // Old API + // DEPRECATED + virtual TQPixmap stylePixmap( StylePixmap stylepixmap, + const TQWidget *widget = 0, + const TQStyleOption& = TQStyleOption::Default ) const; + + virtual TQPixmap stylePixmap( StylePixmap stylepixmap, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const = 0; + + + // Old API + // DEPRECATED + static TQRect visualRect( const TQRect &logical, const TQWidget *w ); + + // New API + static TQRect visualRect( const TQRect &logical, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags ); + + static TQRect visualRect( const TQRect &logical, const TQRect &bounding ); + + + // Object event handling API + typedef TQMap ObjectEventSourceToHandlerMap; + typedef TQMap ObjectEventSourceDataToHandlerMap; + typedef TQMap ObjectEventSourceFlagsToHandlerMap; + typedef bool (*EventHandlerInstallationHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler); + typedef bool (*EventHandlerRemovalHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler); + void installObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + void removeObjectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQStyle* handler ); + void setEventHandlerInstallationHook( EventHandlerInstallationHook ); + void setEventHandlerRemovalHook( EventHandlerRemovalHook hook ); + virtual bool objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); + + enum WidgetActionRequest { + WAR_Repaint, + WAR_RepaintRect, + WAR_EnableMouseTracking, + WAR_DisableMouseTracking, + WAR_SetAutoMask, + WAR_UnSetAutoMask, + WAR_SetCheckable, + WAR_UnSetCheckable, + WAR_FrameSetStyle, + WAR_FrameSetLineWidth, + WAR_SetLayoutMargin, + WAR_SetPalette, + WAR_SetBackgroundMode, + WAR_SetBackgroundOrigin, + WAR_SetFont, + WAR_RepaintAllAccelerators, + WAR_SetDefault, + WAR_UnSetDefault, + WAR_SendPaintEvent + }; + + typedef bool (*WidgetActionRequestHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData); + void setWidgetActionRequestHook( WidgetActionRequestHook ); + virtual bool widgetActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, WidgetActionRequest request, TQStyleWidgetActionRequestData requestData = TQStyleWidgetActionRequestData() ); + + enum ApplicationActionRequest { + AAR_SetPalette, + AAR_SetFont + }; + + typedef bool (*ApplicationActionRequestHook)(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData); + void setApplicationActionRequestHook( ApplicationActionRequestHook ); + virtual bool applicationActionRequest( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, ApplicationActionRequest request, TQStyleApplicationActionRequestData requestData = TQStyleApplicationActionRequestData() ); + + // Old 2.x TQStyle API + +#ifndef TQT_NO_COMPAT + int defaultFrameWidth() const; + void tabbarMetrics( const TQWidget* t, int& hf, int& vf, int& ov ) const; + TQSize scrollBarExtent() const; +#endif + +public: + virtual bool eventFilter( TQObject *, TQEvent * ); + bool acceleratorsShown() const; + +protected: + void acceleratorKeypressEventMonitor( TQObject *, TQEvent * ); + +private: + TQStylePrivate * d; + +#if defined(TQ_DISABLE_COPY) + TQStyle( const TQStyle & ); + TQStyle& operator=( const TQStyle & ); +#endif + + EventHandlerInstallationHook m_eventHandlerInstallationHook; + EventHandlerRemovalHook m_eventHandlerRemovalHook; + WidgetActionRequestHook m_widgetActionRequestHook; + ApplicationActionRequestHook m_applicationActionRequestHook; + ObjectEventSourceToHandlerMap m_objectEventSourceToHandlerMap; + ObjectEventSourceDataToHandlerMap m_objectEventSourceDataToHandlerMap; + ObjectEventSourceFlagsToHandlerMap m_objectEventSourceFlagsToHandlerMap; + bool conditionalAcceleratorsEnabled; +}; + +inline TQStyle::ControlElementFlags operator|(const TQStyle::ControlElementFlags a, const TQStyle::ControlElementFlags b) { return static_cast(static_cast(a) | static_cast(b)); } +// inline TQStyle::ControlElementFlags operator|=(TQStyle::ControlElementFlags &a, const TQStyle::ControlElementFlags b) { a = static_cast(static_cast(a) | static_cast(b)); return a; } + +TQ_EXPORT const TQStyleControlElementData &populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields=true); +TQ_EXPORT const TQStyleControlElementData &populateControlElementDataFromApplication(const TQApplication* app, const TQStyleOption& opt, bool populateReliantFields=true); +TQ_EXPORT TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, const TQStyleOption& opt, bool populateReliantFields=true); +TQ_EXPORT TQStringList getObjectTypeListForObject(const TQObject* object); +TQ_EXPORT const TQStyleControlElementData &populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields, bool populateMinimumNumberOfFields); + +#endif // TQT_NO_STYLE +#endif // TQSTYLE_H diff --git a/src/kernel/tqstylesheet.cpp b/src/kernel/tqstylesheet.cpp new file mode 100644 index 000000000..2af221100 --- /dev/null +++ b/src/kernel/tqstylesheet.cpp @@ -0,0 +1,1623 @@ +/**************************************************************************** +** +** Implementation of the TQStyleSheet class +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "tqstylesheet.h" + +#ifndef TQT_NO_RICHTEXT + +#include "private/qrichtext_p.h" +#include "ntqlayout.h" +#include "ntqpainter.h" +#include "ntqcleanuphandler.h" + +#include + +class TQStyleSheetItemData +{ +public: + TQStyleSheetItem::DisplayMode disp; + int fontitalic; + int fontunderline; + int fontstrikeout; + int fontweight; + int fontsize; + int fontsizelog; + int fontsizestep; + int lineSpacing; + TQString fontfamily; + TQStyleSheetItem *parentstyle; + TQString stylename; + int ncolumns; + TQColor col; + bool anchor; + int align; + TQStyleSheetItem::VerticalAlignment valign; + int margin[5]; + TQStyleSheetItem::ListStyle list; + TQStyleSheetItem::WhiteSpaceMode whitespacemode; + TQString contxt; + bool selfnest; + TQStyleSheet* sheet; +}; + +/*! + \class TQStyleSheetItem tqstylesheet.h + \brief The TQStyleSheetItem class provides an encapsulation of a set of text styles. + + \ingroup text + + A style sheet item consists of a name and a set of attributes that + specifiy its font, color, etc. When used in a \link TQStyleSheet + style sheet\endlink (see styleSheet()), items define the name() of + a rich text tag and the display property changes associated with + it. + + The \link TQStyleSheetItem::DisplayMode display mode\endlink + attribute indicates whether the item is a block, an inline element + or a list element; see setDisplayMode(). The treatment of + whitespace is controlled by the \link + TQStyleSheetItem::WhiteSpaceMode white space mode\endlink; see + setWhiteSpaceMode(). An item's margins are set with setMargin(), + In the case of list items, the list style is set with + setListStyle(). An item may be a hypertext link anchor; see + setAnchor(). Other attributes are set with setAlignment(), + setVerticalAlignment(), setFontFamily(), setFontSize(), + setFontWeight(), setFontItalic(), setFontUnderline(), + setFontStrikeOut and setColor(). +*/ + +/*! \enum TQStyleSheetItem::AdditionalStyleValues + \internal +*/ + +/*! + \enum TQStyleSheetItem::WhiteSpaceMode + + This enum defines the ways in which TQStyleSheet can treat + whitespace. + + \value WhiteSpaceNormal any sequence of whitespace (including + line-breaks) is equivalent to a single space. + + \value WhiteSpacePre whitespace must be output exactly as given + in the input. + + \value WhiteSpaceNoWrap multiple spaces are collapsed as with + WhiteSpaceNormal, but no automatic line-breaks occur. To break + lines manually, use the \c{
        } tag. + +*/ + +/*! + \enum TQStyleSheetItem::Margin + + \value MarginLeft left margin + \value MarginRight right margin + \value MarginTop top margin + \value MarginBottom bottom margin + \value MarginAll all margins (left, right, top and bottom) + \value MarginVertical top and bottom margins + \value MarginHorizontal left and right margins + \value MarginFirstLine margin (indentation) of the first line of + a paragarph (in addition to the MarginLeft of the paragraph) +*/ + +/*! + Constructs a new style called \a name for the stylesheet \a + parent. + + All properties in TQStyleSheetItem are initially in the "do not + change" state, except \link TQStyleSheetItem::DisplayMode display + mode\endlink, which defaults to \c DisplayInline. +*/ +TQStyleSheetItem::TQStyleSheetItem( TQStyleSheet* parent, const TQString& name ) +{ + d = new TQStyleSheetItemData; + d->stylename = name.lower(); + d->sheet = parent; + init(); + if (parent) + parent->insert( this ); +} + +/*! + Copy constructor. Constructs a copy of \a other that is not bound + to any style sheet. +*/ +TQStyleSheetItem::TQStyleSheetItem( const TQStyleSheetItem & other ) +{ + d = new TQStyleSheetItemData; + *d = *other.d; +} + + +/*! + Destroys the style. Note that TQStyleSheetItem objects become + owned by TQStyleSheet when they are created. +*/ +TQStyleSheetItem::~TQStyleSheetItem() +{ + delete d; +} + +/*! + Assignment. Assings a copy of \a other that is not bound to any style sheet. + Unbounds first from previous style sheet. + */ +TQStyleSheetItem& TQStyleSheetItem::operator=( const TQStyleSheetItem& other ) +{ + if ( &other == this ) + return *this; + delete d; + d = new TQStyleSheetItemData; + *d = *other.d; + return *this; +} + +/*! + Returns the style sheet this item is in. +*/ +TQStyleSheet* TQStyleSheetItem::styleSheet() +{ + return d->sheet; +} + +/*! + \overload + + Returns the style sheet this item is in. +*/ +const TQStyleSheet* TQStyleSheetItem::styleSheet() const +{ + return d->sheet; +} + +/*! + \internal + Internal initialization + */ +void TQStyleSheetItem::init() +{ + d->disp = DisplayInline; + + d->fontitalic = Undefined; + d->fontunderline = Undefined; + d->fontstrikeout = Undefined; + d->fontweight = Undefined; + d->fontsize = Undefined; + d->fontsizelog = Undefined; + d->fontsizestep = 0; + d->ncolumns = Undefined; + d->col = TQColor(); // !isValid() + d->anchor = FALSE; + d->align = Undefined; + d->valign = VAlignBaseline; + d->margin[0] = Undefined; + d->margin[1] = Undefined; + d->margin[2] = Undefined; + d->margin[3] = Undefined; + d->margin[4] = Undefined; + d->list = ListStyleUndefined; + d->whitespacemode = WhiteSpaceModeUndefined; + d->selfnest = TRUE; + d->lineSpacing = Undefined; +} + +/*! + Returns the name of the style item. +*/ +TQString TQStyleSheetItem::name() const +{ + return d->stylename; +} + +/*! + Returns the \link TQStyleSheetItem::DisplayMode display + mode\endlink of the style. + + \sa setDisplayMode() +*/ +TQStyleSheetItem::DisplayMode TQStyleSheetItem::displayMode() const +{ + return d->disp; +} + +/*! + \enum TQStyleSheetItem::DisplayMode + + This enum type defines the way adjacent elements are displayed. + + \value DisplayBlock elements are displayed as a rectangular block + (e.g. \c{

        ...

        }). + + \value DisplayInline elements are displayed in a horizontally + flowing sequence (e.g. \c{...}). + + \value DisplayListItem elements are displayed in a vertical + sequence (e.g. \c{
      • ...
      • }). + + \value DisplayNone elements are not displayed at all. +*/ + +/*! + Sets the display mode of the style to \a m. + + \sa displayMode() + */ +void TQStyleSheetItem::setDisplayMode(DisplayMode m) +{ + d->disp=m; +} + + +/*! + Returns the alignment of this style. Possible values are \c + AlignAuto, \c AlignLeft, \c AlignRight, \c AlignCenter or \c + AlignJustify. + + \sa setAlignment(), TQt::AlignmentFlags +*/ +int TQStyleSheetItem::alignment() const +{ + return d->align; +} + +/*! + Sets the alignment to \a f. This only makes sense for styles with + a \link TQStyleSheetItem::DisplayMode display mode\endlink of + DisplayBlock. Possible values are \c AlignAuto, \c AlignLeft, + \c AlignRight, \c AlignCenter or \c AlignJustify. + + \sa alignment(), displayMode(), TQt::AlignmentFlags +*/ +void TQStyleSheetItem::setAlignment( int f ) +{ + d->align = f; +} + + +/*! + Returns the vertical alignment of the style. Possible values are + \c VAlignBaseline, \c VAlignSub or \c VAlignSuper. + + \sa setVerticalAlignment() +*/ +TQStyleSheetItem::VerticalAlignment TQStyleSheetItem::verticalAlignment() const +{ + return d->valign; +} + +/*! + \enum TQStyleSheetItem::VerticalAlignment + + This enum type defines the way elements are aligned vertically. + This is only supported for text elements. + + \value VAlignBaseline align the baseline of the element (or the + bottom, if the element doesn't have a baseline) with the + baseline of the parent + + \value VAlignSub subscript the element + + \value VAlignSuper superscript the element + +*/ + + +/*! + Sets the vertical alignment to \a valign. Possible values are + \c VAlignBaseline, \c VAlignSub or \c VAlignSuper. + + The vertical alignment property is not inherited. + + \sa verticalAlignment() +*/ +void TQStyleSheetItem::setVerticalAlignment( VerticalAlignment valign ) +{ + d->valign = valign; +} + + +/*! + Returns TRUE if the style sets an italic font; otherwise returns + FALSE. + + \sa setFontItalic(), definesFontItalic() +*/ +bool TQStyleSheetItem::fontItalic() const +{ + return d->fontitalic > 0; +} + +/*! + If \a italic is TRUE sets italic for the style; otherwise sets + upright. + + \sa fontItalic(), definesFontItalic() +*/ +void TQStyleSheetItem::setFontItalic(bool italic) +{ + d->fontitalic = italic?1:0; +} + +/*! + Returns TRUE if the style defines a font shape; otherwise returns + FALSE. A style does not define any shape until setFontItalic() is + called. + + \sa setFontItalic(), fontItalic() +*/ +bool TQStyleSheetItem::definesFontItalic() const +{ + return d->fontitalic != Undefined; +} + +/*! + Returns TRUE if the style sets an underlined font; otherwise + returns FALSE. + + \sa setFontUnderline(), definesFontUnderline() +*/ +bool TQStyleSheetItem::fontUnderline() const +{ + return d->fontunderline > 0; +} + +/*! + If \a underline is TRUE, sets underline for the style; otherwise + sets no underline. + + \sa fontUnderline(), definesFontUnderline() +*/ +void TQStyleSheetItem::setFontUnderline(bool underline) +{ + d->fontunderline = underline?1:0; +} + +/*! + Returns TRUE if the style defines a setting for the underline + property of the font; otherwise returns FALSE. A style does not + define this until setFontUnderline() is called. + + \sa setFontUnderline(), fontUnderline() +*/ +bool TQStyleSheetItem::definesFontUnderline() const +{ + return d->fontunderline != Undefined; +} + + +/*! + Returns TRUE if the style sets a strike out font; otherwise + returns FALSE. + + \sa setFontStrikeOut(), definesFontStrikeOut() +*/ +bool TQStyleSheetItem::fontStrikeOut() const +{ + return d->fontstrikeout > 0; +} + +/*! + If \a strikeOut is TRUE, sets strike out for the style; otherwise + sets no strike out. + + \sa fontStrikeOut(), definesFontStrikeOut() +*/ +void TQStyleSheetItem::setFontStrikeOut(bool strikeOut) +{ + d->fontstrikeout = strikeOut?1:0; +} + +/*! + Returns TRUE if the style defines a setting for the strikeOut + property of the font; otherwise returns FALSE. A style does not + define this until setFontStrikeOut() is called. + + \sa setFontStrikeOut(), fontStrikeOut() +*/ +bool TQStyleSheetItem::definesFontStrikeOut() const +{ + return d->fontstrikeout != Undefined; +} + + +/*! + Returns the font weight setting of the style. This is either a + valid \c TQFont::Weight or the value \c TQStyleSheetItem::Undefined. + + \sa setFontWeight(), TQFont +*/ +int TQStyleSheetItem::fontWeight() const +{ + return d->fontweight; +} + +/*! + Sets the font weight setting of the style to \a w. Valid values + are those defined by \c TQFont::Weight. + + \sa TQFont, fontWeight() +*/ +void TQStyleSheetItem::setFontWeight(int w) +{ + d->fontweight = w; +} + +/*! + Returns the logical font size setting of the style. This is either + a valid size between 1 and 7 or \c TQStyleSheetItem::Undefined. + + \sa setLogicalFontSize(), setLogicalFontSizeStep(), TQFont::pointSize(), TQFont::setPointSize() +*/ +int TQStyleSheetItem::logicalFontSize() const +{ + return d->fontsizelog; +} + + +/*! + Sets the logical font size setting of the style to \a s. Valid + logical sizes are 1 to 7. + + \sa logicalFontSize(), TQFont::pointSize(), TQFont::setPointSize() +*/ +void TQStyleSheetItem::setLogicalFontSize(int s) +{ + d->fontsizelog = s; +} + +/*! + Returns the logical font size step of this style. + + The default is 0. Tags such as \c big define \c +1; \c small + defines \c -1. + + \sa setLogicalFontSizeStep() +*/ +int TQStyleSheetItem::logicalFontSizeStep() const +{ + return d->fontsizestep; +} + +/*! + Sets the logical font size step of this style to \a s. + + \sa logicalFontSizeStep() +*/ +void TQStyleSheetItem::setLogicalFontSizeStep( int s ) +{ + d->fontsizestep = s; +} + + + +/*! + Sets the font size setting of the style to \a s points. + + \sa fontSize(), TQFont::pointSize(), TQFont::setPointSize() +*/ +void TQStyleSheetItem::setFontSize(int s) +{ + d->fontsize = s; +} + +/*! + Returns the font size setting of the style. This is either a valid + point size or \c TQStyleSheetItem::Undefined. + + \sa setFontSize(), TQFont::pointSize(), TQFont::setPointSize() +*/ +int TQStyleSheetItem::fontSize() const +{ + return d->fontsize; +} + + +/*! + Returns the font family setting of the style. This is either a + valid font family or TQString::null if no family has been set. + + \sa setFontFamily(), TQFont::family(), TQFont::setFamily() +*/ +TQString TQStyleSheetItem::fontFamily() const +{ + return d->fontfamily; +} + +/*! + Sets the font family setting of the style to \a fam. + + \sa fontFamily(), TQFont::family(), TQFont::setFamily() +*/ +void TQStyleSheetItem::setFontFamily( const TQString& fam) +{ + d->fontfamily = fam; +} + + +/*!\obsolete + Returns the number of columns for this style. + + \sa setNumberOfColumns(), displayMode(), setDisplayMode() + + */ +int TQStyleSheetItem::numberOfColumns() const +{ + return d->ncolumns; +} + + +/*!\obsolete + Sets the number of columns for this style. Elements in the style + are divided into columns. + + This makes sense only if the style uses a block display mode + (see TQStyleSheetItem::DisplayMode). + + \sa numberOfColumns() + */ +void TQStyleSheetItem::setNumberOfColumns(int ncols) +{ + if (ncols > 0) + d->ncolumns = ncols; +} + + +/*! + Returns the text color of this style or an invalid color if no + color has been set. + + \sa setColor() TQColor::isValid() +*/ +TQColor TQStyleSheetItem::color() const +{ + return d->col; +} + +/*! + Sets the text color of this style to \a c. + + \sa color() +*/ +void TQStyleSheetItem::setColor( const TQColor &c) +{ + d->col = c; +} + +/*! + Returns whether this style is an anchor. + + \sa setAnchor() +*/ +bool TQStyleSheetItem::isAnchor() const +{ + return d->anchor; +} + +/*! + If \a anc is TRUE, sets this style to be an anchor (hypertext + link); otherwise sets it to not be an anchor. Elements in this + style link to other documents or anchors. + + \sa isAnchor() +*/ +void TQStyleSheetItem::setAnchor(bool anc) +{ + d->anchor = anc; +} + + +/*! + Returns the whitespace mode. + + \sa setWhiteSpaceMode() WhiteSpaceMode +*/ +TQStyleSheetItem::WhiteSpaceMode TQStyleSheetItem::whiteSpaceMode() const +{ + return d->whitespacemode; +} + +/*! + Sets the whitespace mode to \a m. + + \sa WhiteSpaceMode +*/ +void TQStyleSheetItem::setWhiteSpaceMode(WhiteSpaceMode m) +{ + d->whitespacemode = m; +} + + +/*! + Returns the width of margin \a m in pixels. + + The margin, \a m, can be \c MarginLeft, \c MarginRight, \c + MarginTop, \c MarginBottom, or \c MarginFirstLine. + + \sa setMargin() Margin +*/ +int TQStyleSheetItem::margin(Margin m) const +{ + if (m == MarginAll ) { + return d->margin[MarginLeft]; + } else if (m == MarginVertical) { + return d->margin[MarginTop]; + } else if (m == MarginHorizontal) { + return d->margin[MarginLeft]; + } else { + return d->margin[m]; + } +} + + +/*! + Sets the width of margin \a m to \a v pixels. + + The margin, \a m, can be \c MarginLeft, \c MarginRight, \c + MarginTop, \c MarginBottom, \c MarginFirstLine, \c MarginAll, + \c MarginVertical or \c MarginHorizontal. The value \a v must + be >= 0. + + \sa margin() +*/ +void TQStyleSheetItem::setMargin(Margin m, int v) +{ + if (m == MarginAll) { + d->margin[MarginLeft] = v; + d->margin[MarginRight] = v; + d->margin[MarginTop] = v; + d->margin[MarginBottom] = v; + } else if (m == MarginVertical ) { + d->margin[MarginTop] = v; + d->margin[MarginBottom] = v; + } else if (m == MarginHorizontal ) { + d->margin[MarginLeft] = v; + d->margin[MarginRight] = v; + } else { + d->margin[m] = v; + } +} + + +/*! + Returns the list style of the style. + + \sa setListStyle() ListStyle + */ +TQStyleSheetItem::ListStyle TQStyleSheetItem::listStyle() const +{ + return d->list; +} + +/*! + \enum TQStyleSheetItem::ListStyle + + This enum type defines how the items in a list are prefixed when + displayed. + + \value ListDisc a filled circle (i.e. a bullet) + \value ListCircle an unfilled circle + \value ListSquare a filled square + \value ListDecimal an integer in base 10: \e 1, \e 2, \e 3, ... + \value ListLowerAlpha a lowercase letter: \e a, \e b, \e c, ... + \value ListUpperAlpha an uppercase letter: \e A, \e B, \e C, ... +*/ + +/*! + Sets the list style of the style to \a s. + + This is used by nested elements that have a display mode of \c + DisplayListItem. + + \sa listStyle() DisplayMode ListStyle +*/ +void TQStyleSheetItem::setListStyle(ListStyle s) +{ + d->list=s; +} + + +/*! + Returns a space-separated list of names of styles that may contain + elements of this style. If nothing has been set, contexts() + returns an empty string, which indicates that this style can be + nested everywhere. + + \sa setContexts() +*/ +TQString TQStyleSheetItem::contexts() const +{ + return d->contxt; +} + +/*! + Sets a space-separated list of names of styles that may contain + elements of this style. If \a c is empty, the style can be nested + everywhere. + + \sa contexts() +*/ +void TQStyleSheetItem::setContexts( const TQString& c) +{ + d->contxt = TQChar(' ') + c + TQChar(' '); +} + +/*! + Returns TRUE if this style can be nested into an element of style + \a s; otherwise returns FALSE. + + \sa contexts(), setContexts() +*/ +bool TQStyleSheetItem::allowedInContext( const TQStyleSheetItem* s) const +{ + if ( d->contxt.isEmpty() ) + return TRUE; + return d->contxt.find( TQChar(' ')+s->name()+TQChar(' ')) != -1; +} + + +/*! + Returns TRUE if this style has self-nesting enabled; otherwise + returns FALSE. + + \sa setSelfNesting() +*/ +bool TQStyleSheetItem::selfNesting() const +{ + return d->selfnest; +} + +/*! + Sets the self-nesting property for this style to \a nesting. + + In order to support "dirty" HTML, paragraphs \c{

        } and list + items \c{

      • } are not self-nesting. This means that starting a + new paragraph or list item automatically closes the previous one. + + \sa selfNesting() +*/ +void TQStyleSheetItem::setSelfNesting( bool nesting ) +{ + d->selfnest = nesting; +} + +/*! + \internal + Sets the linespacing to be at least \a ls pixels. + + For compatibility with previous TQt releases, small values get + treated differently: If \a ls is smaller than the default font + line spacing in pixels at parse time, the resulting line spacing + is the sum of the default line spacing plus \a ls. We recommend + not relying on this behavior. +*/ + +void TQStyleSheetItem::setLineSpacing( int ls ) +{ + d->lineSpacing = ls; +} + +/*! + \obsolete + + Returns the linespacing +*/ + +int TQStyleSheetItem::lineSpacing() const +{ + return d->lineSpacing; +} + +//************************************************************************ + + + + +//************************************************************************ + + +/*! + \class TQStyleSheet tqstylesheet.h + \ingroup text + \brief The TQStyleSheet class is a collection of styles for rich text + rendering and a generator of tags. + + \ingroup graphics + \ingroup helpsystem + + By creating TQStyleSheetItem objects for a style sheet you build a + definition of a set of tags. This definition will be used by the + internal rich text rendering system to parse and display text + documents to which the style sheet applies. Rich text is normally + visualized in a TQTextEdit or a TQTextBrowser. However, TQLabel, + TQWhatsThis and TQMessageBox also support it, and other classes are + likely to follow. With TQSimpleRichText it is possible to use the + rich text renderer for custom widgets as well. + + The default TQStyleSheet object has the following style bindings, + sorted by structuring bindings, anchors, character style bindings + (i.e. inline styles), special elements such as horizontal lines or + images, and other tags. In addition, rich text supports simple + HTML tables. + + The structuring tags are + \table + \header \i Structuring tags \i Notes + \row \i \c{}...\c{} + \i A TQt rich text document. It understands the following + attributes: + \list + \i \c title -- The caption of the document. This attribute is + easily accessible with TQTextEdit::documentTitle(). + \i \c type -- The type of the document. The default type is \c + page. It indicates that the document is displayed in a + page of its own. Another style is \c detail, which can be + used to explain certain expressions in more detail in a + few sentences. For \c detail, TQTextBrowser will then keep + the current page and display the new document in a small + popup similar to TQWhatsThis. Note that links will not work + in documents with \c{...}. + \i \c bgcolor -- The background color, for example \c + bgcolor="yellow" or \c bgcolor="#0000FF". + \i \c background -- The background pixmap, for example \c + background="granite.xpm". The pixmap name will be resolved + by a TQMimeSourceFactory(). + \i \c text -- The default text color, for example \c text="red". + \i \c link -- The link color, for example \c link="green". + \endlist + \row \i \c{

        ...

        } + \i A top-level heading. + \row \i \c{

        ...

        } + \i A sublevel heading. + \row \i \c{

        ...

        } + \i A sub-sublevel heading. + \row \i \c{

        ...

        } \c{
        ...
        } + \i Headings of lesser importance. + \row \i \c{

        ...

        } + \i A left-aligned paragraph. Adjust the alignment with the \c + align attribute. Possible values are \c left, \c right and + \c center. + \row \i \c{
        ...}
        \c{
        } + \i A centered paragraph. + \row \i \c{
        ...}
        \c{
        } + \i An indented paragraph that is useful for quotes. + \row \i \c{
          ...
        } + \i An unordered list. You can also pass a type argument to + define the bullet style. The default is \c type=disc; + other types are \c circle and \c square. + \row \i \c{
          ...
        } + \i An ordered list. You can also pass a type argument to + define the enumeration label style. The default is \c + type="1"; other types are \c "a" and \c "A". + \row \i \c{
      • ...
      • } + \i A list item. This tag can be used only within the context + of \c{
          } or \c{
            }. + \row \i \c{
            ...
            } + \i A list of definitions, consisting of terms and descriptions. + \row \i \c{
            ...
            } + \i A term in a list of definitions. This tag can be used only + in the context of \c{
            ...
            }. + \row \i \c{
            ...
            } + \i A description in a list of definitions. This tag can be + used only in the context of \c{
            ...
            }. + \row \i \c{
            ...
            } + \i For larger chunks of code. Whitespaces in the contents are + preserved. For small bits of code use the inline-style \c + code. + \row \i \c{
            ...
            } and \c{...} + \i Block grouping elements. These are used to structure the + document, and are often used to provide hints about the + intended presentation of the document. + \endtable + + Anchors and links are done with a single tag: + \table + \header \i Anchor tags \i Notes + \row \i \c{...} + \i An anchor or link. + \list + \i A link is created by using an \c href + attribute, for example +
            \c{Link Text}. Links to + targets within a document are achieved in the same way + as for HTML, e.g. +
            \c{Link Text}. + \i A target is created by using a \c name + attribute, for example +
            \c{

            Sub Title

            }. + \endlist + \endtable + + The default character style bindings are + \table + \header \i Style tags \i Notes + \row \i \c{...} + \i Emphasized. By default this is the same as \c{...} + (italic). + \row \i \c{...} + \i Strong. By default this is the same as \c{...} + (bold). + \row \i \c{...} + \i Italic font style. + \row \i \c{...} + \i Bold font style. + \row \i \c{...} + \i Underlined font style. + \row \i \c{...} + \i Strike out font style. + \row \i \c{...} + \i A larger font size. + \row \i \c{...} + \i A smaller font size. + \row \i \c{...} + \i Subscripted text + \row \i \c{...} + \i Superscripted text + \row \i \c{...} + \i Indicates code. By default this is the same as + \c{...} (typewriter). For larger chunks of code + use the block-tag \c{<}\c{pre>}. + \row \i \c{...} + \i Typewriter font style. + \row \i \c{...} + \i Customizes the font size, family and text color. The tag + understands the following attributes: + \list + \i \c color -- The text color, for example \c color="red" or + \c color="#FF0000". + \i \c size -- The logical size of the font. Logical sizes 1 + to 7 are supported. The value may either be absolute + (for example, \c size=3) or relative (\c size=-2). In + the latter case the sizes are simply added. + \i \c face -- The family of the font, for example \c face=times. + \endlist + \endtable + + Special elements are: + \table + \header \i Special tags \i Notes + \row \i \c{} + \i An image. The image name for the mime source factory is + given in the source attribute, for example + \c{} The image tag also understands the + attributes \c width and \c height that determine the size + of the image. If the pixmap does not fit the specified + size it will be scaled automatically (by using + TQImage::smoothScale()). +
            + The \c align attribute determines where the image is + placed. By default, an image is placed inline just like a + normal character. Specify \c left or \c right to place the + image at the respective side. + \row \i \c{
            } + \i A horizontal line. + \row \i \c{
            } + \i A line break. + \row \i \c{...} + \i No break. Prevents word wrap. + \endtable + + In addition, rich text supports simple HTML tables. A table + consists of one or more rows each of which contains one or more + cells. Cells are either data cells or header cells, depending on + their content. Cells which span rows and columns are supported. + + \table + \header \i Table tags \i Notes + \row \i \c{...
            } + \i A table. Tables support the following attributes: + \list + \i \c bgcolor -- The background color. + \i \c width -- The table width. This is either an absolute + pixel width or a relative percentage of the table's + width, for example \c width=80%. + \i \c border -- The width of the table border. The default is + 0 (= no border). + \i \c cellspacing -- Additional space around the table cells. + The default is 2. + \i \c cellpadding -- Additional space around the contents of + table cells. The default is 1. + \endlist + \row \i \c{...} + \i A table row. This is only valid within a \c table. Rows + support the following attribute: + \list + \i \c bgcolor -- The background color. + \endlist + \row \i \c{...} + \i A table header cell. Similar to \c td, but defaults to + center alignment and a bold font. + \row \i \c{...} + \i A table data cell. This is only valid within a \c tr. + Cells support the following attributes: + \list + \i \c bgcolor -- The background color. + \i \c width -- The cell width. This is either an absolute + pixel width or a relative percentage of table's width, + for example \c width=50%. + \i \c colspan -- Specifies how many columns this cell spans. + The default is 1. + \i \c rowspan -- Specifies how many rows this cell spans. The + default is 1. + \i \c align -- Alignment; possible values are \c left, \c + right, and \c center. The default is \c left. + \i \c valign -- Vertical alignment; possible values are \c + top, \c middle, and \c bottom. The default is \c middle. + \endlist + \endtable +*/ + +/*! + Creates a style sheet called \a name, with parent \a parent. Like + any TQObject it will be deleted when its parent is destroyed (if + the child still exists). + + By default the style sheet has the tag definitions defined above. +*/ +TQStyleSheet::TQStyleSheet( TQObject *parent, const char *name ) + : TQObject( parent, name ) +{ + init(); +} + +/*! + Destroys the style sheet. All styles inserted into the style sheet + will be deleted. +*/ +TQStyleSheet::~TQStyleSheet() +{ +} + +/*! + \internal + Initialized the style sheet to the basic TQt style. +*/ +void TQStyleSheet::init() +{ + styles.setAutoDelete( TRUE ); + + nullstyle = new TQStyleSheetItem( this, + TQString::fromLatin1("") ); + + TQStyleSheetItem* style; + + style = new TQStyleSheetItem( this, "qml" ); // compatibility + style->setDisplayMode( TQStyleSheetItem::DisplayBlock ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("qt") ); + style->setDisplayMode( TQStyleSheetItem::DisplayBlock ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("a") ); + style->setAnchor( TRUE ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("em") ); + style->setFontItalic( TRUE ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("i") ); + style->setFontItalic( TRUE ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("big") ); + style->setLogicalFontSizeStep( 1 ); + style = new TQStyleSheetItem( this, TQString::fromLatin1("large") ); // compatibility + style->setLogicalFontSizeStep( 1 ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("small") ); + style->setLogicalFontSizeStep( -1 ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("strong") ); + style->setFontWeight( TQFont::Bold); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("b") ); + style->setFontWeight( TQFont::Bold); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("h1") ); + style->setFontWeight( TQFont::Bold); + style->setLogicalFontSize(6); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style-> setMargin(TQStyleSheetItem::MarginTop, 18); + style-> setMargin(TQStyleSheetItem::MarginBottom, 12); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("h2") ); + style->setFontWeight( TQFont::Bold); + style->setLogicalFontSize(5); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style-> setMargin(TQStyleSheetItem::MarginTop, 16); + style-> setMargin(TQStyleSheetItem::MarginBottom, 12); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("h3") ); + style->setFontWeight( TQFont::Bold); + style->setLogicalFontSize(4); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style-> setMargin(TQStyleSheetItem::MarginTop, 14); + style-> setMargin(TQStyleSheetItem::MarginBottom, 12); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("h4") ); + style->setFontWeight( TQFont::Bold); + style->setLogicalFontSize(3); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style-> setMargin(TQStyleSheetItem::MarginVertical, 12); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("h5") ); + style->setFontWeight( TQFont::Bold); + style->setLogicalFontSize(2); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style-> setMargin(TQStyleSheetItem::MarginTop, 12); + style-> setMargin(TQStyleSheetItem::MarginBottom, 4); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("p") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style-> setMargin(TQStyleSheetItem::MarginVertical, 12); + style->setSelfNesting( FALSE ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("center") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setAlignment( AlignCenter ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("twocolumn") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setNumberOfColumns( 2 ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("multicol") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + (void) new TQStyleSheetItem( this, TQString::fromLatin1("font") ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("ul") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setListStyle( TQStyleSheetItem::ListDisc ); + style-> setMargin(TQStyleSheetItem::MarginVertical, 12); + style->setMargin( TQStyleSheetItem::MarginLeft, 40 ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("ol") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setListStyle( TQStyleSheetItem::ListDecimal ); + style-> setMargin(TQStyleSheetItem::MarginVertical, 12); + style->setMargin( TQStyleSheetItem::MarginLeft, 40 ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("li") ); + style->setDisplayMode(TQStyleSheetItem::DisplayListItem); + style->setSelfNesting( FALSE ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("code") ); + style->setFontFamily( TQString::fromLatin1("Courier New,courier") ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("tt") ); + style->setFontFamily( TQString::fromLatin1("Courier New,courier") ); + + new TQStyleSheetItem(this, TQString::fromLatin1("img")); + new TQStyleSheetItem(this, TQString::fromLatin1("br")); + new TQStyleSheetItem(this, TQString::fromLatin1("hr")); + + style = new TQStyleSheetItem(this, TQString::fromLatin1("sub")); + style->setVerticalAlignment( TQStyleSheetItem::VAlignSub ); + style = new TQStyleSheetItem(this, TQString::fromLatin1("sup")); + style->setVerticalAlignment( TQStyleSheetItem::VAlignSuper ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("pre") ); + style->setFontFamily( TQString::fromLatin1("Courier New,courier") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setWhiteSpaceMode(TQStyleSheetItem::WhiteSpacePre); + style-> setMargin(TQStyleSheetItem::MarginVertical, 12); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("blockquote") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setMargin(TQStyleSheetItem::MarginHorizontal, 40 ); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("head") ); + style->setDisplayMode(TQStyleSheetItem::DisplayNone); + style = new TQStyleSheetItem( this, TQString::fromLatin1("body") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style = new TQStyleSheetItem( this, TQString::fromLatin1("div") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock) ; + style = new TQStyleSheetItem( this, TQString::fromLatin1("span") ); + style = new TQStyleSheetItem( this, TQString::fromLatin1("dl") ); + style-> setMargin(TQStyleSheetItem::MarginVertical, 8); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style = new TQStyleSheetItem( this, TQString::fromLatin1("dt") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setContexts(TQString::fromLatin1("dl") ); + style = new TQStyleSheetItem( this, TQString::fromLatin1("dd") ); + style->setDisplayMode(TQStyleSheetItem::DisplayBlock); + style->setMargin(TQStyleSheetItem::MarginLeft, 30); + style->setContexts(TQString::fromLatin1("dt dl") ); + style = new TQStyleSheetItem( this, TQString::fromLatin1("u") ); + style->setFontUnderline( TRUE); + style = new TQStyleSheetItem( this, TQString::fromLatin1("s") ); + style->setFontStrikeOut( TRUE); + style = new TQStyleSheetItem( this, TQString::fromLatin1("nobr") ); + style->setWhiteSpaceMode( TQStyleSheetItem::WhiteSpaceNoWrap ); + + // compatibily with some minor 3.0.x TQt versions that had an + // undocumented tag. ### Remove 3.1 + style = new TQStyleSheetItem( this, TQString::fromLatin1("wsp") ); + style->setWhiteSpaceMode( TQStyleSheetItem::WhiteSpacePre ); + + // tables + style = new TQStyleSheetItem( this, TQString::fromLatin1("table") ); + style = new TQStyleSheetItem( this, TQString::fromLatin1("tr") ); + style->setContexts(TQString::fromLatin1("table")); + style = new TQStyleSheetItem( this, TQString::fromLatin1("td") ); + style->setContexts(TQString::fromLatin1("tr")); + style = new TQStyleSheetItem( this, TQString::fromLatin1("th") ); + style->setFontWeight( TQFont::Bold ); + style->setAlignment( TQt::AlignCenter ); + style->setContexts(TQString::fromLatin1("tr")); + + style = new TQStyleSheetItem( this, TQString::fromLatin1("html") ); +} + + + +static TQStyleSheet* defaultsheet = 0; +static TQSingleCleanupHandler tqt_cleanup_stylesheet; + +/*! + Returns the application-wide default style sheet. This style sheet + is used by rich text rendering classes such as TQSimpleRichText, + TQWhatsThis and TQMessageBox to define the rendering style and + available tags within rich text documents. It also serves as the + initial style sheet for the more complex render widgets, TQTextEdit + and TQTextBrowser. + + \sa setDefaultSheet() +*/ +TQStyleSheet* TQStyleSheet::defaultSheet() +{ + if (!defaultsheet) { + defaultsheet = new TQStyleSheet(); + tqt_cleanup_stylesheet.set( &defaultsheet ); + } + return defaultsheet; +} + +/*! + Sets the application-wide default style sheet to \a sheet, + deleting any style sheet previously set. The ownership is + transferred to TQStyleSheet. + + \sa defaultSheet() +*/ +void TQStyleSheet::setDefaultSheet( TQStyleSheet* sheet) +{ + if ( defaultsheet != sheet ) { + if ( defaultsheet ) + tqt_cleanup_stylesheet.reset(); + delete defaultsheet; + } + defaultsheet = sheet; + if ( defaultsheet ) + tqt_cleanup_stylesheet.set( &defaultsheet ); +} + +/*!\internal + Inserts \a style. Any tags generated after this time will be + bound to this style. Note that \a style becomes owned by the + style sheet and will be deleted when the style sheet is destroyed. +*/ +void TQStyleSheet::insert( TQStyleSheetItem* style ) +{ + styles.insert(style->name(), style); +} + + +/*! + Returns the style called \a name or 0 if there is no such style. +*/ +TQStyleSheetItem* TQStyleSheet::item( const TQString& name) +{ + if ( name.isNull() ) + return 0; + return styles[name]; +} + +/*! + \overload + + Returns the style called \a name or 0 if there is no such style + (const version) +*/ +const TQStyleSheetItem* TQStyleSheet::item( const TQString& name) const +{ + if ( name.isNull() ) + return 0; + return styles[name]; +} + + +/*! + \preliminary + + Generates an internal object for the tag called \a name, given the + attributes \a attr, and using additional information provided by + the mime source factory \a factory. + + \a context is the optional context of the document, i.e. the path + to look for relative links. This becomes important if the text + contains relative references, for example within image tags. + TQSimpleRichText always uses the default mime source factory (see + \l{TQMimeSourceFactory::defaultFactory()}) to resolve these + references. The context will then be used to calculate the + absolute path. See TQMimeSourceFactory::makeAbsolute() for details. + + \a emptyTag and \a doc are for internal use only. + + This function should not be used in application code. +*/ +#ifndef TQT_NO_TEXTCUSTOMITEM +TQTextCustomItem* TQStyleSheet::tag( const TQString& name, + const TQMap &attr, + const TQString& context, + const TQMimeSourceFactory& factory, + bool /*emptyTag */, TQTextDocument *doc ) const +{ + const TQStyleSheetItem* style = item( name ); + // first some known tags + if ( !style ) + return 0; + if ( style->name() == "img" ) + return new TQTextImage( doc, attr, context, (TQMimeSourceFactory&)factory ); + if ( style->name() == "hr" ) + return new TQTextHorizontalLine( doc, attr, context, (TQMimeSourceFactory&)factory ); + return 0; +} +#endif + + +/*! Auxiliary function. Converts the plain text string \a plain to a + rich text formatted paragraph while preserving most of its look. + + \a mode defines the whitespace mode. Possible values are \c + TQStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces + preserved) and \c TQStyleSheetItem::WhiteSpaceNormal (wrapping, + simplified whitespaces). + + \sa escape() +*/ +TQString TQStyleSheet::convertFromPlainText( const TQString& plain, TQStyleSheetItem::WhiteSpaceMode mode ) +{ + int col = 0; + TQString rich; + rich += "

            "; + for ( int i = 0; i < int(plain.length()); ++i ) { + if ( plain[i] == '\n' ){ + int c = 1; + while ( i+1 < int(plain.length()) && plain[i+1] == '\n' ) { + i++; + c++; + } + if ( c == 1) + rich += "
            \n"; + else { + rich += "

            \n"; + while ( --c > 1 ) + rich += "
            \n"; + rich += "

            "; + } + col = 0; + } else { + if ( mode == TQStyleSheetItem::WhiteSpacePre && plain[i] == '\t' ){ + rich += 0x00a0U; + ++col; + while ( col % 8 ) { + rich += 0x00a0U; + ++col; + } + } + else if ( mode == TQStyleSheetItem::WhiteSpacePre && plain[i].isSpace() ) + rich += 0x00a0U; + else if ( plain[i] == '<' ) + rich +="<"; + else if ( plain[i] == '>' ) + rich +=">"; + else if ( plain[i] == '&' ) + rich +="&"; + else + rich += plain[i]; + ++col; + } + } + if ( col != 0 ) + rich += "

            "; + return rich; +} + +/*! + Auxiliary function. Converts the plain text string \a plain to a + rich text formatted string with any HTML meta-characters escaped. + + \sa convertFromPlainText() +*/ +TQString TQStyleSheet::escape( const TQString& plain) +{ + TQString rich; + for ( int i = 0; i < int(plain.length()); ++i ) { + if ( plain[i] == '<' ) + rich +="<"; + else if ( plain[i] == '>' ) + rich +=">"; + else if ( plain[i] == '&' ) + rich +="&"; + else + rich += plain[i]; + } + return rich; +} + +// Must doc this enum somewhere, and it is logically related to TQStyleSheet + +/*! + \enum TQt::TextFormat + + This enum is used in widgets that can display both plain text and + rich text, e.g. TQLabel. It is used for deciding whether a text + string should be interpreted as one or the other. This is normally + done by passing one of the enum values to a setTextFormat() + function. + + \value PlainText The text string is interpreted as a plain text + string. + + \value RichText The text string is interpreted as a rich text + string using the current TQStyleSheet::defaultSheet(). + + \value AutoText The text string is interpreted as for \c RichText + if TQStyleSheet::mightBeRichText() returns TRUE, otherwise as + \c PlainText. + + \value LogText A special, limited text format which is only used + by TQTextEdit in an optimized mode. +*/ + +/*! + Returns TRUE if the string \a text is likely to be rich text; + otherwise returns FALSE. + + This function uses a fast and therefore simple heuristic. It + mainly checks whether there is something that looks like a tag + before the first line break. Although the result may be correct + for common cases, there is no guarantee. +*/ +bool TQStyleSheet::mightBeRichText( const TQString& text) +{ + if ( text.isEmpty() ) + return FALSE; + int start = 0; + + while ( start < int(text.length()) && text[start].isSpace() ) + ++start; + if ( text.mid( start, 5 ).lower() == " + ++open; + } + if ( open < (int)text.length() && text[open] == '<' ) { + int close = text.find('>', open); + if ( close > -1 ) { + TQString tag; + for (int i = open+1; i < close; ++i) { + if ( text[i].isDigit() || text[i].isLetter() ) + tag += text[i]; + else if ( !tag.isEmpty() && text[i].isSpace() ) + break; + else if ( !text[i].isSpace() && (!tag.isEmpty() || text[i] != '!' ) ) + return FALSE; // that's not a tag + } + return defaultSheet()->item( tag.lower() ) != 0; + } + } + return FALSE; +} + + +/*! + \fn void TQStyleSheet::error( const TQString& msg) const + + This virtual function is called when an error occurs when + processing rich text. Reimplement it if you need to catch error + messages. + + Errors might occur if some rich text strings contain tags that are + not understood by the stylesheet, if some tags are nested + incorrectly, or if tags are not closed properly. + + \a msg is the error message. +*/ +void TQStyleSheet::error( const TQString& ) const +{ +} + + +/*! + Scales the font \a font to the appropriate physical point size + corresponding to the logical font size \a logicalSize. + + When calling this function, \a font has a point size corresponding + to the logical font size 3. + + Logical font sizes range from 1 to 7, with 1 being the smallest. + + \sa TQStyleSheetItem::logicalFontSize(), TQStyleSheetItem::logicalFontSizeStep(), TQFont::setPointSize() + */ +void TQStyleSheet::scaleFont( TQFont& font, int logicalSize ) const +{ + if ( logicalSize < 1 ) + logicalSize = 1; + if ( logicalSize > 7 ) + logicalSize = 7; + int baseSize = font.pointSize(); + bool pixel = FALSE; + if ( baseSize == -1 ) { + baseSize = font.pixelSize(); + pixel = TRUE; + } + int s; + switch ( logicalSize ) { + case 1: + s = 7*baseSize/10; + break; + case 2: + s = (8 * baseSize) / 10; + break; + case 4: + s = (12 * baseSize) / 10; + break; + case 5: + s = (15 * baseSize) / 10; + break; + case 6: + s = 2 * baseSize; + break; + case 7: + s = (24 * baseSize) / 10; + break; + default: + s = baseSize; + } + if ( pixel ) + font.setPixelSize( s ); + else + font.setPointSize( s ); +} + +#endif // TQT_NO_RICHTEXT diff --git a/src/kernel/tqstylesheet.h b/src/kernel/tqstylesheet.h new file mode 100644 index 000000000..1c12775cc --- /dev/null +++ b/src/kernel/tqstylesheet.h @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** Definition of the TQStyleSheet class +** +** Created : 990101 +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of the kernel module of the TQt GUI Toolkit. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TQSTYLESHEET_H +#define TQSTYLESHEET_H + +#ifndef QT_H +#include "tqstring.h" +#include "tqvaluelist.h" +#include "tqptrvector.h" +#include "ntqdict.h" +#include "tqobject.h" +#endif // QT_H + +#ifndef TQT_NO_RICHTEXT + +class TQStyleSheet; +class TQTextDocument; +template class TQMap; +class TQStyleSheetItemData; + +class TQ_EXPORT TQStyleSheetItem : public TQt +{ +public: + TQStyleSheetItem( TQStyleSheet* parent, const TQString& name ); + TQStyleSheetItem( const TQStyleSheetItem & ); + ~TQStyleSheetItem(); + + TQStyleSheetItem& operator=( const TQStyleSheetItem& other ); + + TQString name() const; + + TQStyleSheet* styleSheet(); + const TQStyleSheet* styleSheet() const; + + enum AdditionalStyleValues { Undefined = - 1}; + + enum DisplayMode { + DisplayBlock, + DisplayInline, + DisplayListItem, + DisplayNone +#ifndef Q_QDOC + , DisplayModeUndefined = -1 +#endif + }; + + DisplayMode displayMode() const; + void setDisplayMode(DisplayMode m); + + int alignment() const; + void setAlignment( int f); + + enum VerticalAlignment { + VAlignBaseline, + VAlignSub, + VAlignSuper + }; + + VerticalAlignment verticalAlignment() const; + void setVerticalAlignment( VerticalAlignment valign ); + + int fontWeight() const; + void setFontWeight(int w); + + int logicalFontSize() const; + void setLogicalFontSize(int s); + + int logicalFontSizeStep() const; + void setLogicalFontSizeStep( int s ); + + int fontSize() const; + void setFontSize(int s); + + TQString fontFamily() const; + void setFontFamily( const TQString& ); + + int numberOfColumns() const; + void setNumberOfColumns(int ncols); + + TQColor color() const; + void setColor( const TQColor &); + + bool fontItalic() const; + void setFontItalic( bool ); + bool definesFontItalic() const; + + bool fontUnderline() const; + void setFontUnderline( bool ); + bool definesFontUnderline() const; + + bool fontStrikeOut() const; + void setFontStrikeOut( bool ); + bool definesFontStrikeOut() const; + + bool isAnchor() const; + void setAnchor(bool anc); + + enum WhiteSpaceMode { + WhiteSpaceNormal, + WhiteSpacePre, + WhiteSpaceNoWrap +#ifndef Q_QDOC + , WhiteSpaceModeUndefined = -1 +#endif + }; + WhiteSpaceMode whiteSpaceMode() const; + void setWhiteSpaceMode(WhiteSpaceMode m); + + enum Margin { + MarginLeft, + MarginRight, + MarginTop, + MarginBottom, + MarginFirstLine, + MarginAll, + MarginVertical, + MarginHorizontal +#ifndef Q_QDOC + , MarginUndefined = -1 +#endif + }; + + int margin( Margin m) const; + void setMargin( Margin, int); + + enum ListStyle { + ListDisc, + ListCircle, + ListSquare, + ListDecimal, + ListLowerAlpha, + ListUpperAlpha +#ifndef Q_QDOC + , ListStyleUndefined = -1 +#endif + }; + + ListStyle listStyle() const; + void setListStyle( ListStyle ); + + TQString contexts() const; + void setContexts( const TQString& ); + bool allowedInContext( const TQStyleSheetItem* ) const; + + bool selfNesting() const; + void setSelfNesting( bool ); + + void setLineSpacing( int ls ); + int lineSpacing() const; + +private: + void init(); + TQStyleSheetItemData* d; +}; + + +#if defined(Q_TEMPLATEDLL) +// MOC_SKIP_BEGIN +Q_TEMPLATE_EXTERN template class TQ_EXPORT TQDict; +Q_TEMPLATE_EXTERN template class TQ_EXPORT TQValueList< TQPtrVector >; +Q_TEMPLATE_EXTERN template class TQ_EXPORT TQPtrVector; +Q_TEMPLATE_EXTERN template class TQ_EXPORT TQValueList; +// MOC_SKIP_END +#endif + +#ifndef TQT_NO_TEXTCUSTOMITEM +class TQTextCustomItem; +#endif + +class TQ_EXPORT TQStyleSheet : public TQObject +{ + TQ_OBJECT +public: + TQStyleSheet( TQObject *parent=0, const char *name=0 ); + virtual ~TQStyleSheet(); + + static TQStyleSheet* defaultSheet(); + static void setDefaultSheet( TQStyleSheet* ); + + + TQStyleSheetItem* item( const TQString& name); + const TQStyleSheetItem* item( const TQString& name) const; + + void insert( TQStyleSheetItem* item); + +#ifndef TQT_NO_TEXTCUSTOMITEM + virtual TQTextCustomItem* tag( const TQString& name, + const TQMap &attr, + const TQString& context, + const TQMimeSourceFactory& factory, + bool emptyTag, TQTextDocument *doc ) const; +#endif + static TQString escape( const TQString& ); + static TQString convertFromPlainText( const TQString&, + TQStyleSheetItem::WhiteSpaceMode mode = TQStyleSheetItem::WhiteSpacePre ); + static bool mightBeRichText( const TQString& ); + + virtual void scaleFont( TQFont& font, int logicalSize ) const; + + virtual void error( const TQString& ) const; + +private: + void init(); + TQDict styles; + TQStyleSheetItem* nullstyle; +private: // Disabled copy constructor and operator= +#if defined(TQ_DISABLE_COPY) + TQStyleSheet( const TQStyleSheet & ); + TQStyleSheet &operator=( const TQStyleSheet & ); +#endif +}; + +#endif // TQT_NO_RICHTEXT + +#endif // TQSTYLESHEET_H diff --git a/src/kernel/tqwidget.cpp b/src/kernel/tqwidget.cpp index 118429a11..f4f1a8b1c 100644 --- a/src/kernel/tqwidget.cpp +++ b/src/kernel/tqwidget.cpp @@ -51,9 +51,9 @@ #include "qapplication_p.h" #include "ntqbrush.h" #include "ntqlayout.h" -#include "ntqstylefactory.h" +#include "tqstylefactory.h" #include "ntqcleanuphandler.h" -#include "ntqstyle.h" +#include "tqstyle.h" #include "ntqmetaobject.h" #include "ntqguardedptr.h" #if defined(TQT_THREAD_SUPPORT) -- cgit v1.2.3