]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
252e216983b51b24c3922efd7aba3f4e49991f75
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 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
22 wxCheckListBox::wxCheckListBox() :
25 m_hasCheckBoxes
= TRUE
;
27 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
31 const wxString choices
[] = NULL
,
33 const wxValidator
& validator
= wxDefaultValidator
,
34 const wxString
& name
= wxListBoxNameStr
)
36 m_hasCheckBoxes
= TRUE
;
37 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
40 bool wxCheckListBox::IsChecked( int index
) const
42 wxCHECK_MSG( m_list
!= NULL
, FALSE
, "invalid checklistbox" );
44 GList
*child
= g_list_nth( m_list
->children
, index
);
47 GtkBin
*bin
= GTK_BIN( child
->data
);
48 GtkLabel
*label
= GTK_LABEL( bin
->child
);
50 wxString str
= label
->label
;
52 return (str
[1] == 'X');
55 wxFAIL_MSG("wrong checklistbox index");
59 void wxCheckListBox::Check( int index
, bool check
)
61 wxCHECK_RET( m_list
!= NULL
, "invalid checklistbox" );
63 GList
*child
= g_list_nth( m_list
->children
, index
);
66 GtkBin
*bin
= GTK_BIN( child
->data
);
67 GtkLabel
*label
= GTK_LABEL( bin
->child
);
69 wxString str
= label
->label
;
71 if (check
== (str
[1] == 'X')) return;
74 str
.SetChar( 1, 'X' );
76 str
.SetChar( 1, '-' );
78 gtk_label_set( label
, str
);
83 wxFAIL_MSG("wrong checklistbox index");