]>
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 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 bool wxCheckListBox::IsChecked( int index
) const
53 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid checklistbox") );
55 GList
*child
= g_list_nth( m_list
->children
, index
);
58 GtkBin
*bin
= GTK_BIN( child
->data
);
59 GtkLabel
*label
= GTK_LABEL( bin
->child
);
61 wxString
str( wxGTK_CONV_BACK( label
->label
) );
63 return str
.GetChar(1) == wxCHECKLBOX_CHECKED
;
66 wxFAIL_MSG(wxT("wrong checklistbox index"));
70 void wxCheckListBox::Check( int index
, bool check
)
72 wxCHECK_RET( m_list
!= NULL
, wxT("invalid checklistbox") );
74 GList
*child
= g_list_nth( m_list
->children
, index
);
77 GtkBin
*bin
= GTK_BIN( child
->data
);
78 GtkLabel
*label
= GTK_LABEL( bin
->child
);
80 wxString
str( wxGTK_CONV_BACK( label
->label
) );
82 if (check
== (str
.GetChar(1) == wxCHECKLBOX_CHECKED
))
85 str
.SetChar( 1, check
? wxCHECKLBOX_CHECKED
: wxCHECKLBOX_UNCHECKED
);
87 gtk_label_set( label
, wxGTK_CONV( str
) );
92 wxFAIL_MSG(wxT("wrong checklistbox index"));
95 int wxCheckListBox::GetItemHeight() const