]> git.saurik.com Git - wxWidgets.git/blob - src/osx/checklst_osx.cpp
Fix install_name_tool calls in OS X "make install".
[wxWidgets.git] / src / osx / checklst_osx.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/checklst.cpp
3 // Purpose: implementation of wxCheckListBox class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10 //
11 // new DataBrowser-based version
12
13
14 #include "wx/wxprec.h"
15
16 #if wxUSE_CHECKLISTBOX
17
18 #include "wx/checklst.h"
19
20 #ifndef WX_PRECOMP
21 #include "wx/arrstr.h"
22 #endif
23
24 #include "wx/osx/private.h"
25
26 BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
27 END_EVENT_TABLE()
28
29 void wxCheckListBox::Init()
30 {
31 }
32
33 bool wxCheckListBox::Create(
34 wxWindow *parent,
35 wxWindowID id,
36 const wxPoint &pos,
37 const wxSize &size,
38 const wxArrayString& choices,
39 long style,
40 const wxValidator& validator,
41 const wxString &name )
42 {
43 wxCArrayString chs( choices );
44
45 return Create( parent, id, pos, size, chs.GetCount(), chs.GetStrings(), style, validator, name );
46 }
47
48 bool wxCheckListBox::Create(
49 wxWindow *parent,
50 wxWindowID id,
51 const wxPoint& pos,
52 const wxSize& size,
53 int n,
54 const wxString choices[],
55 long style,
56 const wxValidator& validator,
57 const wxString& name )
58 {
59
60 wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
61 wxT("only one of listbox selection modes can be specified") );
62
63 if ( !wxCheckListBoxBase::Create( parent, id, pos, size, n, choices, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
64 return false;
65
66 int colwidth = 30;
67 // TODO adapt the width according to the window variant
68 m_checkColumn = GetListPeer()->InsertCheckColumn(0, wxEmptyString, true, wxALIGN_CENTER, colwidth);
69
70 return true;
71 }
72
73 // ----------------------------------------------------------------------------
74 // wxCheckListBox functions
75 // ----------------------------------------------------------------------------
76
77 // ----------------------------------------------------------------------------
78 // wxCheckListBox functions
79 // ----------------------------------------------------------------------------
80
81 bool wxCheckListBox::IsChecked(unsigned int n) const
82 {
83 wxCHECK_MSG( IsValid(n), false,
84 wxT("invalid index in wxCheckListBox::IsChecked") );
85
86 return m_checks[n] != 0;
87 }
88
89 void wxCheckListBox::Check(unsigned int n, bool check)
90 {
91 wxCHECK_RET( IsValid(n),
92 wxT("invalid index in wxCheckListBox::Check") );
93
94 // intermediate var is needed to avoid compiler warning with VC++
95 bool isChecked = m_checks[n] != 0;
96 if ( check != isChecked )
97 {
98 m_checks[n] = check;
99
100 GetListPeer()->UpdateLine(n);
101 }
102 }
103
104 void wxCheckListBox::GetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value )
105 {
106 if ( col == m_checkColumn )
107 value.Check( IsChecked( n ) );
108 else
109 wxListBox::GetValueCallback( n, col, value );
110 }
111
112 void wxCheckListBox::SetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value )
113 {
114 if ( col == m_checkColumn )
115 {
116 Check( n, value.IsChecked() );
117
118 wxCommandEvent event( wxEVT_CHECKLISTBOX, GetId() );
119 event.SetInt( n );
120 event.SetString( GetString( n ) );
121 event.SetEventObject( this );
122 HandleWindowEvent( event );
123 }
124 }
125
126
127
128 // ----------------------------------------------------------------------------
129 // methods forwarded to wxListBox
130 // ----------------------------------------------------------------------------
131
132 void wxCheckListBox::OnItemInserted(unsigned int pos)
133 {
134 wxListBox::OnItemInserted(pos);
135
136 m_checks.Insert(false, pos );
137 }
138
139 void wxCheckListBox::DoDeleteOneItem(unsigned int n)
140 {
141 wxListBox::DoDeleteOneItem(n);
142
143 m_checks.RemoveAt(n);
144 }
145
146 void wxCheckListBox::DoClear()
147 {
148 wxListBox::DoClear();
149
150 m_checks.Empty();
151 }
152
153 #endif // wxUSE_CHECKLISTBOX