ALBA
albaGUICheckListBox.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaGUICheckListBox
5 Authors: Silvano Imboden
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaGUICheckListBox_H__
18#define __albaGUICheckListBox_H__
19
20//----------------------------------------------------------------------------
21// Include:
22//----------------------------------------------------------------------------
23#include "albaGUIPanel.h"
24#include "albaString.h"
25
26//----------------------------------------------------------------------------
27// Forward refs:
28//----------------------------------------------------------------------------
29class albaObserver;
30
31//----------------------------------------------------------------------------
32// constant
33//----------------------------------------------------------------------------
34#define albaGUICheckListBox_ArraySize 4096
35
37{
40};
41
42//----------------------------------------------------------------------------
43// albaGUICheckListBox :
48//----------------------------------------------------------------------------
49class ALBA_EXPORT albaGUICheckListBox: public albaGUIPanel
50{
51public:
52 albaGUICheckListBox(wxWindow* parent,
53 wxWindowID id,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = wxTAB_TRAVERSAL | wxCLIP_CHILDREN);
57
59
61 void Clear();
62
64 void AddItem(int id, wxString label);
65
67 void AddItem(int id, wxString label, bool checked);
68
70 void RemoveItem(int id);
71
73 void CheckItem(int id, bool check);
74
76 void SetItemLabel(int id, albaString label);
77
80
82 void Select(int id);
83
85 int GetSelection() {return m_SelectedItem;};
86
88 bool IsItemChecked(int id);
89
91 void SetCheckMode(int mode) {m_CheckMode = mode;};
92
94 void SetCheckModeToRadio() {m_CheckMode = MODE_RADIO;};
95
97 void SetCheckModeToCheck() {m_CheckMode = MODE_CHECK;};
98
99 void SetListener(albaObserver *listener) {m_Listener = listener;};
100
102 int FindItem(wxString label);
103
105 int FindItemIndex(int id);
106
108 bool IsCheckEvent() {return m_CheckEvent;};
109
111 int GetNumberOfItems() {return m_CheckListBox->GetCount();};
112
114 void SetCheckEvent(bool enable){m_CheckEvent = enable;}
115
117 void HighlightItem(int index, int rgbText[3], int rgbBack[3]);
118
119protected:
121 void OnSelect(wxCommandEvent &event);
122
124 void OnCheck(wxCommandEvent &event);
125
127 void OnSize(wxSizeEvent& event);
128
131 wxCheckListBox *m_CheckListBox;
134 int m_Array[albaGUICheckListBox_ArraySize]; // item_position_in_CheckListBox -> id
136
137 DECLARE_EVENT_TABLE()
138};
139#endif
#define albaGUICheckListBox_ArraySize
CHECKLIST_MODE_ID
@ MODE_CHECK
@ MODE_RADIO
a CheckList that send albaEventNotification in the form albaEvent(this, widget_id,...
void SetItemLabel(int id, albaString label)
Set the item label.
void Select(int id)
Select the item.
void SetListener(albaObserver *listener)
virtual ~albaGUICheckListBox()
void OnSelect(wxCommandEvent &event)
Send an event to the listener to notify that an item has been selected.
wxCheckListBox * m_CheckListBox
void Clear()
Clear the checked listbox.
bool IsItemChecked(int id)
Return true if the item is checked.
albaString GetItemLabel(int id)
Get the item label.
void RemoveItem(int id)
Remove the item from the checked listbox.
int FindItem(wxString label)
Return the index of the item into the checked listbox, otherwise -1 if the item is not present.
void CheckItem(int id, bool check)
Check/Uncheck the item into the checked listbox.
void SetCheckEvent(bool enable)
Set Flag used to distinguish between Check item and Select item event.
void SetCheckModeToCheck()
Set the check mode of the checked listbox to be MODE_CHECK.
bool m_CheckEvent
Flag used to distinguish between Check item and Select item event.
void AddItem(int id, wxString label)
Add the item to the checked listbox.
void OnCheck(wxCommandEvent &event)
Send an event to the listener to notify that an item has been checked.
albaGUICheckListBox(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxCLIP_CHILDREN)
void AddItem(int id, wxString label, bool checked)
Add the item to the checked listbox and allow to check it.
int GetNumberOfItems()
Return the number of inserted items.
bool IsCheckEvent()
Return true if the event raised is coming from a check/uncheck item.
int FindItemIndex(int id)
Return the index of the item into the array, otherwise -1 if the item is not present.
void SetCheckMode(int mode)
Set the check mode of the checked listbox to be MODE_RADIO or MODE_CHECK.
void OnSize(wxSizeEvent &event)
Resize the checked listbox according to the new parent panel size.
void SetCheckModeToRadio()
Set the check mode of the checked listbox to be MODE_RADIO.
void HighlightItem(int index, int rgbText[3], int rgbBack[3])
Highlight Item.
int GetSelection()
Get the selected item.
class name: albaGUIPanel Inherits directly from wxPanel and adds the pointer to the next panel
Definition: albaGUIPanel.h:27
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaString - performs common string operations on c-strings.
Definition: albaString.h:43