KiCad PCB EDA Suite
CONDITIONAL_MENU::ENTRY Class Reference

< Helper class to organize menu entries. Inserts the entry, preserving the requested order. More...

Public Types

enum  ENTRY_TYPE { ACTION , MENU , WXITEM , SEPARATOR }
 

Public Member Functions

 ENTRY (const TOOL_ACTION *aAction, SELECTION_CONDITION aCondition, int aOrder, bool aCheckmark)
 
 ENTRY (ACTION_MENU *aMenu, SELECTION_CONDITION aCondition, int aOrder)
 
 ENTRY (const wxMenuItem &aItem, BITMAPS aBitmap, SELECTION_CONDITION aCondition, int aOrder, bool aCheckmark)
 
 ENTRY (SELECTION_CONDITION aCondition, int aOrder)
 
 ENTRY (const ENTRY &aEntry)
 
 ~ENTRY ()
 Possible entry types. More...
 
ENTRY_TYPE Type () const
 
BITMAPS GetIcon () const
 
const TOOL_ACTIONAction () const
 
ACTION_MENUMenu () const
 
wxMenuItem * wxItem () const
 
bool IsCheckmarkEntry () const
 
const SELECTION_CONDITIONCondition () const
 
int Order () const
 
void SetOrder (int aOrder)
 

Private Attributes

ENTRY_TYPE m_type
 
BITMAPS m_icon
 
union {
   const TOOL_ACTION *   action
 
   ACTION_MENU *   menu
 
