]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
Child positioning fixes and font adjustments
[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
10#ifdef __GNUG__
11#pragma implementation "checklst.h"
12#endif
13
1e6feb95 14#include "wx/defs.h"
caaa4cfd 15
dcf924a3
RR
16#if wxUSE_CHECKLISTBOX
17
1e6feb95
VZ
18#include "wx/checklst.h"
19
071a2d78
RR
20#include <gdk/gdk.h>
21#include <gtk/gtk.h>
83624f79 22
caaa4cfd
RR
23//-----------------------------------------------------------------------------
24// wxCheckListBox
25//-----------------------------------------------------------------------------
26
27IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
28
88ac883a 29wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd
RR
30{
31 m_hasCheckBoxes = TRUE;
32}
bbe0af5b 33
caaa4cfd 34wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
d752a3c3
VZ
35 const wxPoint& pos,
36 const wxSize& size,
37 int nStrings,
38 const wxString *choices,
39 long style,
40 const wxValidator& validator,
41 const wxString& name )
caaa4cfd
RR
42{
43 m_hasCheckBoxes = TRUE;
44 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
45}
46
47bool wxCheckListBox::IsChecked( int index ) const
48{
223d09f6 49 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
ff8bfdbb 50
caaa4cfd
RR
51 GList *child = g_list_nth( m_list->children, index );
52 if (child)
53 {
54 GtkBin *bin = GTK_BIN( child->data );
55 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 56
9b7e522a 57 wxString str = wxString(label->label,*wxConvCurrent);
ff8bfdbb 58
d752a3c3 59 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 60 }
ff8bfdbb 61
223d09f6 62 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
63 return FALSE;
64}
65
66void wxCheckListBox::Check( int index, bool check )
67{
223d09f6 68 wxCHECK_RET( m_list != NULL, 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
dcf924a3 76 wxString str = wxString(label->label,*wxConvCurrent);
ff8bfdbb 77
d752a3c3
VZ
78 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
79 return;
ff8bfdbb 80
d752a3c3 81 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 82
93c5dd39 83 gtk_label_set( label, str.mbc_str() );
ff8bfdbb
VZ
84
85 return;
caaa4cfd 86 }
ff8bfdbb 87
223d09f6 88 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
89}
90
ff8bfdbb 91int wxCheckListBox::GetItemHeight() const
4f22cf8d 92{
ff8bfdbb 93 // FIXME
4f22cf8d
RR
94 return 22;
95}
dcf924a3
RR
96
97#endif