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