]>
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 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
15 #if wxUSE_CHECKLISTBOX
17 #include "wx/checklst.h"
18 #include "wx/gtk/private.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
29 wxCheckListBox::wxCheckListBox() : wxListBox()
31 m_hasCheckBoxes
= TRUE
;
34 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
38 const wxString
*choices
,
40 const wxValidator
& validator
,
41 const wxString
& name
)
43 m_hasCheckBoxes
= TRUE
;
44 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
47 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
50 const wxArrayString
& choices
,
52 const wxValidator
& validator
,
53 const wxString
& name
)
55 m_hasCheckBoxes
= TRUE
;
56 wxListBox::Create( parent
, id
, pos
, size
, choices
,
57 style
, validator
, name
);
60 bool wxCheckListBox::IsChecked( int index
) const
62 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
64 GList
*child
= g_list_nth( m_list
->children
, index
);
67 GtkBin
*bin
= GTK_BIN( child
->data
);
68 GtkLabel
*label
= GTK_LABEL( bin
->child
);
70 wxString
str( wxGTK_CONV_BACK( label
->label
) );
72 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
75 wxFAIL_MSG(wxT("wrong checklistbox index"));
79 void wxCheckListBox::Check( int index
, bool check
)
81 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
83 GList
*child
= g_list_nth( m_list
->children
, index
);
86 GtkBin
*bin
= GTK_BIN( child
->data
);
87 GtkLabel
*label
= GTK_LABEL( bin
->child
);
89 wxString
str( wxGTK_CONV_BACK( label
->label
) );
91 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
94 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
96 gtk_label_set_text( label
, wxGTK_CONV( str
) );
101 wxFAIL_MSG(wxT("wrong checklistbox index"));
104 int wxCheckListBox::GetItemHeight() const