]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/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"
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
, "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("wrong checklistbox index");
63 void wxCheckListBox::Check( int index
, bool check
)
65 wxCHECK_RET( m_list
!= NULL
, "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] == 'X')) return;
78 str
.SetChar( 1, 'X' );
80 str
.SetChar( 1, '-' );
82 gtk_label_set( label
, str
);
87 wxFAIL_MSG("wrong checklistbox index");
90 int wxCheckListBox::GetItemHeight()