]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
A little clarification
[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
ff8bfdbb 7// Licence: wxWindows licence
caaa4cfd
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
caaa4cfd
RR
11#pragma implementation "checklst.h"
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
1e6feb95 17#include "wx/defs.h"
caaa4cfd 18
dcf924a3
RR
19#if wxUSE_CHECKLISTBOX
20
1e6feb95 21#include "wx/checklst.h"
fab591c5 22#include "wx/gtk/private.h"
1e6feb95 23
071a2d78
RR
24#include <gdk/gdk.h>
25#include <gtk/gtk.h>
83624f79 26
caaa4cfd 27//-----------------------------------------------------------------------------
1169a919
JS
28// wxCheckListBoxBase
29//-----------------------------------------------------------------------------
30
31wxCheckListBoxBase::wxCheckListBoxBase()
32{
33}
34
35//-----------------------------------------------------------------------------
caaa4cfd
RR
36// wxCheckListBox
37//-----------------------------------------------------------------------------
38
39IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
40
88ac883a 41wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
42{
43 m_hasCheckBoxes = TRUE;
44}
bbe0af5b 45
caaa4cfd 46wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
d752a3c3
VZ
47 const wxPoint& pos,
48 const wxSize& size,
49 int nStrings,
50 const wxString *choices,
51 long style,
52 const wxValidator& validator,
53 const wxString& name )
caaa4cfd
RR
54{
55 m_hasCheckBoxes = TRUE;
56 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
57}
58
59bool wxCheckListBox::IsChecked( int index ) const
60{
223d09f6 61 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
ff8bfdbb 62
caaa4cfd
RR
63 GList *child = g_list_nth( m_list->children, index );
64 if (child)
65 {
66 GtkBin *bin = GTK_BIN( child->data );
67 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 68
fab591c5 69 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 70
d752a3c3 71 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 72 }
ff8bfdbb 73
223d09f6 74 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
75 return FALSE;
76}
77
78void wxCheckListBox::Check( int index, bool check )
79{
223d09f6 80 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 81
caaa4cfd
RR
82 GList *child = g_list_nth( m_list->children, index );
83 if (child)
84 {
85 GtkBin *bin = GTK_BIN( child->data );
86 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 87
fab591c5 88 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 89
d752a3c3
VZ
90 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
91 return;
ff8bfdbb 92
d752a3c3 93 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 94
fab591c5 95 gtk_label_set( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
96
97 return;
caaa4cfd 98 }
ff8bfdbb 99
223d09f6 100 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
101}
102
ff8bfdbb 103int wxCheckListBox::GetItemHeight() const
4f22cf8d 104{
ff8bfdbb 105 // FIXME
4f22cf8d
RR
106 return 22;
107}
dcf924a3
RR
108
109#endif