]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/checklst.cpp
6e97994417b488e5b0f3ceed1ba43226ad3054c5
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"
16 #if wxUSE_CHECKLISTBOX
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
27 wxCheckListBox::wxCheckListBox() : wxListBox()
29 m_hasCheckBoxes
= TRUE
;
32 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
36 const wxString
*choices
,
38 const wxValidator
& validator
,
39 const wxString
& name
)
41 m_hasCheckBoxes
= TRUE
;
42 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
45 bool wxCheckListBox::IsChecked( int index
) const
47 wxCHECK_MSG( m_list
!= NULL
, FALSE
, _T("invalid checklistbox") );
49 GList
*child
= g_list_nth( m_list
->children
, index
);
52 GtkBin
*bin
= GTK_BIN( child
->data
);
53 GtkLabel
*label
= GTK_LABEL( bin
->child
);
55 wxString str
= wxString(label
->label
,*wxConvCurrent
);
57 return (str
[1] == _T('X'));
60 wxFAIL_MSG(_T("wrong checklistbox index"));
64 void wxCheckListBox::Check( int index
, bool check
)
66 wxCHECK_RET( m_list
!= NULL
, _T("invalid checklistbox") );
68 GList
*child
= g_list_nth( m_list
->children
, index
);
71 GtkBin
*bin
= GTK_BIN( child
->data
);
72 GtkLabel
*label
= GTK_LABEL( bin
->child
);
74 wxString str
= wxString(label
->label
,*wxConvCurrent
);
76 if (check
== (str
[1] == _T('X'))) return;
79 str
.SetChar( 1, _T('X') );
81 str
.SetChar( 1, _T('-') );
83 gtk_label_set( label
, str
.mbc_str() );
88 wxFAIL_MSG(_T("wrong checklistbox index"));
91 int wxCheckListBox::GetItemHeight() const