]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "control.h"
16 #include "wx/control.h"
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
24 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
29 wxControl::wxControl()
31 m_backgroundColour
= *wxWHITE
;
32 m_foregroundColour
= *wxBLACK
;
37 wxControl::~wxControl()
39 // If we delete an item, we should initialize the parent panel,
40 // because it could now be invalid.
43 wxWindow *parent = (wxWindow *)GetParent();
46 if (parent->GetDefaultItem() == (wxButton*) this)
47 parent->SetDefaultItem((wxButton*) NULL);
52 void wxControl::SetLabel(const wxString
& label
)
54 Widget widget
= (Widget
) GetLabelWidget() ;
58 wxStripMenuCodes((char*) (const char*) label
, wxBuffer
);
60 XmString text
= XmStringCreateSimple (wxBuffer
);
61 XtVaSetValues (widget
,
63 XmNlabelType
, XmSTRING
,
68 wxString
wxControl::GetLabel() const
70 Widget widget
= (Widget
) GetLabelWidget() ;
76 XtVaGetValues (widget
,
77 XmNlabelString
, &text
,
80 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
89 // XmStringFree(text);
94 void wxControl::ProcessCommand (wxCommandEvent
& event
)
97 // 1) A callback function (to become obsolete)
98 // 2) OnCommand, starting at this window and working up parent hierarchy
99 // 3) OnCommand then calls ProcessEvent to search the event tables.
102 (void) (*(m_callback
)) (*this, event
);
106 GetEventHandler()->OnCommand(*this, event
);
110 void wxControl::Centre (int direction
)
112 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
114 wxWindow
*parent
= (wxWindow
*) GetParent ();
118 parent
->GetClientSize (&panel_width
, &panel_height
);
119 GetSize (&width
, &height
);
120 GetPosition (&x
, &y
);
125 if (direction
& wxHORIZONTAL
)
126 new_x
= (int) ((panel_width
- width
) / 2);
128 if (direction
& wxVERTICAL
)
129 new_y
= (int) ((panel_height
- height
) / 2);
131 SetSize (new_x
, new_y
, width
, height
);