]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/checklst.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "checklst.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
19 #if wxUSE_CHECKLISTBOX
21 #include "wx/checklst.h"
22 #include "wx/gtk/private.h"
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
33 wxCheckListBox::wxCheckListBox() : wxListBox()
35 m_hasCheckBoxes
= TRUE
;
38 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
42 const wxString
*choices
,
44 const wxValidator
& validator
,
45 const wxString
& name
)
47 m_hasCheckBoxes
= TRUE
;
48 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
51 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
54 const wxArrayString
& choices
,
56 const wxValidator
& validator
,
57 const wxString
& name
)
59 m_hasCheckBoxes
= TRUE
;
60 wxListBox::Create( parent
, id
, pos
, size
, choices
,
61 style
, validator
, name
);
64 bool wxCheckListBox::IsChecked( int index
) const
66 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
68 GList
*child
= g_list_nth( m_list
->children
, index
);
71 GtkBin
*bin
= GTK_BIN( child
->data
);
72 GtkLabel
*label
= GTK_LABEL( bin
->child
);
74 wxString
str( wxGTK_CONV_BACK( label
->label
) );
76 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
79 wxFAIL_MSG(wxT("wrong checklistbox index"));
83 void wxCheckListBox::Check( int index
, bool check
)
85 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
87 GList
*child
= g_list_nth( m_list
->children
, index
);
90 GtkBin
*bin
= GTK_BIN( child
->data
);
91 GtkLabel
*label
= GTK_LABEL( bin
->child
);
93 wxString
str( wxGTK_CONV_BACK( label
->label
) );
95 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
98 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
100 gtk_label_set( label
, wxGTK_CONV( str
) );
105 wxFAIL_MSG(wxT("wrong checklistbox index"));
108 int wxCheckListBox::GetItemHeight() const