2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fmenulist.h - Menu item container base class *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2019-09-01 23:29:27 +02:00
|
|
|
* Copyright 2015-2019 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut 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 Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
/* Base class
|
|
|
|
* ══════════
|
|
|
|
*
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FMenuList ▏- - - -▕ FMenuItem ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* :1
|
|
|
|
* : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ├- - - - - - -▕ FRadioMenuItem ▏
|
|
|
|
* : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* :
|
|
|
|
* : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* └- - - - - - -▕ 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-10-31 00:41:59 +01:00
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fmenuitem.h"
|
|
|
|
#include "final/fwidget.h"
|
2015-08-09 23:47:08 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
2015-08-09 23:47:08 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FMenuList
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class FMenuList
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
2018-12-03 03:22:36 +01:00
|
|
|
FMenuList() = default;
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2018-12-09 22:04:55 +01:00
|
|
|
// Disable copy constructor
|
|
|
|
FMenuList (const FMenuList&) = delete;
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Destructor
|
|
|
|
virtual ~FMenuList();
|
|
|
|
|
2018-12-09 22:04:55 +01:00
|
|
|
// Disable assignment operator (=)
|
|
|
|
FMenuList& operator = (const FMenuList&) = delete;
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Accessors
|
2019-09-01 23:29:27 +02:00
|
|
|
virtual const char* getClassName() const;
|
|
|
|
std::size_t getCount() const;
|
|
|
|
FMenuItem* getItem (int) const;
|
|
|
|
FMenuItem* getSelectedItem() const;
|
|
|
|
std::vector<FMenuItem*> getItemList() const;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Mutators
|
2019-09-01 23:29:27 +02:00
|
|
|
void enableItem (int);
|
|
|
|
void disableItem (int);
|
|
|
|
void setSelectedItem (FMenuItem*);
|
|
|
|
void unsetSelectedItem();
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Inquiries
|
2019-09-01 23:29:27 +02:00
|
|
|
bool isSelected (int) const;
|
|
|
|
bool hasSelectedItem() const;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Methods
|
2019-09-01 23:29:27 +02:00
|
|
|
virtual void insert (FMenuItem*);
|
|
|
|
virtual void remove (FMenuItem*);
|
|
|
|
void remove (int);
|
|
|
|
void clear();
|
|
|
|
void selectFirstItem();
|
|
|
|
void unselectItem();
|
|
|
|
|
|
|
|
private:
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2019-09-01 23:29:27 +02:00
|
|
|
FMenuItem* selected_item{};
|
|
|
|
std::vector<FMenuItem*> item_list{};
|
2015-08-09 23:47:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// FMenuList inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FMenuList::getClassName() const
|
|
|
|
{ return "FMenuList"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-10-14 06:25:33 +02:00
|
|
|
inline std::size_t FMenuList::getCount() const
|
|
|
|
{ return 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
|
2017-09-17 21:32:46 +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; }
|
|
|
|
|
2019-09-01 23:29:27 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline std::vector<FMenuItem*> FMenuList::getItemList() const
|
|
|
|
{ return item_list; }
|
|
|
|
|
2015-08-09 23:47:08 +02:00
|
|
|
//----------------------------------------------------------------------
|
2015-10-29 21:10:50 +01:00
|
|
|
inline void FMenuList::enableItem (int index)
|
2017-09-15 01:31:02 +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)
|
2017-09-15 01:31:02 +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
|
|
|
|
2019-09-01 23:29:27 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FMenuList::unsetSelectedItem()
|
|
|
|
{ selected_item = nullptr; }
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FMenuList::isSelected(int index) const
|
2017-09-17 21:32:46 +02:00
|
|
|
{ return ( index > 0 ) ? item_list[uInt(index - 1)]->isSelected() : false; }
|
2016-11-02 00:37:58 +01:00
|
|
|
|
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
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FMENULIST_H
|