Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
ManualSelector.cpp
Go to the documentation of this file.
1 
12 #include "stdafx.h"
13 #include "ManualSelector.h"
14 
15 
16 using namespace kome::core;
17 
18 
19 #include <crtdbg.h>
20 #ifdef _DEBUG
21  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
22  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
23 #endif // _DEBUG
24 
25 
26 
27 // constructor
29 }
30 
31 // destructor
33 }
34 
35 // set selection status
36 void ManualSelector::setSelected( const int item, const bool selected ) {
37  // check the item
38  if( item < 0 ) {
39  return;
40  }
41 
42  // set status
43  if( selected ) {
44  m_selectedItemSet.insert( item );
45  }
46  else {
47  m_selectedItemSet.erase( item );
48  }
49 }
50 
51 // on select
52 bool ManualSelector::onSelect( const unsigned int num, const char** items, const char** values, bool* selected ) {
53  // initialize
54  for( unsigned int i = 0; i < num; i++ ) {
55  selected[ i ] = false;
56  }
57 
58  // get selection
59  for( std::set< int >::iterator it = m_selectedItemSet.begin();
60  it != m_selectedItemSet.end(); it++ ) {
61  int item = *it;
62  if( item >= 0 && item < (int)num ) {
63  selected[ item ] = true;
64  }
65  }
66 
67  return true;
68 }
interfaces of ManualSelector class
void setSelected(const int item, const bool selected)
sets selection status
virtual ~ManualSelector()
destructor
virtual bool onSelect(const unsigned int num, const char **items, const char **values, bool *selected)
This method is called by select method. (override method)
std::set< int > m_selectedItemSet