]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/checklst.cpp
compile fix
[wxWidgets.git] / src / gtk1 / checklst.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: checklst.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11#pragma implementation "checklst.h"
12#endif
13
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
17#include "wx/defs.h"
18
19#if wxUSE_CHECKLISTBOX
20
21#include "wx/checklst.h"
22#include "wx/gtk/private.h"
23
24#include <gdk/gdk.h>
25#include <gtk/gtk.h>
26
27//-----------------------------------------------------------------------------
28// wxCheckListBox
29//-----------------------------------------------------------------------------
30
31IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox)
32
33wxCheckListBox::wxCheckListBox() : wxListBox()
34{
35 m_hasCheckBoxes = TRUE;
36}
37
38wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
39 const wxPoint& pos,
40 const wxSize& size,
41 int nStrings,
42 const wxString *choices,
43 long style,
44 const wxValidator& validator,
45 const wxString& name )
46{
47 m_hasCheckBoxes = TRUE;
48 wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name );
49}
50
51wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
52 const wxPoint& pos,
53 const wxSize& size,
54 const wxArrayString& choices,
55 long style,
56 const wxValidator& validator,
57 const wxString& name )
58{
59 m_hasCheckBoxes = TRUE;
60 wxListBox::Create( parent, id, pos, size, choices,
61 style, validator, name );
62}
63
64bool wxCheckListBox::IsChecked( int index ) const
65{
66 wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") );
67
68 GList *child = g_list_nth( m_list->children, index );
69 if (child)
70 {
71 GtkBin *bin = GTK_BIN( child->data );
72 GtkLabel *label = GTK_LABEL( bin->child );
73
74 wxString str( wxGTK_CONV_BACK( label->label ) );
75
76 return str.GetChar(1) == wxCHECKLBOX_CHECKED;
77 }
78
79 wxFAIL_MSG(wxT("wrong checklistbox index"));
80 return FALSE;
81}
82
83void wxCheckListBox::Check( int index, bool check )
84{
85 wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") );
86
87 GList *child = g_list_nth( m_list->children, index );
88 if (child)
89 {
90 GtkBin *bin = GTK_BIN( child->data );
91 GtkLabel *label = GTK_LABEL( bin->child );
92
93 wxString str( wxGTK_CONV_BACK( label->label ) );
94
95 if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
96 return;
97
98 str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
99
100 gtk_label_set( label, wxGTK_CONV( str ) );
101
102 return;
103 }
104
105 wxFAIL_MSG(wxT("wrong checklistbox index"));
106}
107
108int wxCheckListBox::GetItemHeight() const
109{
110 // FIXME
111 return 22;
112}
113
114#endif