]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/checklst.cpp
Sun CC doesn't allow calling static function from template instantiations so rename...
[wxWidgets.git] / src / gtk1 / checklst.cpp
CommitLineData
caaa4cfd 1/////////////////////////////////////////////////////////////////////////////
caf6e6de 2// Name: src/gtk1/checklst.cpp
caaa4cfd
RR
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
dcf924a3
RR
13#if wxUSE_CHECKLISTBOX
14
1e6feb95 15#include "wx/checklst.h"
3cbab641 16#include "wx/gtk1/private.h"
1e6feb95 17
071a2d78
RR
18#include <gdk/gdk.h>
19#include <gtk/gtk.h>
83624f79 20
caaa4cfd
RR
21//-----------------------------------------------------------------------------
22// wxCheckListBox
23//-----------------------------------------------------------------------------
24
25IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
26
88ac883a 27wxCheckListBox::wxCheckListBox() : wxListBox()
caaa4cfd 28{
caf6e6de 29 m_hasCheckBoxes = true;
caaa4cfd 30}
bbe0af5b 31
caaa4cfd 32wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
d752a3c3
VZ
33 const wxPoint& pos,
34 const wxSize& size,
3d257b8d 35 int nStrings,
d752a3c3
VZ
36 const wxString *choices,
37 long style,
38 const wxValidator& validator,
39 const wxString& name )
caaa4cfd 40{
caf6e6de 41 m_hasCheckBoxes = true;
caaa4cfd
RR
42 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
43}
44
584ad2a3
MB
45wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
46 const wxPoint& pos,
47 const wxSize& size,
48 const wxArrayString& choices,
49 long style,
50 const wxValidator& validator,
51 const wxString& name )
52{
caf6e6de 53 m_hasCheckBoxes = true;
584ad2a3
MB
54 wxListBox::Create( parent, id, pos, size, choices,
55 style, validator, name );
56}
57
aa61d352 58bool wxCheckListBox::IsChecked(unsigned int index) const
caaa4cfd 59{
caf6e6de 60 wxCHECK_MSG( m_list != NULL, false, wxT("invalid checklistbox") );
ff8bfdbb 61
caaa4cfd
RR
62 GList *child = g_list_nth( m_list->children, index );
63 if (child)
64 {
65 GtkBin *bin = GTK_BIN( child->data );
66 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 67
fab591c5 68 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 69
d752a3c3 70 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 71 }
ff8bfdbb 72
223d09f6 73 wxFAIL_MSG(wxT("wrong checklistbox index"));
caf6e6de 74 return false;
caaa4cfd
RR
75}
76
aa61d352 77void wxCheckListBox::Check(unsigned int index, bool check )
caaa4cfd 78{
223d09f6 79 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 80
caaa4cfd
RR
81 GList *child = g_list_nth( m_list->children, index );
82 if (child)
83 {
84 GtkBin *bin = GTK_BIN( child->data );
85 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 86
fab591c5 87 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 88
d752a3c3
VZ
89 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
90 return;
ff8bfdbb 91
d752a3c3 92 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 93
fab591c5 94 gtk_label_set( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
95
96 return;
caaa4cfd 97 }
ff8bfdbb 98
223d09f6 99 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
100}
101
ff8bfdbb 102int wxCheckListBox::GetItemHeight() const
4f22cf8d 103{
ff8bfdbb 104 // FIXME
4f22cf8d
RR
105 return 22;
106}
dcf924a3
RR
107
108#endif