   wxMenuItem *   wxItem
 
m_data
 Condition to be fulfilled to show the entry in menu. More...
 
SELECTION_CONDITION m_condition
 Order number, the higher the number the lower position it takes it is in the menu. More...
 
int m_order
 
bool m_isCheckmarkEntry
 

Detailed Description

< Helper class to organize menu entries. Inserts the entry, preserving the requested order.

Definition at line 122 of file conditional_menu.h.

Member Enumeration Documentation

◆ ENTRY_TYPE

Enumerator
ACTION 
MENU 
WXITEM 
SEPARATOR 

Definition at line 174 of file conditional_menu.h.

Constructor & Destructor Documentation

◆ ENTRY() [1/5]

CONDITIONAL_MENU::ENTRY::ENTRY ( const TOOL_ACTION aAction,
SELECTION_CONDITION  aCondition,
int  aOrder,
bool  aCheckmark 
)
inline

Definition at line 125 of file conditional_menu.h.

126 :
127 m_type( ACTION ),
128 m_icon( static_cast<BITMAPS>( 0 ) ),
129 m_condition( aCondition ),
130 m_order( aOrder ),
131 m_isCheckmarkEntry( aCheckmark )
132 {
133 m_data.action = aAction;
134 }
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
SELECTION_CONDITION m_condition
Order number, the higher the number the lower position it takes it is in the menu.
union CONDITIONAL_MENU::ENTRY::@35 m_data
Condition to be fulfilled to show the entry in menu.

References m_data.

◆ ENTRY() [2/5]

CONDITIONAL_MENU::ENTRY::ENTRY ( ACTION_MENU aMenu,
SELECTION_CONDITION  aCondition,
int  aOrder 
)
inline

Definition at line 136 of file conditional_menu.h.

136 :
137 m_type( MENU ),
138 m_icon( static_cast<BITMAPS>( 0 ) ),
139 m_condition( aCondition ),
140 m_order( aOrder ),
141 m_isCheckmarkEntry( false )
142 {
143 m_data.menu = aMenu;
144 }

References m_data.

◆ ENTRY() [3/5]

CONDITIONAL_MENU::ENTRY::ENTRY ( const wxMenuItem &  aItem,
BITMAPS  aBitmap,
SELECTION_CONDITION  aCondition,
int  aOrder,
bool  aCheckmark 
)
inline

Definition at line 146 of file conditional_menu.h.

147 :
148 m_type( WXITEM ),
149 m_icon( aBitmap ),
150 m_condition( aCondition ),
151 m_order( aOrder ),
152 m_isCheckmarkEntry( aCheckmark )
153 {
154 m_data.wxItem = new wxMenuItem( nullptr, aItem.GetId(), aItem.GetItemLabel(),
155 aItem.GetHelp(), aItem.GetKind() );
156 }

References m_data.

◆ ENTRY() [4/5]

CONDITIONAL_MENU::ENTRY::ENTRY ( SELECTION_CONDITION  aCondition,
int  aOrder 
)
inline

Definition at line 159 of file conditional_menu.h.

159 :
160 m_type( SEPARATOR ),
161 m_icon( static_cast<BITMAPS>( 0 ) ),
162 m_data(),
163 m_condition( aCondition ),
164 m_order( aOrder ),
165 m_isCheckmarkEntry( false )
166 {
167 }

◆ ENTRY() [5/5]

CONDITIONAL_MENU::ENTRY::ENTRY ( const ENTRY aEntry)

Definition at line 223 of file conditional_menu.cpp.

224{
225 m_type = aEntry.m_type;
226 m_icon = aEntry.m_icon;
227
228 switch( aEntry.m_type )
229 {
230 case ACTION:
231 m_data.action = aEntry.m_data.action;
232 break;
233 case MENU:
234 m_data.menu = aEntry.m_data.menu;
235 break;
236 case WXITEM:
237 // We own the wxItem, so we need to make a new one for the new object
238 m_data.wxItem = new wxMenuItem( nullptr,
239 aEntry.m_data.wxItem->GetId(),
240 aEntry.m_data.wxItem->GetItemLabel(),
241 aEntry.m_data.wxItem->GetHelp(),
242 aEntry.m_data.wxItem->GetKind() );
243 break;
244 case SEPARATOR:
245 break; //No data to copy
246 }
247 m_condition = aEntry.m_condition;
248 m_order = aEntry.m_order;
249 m_isCheckmarkEntry = aEntry.m_isCheckmarkEntry;
250}

References ACTION, action, m_condition, m_data, m_icon, m_isCheckmarkEntry, m_order, m_type, MENU, menu, SEPARATOR, WXITEM, and wxItem.

◆ ~ENTRY()

CONDITIONAL_MENU::ENTRY::~ENTRY ( )

Possible entry types.

Definition at line 252 of file conditional_menu.cpp.

253{
254 if( WXITEM == m_type )
255 delete m_data.wxItem;
256}

Member Function Documentation

◆ Action()

const TOOL_ACTION * CONDITIONAL_MENU::ENTRY::Action ( ) const
inline

Definition at line 191 of file conditional_menu.h.

192 {
193 assert( m_type == ACTION );
194 return m_data.action;
195 }

References ACTION, m_data, and m_type.

◆ Condition()

const SELECTION_CONDITION & CONDITIONAL_MENU::ENTRY::Condition ( ) const
inline

Definition at line 214 of file conditional_menu.h.

215 {
216 return m_condition;
217 }

References m_condition.

◆ GetIcon()

BITMAPS CONDITIONAL_MENU::ENTRY::GetIcon ( ) const
inline

Definition at line 186 of file conditional_menu.h.

187 {
188 return m_icon;
189 }

References m_icon.

◆ IsCheckmarkEntry()

bool CONDITIONAL_MENU::ENTRY::IsCheckmarkEntry ( ) const
inline

Definition at line 209 of file conditional_menu.h.

210 {
211 return m_isCheckmarkEntry;
212 }

References m_isCheckmarkEntry.

◆ Menu()

ACTION_MENU * CONDITIONAL_MENU::ENTRY::Menu ( ) const
inline

Definition at line 197 of file conditional_menu.h.

198 {
199 assert( m_type == MENU );
200 return m_data.menu;
201 }

References m_data, m_type, and MENU.

◆ Order()

int CONDITIONAL_MENU::ENTRY::Order ( ) const
inline

Definition at line 219 of file conditional_menu.h.

220 {
221 return m_order;
222 }

References m_order.

Referenced by CONDITIONAL_MENU::addEntry().

◆ SetOrder()

void CONDITIONAL_MENU::ENTRY::SetOrder ( int  aOrder)
inline

Definition at line 224 of file conditional_menu.h.

225 {
226 m_order = aOrder;
227 }

References m_order.

Referenced by CONDITIONAL_MENU::addEntry().

◆ Type()

ENTRY_TYPE CONDITIONAL_MENU::ENTRY::Type ( ) const
inline

Definition at line 181 of file conditional_menu.h.

182 {
183 return m_type;
184 }

References m_type.

◆ wxItem()

wxMenuItem * CONDITIONAL_MENU::ENTRY::wxItem ( ) const
inline

Definition at line 203 of file conditional_menu.h.

204 {
205 assert( m_type == WXITEM );
206 return m_data.wxItem;
207 }

References m_data, m_type, and WXITEM.

Member Data Documentation

◆ action

const TOOL_ACTION* CONDITIONAL_MENU::ENTRY::action

Definition at line 236 of file conditional_menu.h.

Referenced by ENTRY().

◆ m_condition

SELECTION_CONDITION CONDITIONAL_MENU::ENTRY::m_condition
private

Order number, the higher the number the lower position it takes it is in the menu.

Definition at line 242 of file conditional_menu.h.

Referenced by Condition(), and ENTRY().

◆ 

union { ... } CONDITIONAL_MENU::ENTRY::m_data

Condition to be fulfilled to show the entry in menu.

Referenced by Action(), ENTRY(), Menu(), and wxItem().

◆ m_icon

BITMAPS CONDITIONAL_MENU::ENTRY::m_icon
private

Definition at line 231 of file conditional_menu.h.

Referenced by ENTRY(), and GetIcon().

◆ m_isCheckmarkEntry

bool CONDITIONAL_MENU::ENTRY::m_isCheckmarkEntry
private

Definition at line 247 of file conditional_menu.h.

Referenced by ENTRY(), and IsCheckmarkEntry().

◆ m_order

int CONDITIONAL_MENU::ENTRY::m_order
private

Definition at line 245 of file conditional_menu.h.

Referenced by ENTRY(), Order(), and SetOrder().

◆ m_type

ENTRY_TYPE CONDITIONAL_MENU::ENTRY::m_type
private

Definition at line 230 of file conditional_menu.h.

Referenced by Action(), ENTRY(), Menu(), Type(), and wxItem().

◆ menu

ACTION_MENU* CONDITIONAL_MENU::ENTRY::menu

Definition at line 237 of file conditional_menu.h.

Referenced by ENTRY().

◆ wxItem

wxMenuItem* CONDITIONAL_MENU::ENTRY::wxItem

Definition at line 238 of file conditional_menu.h.

Referenced by ENTRY().


The documentation for this class was generated from the following files: