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