]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/checklst.cpp
fc439b68de6d4e7c07cdb599aaadcde3d75c213c
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "checklst.h"
14 #include "wx/checklst.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
25 wxCheckListBox::wxCheckListBox() :
28 m_hasCheckBoxes
= TRUE
;
31 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
35 const wxString
*choices
,
37 const wxValidator
& validator
,
38 const wxString
& name
)
40 m_hasCheckBoxes
= TRUE
;
41 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
44 bool wxCheckListBox::IsChecked( int index
) const
46 wxCHECK_MSG( m_list
!= NULL
, FALSE
, _T("invalid checklistbox") );
48 GList
*child
= g_list_nth( m_list
->children
, index
);
51 GtkBin
*bin
= GTK_BIN( child
->data
);
52 GtkLabel
*label
= GTK_LABEL( bin
->child
);
54 wxString str
= label
->label
;
56 return (str
[1] == 'X');
59 wxFAIL_MSG(_T("wrong checklistbox index"));
63 void wxCheckListBox::Check( int index
, bool check
)
65 wxCHECK_RET( m_list
!= NULL
, _T("invalid checklistbox") );
67 GList
*child
= g_list_nth( m_list
->children
, index
);
70 GtkBin
*bin
= GTK_BIN( child
->data
);
71 GtkLabel
*label
= GTK_LABEL( bin
->child
);
73 wxString str
= label
->label
;
75 if (check
== (str
[1] == _T('X'))) return;
78 str
.SetChar( 1, _T('X') );
80 str
.SetChar( 1, _T('-') );
82 gtk_label_set( label
, str
.mbc_str() );
87 wxFAIL_MSG(_T("wrong checklistbox index"));
90 int wxCheckListBox::GetItemHeight() const