]>
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"
16 #if wxUSE_CHECKLISTBOX
18 #include "wx/checklst.h"
19 #include "wx/gtk/private.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
30 wxCheckListBox::wxCheckListBox() : wxListBox()
32 m_hasCheckBoxes
= TRUE
;
35 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
39 const wxString
*choices
,
41 const wxValidator
& validator
,
42 const wxString
& name
)
44 m_hasCheckBoxes
= TRUE
;
45 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
48 bool wxCheckListBox::IsChecked( int index
) const
50 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
52 GList
*child
= g_list_nth( m_list
->children
, index
);
55 GtkBin
*bin
= GTK_BIN( child
->data
);
56 GtkLabel
*label
= GTK_LABEL( bin
->child
);
58 wxString
str( wxGTK_CONV_BACK( label
->label
) );
60 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
63 wxFAIL_MSG(wxT("wrong checklistbox index"));
67 void wxCheckListBox::Check( int index
, bool check
)
69 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
71 GList
*child
= g_list_nth( m_list
->children
, index
);
74 GtkBin
*bin
= GTK_BIN( child
->data
);
75 GtkLabel
*label
= GTK_LABEL( bin
->child
);
77 wxString
str( wxGTK_CONV_BACK( label
->label
) );
79 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
82 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
84 gtk_label_set( label
, wxGTK_CONV( str
) );
89 wxFAIL_MSG(wxT("wrong checklistbox index"));
92 int wxCheckListBox::GetItemHeight() const