// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
+// bool needMore = FALSE;
if (needMore)
event.RequestMore(TRUE);
#pragma hdrstop
#endif
+#if USE_OWNER_DRAWN
+
#include <windows.h>
#include "wx/ownerdrw.h"
event.Skip();
}
}
+
+#endif
+
}
*/
-#if 0
-// We can't rely on Windows giving us events corresponding to the wxWindows Z-ordering.
-// E.g. we can't push a wxGroupBox to the back for editing purposes.
-// Convert the item event to parent coordinates, then search for
-// an item that could receive this event.
-wxControl *wxFakeItemEvent(wxWindow *parent, wxControl *item, wxMouseEvent& event)
-{
- int x, y;
- item->GetPosition(&x, &y);
- event.m_x += x;
- event.m_y += y;
-
- wxNode *node = parent->GetChildren()->Last();
- while (node)
- {
- wxControl *newItem = (wxControl *)node->Data();
- if (newItem->IsSelected() && newItem->SelectionHandleHitTest(event.x, event.GetY()))
- {
- // This event belongs to the panel.
- parent->GetEventHandler()->OldOnMouseEvent(event);
- return NULL;
- }
- else if (newItem->HitTest(event.x, event.GetY()))
- {
- int x1, y1;
- newItem->GetPosition(&x1, &y1);
- event.x -= x1;
- event.GetY() -= y1;
- newItem->OldOnMouseEvent(event);
- return newItem;
- }
- node = node->Previous();
- }
- // No takers, so do what we would have done anyway.
- event.x -= x;
- event.y -= y;
- item->OldOnMouseEvent(event);
- return item;
-}
-#endif
-
void wxControl::MSWOnMouseMove(const int x, const int y, const WXUINT flags)
{
/*
m_staticPaintHDC = m_hDC ;
}
else
+ {
+ wxDebugMsg("wxPaintDC: Using existing HDC\n");
m_hDC = m_staticPaintHDC ;
+ }
m_canvas = the_canvas;
RECT updateRect1 = g_paintStruct.rcPaint;
m_hDCCount --;
m_hDC = 0;
}
+ else
+ wxDebugMsg("~wxPaintDC: Did not release HDC\n");
+
m_staticPaintHDC = 0 ;
}
+ else
+ {
+ wxDebugMsg("~wxPaintDC: Did not release HDC\n");
+ }
}
{
m_hDC = (WXHDC) ::CreateCompatibleDC(NULL);
m_ok = (m_hDC != 0);
+ m_bOwnsDC = TRUE;
SetBrush(*wxWHITE_BRUSH);
SetPen(*wxBLACK_PEN);
// If child windows aren't properly drawn initially, WS_CLIPCHILDREN
// could be the culprit. But without it, you can get a lot of flicker.
-// DWORD msflags = WS_POPUP | WS_CLIPCHILDREN ;
-
DWORD msflags = 0;
if ((style & wxCAPTION) == wxCAPTION)
- msflags = WS_OVERLAPPED | WS_CLIPCHILDREN ; // WS_POPUP | WS_CLIPCHILDREN ;
+ msflags = WS_OVERLAPPED;
else
- msflags = WS_POPUP | WS_CLIPCHILDREN ;
+ msflags = WS_POPUP;
if (style & wxMINIMIZE_BOX)
msflags |= WS_MINIMIZEBOX;
msflags |= WS_MAXIMIZE;
if (style & wxCAPTION)
msflags |= WS_CAPTION;
+ if (style & wxCLIP_CHILDREN)
+ msflags |= WS_CLIPCHILDREN;
// Keep this in wxFrame because it saves recoding this function
// in wxTinyFrame
EndPaint((HWND) GetHWND(), &ps);
}
-
- if (!m_iconized)
+ else
{
-// m_paintHDC = (WXHDC) cdc;
GetEventHandler()->OldOnPaint();
-// m_paintHDC = NULL;
}
return 0;
}
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
y1 = currentY;
- float control_width, control_height, control_x, control_y;
-
// If we're prepared to use the existing size, then...
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
{
- GetSize(&x1, &y1);
+ GetSize(&w1, &h1);
}
// Deal with default size (using -1 values)
- if (width<=0)
+ if (w1<=0)
w1 = DEFAULT_ITEM_WIDTH;
- if (height<=0)
+ if (h1<=0)
h1 = DEFAULT_ITEM_HEIGHT;
- control_x = (float)x1;
- control_y = (float)y1;
- control_width = (float)w1;
- control_height = (float)h1;
-
- MoveWindow((HWND) GetHWND(), (int)control_x, (int)control_y, (int)control_width, (int)control_height, TRUE);
+ MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
#if WXWIN_COMPATIBILITY
GetEventHandler()->OldOnSize(width, height);
0, 0, 0, 0,
(HWND)parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
+
+ m_hWnd = (WXHWND)wx_list;
+
#if CTL3D
if (want3D)
{
}
#endif
+ // Subclass again to catch messages
+ SubclassWin((WXHWND)wx_list);
+
uint ui;
for (ui = 0; ui < (uint)n; ui++) {
SendMessage(wx_list, LB_ADDSTRING, 0, (LPARAM)(const char *)choices[ui]);
}
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
for (ui = 0; ui < (uint)n; ui++) {
// create new item which will process WM_{DRAW|MEASURE}ITEM messages
ListBox_SetItemData(wx_list, ui, pNewItem);
}
}
- #endif
+#endif
if ((m_windowStyle & wxLB_MULTIPLE) == 0)
SendMessage(wx_list, LB_SETCURSEL, 0, 0);
- ShowWindow(wx_list, SW_SHOW);
-
- m_hWnd = (WXHWND)wx_list;
-
- // Subclass again for purposes of dialog editing mode
- SubclassWin((WXHWND)wx_list);
-
SetFont(* parent->GetFont());
SetSize(x, y, width, height);
+ ShowWindow(wx_list, SW_SHOW);
+
return TRUE;
}
wxListBox::~wxListBox(void)
{
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
uint uiCount = m_aItems.Count();
while ( uiCount-- != 0 ) {
delete m_aItems[uiCount];
}
- #endif
+#endif
+
+ DELETEA(m_selections);
}
void wxListBox::SetupColours(void)
int index = ListBox_AddString(hwnd, item);
m_noItems ++;
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
wxOwnerDrawn *pNewItem = CreateItem(-1); // dummy argument
pNewItem->SetName(item);
m_aItems.Add(pNewItem);
ListBox_SetItemData(hwnd, index, pNewItem);
}
- #endif
+#endif
SetHorizontalExtent(item);
}
int index = ListBox_AddString(hwnd, item);
m_noItems ++;
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// client data must be pointer to wxOwnerDrawn, otherwise we would crash
// in OnMeasure/OnDraw.
wxFAIL_MSG("Can't use client data with owner-drawn listboxes");
}
else
- #endif
+#endif
ListBox_SetItemData(hwnd, index, Client_data);
SetHorizontalExtent(item);
}
m_noItems = n;
- #if USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW ) {
// first delete old items
uint ui = m_aItems.Count();
"Can't use client data with owner-drawn listboxes");
}
}
- #endif
+#endif
SetHorizontalExtent("");
ShowWindow(hwnd, SW_SHOW);
long wxListBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
-/*
switch (nMsg)
{
case WM_INITDIALOG:
case WM_MBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
-// case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDBLCLK:
case WM_MOUSEMOVE:
case WM_DESTROY:
case WM_COMMAND:
case WM_NCHITTEST:
return MSWDefWindowProc(nMsg, wParam, lParam );
}
-*/
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
<<
+$(MSWDIR)/notebook.obj: $*.$(SRCSUFF)
+ cl @<<
+$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
+<<
+
$(MSWDIR)/ownerdrw.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
msflags |= WS_MAXIMIZE;
if (style & wxCAPTION)
msflags |= WS_CAPTION;
+ if (style & wxCLIP_CHILDREN)
+ msflags |= WS_CLIPCHILDREN;
wxWindow::MSWCreate(m_windowId, parent, wxMDIFrameClassName, this, title, x, y, width, height,
msflags);
{
wxASSERT( pParentMenu != NULL );
-#ifdef USE_OWNER_DRAWN
+#if USE_OWNER_DRAWN
// set default menu colors
#define SYS_COLOR(c) (wxSystemSettings::GetSystemColour(wxSYS_COLOUR_##c))
::SetScrollPos(scroll_bar, SB_CTL, 0, FALSE);
ShowWindow(scroll_bar, SW_SHOW);
+ SetFont(parent->GetFont());
+
m_hWnd = (WXHWND)scroll_bar;
// Subclass again for purposes of dialog editing mode
SubclassWin(GetHWND());
+ SetFont(parent->GetFont());
+
if ( m_windowStyle & wxSL_LABELS )
{
// Finally, create max value static item
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(),
wxGetInstance(), NULL);
- SetFont(parent->GetFont());
-
if (GetFont())
{
// GetFont()->RealizeResource();
// outline.
void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
{
+ // If we don't have this (call Default()), we don't paint the background properly.
+ // If we do have this, we seem to overwrite enclosed controls.
+ // Is it the WS_CLIPCHILDREN style that's causing the problems?
+ // Probably - without this style, the background of the window will show through,
+ // so the control doesn't have to paint it. The window background will always be
+ // painted before all other controls, therefore there are no problems with
+ // controls being hidden by the static box.
+ // So, if we could specify wxCLIP_CHILDREN in window, or not, we could optimise painting better.
+ // We would assume wxCLIP_CHILDREN in a frame and a scrolled window, but not in a panel.
+ // Is this too platform-specific?? What else can we do? Not a lot, since we have to pass
+ // this information from arbitrary wxWindow derivatives, and it depends on what you wish to
+ // do with the windows.
+ // Alternatively, just make sure that wxStaticBox is always at the back! There are probably
+ // few other circumstances where it matters about child clipping. But what about painting onto
+ // to panel, inside a groupbox? Doesn't appear, because the box wipes it out.
wxWindow *parent = GetParent();
if ( parent && parent->GetHWND() && (::GetWindowLong((HWND) parent->GetHWND(), GWL_STYLE) & WS_CLIPCHILDREN) )
{
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
- // TODO: somehow, this has to accept mouse clicks in user interface edit mode,
+ // TODO: somehow, this has to accept mouse clicks in user interface edit mode,
// but not otherwise. Only there is no longer a UI edit mode...
// It worked before because the message could be processed if not in UI
// skip the code below. Too time consuming though.
// Perhaps it's ok to do the default thing *anyway* because the title or edge
// of the window may still be active!
+// if (nMsg == WM_NCHITTEST)
+// return Default();
+
if (nMsg == WM_NCHITTEST)
- return Default();
+ {
+ int xPos = LOWORD(lParam); // horizontal position of cursor
+ int yPos = HIWORD(lParam); // vertical position of cursor
+
+ ScreenToClient(&xPos, &yPos);
+
+ // Make sure you can drag by the top of the groupbox, but let
+ // other (enclosed) controls get mouse events also
+ if (yPos < 10)
+ return (long)HTCLIENT;
+ }
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
m_windowId = id == -1 ? NewControlId() : id;
DWORD wstyle = WS_CHILD | WS_VISIBLE;
- if ( style & wxSB_SIZEGRIP )
+ if ( style & wxST_SIZEGRIP )
wstyle |= SBARS_SIZEGRIP;
m_hWnd = (WXHWND)CreateStatusWindow(wstyle,
m_windowStyle = style;
- SetFont(wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL));
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
SetParent(parent);
msflags |= WS_BORDER;
if (style & wxTHICK_FRAME)
msflags |= WS_THICKFRAME;
- // TODO: probably make WS_CLIPCHILDREN this a setting in wx/setup.h,
- // to reduce flicker with the trade-off that groupboxes must paint in a solid
- // colour (so your control order must be correct, and you can't easily draw a
- // transparent group).
- msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN;
+
+ msflags |= WS_CHILD | WS_VISIBLE;
+ if (style & wxCLIP_CHILDREN)
+ msflags |= WS_CLIPCHILDREN;
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
HFONT was = 0;
if (fontToUse && fontToUse->Ok())
{
-// fontToUse->UseResource();
-
-// fontToUse->RealizeResource();
if ((fnt=(HFONT) fontToUse->GetResourceHandle()))
was = SelectObject(dc,fnt) ;
}
}
}
-// TODO: Are these really necessary now?
-/*
-WXHDC wxWindow::GetHDC(void) const
-{
- wxWindow *nonConst = (wxWindow *)this;
- if (m_paintHDC)
- return(m_paintHDC) ;
- nonConst->m_tempHDC = (WXHDC) ::GetDC((HWND) GetHWND()) ;
- return(m_tempHDC) ;
-}
-
-void wxWindow::ReleaseHDC(void)
-{
- // We're within an OnPaint: it'll be released.
- if (m_paintHDC)
- return ;
-
- ::ReleaseDC((HWND) GetHWND(),(HDC) m_tempHDC) ;
-}
-*/
-
// Hook for new window just as it's being created,
// when the window isn't yet associated with the handle
wxWindow *wxWndHook = NULL;
-/*
-#if HAVE_SOCKET
-// DDE Interface Handler
-extern "C" {
- long ddeWindowProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam);
- void __ddeUnblock(HWND hWnd, WPARAM wParam);
-};
-#endif
-*/
-
-// Main Windows 3 window proc
+// Main window proc
LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
wnd->m_lastMsg = message;
wnd->m_lastWParam = wParam;
wnd->m_lastLParam = lParam;
-/* Don't know why this was here
- if (message == WM_SETFONT)
- return 0;
- else if (message == WM_INITDIALOG)
- return TRUE;
-*/
}
if (wnd)
return wnd->MSWWindowProc(message, wParam, lParam);
switch (message)
{
-/*
- case WM_SETFONT:
- {
- return 0;
- }
-*/
case WM_ACTIVATE:
{
#ifdef __WIN32__
case WM_KEYDOWN:
{
- // these keys are not interesting to the application (@@ or are they?)
- if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
- return Default();
+ if (wParam == VK_SHIFT)
+ return Default();
+
+ else if (wParam == VK_CONTROL)
+ return Default();
// Avoid duplicate messages to OnChar
- if ((wParam == VK_ESCAPE) || (wParam == VK_SPACE) ||
- (wParam == VK_RETURN) || (wParam == VK_BACK) ||
- (wParam == VK_TAB))
- return Default();
-
- MSWOnChar((WORD)wParam, lParam);
- //VZ: commented - what is it for?
- //if (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE)
- // return Default();
+ else if ((wParam != VK_ESCAPE) && (wParam != VK_SPACE) && (wParam != VK_RETURN) && (wParam != VK_BACK) && (wParam != VK_TAB))
+ {
+ MSWOnChar((WORD)wParam, lParam);
+ if (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE)
+ return Default();
+ }
+ else
+ return Default();
+ }
+ case WM_KEYUP:
+ {
break;
}
-
// VZ: WM_KEYUP not processed
-
case WM_CHAR: // Always an ASCII character
{
MSWOnChar((WORD)wParam, lParam, TRUE);
long wxWindow::Default()
{
- return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
+ // These are fake events, ignore them
+ if (m_lastEvent != wxEVT_ENTER_WINDOW && m_lastEvent != wxEVT_LEAVE_WINDOW)
+ return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam);
+ else
+ return 0;
}
bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
void wxWindow::MSWOnLButtonDClick(const int x, const int y, const WXUINT flags)
{
- /* MATTHEW: If dclick not allowed, generate another single-click */
- wxMouseEvent event(m_doubleClickAllowed ?
- wxEVENT_TYPE_LEFT_DCLICK : wxEVENT_TYPE_LEFT_DOWN);
+ wxMouseEvent event(wxEVENT_TYPE_LEFT_DCLICK);
event.m_x = x; event.m_y = y;
event.m_shiftDown = ((flags & MK_SHIFT) != 0);
event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DOWN;
+ m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_MIDDLE_DOWN;
GetEventHandler()->OldOnMouseEvent(event);
}
event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_UP;
+ m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_MIDDLE_UP;
GetEventHandler()->OldOnMouseEvent(event);
}
void wxWindow::MSWOnMButtonDClick(const int x, const int y, const WXUINT flags)
{
-//wxDebugMsg("MButtonDClick\n") ;
- /* MATTHEW: If dclick not allowed, generate another single-click */
- wxMouseEvent event((m_doubleClickAllowed) ?
- wxEVENT_TYPE_MIDDLE_DCLICK : wxEVENT_TYPE_MIDDLE_DOWN);
+ wxMouseEvent event(wxEVENT_TYPE_MIDDLE_DCLICK);
event.m_x = x; event.m_y = y;
event.m_shiftDown = ((flags & MK_SHIFT) != 0);
event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */
event.m_eventObject = this;
- m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_LEFT_DCLICK;
+ m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVENT_TYPE_MIDDLE_DCLICK;
// if (m_doubleClickAllowed)
GetEventHandler()->OldOnMouseEvent(event);
}
void wxWindow::MSWOnRButtonDClick(const int x, const int y, const WXUINT flags)
{
- /* MATTHEW: If dclick not allowed, generate another single-click */
- wxMouseEvent event((m_doubleClickAllowed) ?
- wxEVENT_TYPE_RIGHT_DCLICK : wxEVENT_TYPE_RIGHT_DOWN);
+ wxMouseEvent event(wxEVENT_TYPE_RIGHT_DCLICK);
event.m_x = x; event.m_y = y;
event.m_shiftDown = ((flags & MK_SHIFT) != 0);
m_lastEvent = wxEVT_ENTER_WINDOW;
m_lastXPos = event.m_x; m_lastYPos = event.m_y;
- GetEventHandler()->OldOnMouseEvent(event);
+ GetEventHandler()->ProcessEvent(event);
}
void wxWindow::MSWOnMouseLeave(const int x, const int y, const WXUINT flags)
m_lastEvent = wxEVT_LEAVE_WINDOW;
m_lastXPos = event.m_x; m_lastYPos = event.m_y;
- GetEventHandler()->OldOnMouseEvent(event);
+ GetEventHandler()->ProcessEvent(event);
}
void wxWindow::MSWOnChar(const WXWORD wParam, const WXLPARAM lParam, const bool isASCII)
MSWOnMouseLeave(pt.x, pt.y, 0);
}
}
-
UpdateWindowUI();
}