]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/checklst.cpp
Start/EndDrawingOnTop are still used under Motif, don't deprecate them
[wxWidgets.git] / src / gtk1 / 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
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
1e6feb95 13#include "wx/defs.h"
caaa4cfd 14
dcf924a3
RR
15#if wxUSE_CHECKLISTBOX
16
1e6feb95 17#include "wx/checklst.h"
fab591c5 18#include "wx/gtk/private.h"
1e6feb95 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
584ad2a3
MB
47wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
48 const wxPoint& pos,
49 const wxSize& size,
50 const wxArrayString& choices,
51 long style,
52 const wxValidator& validator,
53 const wxString& name )
54{
55 m_hasCheckBoxes = TRUE;
56 wxListBox::Create( parent, id, pos, size, choices,
57 style, validator, name );
58}
59
caaa4cfd
RR
60bool wxCheckListBox::IsChecked( int index ) const
61{
223d09f6 62 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
ff8bfdbb 63
caaa4cfd
RR
64 GList *child = g_list_nth( m_list->children, index );
65 if (child)
66 {
67 GtkBin *bin = GTK_BIN( child->data );
68 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 69
fab591c5 70 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 71
d752a3c3 72 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
caaa4cfd 73 }
ff8bfdbb 74
223d09f6 75 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
76 return FALSE;
77}
78
79void wxCheckListBox::Check( int index, bool check )
80{
223d09f6 81 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
ff8bfdbb 82
caaa4cfd
RR
83 GList *child = g_list_nth( m_list->children, index );
84 if (child)
85 {
86 GtkBin *bin = GTK_BIN( child->data );
87 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb 88
fab591c5 89 wxString str( wxGTK_CONV_BACK( label->label ) );
ff8bfdbb 90
d752a3c3
VZ
91 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
92 return;
ff8bfdbb 93
d752a3c3 94 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
ff8bfdbb 95
fab591c5 96 gtk_label_set( label, wxGTK_CONV( str ) );
ff8bfdbb
VZ
97
98 return;
caaa4cfd 99 }
ff8bfdbb 100
223d09f6 101 wxFAIL_MSG(wxT("wrong checklistbox index"));
caaa4cfd
RR
102}
103
ff8bfdbb 104int wxCheckListBox::GetItemHeight() const
4f22cf8d 105{
ff8bfdbb 106 // FIXME
4f22cf8d
RR
107 return 22;
108}
dcf924a3
RR
109
110#endif