]>
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 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
29 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
30 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
34 wxControl::wxControl()
36 m_backgroundColour
= *wxWHITE
;
37 m_foregroundColour
= *wxBLACK
;
39 #if WXWIN_COMPATIBILITY
41 #endif // WXWIN_COMPATIBILITY
44 wxControl::~wxControl()
46 m_isBeingDeleted
= TRUE
;
49 bool wxControl::OS2CreateControl(const wxChar
*classname
, WXDWORD style
)
51 m_hWnd
= (WXHWND
)::WinCreateWindow( GetHwndOf(GetParent())
67 wxLogError(wxT("Failed to create a control of class '%s'"), classname
);
73 // subclass again for purposes of dialog editing mode
76 // controls use the same font and colours as their parent dialog by default
82 wxSize
wxControl::DoGetBestSize() const
84 return wxSize(DEFAULT_ITEM_WIDTH
, DEFAULT_ITEM_HEIGHT
);
87 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
89 #if WXWIN_COMPATIBILITY
92 (void)(*m_callback
)(this, event
);
97 #endif // WXWIN_COMPATIBILITY
99 return GetEventHandler()->ProcessEvent(event
);
102 bool wxControl::OS2OnNotify(int idCtrl
,
106 wxCommandEvent
event(wxEVT_NULL
, m_windowId
);
107 wxEventType eventType
= wxEVT_NULL
;
109 NMHDR *hdr1 = (NMHDR*) lParam;
110 switch ( hdr1->code )
113 eventType = wxEVT_COMMAND_LEFT_CLICK;
117 eventType = wxEVT_COMMAND_LEFT_DCLICK;
121 eventType = wxEVT_COMMAND_RIGHT_CLICK;
125 eventType = wxEVT_COMMAND_RIGHT_DCLICK;
129 eventType = wxEVT_COMMAND_SET_FOCUS;
133 eventType = wxEVT_COMMAND_KILL_FOCUS;
137 eventType = wxEVT_COMMAND_ENTER;
141 return wxWindow::OS2OnNotify(idCtrl, lParam, result);
144 event
.SetEventType(eventType
);
145 event
.SetEventObject(this);
147 return GetEventHandler()->ProcessEvent(event
);
150 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
152 // In general, you don't want to erase the background of a control,
153 // or you'll get a flicker.
154 // TODO: move this 'null' function into each control that
160 * TODO: convert to PM Code
161 * ::GetClientRect((HWND) GetHWND(), &rect);
163 * HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(),
164 * GetBackgroundColour().Green(),
165 * GetBackgroundColour().Blue()));
166 * int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
168 * ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
169 * ::DeleteObject(hBrush);
170 * ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
174 WXDWORD
wxControl::GetExStyle(WXDWORD
& style
) const
177 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
179 // Even with extended styles, need to combine with FS_BORDER
180 // for them to look right. Check it out later, base window style does
181 // not designate BORDERS. Down in Frame and And controls.
183 if ( want3D
|| wxStyleHasBorder(m_windowStyle
) )
189 // ---------------------------------------------------------------------------
191 // ---------------------------------------------------------------------------
193 // Call this repeatedly for several wnds to find the overall size
195 // Call it initially with -1 for all values in rect.
196 // Keep calling for other widgets, and rect will be modified
197 // to calculate largest bounding rectangle.
198 void wxFindMaxSize(WXHWND wnd
, RECT
*rect
)
200 int left
= rect
->xLeft
;
201 int right
= rect
->xRight
;
202 int top
= rect
->yTop
;
203 int bottom
= rect
->yBottom
;
205 ::WinQueryWindowRect((HWND
) wnd
, rect
);
210 if (left
< rect
->xLeft
)
213 if (right
> rect
->xRight
)
214 rect
->xRight
= right
;
216 if (top
< rect
->yTop
)
219 if (bottom
> rect
->yBottom
)
220 rect
->yBottom
= bottom
;