1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxControl class
4 // Author: Julian Smart
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"
26 #include "wx/dcclient.h"
29 #include "wx/control.h"
31 #include "wx/msw/private.h"
33 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
37 #if !USE_SHARED_LIBRARY
38 IMPLEMENT_ABSTRACT_CLASS(wxControl
, wxWindow
)
40 BEGIN_EVENT_TABLE(wxControl
, wxWindow
)
41 EVT_ERASE_BACKGROUND(wxControl::OnEraseBackground
)
46 wxControl::wxControl()
48 m_backgroundColour
= *wxWHITE
;
49 m_foregroundColour
= *wxBLACK
;
51 #if WXWIN_COMPATIBILITY
53 #endif // WXWIN_COMPATIBILITY
56 wxControl::~wxControl()
58 m_isBeingDeleted
= TRUE
;
61 bool wxControl::ProcessCommand(wxCommandEvent
& event
)
63 #if WXWIN_COMPATIBILITY
66 (void)(*m_callback
)(this, event
);
71 #endif // WXWIN_COMPATIBILITY
73 return GetEventHandler()->ProcessEvent(event
);
77 bool wxControl::MSWOnNotify(int idCtrl
,
81 wxCommandEvent
event(wxEVT_NULL
, m_windowId
);
82 wxEventType eventType
= wxEVT_NULL
;
83 NMHDR
*hdr1
= (NMHDR
*) lParam
;
87 eventType
= wxEVT_COMMAND_LEFT_CLICK
;
91 eventType
= wxEVT_COMMAND_LEFT_DCLICK
;
95 eventType
= wxEVT_COMMAND_RIGHT_CLICK
;
99 eventType
= wxEVT_COMMAND_RIGHT_DCLICK
;
103 eventType
= wxEVT_COMMAND_SET_FOCUS
;
107 eventType
= wxEVT_COMMAND_KILL_FOCUS
;
111 eventType
= wxEVT_COMMAND_ENTER
;
115 return wxWindow::MSWOnNotify(idCtrl
, lParam
, result
);
118 event
.SetEventType(eventType
);
119 event
.SetEventObject(this);
121 return GetEventHandler()->ProcessEvent(event
);
125 void wxControl::OnEraseBackground(wxEraseEvent
& event
)
127 // In general, you don't want to erase the background of a control,
128 // or you'll get a flicker.
129 // TODO: move this 'null' function into each control that
133 ::GetClientRect((HWND
) GetHWND(), &rect
);
135 HBRUSH hBrush
= ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(),
136 GetBackgroundColour().Green(),
137 GetBackgroundColour().Blue()));
138 int mode
= ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), MM_TEXT
);
140 ::FillRect ((HDC
) event
.GetDC()->GetHDC(), &rect
, hBrush
);
141 ::DeleteObject(hBrush
);
142 ::SetMapMode((HDC
) event
.GetDC()->GetHDC(), mode
);
145 // ---------------------------------------------------------------------------
147 // ---------------------------------------------------------------------------
149 // Call this repeatedly for several wnds to find the overall size
151 // Call it initially with -1 for all values in rect.
152 // Keep calling for other widgets, and rect will be modified
153 // to calculate largest bounding rectangle.
154 void wxFindMaxSize(WXHWND wnd
, RECT
*rect
)
156 int left
= rect
->left
;
157 int right
= rect
->right
;
159 int bottom
= rect
->bottom
;
161 GetWindowRect((HWND
) wnd
, rect
);
166 if (left
< rect
->left
)
169 if (right
> rect
->right
)
175 if (bottom
> rect
->bottom
)
176 rect
->bottom
= bottom
;