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.
koffice/lib/kofficeui/tkcoloractions.h

174 lines
4.3 KiB

/*
* Kivio - Visual Modelling and Flowcharting
* Copyright (C) 2000 theKompany.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef TKCOLORACTION_H
#define TKCOLORACTION_H
#include "tkaction.h"
#include <koffice_export.h>
#include <kpopupmenu.h>
#include <tqdict.h>
class TQGridLayout;
class TKColorPanel;
class TKSelectColorActionPrivate;
class TKColorPopupMenu : public KPopupMenu
{ Q_OBJECT
TQ_OBJECT
public:
TKColorPopupMenu( TQWidget* tqparent = 0, const char* name = 0 );
~TKColorPopupMenu();
public slots:
void updateItemSize();
};
/****************************************************************************************/
class KOFFICEUI_EXPORT TKSelectColorAction : public TKAction
{ Q_OBJECT
TQ_OBJECT
public:
enum Type {
TextColor,
LineColor,
FillColor,
Color
};
TKSelectColorAction( const TQString& text, Type type, TQObject* tqparent, const char* name, bool menuDefaultColor=false);
TKSelectColorAction( const TQString& text, Type type,
TQObject* receiver, const char* slot,
TQObject* tqparent, const char* name,bool menuDefaultColor=false );
virtual ~TKSelectColorAction();
TQColor color() const { return m_pCurrentColor; }
KPopupMenu* popupMenu() const { return m_pMenu; }
void setDefaultColor(const TQColor &_col);
public slots:
void setCurrentColor( const TQColor& );
void setActiveColor( const TQColor& );
virtual void activate();
signals:
void colorSelected( const TQColor& );
protected slots:
void selectColorDialog();
void panelColorSelected( const TQColor& );
void panelReject();
virtual void slotActivated();
void defaultColor();
protected:
void init();
virtual void initToolBarButton(TKToolBarButton*);
void updatePixmap();
void updatePixmap(TKToolBarButton*);
protected:
TKColorPopupMenu* m_pMenu;
TKColorPanel* m_pStandardColor;
TKColorPanel* m_pRecentColor;
int m_type;
TQColor m_pCurrentColor;
private:
TKSelectColorActionPrivate *d;
};
/****************************************************************************************/
class TKColorPanelButton : public TQFrame
{ Q_OBJECT
TQ_OBJECT
public:
TKColorPanelButton( const TQColor&, TQWidget* tqparent, const char* name = 0 );
~TKColorPanelButton();
void setActive( bool );
TQColor panelColor() const { return m_Color; }
signals:
void selected( const TQColor& );
protected:
virtual void paintEvent( TQPaintEvent* );
virtual void enterEvent( TQEvent* );
virtual void leaveEvent( TQEvent* );
virtual void mouseReleaseEvent( TQMouseEvent* );
TQColor m_Color;
bool m_bActive;
private:
class TKColorPanelButtonPrivate;
TKColorPanelButtonPrivate *d;
};
/****************************************************************************************/
class TKColorPanel : public TQWidget
{ Q_OBJECT
TQ_OBJECT
public:
TKColorPanel( TQWidget* tqparent = 0L, const char* name = 0 );
~TKColorPanel();
void setActiveColor( const TQColor& );
void setNumCols( int col );
void clear();
public slots:
void insertColor( const TQColor& );
void insertColor( const TQColor&, const TQString& );
void selected( const TQColor& );
signals:
void colorSelected( const TQColor& );
void reject();
void sizeChanged();
protected:
void addToGrid( TKColorPanelButton* );
void resetGrid();
virtual void mouseReleaseEvent( TQMouseEvent* );
virtual void showEvent( TQShowEvent *e );
TQGridLayout* m_pLayout;
int m_iWidth;
int m_iX;
int m_iY;
TQColor m_activeColor;
TQDict<TKColorPanelButton> m_pColorDict;
private:
void fillPanel();
class TKColorPanelPrivate;
TKColorPanelPrivate *d;
};
#endif