You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
340 lines
12 KiB
340 lines
12 KiB
14 years ago
|
/*
|
||
|
* $Id$
|
||
|
*
|
||
12 years ago
|
* TDEStyle
|
||
14 years ago
|
* Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
|
||
|
*
|
||
14 years ago
|
* TQWindowsStyle CC_ListView and style images were kindly donated by TrollTech,
|
||
14 years ago
|
* Copyright (C) 1998-2000 TrollTech AS.
|
||
|
*
|
||
|
* Many thanks to Bradley T. Hughes for the 3 button scrollbar code.
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Library General Public
|
||
|
* License version 2 as published by the Free Software Foundation.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Library General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Library General Public License
|
||
|
* along with this library; see the file COPYING.LIB. If not, write to
|
||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#ifndef __TQTC_KSTYLE_H
|
||
|
#define __TQTC_KSTYLE_H
|
||
14 years ago
|
|
||
|
// W A R N I N G
|
||
|
// -------------
|
||
|
// This API is still subject to change.
|
||
|
// I will remove this warning when I feel the API is sufficiently flexible.
|
||
|
|
||
14 years ago
|
#include <tqcommonstyle.h>
|
||
14 years ago
|
|
||
12 years ago
|
struct TQtCTDEStylePrivate;
|
||
14 years ago
|
/**
|
||
14 years ago
|
* Simplifies and extends the TQStyle API to make style coding easier.
|
||
14 years ago
|
*
|
||
12 years ago
|
* The TDEStyle class provides a simple internal menu transparency engine
|
||
14 years ago
|
* which attempts to use XRender for accelerated blending where requested,
|
||
|
* or falls back to fast internal software tinting/blending routines.
|
||
14 years ago
|
* It also simplifies more complex portions of the TQStyle API, such as
|
||
14 years ago
|
* the PopupMenuItems, ScrollBars and Sliders by providing extra "primitive
|
||
|
* elements" which are simple to implement by the style writer.
|
||
|
*
|
||
14 years ago
|
* @see TQStyle::TQStyle
|
||
|
* @see TQCommonStyle::TQCommonStyle
|
||
14 years ago
|
* @author Karol Szwed (gallium@kde.org)
|
||
|
* @version $Id$
|
||
|
*/
|
||
12 years ago
|
class TQtCTDEStyle: public TQCommonStyle
|
||
14 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
14 years ago
|
|
||
|
public:
|
||
|
|
||
|
/**
|
||
12 years ago
|
* TQtCTDEStyle Flags:
|
||
14 years ago
|
*
|
||
|
* @li Default - Default style setting, where menu transparency
|
||
|
* and the FilledFrameWorkaround are disabled.
|
||
|
*
|
||
12 years ago
|
* @li AllowMenuTransparency - Enable this flag to use TQtCTDEStyle's
|
||
14 years ago
|
* internal menu transparency engine.
|
||
|
*
|
||
|
* @li FilledFrameWorkaround - Enable this flag to facilitate
|
||
14 years ago
|
* proper repaints of TQMenuBars and TQToolBars when the style chooses
|
||
14 years ago
|
* to paint the interior of a TQFrame. The style primitives in question
|
||
14 years ago
|
* are PE_PanelMenuBar and PE_PanelDockWindow. The HighColor style uses
|
||
|
* this workaround to enable painting of gradients in menubars and
|
||
|
* toolbars.
|
||
|
*/
|
||
12 years ago
|
typedef uint TDEStyleFlags;
|
||
|
enum TDEStyleOption {
|
||
14 years ago
|
Default = 0x00000000, //!< All options disabled
|
||
|
AllowMenuTransparency = 0x00000001, //!< Internal transparency enabled
|
||
|
FilledFrameWorkaround = 0x00000002 //!< Filled frames enabled
|
||
|
};
|
||
|
|
||
|
/**
|
||
12 years ago
|
* TDEStyle ScrollBarType:
|
||
14 years ago
|
*
|
||
|
* Allows the style writer to easily select what type of scrollbar
|
||
|
* should be used without having to duplicate large amounts of source
|
||
|
* code by implementing the complex control CC_ScrollBar.
|
||
|
*
|
||
|
* @li WindowsStyleScrollBar - Two button scrollbar with the previous
|
||
|
* button at the top/left, and the next button at the bottom/right.
|
||
|
*
|
||
|
* @li PlatinumStyleScrollBar - Two button scrollbar with both the
|
||
|
* previous and next buttons at the bottom/right.
|
||
|
*
|
||
|
* @li ThreeButtonScrollBar - %KDE style three button scrollbar with
|
||
|
* two previous buttons, and one next button. The next button is always
|
||
|
* at the bottom/right, whilst the two previous buttons are on either
|
||
|
* end of the scrollbar.
|
||
|
*
|
||
|
* @li NextStyleScrollBar - Similar to the PlatinumStyle scroll bar, but
|
||
|
* with the buttons grouped on the opposite end of the scrollbar.
|
||
|
*
|
||
12 years ago
|
* @see TDEStyle::TDEStyle()
|
||
14 years ago
|
*/
|
||
12 years ago
|
enum TDEStyleScrollBarType {
|
||
14 years ago
|
WindowsStyleScrollBar = 0x00000000, //!< two button, windows style
|
||
|
PlatinumStyleScrollBar = 0x00000001, //!< two button, platinum style
|
||
|
ThreeButtonScrollBar = 0x00000002, //!< three buttons, %KDE style
|
||
|
NextStyleScrollBar = 0x00000004 //!< two button, NeXT style
|
||
|
};
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Constructs a TDEStyle object.
|
||
14 years ago
|
*
|
||
12 years ago
|
* Select the appropriate TDEStyle flags and scrollbar type
|
||
14 years ago
|
* for your style. The user's style preferences selected in KControl
|
||
14 years ago
|
* are read by using TQSettings and are automatically applied to the style.
|
||
12 years ago
|
* As a fallback, TDEStyle paints progressbars and tabbars. It inherits from
|
||
14 years ago
|
* TQCommonStyle for speed, so don't expect much to be implemented.
|
||
14 years ago
|
*
|
||
|
* It is advisable to use a currently implemented style such as the HighColor
|
||
12 years ago
|
* style as a foundation for any new TDEStyle, so the limited number of
|
||
14 years ago
|
* drawing fallbacks should not prove problematic.
|
||
|
*
|
||
|
* @param flags the style to be applied
|
||
|
* @param sbtype the scroll bar type
|
||
12 years ago
|
* @see TDEStyle::TDEStyleFlags
|
||
|
* @see TDEStyle::TDEStyleScrollBarType
|
||
14 years ago
|
* @author Karol Szwed (gallium@kde.org)
|
||
|
*/
|
||
12 years ago
|
TQtCTDEStyle( TDEStyleFlags flags = TQtCTDEStyle::Default,
|
||
|
TDEStyleScrollBarType sbtype = TQtCTDEStyle::WindowsStyleScrollBar );
|
||
14 years ago
|
|
||
|
/**
|
||
12 years ago
|
* Destructs the TQtCTDEStyle object.
|
||
14 years ago
|
*/
|
||
12 years ago
|
~TQtCTDEStyle();
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Returns the default widget style depending on color depth.
|
||
|
*/
|
||
14 years ago
|
static TQString defaultStyle();
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Modifies the scrollbar type used by the style.
|
||
|
*
|
||
|
* This function is only provided for convenience. It allows
|
||
|
* you to make a late decision about what scrollbar type to use for the
|
||
|
* style after performing some processing in your style's constructor.
|
||
12 years ago
|
* In most situations however, setting the scrollbar type via the TQtCTDEStyle
|
||
14 years ago
|
* constructor should suffice.
|
||
|
* @param sbtype the scroll bar type
|
||
12 years ago
|
* @see TQtCTDEStyle::TDEStyleScrollBarType
|
||
14 years ago
|
*/
|
||
12 years ago
|
void setScrollBarType(TDEStyleScrollBarType sbtype);
|
||
14 years ago
|
|
||
|
/**
|
||
12 years ago
|
* Returns the TDEStyle flags used to initialize the style.
|
||
14 years ago
|
*
|
||
|
* This is used solely for the kcmstyle module, and hence is internal.
|
||
|
*/
|
||
12 years ago
|
TDEStyleFlags styleFlags() const;
|
||
14 years ago
|
|
||
|
/**
|
||
12 years ago
|
* TDEStyle Primitive Elements:
|
||
14 years ago
|
*
|
||
12 years ago
|
* The TDEStyle class extends the TQt's Style API by providing certain
|
||
|
* simplifications for parts of TQStyle. To do this, the TDEStylePrimitive
|
||
14 years ago
|
* elements were defined, which are very similar to TQt's PrimitiveElement.
|
||
14 years ago
|
*
|
||
|
* The first three Handle primitives simplify and extend PE_DockWindowHandle,
|
||
12 years ago
|
* so do not reimplement PE_DockWindowHandle if you want the TDEStyle handle
|
||
14 years ago
|
* simplifications to be operable. Similarly do not reimplement CC_Slider,
|
||
12 years ago
|
* SC_SliderGroove and SC_SliderHandle when using the TDEStyle slider
|
||
|
* primitives. TDEStyle automatically double-buffers slider painting
|
||
|
* when they are drawn via these TDEStyle primitives to avoid flicker.
|
||
14 years ago
|
*
|
||
12 years ago
|
* @li KPE_DockWindowHandle - This primitive is already implemented in TDEStyle,
|
||
14 years ago
|
* and paints a bevelled rect with the DockWindow caption text. Re-implement
|
||
|
* this primitive to perform other more fancy effects when drawing the dock window
|
||
|
* handle.
|
||
|
*
|
||
|
* @li KPE_ToolBarHandle - This primitive must be reimplemented. It currently
|
||
|
* only paints a filled rectangle as default behavior. This primitive is used
|
||
14 years ago
|
* to render TQToolBar handles.
|
||
14 years ago
|
*
|
||
|
* @li KPE_GeneralHandle - This primitive must be reimplemented. It is used
|
||
14 years ago
|
* to render general handles that are not part of a TQToolBar or TQDockWindow, such
|
||
14 years ago
|
* as the applet handles used in Kicker. The default implementation paints a filled
|
||
|
* rect of arbitrary color.
|
||
|
*
|
||
|
* @li KPE_SliderGroove - This primitive must be reimplemented. It is used to
|
||
|
* paint the slider groove. The default implementation paints a filled rect of
|
||
|
* arbitrary color.
|
||
|
*
|
||
|
* @li KPE_SliderHandle - This primitive must be reimplemented. It is used to
|
||
|
* paint the slider handle. The default implementation paints a filled rect of
|
||
|
* arbitrary color.
|
||
|
*
|
||
12 years ago
|
* @li KPE_ListViewExpander - This primitive is already implemented in TDEStyle. It
|
||
14 years ago
|
* is used to draw the Expand/Collapse element in TQListViews. To indicate the
|
||
14 years ago
|
* expanded state, the style flags are set to Style_Off, while Style_On implies collapsed.
|
||
|
*
|
||
12 years ago
|
* @li KPE_ListViewBranch - This primitive is already implemented in TDEStyle. It is
|
||
14 years ago
|
* used to draw the ListView branches where necessary.
|
||
|
*/
|
||
12 years ago
|
enum TDEStylePrimitive {
|
||
14 years ago
|
KPE_DockWindowHandle,
|
||
|
KPE_ToolBarHandle,
|
||
|
KPE_GeneralHandle,
|
||
|
|
||
|
KPE_SliderGroove,
|
||
|
KPE_SliderHandle,
|
||
|
|
||
|
KPE_ListViewExpander,
|
||
|
KPE_ListViewBranch
|
||
|
};
|
||
|
|
||
|
/**
|
||
14 years ago
|
* This function is identical to TQt's TQStyle::drawPrimitive(), except that
|
||
14 years ago
|
* it adds one further parameter, 'widget', that can be used to determine
|
||
12 years ago
|
* the widget state of the TDEStylePrimitive in question.
|
||
14 years ago
|
*
|
||
12 years ago
|
* @see TDEStyle::TDEStylePrimitive
|
||
14 years ago
|
* @see TQStyle::drawPrimitive
|
||
13 years ago
|
* @see TQStyle::drawComplexControl
|
||
14 years ago
|
*/
|
||
12 years ago
|
virtual void drawTDEStylePrimitive( TDEStylePrimitive kpe,
|
||
14 years ago
|
TQPainter* p,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
14 years ago
|
SFlags flags = Style_Default,
|
||
12 years ago
|
const TQStyleOption& = TQStyleOption::Default,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
|
|
||
12 years ago
|
enum TDEStylePixelMetric {
|
||
14 years ago
|
KPM_MenuItemSeparatorHeight = 0x00000001,
|
||
|
KPM_MenuItemHMargin = 0x00000002,
|
||
|
KPM_MenuItemVMargin = 0x00000004,
|
||
|
KPM_MenuItemHFrame = 0x00000008,
|
||
|
KPM_MenuItemVFrame = 0x00000010,
|
||
|
KPM_MenuItemCheckMarkHMargin = 0x00000020,
|
||
|
KPM_MenuItemArrowHMargin = 0x00000040,
|
||
|
KPM_MenuItemTabSpacing = 0x00000080,
|
||
|
KPM_ListViewBranchThickness = 0x00000100
|
||
|
};
|
||
|
|
||
12 years ago
|
int kPixelMetric( TDEStylePixelMetric kpm, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
|
// ---------------------------------------------------------------------------
|
||
|
|
||
12 years ago
|
void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
|
||
|
void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * );
|
||
12 years ago
|
void polishPopupMenu( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr );
|
||
14 years ago
|
|
||
|
void drawPrimitive( PrimitiveElement pe,
|
||
14 years ago
|
TQPainter* p,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
14 years ago
|
SFlags flags = Style_Default,
|
||
14 years ago
|
const TQStyleOption& = TQStyleOption::Default ) const;
|
||
14 years ago
|
|
||
13 years ago
|
void drawControl( ControlElement element,
|
||
14 years ago
|
TQPainter* p,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
14 years ago
|
SFlags flags = Style_Default,
|
||
12 years ago
|
const TQStyleOption& = TQStyleOption::Default,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
13 years ago
|
void drawComplexControl( ComplexControl control,
|
||
14 years ago
|
TQPainter *p,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
14 years ago
|
SFlags flags = Style_Default,
|
||
|
SCFlags controls = SC_All,
|
||
|
SCFlags active = SC_None,
|
||
12 years ago
|
const TQStyleOption& = TQStyleOption::Default,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
|
SubControl querySubControl( ComplexControl control,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQPoint &pos,
|
||
12 years ago
|
const TQStyleOption& = TQStyleOption::Default,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
14 years ago
|
TQRect querySubControlMetrics( ComplexControl control,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
14 years ago
|
SubControl sc,
|
||
12 years ago
|
const TQStyleOption& = TQStyleOption::Default,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
12 years ago
|
int pixelMetric( PixelMetric m, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
12 years ago
|
TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
14 years ago
|
TQPixmap stylePixmap( StylePixmap stylepixmap,
|
||
12 years ago
|
TQStyleControlElementData ceData,
|
||
|
ControlElementFlags elementFlags,
|
||
|
const TQStyleOption& = TQStyleOption::Default,
|
||
|
const TQWidget* widget = 0 ) const;
|
||
14 years ago
|
|
||
12 years ago
|
int styleHint( StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
|
||
14 years ago
|
const TQStyleOption &opt = TQStyleOption::Default,
|
||
12 years ago
|
TQStyleHintReturn* shr = 0,
|
||
|
const TQWidget* w = 0 ) const;
|
||
14 years ago
|
|
||
|
protected:
|
||
12 years ago
|
virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e );
|
||
14 years ago
|
|
||
|
private:
|
||
|
// Disable copy constructor and = operator
|
||
12 years ago
|
TQtCTDEStyle( const TQtCTDEStyle & );
|
||
|
TQtCTDEStyle& operator=( const TQtCTDEStyle & );
|
||
14 years ago
|
|
||
|
protected:
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
private:
|
||
12 years ago
|
TQtCTDEStylePrivate *d;
|
||
14 years ago
|
};
|
||
|
|
||
|
|
||
|
// vim: set noet ts=4 sw=4:
|
||
|
#endif
|
||
|
|