]>
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
;
36 wxControl::~wxControl()
38 // If we delete an item, we should initialize the parent panel,
39 // because it could now be invalid.
40 wxWindow
*parent
= (wxWindow
*)GetParent();
43 if (parent
->GetDefaultItem() == (wxButton
*) this)
44 parent
->SetDefaultItem(NULL
);
48 void wxControl::SetLabel(const wxString
& label
)
53 wxStripMenuCodes((char*) (const char*) label
, wxBuffer
);
55 XmString text
= XmStringCreateSimple (wxBuffer
);
56 XtVaSetValues ((Widget
) GetMainWidget(),
58 XmNlabelType
, XmSTRING
,
63 wxString
wxControl::GetLabel() const
70 XtVaGetValues ((Widget
) GetMainWidget(),
71 XmNlabelString
, &text
,
74 if (XmStringGetLtoR (text
, XmSTRING_DEFAULT_CHARSET
, &s
))
88 void wxControl::ProcessCommand (wxCommandEvent
& event
)
91 // 1) A callback function (to become obsolete)
92 // 2) OnCommand, starting at this window and working up parent hierarchy
93 // 3) OnCommand then calls ProcessEvent to search the event tables.
96 (void) (*(m_callback
)) (*this, event
);
100 GetEventHandler()->OnCommand(*this, event
);
104 void wxControl::Centre (int direction
)
106 int x
, y
, width
, height
, panel_width
, panel_height
, new_x
, new_y
;
108 wxWindow
*parent
= (wxWindow
*) GetParent ();
112 parent
->GetClientSize (&panel_width
, &panel_height
);
113 GetSize (&width
, &height
);
114 GetPosition (&x
, &y
);
119 if (direction
& wxHORIZONTAL
)
120 new_x
= (int) ((panel_width
- width
) / 2);
122 if (direction
& wxVERTICAL
)
123 new_y
= (int) ((panel_height
- height
) / 2);
125 SetSize (new_x
, new_y
, width
, height
);