]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
Further sorting work using the sorting data model.
[wxWidgets.git] / src / gtk / checklst.cpp
CommitLineData
caaa4cfd
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: checklst.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
caaa4cfd
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
1e6feb95 13#include "wx/defs.h"
caaa4cfd 14
dcf924a3
RR
15#if wxUSE_CHECKLISTBOX
16
1e6feb95 17#include "wx/checklst.h"
1efb5db8
MR
18
19// FIXME: We use GtkList to implement wxListBox
20#ifdef GTK_DISABLE_DEPRECATED
21#undef GTK_DISABLE_DEPRECATED
22#endif
23
fab591c5 24#include "wx/gtk/private.h"
1e6feb95 25
071a2d78
RR
26#include <gdk/gdk.h>
27#include <gtk/gtk.h>
83624f79 28
caaa4cfd
RR
29//-----------------------------------------------------------------------------
30// wxCheckListBox
31//-----------------------------------------------------------------------------
32
33IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
34
88ac883a 35wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
36{
37 m_hasCheckBoxes = TRUE;
38}
bbe0af5b 39
caaa4cfd 40wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
d752a3c3
VZ
41 const wxPoint& pos,
42 const wxSize& size,
3d257b8d 43 int nStrings,
d752a3c3
VZ
44 const wxString *choices,
45 long style,
46 const wxValidator& validator,
47 const wxString& name )
caaa4cfd
RR
48{
49 m_hasCheckBoxes = TRUE;
50 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
51}
52
584ad2a3
MB
53wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
54 const wxPoint& pos,
55 const wxSize& size,
56 const wxArrayString& choices,
57 long style,
58 const wxValidator& validator,
59 const wxString& name )
60{
61 m_hasCheckBoxes = TRUE;
62 wxListBox::Create( parent, id, pos, size, choices,
63 style, validator, name );
64}
65
caaa4cfd
RR
66bool wxCheckListBox::IsChecked( int index ) const
67{
223d09f6 68 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
ff8bfdbb 69
caaa4cfd
RR
70 GList *child = g_list_nth( m_list->children, index );
71 if (child)
72 {
73 GtkBin *bin = GTK_BIN( child->data );
74 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 75
fab591c5 76 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 77
d752a3c3 78 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 79 }
ff8bfdbb 80
223d09f6 81 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
82 return FALSE;
83}
84
85void wxCheckListBox::Check( int index, bool check )
86{
223d09f6 87 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 88
caaa4cfd
RR
89 GList *child = g_list_nth( m_list->children, index );
90 if (child)
91 {
92 GtkBin *bin = GTK_BIN( child->data );
93 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 94
fab591c5 95 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 96
d752a3c3
VZ
97 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
98 return;
ff8bfdbb 99
d752a3c3 100 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 101
a7c12d28 102 gtk_label_set_text( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
103
104 return;
caaa4cfd 105 }
ff8bfdbb 106
223d09f6 107 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
108}
109
ff8bfdbb 110int wxCheckListBox::GetItemHeight() const
4f22cf8d 111{
ff8bfdbb 112 // FIXME
4f22cf8d
RR
113 return 22;
114}
dcf924a3
RR
115
116#endif