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.
283 lines
8.3 KiB
283 lines
8.3 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 2000 Daniel M. Duley <mosfet@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.
|
||
|
*/
|
||
|
#ifndef _KPOPUP_H
|
||
|
#define _KPOPUP_H "$Id$"
|
||
|
|
||
|
#define INCLUDE_MENUITEM_DEF
|
||
|
|
||
15 years ago
|
#include <tqpopupmenu.h>
|
||
15 years ago
|
#include <kpixmapeffect.h>
|
||
|
#include <kpixmap.h>
|
||
13 years ago
|
#include <tdelibs_export.h>
|
||
15 years ago
|
/**
|
||
12 years ago
|
* @short TDEPopupMenu title widget.
|
||
15 years ago
|
*
|
||
12 years ago
|
* Title widget for use in TDEPopupMenu.
|
||
15 years ago
|
*
|
||
|
* You usually don't have to create this manually since
|
||
12 years ago
|
* TDEPopupMenu::insertTitle will do it for you, but it is allowed if
|
||
15 years ago
|
* you wish to customize it's look.
|
||
|
*
|
||
|
* @author Daniel M. Duley <mosfet@kde.org>
|
||
|
*/
|
||
12 years ago
|
class TDEUI_EXPORT TDEPopupTitle : public TQWidget
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
/**
|
||
|
* Constructs a title widget with the user specified gradient, pixmap,
|
||
|
* and colors.
|
||
|
*/
|
||
12 years ago
|
TDEPopupTitle(TQWidget *parent=0, const char *name=0);
|
||
15 years ago
|
/**
|
||
|
* @deprecated
|
||
|
* Constructs a title widget with the specified gradient and colors.
|
||
|
*/
|
||
12 years ago
|
TDEPopupTitle(KPixmapEffect::GradientType gradient, const TQColor &color,
|
||
15 years ago
|
const TQColor &textColor, TQWidget *parent=0,
|
||
15 years ago
|
const char *name=0) KDE_DEPRECATED;
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Constructs a title widget with the specified pixmap and colors.
|
||
|
*/
|
||
12 years ago
|
TDEPopupTitle(const KPixmap &background, const TQColor &color,
|
||
15 years ago
|
const TQColor &textColor, TQWidget *parent=0,
|
||
15 years ago
|
const char *name=0) KDE_DEPRECATED;
|
||
|
/**
|
||
|
* Sets the title string and optional icon for the title widget.
|
||
|
*
|
||
|
* You will want to call this before inserting into a menu.
|
||
|
*/
|
||
15 years ago
|
void setTitle(const TQString &text, const TQPixmap *icon=0);
|
||
15 years ago
|
/**
|
||
|
* Returns the current title.
|
||
|
*/
|
||
15 years ago
|
TQString title() const { return titleStr; }
|
||
15 years ago
|
/**
|
||
|
* Returns the current icon.
|
||
|
*/
|
||
15 years ago
|
TQPixmap icon() const { return miniicon; }
|
||
15 years ago
|
|
||
13 years ago
|
TQSize sizeHint() const;
|
||
15 years ago
|
|
||
|
public slots:
|
||
|
/// @since 3.1
|
||
15 years ago
|
void setText( const TQString &text );
|
||
15 years ago
|
/// @since 3.1
|
||
15 years ago
|
void setIcon( const TQPixmap &pix );
|
||
15 years ago
|
|
||
|
protected:
|
||
|
void calcSize();
|
||
15 years ago
|
void paintEvent(TQPaintEvent *ev);
|
||
15 years ago
|
|
||
|
// Remove in KDE4
|
||
|
KPixmapEffect::GradientType grType;
|
||
15 years ago
|
TQString titleStr;
|
||
15 years ago
|
// Remove in KDE4
|
||
|
KPixmap fill;
|
||
15 years ago
|
TQPixmap miniicon;
|
||
|
TQColor fgColor, bgColor, grHigh, grLow;
|
||
15 years ago
|
bool useGradient;
|
||
|
|
||
|
protected:
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
private:
|
||
12 years ago
|
class TDEPopupTitlePrivate;
|
||
|
TDEPopupTitlePrivate *d;
|
||
15 years ago
|
};
|
||
|
|
||
|
/**
|
||
|
* @short A menu with title items.
|
||
|
*
|
||
12 years ago
|
* TDEPopupMenu is a class for menus with standard title items and keyboard
|
||
15 years ago
|
* accessibility for popups with many options and/or varying options. It acts
|
||
15 years ago
|
* identically to TQPopupMenu, with the addition of insertTitle(),
|
||
15 years ago
|
* changeTitle(), setKeyboardShortcutsEnabled() and
|
||
|
* setKeyboardShortcutsExecute() methods.
|
||
|
*
|
||
|
* The titles support a text string, an icon, plus user defined gradients,
|
||
|
* colors, and background pixmaps.
|
||
|
*
|
||
|
* The keyboard search algorithm is incremental with additional underlining
|
||
|
* for user feedback.
|
||
|
*
|
||
|
* @author Daniel M. Duley <mosfet@kde.org>
|
||
|
* @author Hamish Rodda <rodda@kde.org>
|
||
|
*/
|
||
12 years ago
|
class TDEUI_EXPORT TDEPopupMenu : public TQPopupMenu {
|
||
15 years ago
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
public:
|
||
|
/**
|
||
12 years ago
|
* Constructs a TDEPopupMenu.
|
||
15 years ago
|
*/
|
||
12 years ago
|
TDEPopupMenu(TQWidget *parent=0, const char *name=0);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Destructs the object
|
||
|
*/
|
||
12 years ago
|
~TDEPopupMenu();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Inserts a title item with no icon.
|
||
|
*/
|
||
15 years ago
|
int insertTitle(const TQString &text, int id=-1, int index=-1);
|
||
15 years ago
|
/**
|
||
|
* Inserts a title item with the given icon and title.
|
||
|
*/
|
||
15 years ago
|
int insertTitle(const TQPixmap &icon, const TQString &text, int id=-1,
|
||
15 years ago
|
int index=-1);
|
||
|
/**
|
||
|
* Changes the title of the item at the specified id. If a icon was
|
||
|
* previously set it is cleared.
|
||
|
*/
|
||
15 years ago
|
void changeTitle(int id, const TQString &text);
|
||
15 years ago
|
/**
|
||
|
* Changes the title and icon of the title item at the specified id.
|
||
|
*/
|
||
15 years ago
|
void changeTitle(int id, const TQPixmap &icon, const TQString &text);
|
||
15 years ago
|
/**
|
||
|
* Returns the title of the title item at the specified id. The default
|
||
|
* id of -1 is for backwards compatibility only, you should always specify
|
||
|
* the id.
|
||
|
*/
|
||
15 years ago
|
TQString title(int id=-1) const;
|
||
15 years ago
|
/**
|
||
|
* Returns the icon of the title item at the specified id.
|
||
|
*/
|
||
15 years ago
|
TQPixmap titlePixmap(int id) const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Enables keyboard navigation by searching for the entered key sequence.
|
||
|
* Also underlines the currently selected item, providing feedback on the search.
|
||
|
*
|
||
|
* Defaults to off.
|
||
|
*
|
||
|
* WARNING: calls to text() of currently keyboard-selected items will
|
||
|
* contain additional ampersand characters.
|
||
|
*
|
||
|
* WARNING: though pre-existing keyboard shortcuts will not interfere with the
|
||
|
* operation of this feature, they may be confusing to the user as the existing
|
||
|
* shortcuts will not work.
|
||
|
* @since 3.1
|
||
|
*/
|
||
|
void setKeyboardShortcutsEnabled(bool enable);
|
||
|
|
||
|
/**
|
||
|
* Enables execution of the menu item once it is uniquely specified.
|
||
|
* Defaults to off.
|
||
|
* @since 3.1
|
||
|
*/
|
||
|
void setKeyboardShortcutsExecute(bool enable);
|
||
|
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Obsolete method provided for backwards compatibility only. Use the
|
||
|
* normal constructor and insertTitle instead.
|
||
|
*/
|
||
12 years ago
|
TDEPopupMenu(const TQString &title, TQWidget *parent=0, const char *name=0) KDE_DEPRECATED;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @deprecated
|
||
|
* Obsolete method provided for backwards compatibility only. Use
|
||
|
* insertTitle and changeTitle instead.
|
||
|
*/
|
||
15 years ago
|
void setTitle(const TQString &title) KDE_DEPRECATED;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the context menu associated with this menu
|
||
|
* @since 3.2
|
||
|
*/
|
||
15 years ago
|
TQPopupMenu* contextMenu();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Returns the context menu associated with this menu
|
||
|
* @since 3.2
|
||
|
*/
|
||
15 years ago
|
const TQPopupMenu* contextMenu() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Hides the context menu if shown
|
||
|
* @since 3.2
|
||
|
*/
|
||
|
void hideContextMenu();
|
||
|
|
||
|
/**
|
||
12 years ago
|
* Returns the TDEPopupMenu associated with the current context menu
|
||
15 years ago
|
* @since 3.2
|
||
|
*/
|
||
12 years ago
|
static TDEPopupMenu* contextMenuFocus();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* returns the ID of the menuitem associated with the current context menu
|
||
|
* @since 3.2
|
||
|
*/
|
||
|
static int contextMenuFocusItem();
|
||
|
|
||
|
/**
|
||
|
* Reimplemented for internal purposes
|
||
|
* @since 3.4
|
||
|
*/
|
||
|
virtual void activateItemAt(int index);
|
||
|
/**
|
||
|
* Return the state of the mouse button and keyboard modifiers
|
||
|
* when the last menuitem was activated.
|
||
|
* @since 3.4
|
||
|
*/
|
||
14 years ago
|
TQt::ButtonState state() const;
|
||
15 years ago
|
|
||
|
signals:
|
||
|
/**
|
||
|
* connect to this signal to be notified when a context menu is about to be shown
|
||
|
* @param menu The menu that the context menu is about to be shown for
|
||
|
* @param menuItem The menu item that the context menu is currently on
|
||
|
* @param ctxMenu The context menu itself
|
||
|
* @since 3.2
|
||
|
*/
|
||
12 years ago
|
void aboutToShowContextMenu(TDEPopupMenu* menu, int menuItem, TQPopupMenu* ctxMenu);
|
||
15 years ago
|
|
||
|
protected:
|
||
15 years ago
|
virtual void closeEvent(TQCloseEvent *);
|
||
|
virtual void keyPressEvent(TQKeyEvent* e);
|
||
15 years ago
|
/// @since 3.4
|
||
15 years ago
|
virtual void mouseReleaseEvent(TQMouseEvent* e);
|
||
|
virtual void mousePressEvent(TQMouseEvent* e);
|
||
15 years ago
|
virtual bool focusNextPrevChild( bool next );
|
||
15 years ago
|
virtual void contextMenuEvent(TQContextMenuEvent *e);
|
||
|
virtual void hideEvent(TQHideEvent*);
|
||
15 years ago
|
|
||
|
virtual void virtual_hook( int id, void* data );
|
||
|
|
||
|
protected slots:
|
||
|
/// @since 3.1
|
||
15 years ago
|
TQString underlineText(const TQString& text, uint length);
|
||
15 years ago
|
/// @since 3.1
|
||
|
void resetKeyboardVars(bool noMatches = false);
|
||
|
void itemHighlighted(int whichItem);
|
||
15 years ago
|
void showCtxMenu(TQPoint pos);
|
||
15 years ago
|
void ctxMenuHiding();
|
||
|
void ctxMenuHideShowingMenu();
|
||
|
|
||
|
private:
|
||
12 years ago
|
class TDEPopupMenuPrivate;
|
||
|
TDEPopupMenuPrivate *d;
|
||
15 years ago
|
};
|
||
|
|
||
|
#endif
|