]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/checklst.cpp
resize fun
[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
14#include "wx/checklst.h"
15
83624f79
RR
16#include "gdk/gdk.h"
17#include "gtk/gtk.h"
18
caaa4cfd
RR
19//-----------------------------------------------------------------------------
20// wxCheckListBox
21//-----------------------------------------------------------------------------
22
23IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
24
25wxCheckListBox::wxCheckListBox() :
26 wxListBox()
27{
28 m_hasCheckBoxes = TRUE;
29}
bbe0af5b 30
caaa4cfd 31wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
bbe0af5b
RR
32 const wxPoint& pos,
33 const wxSize& size,
3f263f45
VZ
34 int nStrings,
35 const wxString *choices,
bbe0af5b
RR
36 long style,
37 const wxValidator& validator,
38 const wxString& name )
caaa4cfd
RR
39{
40 m_hasCheckBoxes = TRUE;
41 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
42}
43
44bool wxCheckListBox::IsChecked( int index ) const
45{
46 wxCHECK_MSG( m_list != NULL, FALSE, "invalid checklistbox" );
ff8bfdbb 47
caaa4cfd
RR
48 GList *child = g_list_nth( m_list->children, index );
49 if (child)
50 {
51 GtkBin *bin = GTK_BIN( child->data );
52 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb
VZ
53
54 wxString str = label->label;
55
caaa4cfd
RR
56 return (str[1] == 'X');
57 }
ff8bfdbb 58
caaa4cfd
RR
59 wxFAIL_MSG("wrong checklistbox index");
60 return FALSE;
61}
62
63void wxCheckListBox::Check( int index, bool check )
64{
65 wxCHECK_RET( m_list != NULL, "invalid checklistbox" );
ff8bfdbb 66
caaa4cfd
RR
67 GList *child = g_list_nth( m_list->children, index );
68 if (child)
69 {
70 GtkBin *bin = GTK_BIN( child->data );
71 GtkLabel *label = GTK_LABEL( bin->child );
ff8bfdbb
VZ
72
73 wxString str = label->label;
74
caaa4cfd 75 if (check == (str[1] == 'X')) return;
ff8bfdbb
VZ
76
77 if (check)
78 str.SetChar( 1, 'X' );
79 else
80 str.SetChar( 1, '-' );
81
82 gtk_label_set( label, str );
83
84 return;
caaa4cfd 85 }
ff8bfdbb 86
caaa4cfd
RR
87 wxFAIL_MSG("wrong checklistbox index");
88}
89
ff8bfdbb 90int wxCheckListBox::GetItemHeight() const
4f22cf8d 91{
ff8bfdbb 92 // FIXME
4f22cf8d
RR
93 return 22;
94}