]>
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 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
27 wxCheckListBox::wxCheckListBox() : wxListBox()
29 m_hasCheckBoxes
= true;
32 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
36 const wxString
*choices
,
38 const wxValidator
& validator
,
39 const wxString
& name
)
41 m_hasCheckBoxes
= true;
42 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
45 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
48 const wxArrayString
& choices
,
50 const wxValidator
& validator
,
51 const wxString
& name
)
53 m_hasCheckBoxes
= true;
54 wxListBox::Create( parent
, id
, pos
, size
, choices
,
55 style
, validator
, name
);
58 bool wxCheckListBox::IsChecked(unsigned int index
) const
60 wxCHECK_MSG( m_list
!= NULL
, false, wxT("invalid checklistbox") );
62 GList
*child
= g_list_nth( m_list
->children
, index
);
65 GtkBin
*bin
= GTK_BIN( child
->data
);
66 GtkLabel
*label
= GTK_LABEL( bin
->child
);
68 wxString
str( wxGTK_CONV_BACK( label
->label
) );
70 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
73 wxFAIL_MSG(wxT("wrong checklistbox index"));
77 void wxCheckListBox::Check(unsigned int index
, bool check
)
79 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
81 GList
*child
= g_list_nth( m_list
->children
, index
);
84 GtkBin
*bin
= GTK_BIN( child
->data
);
85 GtkLabel
*label
= GTK_LABEL( bin
->child
);
87 wxString
str( wxGTK_CONV_BACK( label
->label
) );
89 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
92 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
94 gtk_label_set( label
, wxGTK_CONV( str
) );
99 wxFAIL_MSG(wxT("wrong checklistbox index"));
102 int wxCheckListBox::GetItemHeight() const