]>
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"
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
, wxT("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
.GetChar(1) == wxCHECKLBOX_CHECKED
;
60 wxFAIL_MSG(wxT("wrong checklistbox index"));
64 void wxCheckListBox::Check( int index
, bool check
)
66 wxCHECK_RET( m_list
!= NULL
, wxT("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
.GetChar(1) == wxCHECKLBOX_CHECKED
))
79 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
81 gtk_label_set( label
, str
.mbc_str() );
86 wxFAIL_MSG(wxT("wrong checklistbox index"));
89 int wxCheckListBox::GetItemHeight() const