]>
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"
19 // FIXME: We use GtkList to implement wxListBox
20 #ifdef GTK_DISABLE_DEPRECATED
21 #undef GTK_DISABLE_DEPRECATED
24 #include "wx/gtk/private.h"
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
35 wxCheckListBox::wxCheckListBox() : wxListBox()
37 m_hasCheckBoxes
= TRUE
;
40 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
44 const wxString
*choices
,
46 const wxValidator
& validator
,
47 const wxString
& name
)
49 m_hasCheckBoxes
= TRUE
;
50 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
53 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
56 const wxArrayString
& choices
,
58 const wxValidator
& validator
,
59 const wxString
& name
)
61 m_hasCheckBoxes
= TRUE
;
62 wxListBox::Create( parent
, id
, pos
, size
, choices
,
63 style
, validator
, name
);
66 bool wxCheckListBox::IsChecked( int index
) const
68 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
70 GList
*child
= g_list_nth( m_list
->children
, index
);
73 GtkBin
*bin
= GTK_BIN( child
->data
);
74 GtkLabel
*label
= GTK_LABEL( bin
->child
);
76 wxString
str( wxGTK_CONV_BACK( label
->label
) );
78 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
81 wxFAIL_MSG(wxT("wrong checklistbox index"));
85 void wxCheckListBox::Check( int index
, bool check
)
87 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
89 GList
*child
= g_list_nth( m_list
->children
, index
);
92 GtkBin
*bin
= GTK_BIN( child
->data
);
93 GtkLabel
*label
= GTK_LABEL( bin
->child
);
95 wxString
str( wxGTK_CONV_BACK( label
->label
) );
97 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
100 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
102 gtk_label_set_text( label
, wxGTK_CONV( str
) );
107 wxFAIL_MSG(wxT("wrong checklistbox index"));
110 int wxCheckListBox::GetItemHeight() const