]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/checklst.cpp
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"
13 #if wxUSE_CHECKLISTBOX
15 #include "wx/checklst.h"
16 #include "wx/gtk1/private.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 wxCheckListBox::wxCheckListBox() : wxCheckListBoxBase()
27 m_hasCheckBoxes
= true;
30 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
34 const wxString
*choices
,
36 const wxValidator
& validator
,
37 const wxString
& name
)
39 m_hasCheckBoxes
= true;
40 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
43 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
46 const wxArrayString
& choices
,
48 const wxValidator
& validator
,
49 const wxString
& name
)
51 m_hasCheckBoxes
= true;
52 wxListBox::Create( parent
, id
, pos
, size
, choices
,
53 style
, validator
, name
);
56 bool wxCheckListBox::IsChecked(unsigned int index
) const
58 wxCHECK_MSG( m_list
!= NULL
, false, wxT("invalid checklistbox") );
60 GList
*child
= g_list_nth( m_list
->children
, index
);
63 GtkBin
*bin
= GTK_BIN( child
->data
);
64 GtkLabel
*label
= GTK_LABEL( bin
->child
);
66 wxString
str( wxGTK_CONV_BACK( label
->label
) );
68 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
71 wxFAIL_MSG(wxT("wrong checklistbox index"));
75 void wxCheckListBox::Check(unsigned int index
, bool check
)
77 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
79 GList
*child
= g_list_nth( m_list
->children
, index
);
82 GtkBin
*bin
= GTK_BIN( child
->data
);
83 GtkLabel
*label
= GTK_LABEL( bin
->child
);
85 wxString
str( wxGTK_CONV_BACK( label
->label
) );
87 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
90 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
92 gtk_label_set( label
, wxGTK_CONV( str
) );
97 wxFAIL_MSG(wxT("wrong checklistbox index"));
100 int wxCheckListBox::GetItemHeight() const