20#ifndef _kotoolbutton_h_
21#define _kotoolbutton_h_
23#include <tdetoolbarbutton.h>
26#include <koffice_export.h>
30class KOFFICEUI_EXPORT KoColorPanel :
public TQWidget
35 KoColorPanel( TQWidget* parent = 0,
const char* name = 0 );
36 virtual ~KoColorPanel();
38 virtual TQSize sizeHint()
const;
39 virtual TQSize minimumSizeHint()
const;
41 enum MenuStyle { Plain, CustomColors };
42 static TQPopupMenu* createColorPopup( MenuStyle style,
const TQColor& defaultColor,
43 const TQObject* receiver,
const char* slot,
44 TQWidget* parent,
const char* name );
48 void insertColor(
const TQColor& color );
49 void insertColor(
const TQColor& color,
const TQString& toolTip );
50 void insertDefaultColors();
53 void colorSelected(
const TQColor& color );
56 virtual void mousePressEvent( TQMouseEvent* e );
57 virtual void mouseReleaseEvent( TQMouseEvent* e );
58 virtual void mouseMoveEvent( TQMouseEvent* e );
59 virtual void paintEvent( TQPaintEvent* e );
60 virtual void keyPressEvent( TQKeyEvent* e );
61 virtual void focusInEvent( TQFocusEvent* e );
62 virtual void dragEnterEvent( TQDragEnterEvent* e );
63 virtual void dropEvent( TQDropEvent* e );
68 Position() : x( -1 ), y( -1 ) {}
69 Position(
short x_,
short y_ ) : x( x_ ), y( y_ ) {}
74 friend bool operator<(
const KoColorPanel::Position& lhs,
const KoColorPanel::Position& rhs );
76 void finalizeInsertion(
const Position& pos );
77 bool insertColor(
const TQColor& color,
bool checking );
78 bool insertColor(
const TQColor& color,
const TQString& toolTip,
bool checking );
79 bool isAvailable(
const TQColor& color );
81 Position mapToPosition(
const TQPoint& point )
const;
82 TQColor mapToColor(
const TQPoint& point )
const;
83 TQColor mapToColor(
const Position& position )
const;
84 TQRect mapFromPosition(
const Position& position )
const;
85 Position validPosition(
const Position& position );
88 void paintArea(
const TQRect& rect,
int& startRow,
int& endRow,
int& startCol,
int& endCol )
const;
89 void updateFocusPosition(
const Position& newPosition );
90 void paint(
const Position& position );
93 Position m_nextPosition, m_focusPosition;
94 TQMap<Position, TQColor> m_colorMap;
100bool operator<(
const KoColorPanel::Position& lhs,
const KoColorPanel::Position& rhs );
107class KOFFICEUI_EXPORT KoColorPopupProxy :
public TQObject
112 KoColorPopupProxy(
const TQColor& defaultColor, KoColorPanel* recentColors, TQObject* parent,
const char* name );
113 virtual ~KoColorPopupProxy() {}
115 void setRecentColorPanel( KoColorPanel* recentColors );
118 void slotDefaultColor();
119 void slotMoreColors();
122 void colorSelected(
const TQColor& color );
125 TQColor m_defaultColor;
126 KoColorPanel* m_recentColors;
147 KoToolButton(
const TQString& icon,
int id, TQWidget* parent,
148 const char* name = 0L,
const TQString& txt = TQString(),
149 TDEInstance* _instance = TDEGlobal::instance() );
162 KoToolButton(
const TQPixmap& pixmap,
int id, TQWidget* parent,
163 const char* name = 0L,
const TQString& txt = TQString() );
165 virtual ~KoToolButton();
167 virtual TQSize sizeHint()
const;
168 virtual TQSize minimumSizeHint()
const;
169 virtual TQSize minimumSize()
const;
172 void colorSelected(
const TQColor& color );
175 virtual void drawButton(TQPainter *p);
176 virtual bool eventFilter( TQObject* o, TQEvent* e );
180 void buttonShift(
int& dx,
int& dy );
181 bool hitArrow(
const TQPoint& pos );
183 TQPopupMenu* m_popup;
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)