]>
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 #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 wxCheckListBoxBase::wxCheckListBoxBase()
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox
,wxListBox
)
41 wxCheckListBox::wxCheckListBox() : wxListBox()
43 m_hasCheckBoxes
= TRUE
;
46 wxCheckListBox::wxCheckListBox(wxWindow
*parent
, wxWindowID id
,
50 const wxString
*choices
,
52 const wxValidator
& validator
,
53 const wxString
& name
)
55 m_hasCheckBoxes
= TRUE
;
56 wxListBox::Create( parent
, id
, pos
, size
, nStrings
, choices
, style
, validator
, name
);
59 bool wxCheckListBox::IsChecked( int index
) const
61 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
63 GList
*child
= g_list_nth( m_list
->children
, index
);
66 GtkBin
*bin
= GTK_BIN( child
->data
);
67 GtkLabel
*label
= GTK_LABEL( bin
->child
);
69 wxString
str( wxGTK_CONV_BACK( label
->label
) );
71 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
74 wxFAIL_MSG(wxT("wrong checklistbox index"));
78 void wxCheckListBox::Check( int index
, bool check
)
80 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
82 GList
*child
= g_list_nth( m_list
->children
, index
);
85 GtkBin
*bin
= GTK_BIN( child
->data
);
86 GtkLabel
*label
= GTK_LABEL( bin
->child
);
88 wxString
str( wxGTK_CONV_BACK( label
->label
) );
90 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
93 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
95 gtk_label_set( label
, wxGTK_CONV( str
) );
100 wxFAIL_MSG(wxT("wrong checklistbox index"));
103 int wxCheckListBox::GetItemHeight() const