Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MenuButton Class Reference

The MenuButton class is a pushbutton with a menu. More...

#include </home/clem/local/src/opie/library/menubutton.h>

Collaboration diagram for MenuButton:

Collaboration graph
[legend]
List of all members.

Public Slots

void select (int)
void select (const QString &)

Signals

void selected (int)
void selected (const QString &)

Public Member Functions

 MenuButton (QWidget *parent, const char *name=0)
 MenuButton (const QStringList &items, QWidget *parent, const char *name=0)
void clear ()
int currentItem () const
QString currentText () const
void insertItems (const QStringList &items)
void insertItem (const QIconSet &icon, const QString &text=QString::null)
void insertItem (const QString &text)
void insertSeparator ()
void setLabel (const QString &label)
int count ()
void remove (int id)
QString text (int id)
void setUseLabel (bool b)

Private Member Functions

void init ()
void updateLabel ()

Private Attributes

bool useLabel
QStringList txts
QPopupMenu * pop
int nitems
int cur
QString lab

Detailed Description

The MenuButton class is a pushbutton with a menu.

When the user presses the menubutton's pushbutton, the menu pops up. A menu is composed of menu items each of which has a string label, and optionally an icon.

The index of the item that the user's input device (e.g. stylus) is pointing at is the currentItem(), whose text is available using currentText().

Menu items are inserted with the constructor, insertItem() or insertItems(). Separators are inserted with insertSeparator(). All the items in the menu can be removed by calling clear().

Items can be selected programmatically using select(). When a menu item is selected (programmatically or by the user), the selected() signal is emitted.

Definition at line 26 of file menubutton.h.


Constructor & Destructor Documentation

MenuButton::MenuButton QWidget *  parent,
const char *  name = 0
 

Constructs an empty MenuButton. The standard parent an name arguments are passed to the base class.

See also:
insertItem() insertItems()

Definition at line 81 of file menubutton.cpp.

References init().

MenuButton::MenuButton const QStringList items,
QWidget *  parent,
const char *  name = 0
 

Constructs a MenuButton. A menu item is created (see insertItem() and insertItems()) for each string in the items string list. The standard parent an name arguments are passed to the base class.

Definition at line 67 of file menubutton.cpp.

References init(), insertItems(), and useLabel.


Member Function Documentation

void MenuButton::clear  ) 
 

Removes all the menu items from the button and menu.

Definition at line 100 of file menubutton.cpp.

References init(), and pop.

int MenuButton::count  ) 
 

return count of items in menu

Definition at line 234 of file menubutton.cpp.

References nitems.

int MenuButton::currentItem  )  const
 

Returns the index position of the current item.

Definition at line 186 of file menubutton.cpp.

References cur.

QString MenuButton::currentText  )  const
 

Returns the label text of the current item.

Definition at line 194 of file menubutton.cpp.

References cur, and pop.

Referenced by select().

void MenuButton::init  )  [private]
 

Definition at line 87 of file menubutton.cpp.

References FALSE, nitems, pop, and select().

Referenced by clear(), and MenuButton().

void MenuButton::insertItem const QString text  ) 
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Inserts a menu item with the label text into the menu.

See also:
insertItems()

Definition at line 140 of file menubutton.cpp.

References nitems, and pop.

void MenuButton::insertItem const QIconSet &  icon,
const QString text = QString::null
 

Inserts a menu item with the icon icon and label text into the menu.

See also:
insertItems()

Definition at line 128 of file menubutton.cpp.

References nitems, and pop.

Referenced by AdvancedFm::addCustomDir(), AdvancedFm::init(), and insertItems().

void MenuButton::insertItems const QStringList items  ) 
 

A menu item is created (see insertItem()) for each string in the items string list. If any string is "--" a separator (see insertSeparator()) is inserted in its place.

Definition at line 111 of file menubutton.cpp.

References QValueList< T >::begin(), QValueList< T >::end(), insertItem(), and insertSeparator().

Referenced by AdvancedFm::customDirsToMenu(), and MenuButton().

void MenuButton::insertSeparator  ) 
 

Inserts a separator into the menu.

See also:
insertItems()

Definition at line 151 of file menubutton.cpp.

References pop.

Referenced by AdvancedFm::init(), and insertItems().

void MenuButton::remove int  id  ) 
 

remove item at id

Definition at line 225 of file menubutton.cpp.

References nitems, and pop.

Referenced by AdvancedFm::removeCustomDir().

void MenuButton::select const QString s  )  [slot]
 

Selects the items with label text s.

Definition at line 159 of file menubutton.cpp.

References i, nitems, pop, and select().

void MenuButton::select int  s  )  [slot]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Selects the item at index position s.

Definition at line 173 of file menubutton.cpp.

References cur, currentText(), pop, selected(), and updateLabel().

Referenced by init(), and select().

void MenuButton::selected const QString text  )  [signal]
 

This signal is emitted when the item with the label text is selected.

void MenuButton::selected int  index  )  [signal]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

This signal is emitted when the item at position index is selected.

Referenced by select().

void MenuButton::setLabel const QString label  ) 
 

Sets the menubutton's label. If label is empty, the current item text is displayed, otherwise label should contain "%1", which will be replaced by the current item text.

Definition at line 204 of file menubutton.cpp.

References lab, and updateLabel().

void MenuButton::setUseLabel bool  b  ) 
 

sets true or false the use of label

Definition at line 250 of file menubutton.cpp.

References useLabel.

Referenced by AdvancedFm::init().

QString MenuButton::text int  id  ) 
 

returns text of item id

Definition at line 242 of file menubutton.cpp.

References pop.

void MenuButton::updateLabel  )  [private]
 

Definition at line 210 of file menubutton.cpp.

References QString::arg(), cur, QString::isEmpty(), lab, pop, t, and useLabel.

Referenced by select(), and setLabel().


Member Data Documentation

int MenuButton::cur [private]
 

Definition at line 63 of file menubutton.h.

Referenced by currentItem(), currentText(), select(), and updateLabel().

QString MenuButton::lab [private]
 

Definition at line 64 of file menubutton.h.

Referenced by setLabel(), and updateLabel().

int MenuButton::nitems [private]
 

Definition at line 62 of file menubutton.h.

Referenced by count(), init(), insertItem(), remove(), and select().

QPopupMenu* MenuButton::pop [private]
 

Definition at line 61 of file menubutton.h.

Referenced by clear(), currentText(), init(), insertItem(), insertSeparator(), remove(), select(), text(), and updateLabel().

QStringList MenuButton::txts [private]
 

Definition at line 60 of file menubutton.h.

bool MenuButton::useLabel [private]
 

Definition at line 58 of file menubutton.h.

Referenced by MenuButton(), setUseLabel(), and updateLabel().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:40:05 2005 for OPIE by  doxygen 1.4.2