Commit 10d868d4 authored by Casper Boemann's avatar Casper Boemann

removed all tk class stuff.

In KSpread this means that color selection is diasabled but since we are 
moving to pigment anyway, it not such a big loss.


svn path=/trunk/koffice/; revision=658734
parent e4fcccf0
......@@ -40,10 +40,6 @@ set(kofficeui_LIB_SRCS
KoZoomController.cpp
KoZoomHandler.cpp
KoZoomMode.cpp
tkaction.cpp
tkcoloractions.cpp
tkcombobox.cpp
tktoolbarbutton.cpp
KoToolBoxFactory.cpp
KoToolDocker.cpp
KoToolDockerFactory.cpp
......@@ -103,10 +99,6 @@ install(
KoZoomController.h
KoZoomHandler.h
KoZoomMode.h
tkaction.h
tkcoloractions.h
tkcombobox.h
tktoolbarbutton.h
KoToolBoxFactory.h
KoToolDocker.h
KoToolDockerFactory.h
......
/*
* 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.
*/
#include "tkaction.h"
#include "tktoolbarbutton.h"
#include "tkcombobox.h"
#include <QLabel>
#include <QLayout>
#include <QToolBar>
#include <QPixmap>
#include <QHBoxLayout>
#include <ktoolbar.h>
#include <kiconloader.h>
#include <kicon.h>
#if 0
#define SET_FOR_ALL_CONTAINER(WIDGET_TYPE,METHOD_NAME,VALUE) \
for( int id = 0; id < containerCount(); ++id ) { \
QWidget* w = container(id); \
if ( w->inherits("KToolBar") ) { \
QWidget* r = static_cast<KToolBar*>(w)->getWidget(itemId(id)); \
if (qstrcmp(r->name(),"KTToolBarLayout")==0) \
r = (QWidget*)r->child("widget"); \
if ( r && r->inherits(#WIDGET_TYPE) ) { \
WIDGET_TYPE* b = static_cast<WIDGET_TYPE*>(r); \
b->METHOD_NAME(VALUE); \
} \
} \
}
#endif
TKAction::TKAction(KActionCollection* parent, const char* name)
: KAction( "", parent ), d( 0 )
{
m_imode = TK::IconOnly;
if(parent)
parent->addAction(name, this);
}
TKAction::~TKAction()
{
}
QWidget* TKAction::createToolBarWidget(QToolBar* parent)
{
TKToolBarButton* button = new TKToolBarButton(
icon().pixmap(parent->iconSize()), iconText(),
parent);
button->setIconMode(m_imode);
initToolBarButton(button);
return button;
}
#if 0
int TKAction::plug(QWidget* widget, int index)
{
if ( widget->inherits("KToolBar") ) {
KToolBar* bar = static_cast<KToolBar*>(widget);
int id_ = KAction::getToolButtonID();
KComponentData instance;
if ( parentCollection() )
instance = parentCollection()->componentData();
else
instance = KGlobal::mainComponent();
TKToolBarButton* b = new TKToolBarButton(icon(),plainText(),bar,name(),instance);
// we don't need clicked() and buttonClicked(), do we?
// connect(b,SIGNAL(clicked()),SLOT(slotActivated()));
b->setIconMode(m_imode);
initToolBarButton(b);
bar->insertWidget( id_, 100, b, index );
addContainer(bar,id_);
connect( bar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
return containerCount() - 1;
}
return KAction::plug(widget,index);
}
#endif
void TKAction::initToolBarButton(TKToolBarButton* button)
{
connect(button,SIGNAL(buttonClicked()),SLOT(slotActivated()));
}
TK::IconMode TKAction::iconMode()
{
return m_imode;
}
void TKAction::setIconMode(TK::IconMode mode)
{
m_imode = mode;
#if 0
SET_FOR_ALL_CONTAINER(TKToolBarButton,setIconMode,mode)
#endif
}
void TKAction::setText(const QString& text)
{
KAction::setText(text);
updateLayout();
}
void TKAction::setIcon(const QString& icon)
{
KAction::setIcon(KIcon(icon));
updateLayout();
}
void TKAction::updateLayout()
{
#if 0
int len = containerCount();
for( int id = 0; id < len; ++id ) {
QWidget* w = container( id );
if (w->inherits("KToolBar")) {
QWidget* r = static_cast<KToolBar*>(w)->getWidget(itemId(id));
if (qstrcmp(r->name(),"KTToolBarLayout")==0) {
updateLayout(r);
}
}
}
#endif
}
QWidget* TKAction::createLayout(QWidget* parent, QWidget* children)
{
QWidget* base = new QWidget(parent);
QLabel* textLabel = new QLabel(base);
textLabel->setMinimumHeight(1);
QLabel* pixLabel = new QLabel(base);
children->setParent(base);
children->setObjectName("widget");
QHBoxLayout* layout = new QHBoxLayout(base);
layout->setMargin(0);
layout->setSpacing(3);
layout->setSizeConstraint(QLayout::SetMinimumSize);
layout->addWidget(textLabel);
layout->addWidget(pixLabel);
layout->addWidget(children,1);
updateLayout(base);
return base;
}
void TKAction::updateLayout(QWidget* base)
{
QLabel* textLabel = base->findChild<QLabel*>("text");
QLabel* pixLabel = base->findChild<QLabel*>("pixmap");
QWidget* w = base->findChild<QWidget*>("widget");
if (!textLabel || !pixLabel || !w)
return;
if (!text().isEmpty() && m_imode != TK::IconOnly ) {
textLabel->setText(text());
textLabel->show();
} else
textLabel->hide();
QPixmap pix;
#if 0
if (hasIcon())
pix = iconSet(K3Icon::Small).pixmap();
if (!icon().isEmpty())
pix = BarIcon(icon());
#endif
if (!pix.isNull() && m_imode != TK::TextOnly) {
pixLabel->setPixmap(pix);
pixLabel->show();
} else
pixLabel->hide();
base->setFixedWidth( w->sizeHint().width() +
(textLabel->isVisible() ? textLabel->sizeHint().width():0) +
(pixLabel->isVisible() ? pixLabel->sizeHint().width():0) );
}
/******************************************************************************/
TKBaseSelectAction::TKBaseSelectAction( KActionCollection* parent, const char* name )
: TKAction(parent,name), d( 0 )
{
m_current = 0;
m_editable = false;
}
TKBaseSelectAction::~TKBaseSelectAction()
{
}
QWidget* TKBaseSelectAction::createToolBarWidget(QToolBar* parent)
{
TKComboBox* combo = new TKComboBox(m_editable, parent);
initComboBox(combo);
combo->setMinimumWidth(combo->sizeHint().width());
QWidget* base = createLayout(parent, combo);
setCurrentItem(currentItem());
return base;
}
#if 0
int TKBaseSelectAction::plug(QWidget* widget, int index)
{
if ( widget->inherits("KToolBar") )
{
KToolBar* bar = static_cast<KToolBar*>( widget );
int id_ = KAction::getToolButtonID();
TKComboBox* cb = new TKComboBox(m_editable,bar);
initComboBox(cb);
cb->setMinimumWidth( cb->sizeHint().width() );
QWidget* base = createLayout(bar,cb);
bar->insertWidget( id_, 100, base, index );
addContainer( bar, id_ );
connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
setCurrentItem(currentItem());
return containerCount() - 1;
}
return -1;
}
#endif
int TKBaseSelectAction::currentItem()
{
return m_current;
}
void TKBaseSelectAction::initComboBox(TKComboBox* cb)
{
connect(cb,SIGNAL(activated(int)),SLOT(slotActivated(int)));
}
void TKBaseSelectAction::setEditable(bool editable)
{
m_editable = editable;
#if 0
SET_FOR_ALL_CONTAINER(TKComboBox,setEditable,editable)
#endif
}
bool TKBaseSelectAction::isEditable()
{
return m_editable;
}
void TKBaseSelectAction::setCurrentItem(int index)
{
m_current = index;
#if 0
SET_FOR_ALL_CONTAINER(TKComboBox,setCurrentItem,index)
#endif
}
void TKBaseSelectAction::slotActivated(int id)
{
if ( m_current == id )
return;
m_current = id;
setCurrentItem(id);
activate(id);
}
void TKBaseSelectAction::activate(int id)
{
emit activated(id);
}
/******************************************************************************/
TKSelectAction::TKSelectAction( KActionCollection* parent, const char* name )
: TKBaseSelectAction(parent,name), d( 0 )
{
}
TKSelectAction::~TKSelectAction()
{
}
void TKSelectAction::initComboBox(TKComboBox* cb)
{
TKBaseSelectAction::initComboBox(cb);
connect(cb,SIGNAL(activated(const QString&)),SLOT(slotActivated(const QString&)));
cb->insertStringList(items());
}
void TKSelectAction::slotActivated(const QString& text)
{
emit activated(text);
}
void TKSelectAction::setItems(const QStringList& lst )
{
m_list = lst;
m_current = -1;
#if 0
SET_FOR_ALL_CONTAINER(TKComboBox,clear, )
SET_FOR_ALL_CONTAINER(TKComboBox,insertStringList,lst)
#endif
// Disable if empty and not editable
setEnabled ( lst.count() > 0 || m_editable );
}
QStringList TKSelectAction::items() const
{
return m_list;
}
void TKSelectAction::clear()
{
#if 0
SET_FOR_ALL_CONTAINER(TKComboBox,clear, )
#endif
}
void TKSelectAction::setEditText(const QString& /*text*/)
{
#if 0
SET_FOR_ALL_CONTAINER(TKComboBox,setEditText,text)
#endif
}
#undef SET_FOR_ALL_CONTAINER
#include "tkaction.moc"
/*
* 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 TKACTION_H
#define TKACTION_H
#include <QWidgetAction>
#include <kaction.h>
#include <QStringList>
#include <kactioncollection.h>
#include <kofficeui_export.h>
// TODO Remove as we can use the Qt enum for this
namespace TK {
enum IconMode { IconOnly, IconAndText, TextOnly };
}
class TKToolBarButton;
class TKComboBox;
class QToolBar;
class KOFFICEUI_EXPORT TKAction : public KAction
{ Q_OBJECT
public:
TKAction(KActionCollection* parent, const char* name);
~TKAction();
#if 0
virtual int plug(QWidget* widget, int index = -1);
#endif
TK::IconMode iconMode();
/// Creates the toolbar button
virtual QWidget* createToolBarWidget(QToolBar* parent);
protected:
virtual void initToolBarButton(TKToolBarButton*);
QWidget* createLayout(QWidget* parent, QWidget* children);
void updateLayout();
virtual void updateLayout(QWidget*);
public slots:
virtual void setIconMode(TK::IconMode);
void setText(const QString&);
void setIcon(const QString&);
private:
TK::IconMode m_imode;
class TKActionPrivate;
TKActionPrivate * const d;
};
/******************************************************************************/
class KOFFICEUI_EXPORT TKBaseSelectAction : public TKAction
{ Q_OBJECT
friend class TKSelectAction;
public:
TKBaseSelectAction(KActionCollection* parent, const char* name);
~TKBaseSelectAction();
#if 0
virtual int plug(QWidget* widget, int index = -1);
#endif
int currentItem();
bool isEditable();
void activate(int);
virtual QWidget* createToolBarWidget(QToolBar* parent);
protected:
virtual void initComboBox(TKComboBox*);
public slots:
virtual void setCurrentItem(int index);
virtual void setEditable(bool);
protected slots:
virtual void slotActivated(int);
signals:
void activated(int);
private:
int m_current;
bool m_editable;
class TKBaseSelectActionPrivate;
TKBaseSelectActionPrivate * const d;
};
/******************************************************************************/
class KOFFICEUI_EXPORT TKSelectAction : public TKBaseSelectAction
{ Q_OBJECT
public:
TKSelectAction(KActionCollection* parent, const char* name);
~TKSelectAction();
QStringList items() const;
public slots:
virtual void setItems(const QStringList& );
virtual void setEditText(const QString&);
virtual void clear();
protected:
virtual void initComboBox(TKComboBox*);
protected slots:
void slotActivated(const QString&);
signals:
void activated(const QString&);
private:
QStringList m_list;
class TKSelectActionPrivate;
TKSelectActionPrivate * const d;
};
/******************************************************************************/
#endif
This diff is collapsed.
/*
* 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 <kofficeui_export.h>
#include <kmenu.h>
#include <q3dict.h>
#include <QMouseEvent>
#include <QShowEvent>
#include <Q3Frame>
#include <QEvent>
#include <QPaintEvent>
class QGridLayout;
class TKColorPanel;
class TKSelectColorActionPrivate;
class TKColorPopupMenu : public KMenu
{ Q_OBJECT
public:
explicit TKColorPopupMenu( QWidget* parent = 0, const char* name = 0 );
~TKColorPopupMenu();
public slots:
void updateItemSize();
};
/****************************************************************************************/
class KOFFICEUI_EXPORT TKSelectColorAction : public TKAction
{ Q_OBJECT
public:
enum Type {
TextColor,
LineColor,
FillColor,
Color
};
TKSelectColorAction( const QString& text, Type type, KActionCollection* parent, const char* name, bool menuDefaultColor=false);
TKSelectColorAction( const QString& text, Type type,
QObject* receiver, const char* slot,
KActionCollection* parent, const char* name,bool menuDefaultColor=false );
virtual ~TKSelectColorAction();
QColor color() const { return m_pCurrentColor; }
KMenu* popupMenu() const { return m_pMenu; }
void setDefaultColor(const QColor &_col);
public slots:
void setCurrentColor( const QColor& );
void setActiveColor( const QColor& );
virtual void activate();
signals:
void colorSelected( const QColor& );
protected slots:
void selectColorDialog();
void panelColorSelected( const QColor& );
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;
QColor m_pCurrentColor;
private:
TKSelectColorActionPrivate * const d;
};
/****************************************************************************************/
class TKColorPanelButton : public Q3Frame
{ Q_OBJECT
public:
TKColorPanelButton( const QColor&, QWidget* parent, const char* name = 0 );
~TKColorPanelButton();
void setActive( bool );
QColor panelColor() const { return m_Color; }
signals:
void selected( const QColor& );
protected:
virtual void paintEvent( QPaintEvent* );
virtual void enterEvent( QEvent* );
virtual void leaveEvent( QEvent* );
virtual void mouseReleaseEvent( QMouseEvent* );
QColor m_Color;
bool m_bActive;
private:
class TKColorPanelButtonPrivate;
TKColorPanelButtonPrivate * const d;
};
/****************************************************************************************/
class TKColorPanel : public QWidget
{ Q_OBJECT
public:
explicit TKColorPanel( QWidget* parent = 0L, const char* name = 0 );
~TKColorPanel();
void setActiveColor( const QColor& );
void setNumCols( int col );
void clear();
public slots:
void insertColor( const QColor& );
void insertColor( const QColor&, const QString& );
void selected( const QColor& );
signals:
void colorSelected( const QColor& );
void reject();
void sizeChanged();
protected:
void addToGrid( TKColorPanelButton* );
void resetGrid();
virtual void mouseReleaseEvent( QMouseEvent* );
virtual void showEvent( QShowEvent *e );
QGridLayout* m_pLayout;
int m_iWidth;
int m_iX;
int m_iY;
QColor m_activeColor;
Q3Dict<TKColorPanelButton> m_pColorDict;
private:
void fillPanel();
class TKColorPanelPrivate;
TKColorPanelPrivate * const d;
};
#endif
/*
* 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