]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "checklst.h"
16 #if wxUSE_CHECKLISTBOX
18 #include "wx/checklst.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
29 wxCheckListBox::wxCheckListBox() : wxListBox()
31 m_hasCheckBoxes
= TRUE
;
34 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
38 const wxString
*choices
,
40 const wxValidator
& validator
,
41 const wxString
& name
)
43 m_hasCheckBoxes
= TRUE
;
44 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
47 bool wxCheckListBox::IsChecked( int index
) const
49 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
51 GList
*child
= g_list_nth( m_list
->children
, index
);
54 GtkBin
*bin
= GTK_BIN( child
->data
);
55 GtkLabel
*label
= GTK_LABEL( bin
->child
);
57 wxString str
= wxString(label
->label
,*wxConvCurrent
);
59 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
62 wxFAIL_MSG(wxT("wrong checklistbox index"));
66 void wxCheckListBox::Check( int index
, bool check
)
68 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
70 GList
*child
= g_list_nth( m_list
->children
, index
);
73 GtkBin
*bin
= GTK_BIN( child
->data
);
74 GtkLabel
*label
= GTK_LABEL( bin
->child
);
76 wxString str
= wxString(label
->label
,*wxConvCurrent
);
78 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
81 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
83 gtk_label_set( label
, str
.mbc_str() );
88 wxFAIL_MSG(wxT("wrong checklistbox index"));
91 int wxCheckListBox::GetItemHeight() const