]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/control.cpp
Changed stopat to stopafter in CountColours
[wxWidgets.git] / src / motif / control.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: control.cpp
3// Purpose: wxControl class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "control.h"
14#endif
15
16#include "wx/control.h"
17#include "wx/panel.h"
18#include "wx/utils.h"
19
20#ifdef __VMS__
21#pragma message disable nosimpint
22#endif
23#include <Xm/Xm.h>
24#ifdef __VMS__
25#pragma message enable nosimpint
26#endif
27
28IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
29
30BEGIN_EVENT_TABLE(wxControl, wxWindow)
31END_EVENT_TABLE()
32
33// Item members
34wxControl::wxControl()
35{
36 m_backgroundColour = *wxWHITE;
37 m_foregroundColour = *wxBLACK;
38
39#if WXWIN_COMPATIBILITY
40 m_callback = 0;
41#endif // WXWIN_COMPATIBILITY
42
43 m_inSetValue = FALSE;
44}
45
46wxControl::~wxControl()
47{
48 // If we delete an item, we should initialize the parent panel,
49 // because it could now be invalid.
50 wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
51 if (panel)
52 {
53 if (panel->GetDefaultItem() == this)
54 panel->SetDefaultItem((wxButton*) NULL);
55 }
56}
57
58void wxControl::SetLabel(const wxString& label)
59{
60 Widget widget = (Widget) GetLabelWidget() ;
61 if (!widget)
62 return;
63
64 wxStripMenuCodes((char*) (const char*) label, wxBuffer);
65
66 XmString text = XmStringCreateSimple (wxBuffer);
67 XtVaSetValues (widget,
68 XmNlabelString, text,
69 XmNlabelType, XmSTRING,
70 NULL);
71 XmStringFree (text);
72}
73
74wxString wxControl::GetLabel() const
75{
76 Widget widget = (Widget) GetLabelWidget() ;
77 if (!widget)
78 return wxEmptyString;
79
80 XmString text;
81 char *s;
82 XtVaGetValues (widget,
83 XmNlabelString, &text,
84 NULL);
85
86 if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
87 {
88 wxString str(s);
89 XtFree (s);
90 XmStringFree(text);
91 return str;
92 }
93 else
94 {
95 // XmStringFree(text);
96 return wxEmptyString;
97 }
98}
99
100bool wxControl::ProcessCommand(wxCommandEvent & event)
101{
102#if WXWIN_COMPATIBILITY
103 if ( m_callback )
104 {
105 (void)(*m_callback)(this, event);
106
107 return TRUE;
108 }
109 else
110#endif // WXWIN_COMPATIBILITY
111
112 return GetEventHandler()->ProcessEvent(event);
113}