]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/checklst.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
12 #if wxUSE_CHECKLISTBOX
14 #include "wx/checklst.h"
15 #include "wx/gtk1/private.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 wxCheckListBox::wxCheckListBox() : wxCheckListBoxBase()
26 m_hasCheckBoxes
= true;
29 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
33 const wxString
*choices
,
35 const wxValidator
& validator
,
36 const wxString
& name
)
38 m_hasCheckBoxes
= true;
39 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
42 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
45 const wxArrayString
& choices
,
47 const wxValidator
& validator
,
48 const wxString
& name
)
50 m_hasCheckBoxes
= true;
51 wxListBox::Create( parent
, id
, pos
, size
, choices
,
52 style
, validator
, name
);
55 bool wxCheckListBox::IsChecked(unsigned int index
) const
57 wxCHECK_MSG( m_list
!= NULL
, false, wxT("invalid checklistbox") );
59 GList
*child
= g_list_nth( m_list
->children
, index
);
62 GtkBin
*bin
= GTK_BIN( child
->data
);
63 GtkLabel
*label
= GTK_LABEL( bin
->child
);
65 wxString
str( wxGTK_CONV_BACK( label
->label
) );
67 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
70 wxFAIL_MSG(wxT("wrong checklistbox index"));
74 void wxCheckListBox::Check(unsigned int index
, bool check
)
76 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
78 GList
*child
= g_list_nth( m_list
->children
, index
);
81 GtkBin
*bin
= GTK_BIN( child
->data
);
82 GtkLabel
*label
= GTK_LABEL( bin
->child
);
84 wxString
str( wxGTK_CONV_BACK( label
->label
) );
86 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
89 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
91 gtk_label_set( label
, wxGTK_CONV( str
) );
96 wxFAIL_MSG(wxT("wrong checklistbox index"));
99 int wxCheckListBox::GetItemHeight() const