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