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.
314 lines
9.4 KiB
314 lines
9.4 KiB
14 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
|
||
|
(C) 1997, 1998 Sven Radej (radej@kde.org)
|
||
|
(C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
|
||
|
(C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
|
||
|
(C) 2000 Kurt Granroth (granroth@kde.org)
|
||
|
|
||
|
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.
|
||
|
*/
|
||
|
|
||
|
// $Id: ktoolbarbutton.h,v 1.21.2.1 2002/04/28 20:59:16 wtrobin Exp $
|
||
|
#ifndef _KTOOLBARBUTTON_H
|
||
|
#define _KTOOLBARBUTTON_H
|
||
|
|
||
13 years ago
|
#include <tqpixmap.h>
|
||
|
#include <tqtoolbutton.h>
|
||
|
#include <tqintdict.h>
|
||
|
#include <tqstring.h>
|
||
14 years ago
|
#include <kglobal.h>
|
||
|
|
||
12 years ago
|
class TDEToolBar;
|
||
|
class TDEToolBarButtonPrivate;
|
||
12 years ago
|
class TDEInstance;
|
||
13 years ago
|
class TQEvent;
|
||
|
class TQPopupMenu;
|
||
|
class TQPainter;
|
||
14 years ago
|
|
||
|
/**
|
||
12 years ago
|
* A toolbar button. This is used internally by @ref TDEToolBar, use the
|
||
|
* TDEToolBar methods instead.
|
||
14 years ago
|
* @internal
|
||
|
*/
|
||
12 years ago
|
class TDEToolBarButton : public TQToolButton
|
||
14 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
/**
|
||
|
* Construct a button with an icon loaded by the button itself.
|
||
|
* This will trust the button to load the correct icon with the
|
||
|
* correct size.
|
||
|
*
|
||
|
* @param icon Name of icon to load (may be absolute or relative)
|
||
|
* @param id Id of this button
|
||
|
* @param parent This button's parent
|
||
|
* @param name This button's internal name
|
||
|
* @param txt This button's text (in a tooltip or otherwise)
|
||
|
*/
|
||
12 years ago
|
TDEToolBarButton(const TQString& icon, int id, TQWidget *parent,
|
||
13 years ago
|
const char *name=0L, const TQString &txt=TQString::null,
|
||
12 years ago
|
TDEInstance *_instance = TDEGlobal::instance());
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Construct a button with an existing pixmap. It is not
|
||
|
* recommended that you use this as the internal icon loading code
|
||
|
* will almost always get it "right".
|
||
|
*
|
||
|
* @param icon Name of icon to load (may be absolute or relative)
|
||
|
* @param id Id of this button
|
||
|
* @param parent This button's parent
|
||
|
* @param name This button's internal name
|
||
|
* @param txt This button's text (in a tooltip or otherwise)
|
||
|
*/
|
||
12 years ago
|
TDEToolBarButton(const TQPixmap& pixmap, int id, TQWidget *parent,
|
||
13 years ago
|
const char *name=0L, const TQString &txt=TQString::null);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Construct a separator button
|
||
|
*
|
||
|
* @param parent This button's parent
|
||
|
* @param name This button's internal name
|
||
|
*/
|
||
12 years ago
|
TDEToolBarButton(TQWidget *parent=0L, const char *name=0L);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Standard destructor
|
||
|
*/
|
||
12 years ago
|
~TDEToolBarButton();
|
||
14 years ago
|
|
||
|
#ifndef KDE_NO_COMPAT
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Set the pixmap directly for this button. This pixmap should be
|
||
|
* the active one... the dimmed and disabled pixmaps are constructed
|
||
|
* based on this one. However, don't use this function unless you
|
||
|
* are positive that you don't want to use @ref setIcon.
|
||
|
*
|
||
|
* @param pixmap The active pixmap
|
||
|
*/
|
||
13 years ago
|
// this one is from TQButton, so #ifdef-ing it out doesn't break BC
|
||
|
virtual void setPixmap(const TQPixmap &pixmap);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Force the button to use this pixmap as the default one rather
|
||
|
* then generating it using effects.
|
||
|
*
|
||
|
* @param pixmap The pixmap to use as the default (normal) one
|
||
|
*/
|
||
13 years ago
|
void setDefaultPixmap(const TQPixmap& pixmap);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Force the button to use this pixmap when disabled one rather then
|
||
|
* generating it using effects.
|
||
|
*
|
||
|
* @param pixmap The pixmap to use when disabled
|
||
|
*/
|
||
13 years ago
|
void setDisabledPixmap(const TQPixmap& pixmap);
|
||
14 years ago
|
#endif
|
||
|
|
||
|
/**
|
||
|
* Set the text for this button. The text will be either used as a
|
||
|
* tooltip (IconOnly) or will be along side the icon
|
||
|
*
|
||
|
* @param text The button (or tooltip) text
|
||
|
*/
|
||
13 years ago
|
virtual void setText(const TQString &text);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Set the icon for this button. The icon will be loaded internally
|
||
|
* with the correct size. This function is preferred over @ref setIconSet
|
||
|
*
|
||
|
* @param icon The name of the icon
|
||
|
*/
|
||
13 years ago
|
virtual void setIcon(const TQString &icon);
|
||
14 years ago
|
|
||
13 years ago
|
virtual void setIcon( const TQPixmap &pixmap )
|
||
|
{ return TQToolButton::setIcon( pixmap ); }
|
||
14 years ago
|
|
||
|
/**
|
||
13 years ago
|
* Set the pixmaps for this toolbar button from a TQIconSet.
|
||
14 years ago
|
* If you call this you don't need to call any of the other methods
|
||
|
* that set icons or pixmaps.
|
||
|
* @param iconset The iconset to use
|
||
|
*/
|
||
13 years ago
|
virtual void setIconSet( const TQIconSet &iconset );
|
||
14 years ago
|
|
||
|
#ifndef KDE_NO_COMPAT
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Set the active icon for this button. The pixmap itself is loaded
|
||
|
* internally based on the icon size... .. the disabled and default
|
||
|
* pixmaps, however will only be constructed if @ref #generate is
|
||
|
* true. This function is preferred over @ref setPixmap
|
||
|
*
|
||
|
* @param icon The name of the active icon
|
||
|
* @param generate If true, then the other icons are automagically
|
||
|
* generated from this one
|
||
|
*/
|
||
13 years ago
|
void setIcon(const TQString &icon, bool /*generate*/ ) { setIcon( icon ); }
|
||
14 years ago
|
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Force the button to use this icon as the default one rather
|
||
|
* then generating it using effects.
|
||
|
*
|
||
|
* @param icon The icon to use as the default (normal) one
|
||
|
*/
|
||
13 years ago
|
void setDefaultIcon(const TQString& icon);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Force the button to use this icon when disabled one rather then
|
||
|
* generating it using effects.
|
||
|
*
|
||
|
* @param icon The icon to use when disabled
|
||
|
*/
|
||
13 years ago
|
void setDisabledIcon(const TQString& icon);
|
||
14 years ago
|
#endif
|
||
|
|
||
|
/**
|
||
|
* Turn this button on or off
|
||
|
*
|
||
|
* @param flag true or false
|
||
|
*/
|
||
|
void on(bool flag = true);
|
||
|
|
||
|
/**
|
||
|
* Toggle this button
|
||
|
*/
|
||
|
void toggle();
|
||
|
|
||
|
/**
|
||
|
* Turn this button into a toggle button or disable the toggle
|
||
|
* aspects of it. This does not toggle the button itself. Use @ref
|
||
|
* toggle for that.
|
||
|
*
|
||
|
* @param toggle true or false
|
||
|
*/
|
||
|
void setToggle(bool toggle = true);
|
||
|
|
||
|
/**
|
||
|
* Return a pointer to this button's popup menu (if it exists)
|
||
|
*/
|
||
13 years ago
|
TQPopupMenu *popup();
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Give this button a popup menu. There will not be a delay when
|
||
|
* you press the button. Use @ref setDelayedPopup if you want that
|
||
|
* behavior. You can also make the popup-menu
|
||
|
* "sticky", i.e. visible until a selection is made or the mouse is
|
||
|
* clikced elsewhere, by simply setting the second argument to true.
|
||
|
* This "sticky" button feature allows you to make a selection without
|
||
|
* having to press and hold down the mouse while making a selection.
|
||
|
*
|
||
|
* @param p The new popup menu
|
||
|
* @param toggle if true, makes the button "sticky" (toggled)
|
||
|
*/
|
||
13 years ago
|
void setPopup (TQPopupMenu *p, bool toggle = false);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Gives this button a delayed popup menu.
|
||
|
*
|
||
|
* This function allows you to add a delayed popup menu to the button.
|
||
|
* The popup menu is then only displayed when the button is pressed and
|
||
|
* held down for about half a second. You can also make the popup-menu
|
||
|
* "sticky", i.e. visible until a selection is made or the mouse is
|
||
|
* clikced elsewhere, by simply setting the second argument to true.
|
||
|
* This "sticky" button feature allows you to make a selection without
|
||
|
* having to press and hold down the mouse while making a selection.
|
||
|
*
|
||
|
* @param p the new popup menu
|
||
|
* @param toggle if true, makes the button "sticky" (toggled)
|
||
|
*/
|
||
13 years ago
|
void setDelayedPopup(TQPopupMenu *p, bool toggle = false);
|
||
14 years ago
|
|
||
|
/**
|
||
|
* Turn this button into a radio button
|
||
|
*
|
||
|
* @param f true or false
|
||
|
*/
|
||
|
void setRadio(bool f = true);
|
||
|
|
||
|
/**
|
||
|
* Toolbar buttons naturally will assume the global styles
|
||
|
* concerning icons, icons sizes, etc. You can use this function to
|
||
|
* explicitely turn this off, if you like.
|
||
|
*
|
||
|
* @param no_style Will disable styles if true
|
||
|
*/
|
||
|
void setNoStyle(bool no_style = true);
|
||
|
|
||
|
signals:
|
||
|
void clicked(int);
|
||
|
void doubleClicked(int);
|
||
|
void pressed(int);
|
||
|
void released(int);
|
||
|
void toggled(int);
|
||
|
void highlighted(int, bool);
|
||
|
|
||
|
public slots:
|
||
|
/**
|
||
|
* This slot should be called whenever the toolbar mode has
|
||
|
* potentially changed. This includes such events as text changing,
|
||
|
* orientation changing, etc.
|
||
|
*/
|
||
|
void modeChange();
|
||
13 years ago
|
virtual void setTextLabel(const TQString&, bool tipToo);
|
||
14 years ago
|
|
||
|
protected:
|
||
13 years ago
|
void paletteChange(const TQPalette &);
|
||
|
void leaveEvent(TQEvent *e);
|
||
|
void enterEvent(TQEvent *e);
|
||
|
void drawButton(TQPainter *p);
|
||
|
bool eventFilter (TQObject *o, TQEvent *e);
|
||
14 years ago
|
void showMenu();
|
||
13 years ago
|
TQSize sizeHint() const;
|
||
|
TQSize minimumSizeHint() const;
|
||
|
TQSize minimumSize() const;
|
||
14 years ago
|
|
||
|
bool isRaised() const;
|
||
|
bool isActive() const;
|
||
|
int iconTextMode() const;
|
||
|
|
||
|
protected slots:
|
||
|
void slotClicked();
|
||
|
void slotPressed();
|
||
|
void slotReleased();
|
||
|
void slotToggled();
|
||
|
void slotDelayTimeout();
|
||
|
|
||
|
protected:
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
private:
|
||
12 years ago
|
TDEToolBarButtonPrivate *d;
|
||
14 years ago
|
};
|
||
|
|
||
|
/**
|
||
12 years ago
|
* List of @ref TDEToolBarButton objects.
|
||
14 years ago
|
* @internal
|
||
|
* @version $Id: ktoolbarbutton.h,v 1.21.2.1 2002/04/28 20:59:16 wtrobin Exp $
|
||
|
*/
|
||
12 years ago
|
class TDEToolBarButtonList : public TQIntDict<TDEToolBarButton>
|
||
14 years ago
|
{
|
||
|
public:
|
||
12 years ago
|
TDEToolBarButtonList();
|
||
|
~TDEToolBarButtonList() {}
|
||
14 years ago
|
};
|
||
|
|
||
|
#endif
|