]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
8d1d92f1f33e9614f1a2f42a4236f3a47731075c
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) == wxT('X'));
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) == wxT('X'))) return;
79 str
.SetChar( 1, wxT('X') );
81 str
.SetChar( 1, wxT('-') );
83 gtk_label_set( label
, str
.mbc_str() );
88 wxFAIL_MSG(wxT("wrong checklistbox index"));
91 int wxCheckListBox::GetItemHeight() const