2015-09-25 21:37:19 +02:00
|
|
|
// File: fmenulist.h
|
|
|
|
// Provides: class FMenuList
|
|
|
|
//
|
|
|
|
// Base class
|
|
|
|
// ══════════
|
|
|
|
//
|
|
|
|
// ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ▕ FMenuList ▏- - - -▕ FMenuItem ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-11-15 19:46:33 +01:00
|
|
|
// :1
|
|
|
|
// : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// ├- - - - - - -▕ FRadioMenuItem ▏
|
|
|
|
// : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-11-24 23:40:41 +01:00
|
|
|
// :
|
2015-11-15 19:46:33 +01:00
|
|
|
// : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
// └- - - - - - -▕ FCheckMenuItem ▏
|
|
|
|
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FMENULIST_H
|
|
|
|
#define FMENULIST_H
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
#include "fmenuitem.h"
|
2015-08-16 20:05:39 +02:00
|
|
|
#include "fwidget.h"
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FMenuList
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FMenuList
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
explicit FMenuList();
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FMenuList();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
virtual const char* getClassName() const;
|
|
|
|
uInt getCount() const;
|
|
|
|
FMenuItem* getItem (int) const;
|
|
|
|
FMenuItem* getSelectedItem() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void enableItem (int);
|
|
|
|
void disableItem (int);
|
|
|
|
void setSelectedItem (FMenuItem*);
|
|
|
|
|
|
|
|
// Inquiries
|
|
|
|
bool isSelected (int) const;
|
|
|
|
bool hasSelectedItem() const;
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
virtual void insert (FMenuItem*);
|
|
|
|
virtual void remove (FMenuItem*);
|
|
|
|
void remove (int);
|
|
|
|
void clear();
|
|
|
|
void selectFirstItem();
|
|
|
|
void unselectItem();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FMenuItem* selected_item;
|
|
|
|
std::vector<FMenuItem*> item_list;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
FMenuList (const FMenuList&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FMenuList& operator = (const FMenuList&);
|
2015-08-09 23:47:08 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FMenuList inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FMenuList::getClassName() const
|
|
|
|
{ return "FMenuList"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline uInt FMenuList::getCount() const
|
2016-09-27 00:46:05 +02:00
|
|
|
{ return uInt(item_list.size()); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-11-02 00:37:58 +01:00
|
|
|
inline FMenuItem* FMenuList::getItem (int index) const
|
2016-09-27 00:46:05 +02:00
|
|
|
{ return (index > 0) ? item_list[uInt(index-1)] : 0; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline FMenuItem* FMenuList::getSelectedItem() const
|
|
|
|
{ return selected_item; }
|
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
2015-10-29 21:10:50 +01:00
|
|
|
inline void FMenuList::enableItem (int index)
|
2016-09-27 00:46:05 +02:00
|
|
|
{ item_list[uInt(index-1)]->setEnable(); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2015-10-29 21:10:50 +01:00
|
|
|
inline void FMenuList::disableItem (int index)
|
2016-09-27 00:46:05 +02:00
|
|
|
{ item_list[uInt(index-1)]->unsetEnable(); }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2015-11-07 23:16:09 +01:00
|
|
|
//----------------------------------------------------------------------
|
2015-11-12 01:33:16 +01:00
|
|
|
inline void FMenuList::setSelectedItem (FMenuItem* menuitem)
|
2016-09-27 00:46:05 +02:00
|
|
|
{ selected_item = menuitem; }
|
2015-11-07 23:16:09 +01:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuList::isSelected(int index) const
|
|
|
|
{ return (index > 0) ? item_list[uInt(index-1)]->isSelected() : false; }
|
|
|
|
|
2015-11-07 23:16:09 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuList::hasSelectedItem() const
|
2016-09-27 00:46:05 +02:00
|
|
|
{ return selected_item; }
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FMENULIST_H
|