]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: David Webster
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "control.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
22 #include "wx/dcclient.h"
24 #include "wx/os2/private.h"
25 #include "wx/control.h"
27 #if !USE_SHARED_LIBRARY
28 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
30 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
31 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
36 wxControl::wxControl()
38 m_backgroundColour
= *wxWHITE
;
39 m_foregroundColour
= *wxBLACK
;
41 #if WXWIN_COMPATIBILITY
43 #endif // WXWIN_COMPATIBILITY
46 wxControl::~wxControl()
48 m_isBeingDeleted
= TRUE
;
51 bool wxControl::OS2CreateControl(const wxChar
*classname
, WXDWORD style
)
53 m_hWnd
= (WXHWND
)::WinCreateWindow( GetHwndOf(GetParent())
69 wxLogError(wxT("Failed to create a control of class '%s'"), classname
);
75 // subclass again for purposes of dialog editing mode
78 // controls use the same font and colours as their parent dialog by default
84 wxSize
wxControl::DoGetBestSize() const
86 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
89 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
91 #if WXWIN_COMPATIBILITY
94 (void)(*m_callback
)(this, event
);
99 #endif // WXWIN_COMPATIBILITY
101 return GetEventHandler()->ProcessEvent(event
);
104 bool wxControl::OS2OnNotify(int idCtrl
,
108 wxCommandEvent
event(wxEVT_NULL
, m_windowId
);
109 wxEventType eventType
= wxEVT_NULL
;
111 NMHDR *hdr1 = (NMHDR*) lParam;
112 switch ( hdr1->code )
115 eventType = wxEVT_COMMAND_LEFT_CLICK;
119 eventType = wxEVT_COMMAND_LEFT_DCLICK;
123 eventType = wxEVT_COMMAND_RIGHT_CLICK;
127 eventType = wxEVT_COMMAND_RIGHT_DCLICK;
131 eventType = wxEVT_COMMAND_SET_FOCUS;
135 eventType = wxEVT_COMMAND_KILL_FOCUS;
139 eventType = wxEVT_COMMAND_ENTER;
143 return wxWindow::OS2OnNotify(idCtrl, lParam, result);
146 event
.SetEventType(eventType
);
147 event
.SetEventObject(this);
149 return GetEventHandler()->ProcessEvent(event
);
152 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
154 // In general, you don't want to erase the background of a control,
155 // or you'll get a flicker.
156 // TODO: move this 'null' function into each control that
162 * TODO: convert to PM Code
163 * ::GetClientRect((HWND) GetHWND(), &rect);
165 * HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(),
166 * GetBackgroundColour().Green(),
167 * GetBackgroundColour().Blue()));
168 * int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
170 * ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
171 * ::DeleteObject(hBrush);
172 * ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
176 WXDWORD
wxControl::GetExStyle(WXDWORD
& style
) const
179 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
181 // Even with extended styles, need to combine with FS_BORDER
182 // for them to look right. Check it out later, base window style does
183 // not designate BORDERS. Down in Frame and And controls.
185 if ( want3D
|| wxStyleHasBorder(m_windowStyle
) )
191 // ---------------------------------------------------------------------------
193 // ---------------------------------------------------------------------------
195 // Call this repeatedly for several wnds to find the overall size
197 // Call it initially with -1 for all values in rect.
198 // Keep calling for other widgets, and rect will be modified
199 // to calculate largest bounding rectangle.
200 void wxFindMaxSize(WXHWND wnd
, RECT
*rect
)
202 int left
= rect
->xLeft
;
203 int right
= rect
->xRight
;
204 int top
= rect
->yTop
;
205 int bottom
= rect
->yBottom
;
207 ::WinQueryWindowRect((HWND
) wnd
, rect
);
212 if (left
< rect
->xLeft
)
215 if (right
> rect
->xRight
)
216 rect
->xRight
= right
;
218 if (top
< rect
->yTop
)
221 if (bottom
> rect
->yBottom
)
222 rect
->yBottom
= bottom
;