From 98cc6d95b0620ff48aedfa0c8caa2195e69cbb0e Mon Sep 17 00:00:00 2001 From: Andrew Greenwood Date: Fri, 15 Aug 2003 02:51:53 +0000 Subject: [PATCH] This commit mostly adds DbgPrint() statements to places relevant to the button control, and also partially implements DrawState(), although it doesn't seem to work *at all* at the moment. svn path=/trunk/; revision=5575 --- reactos/lib/user32/controls/button.c | 41 ++++++++++++++++++++++-- reactos/lib/user32/controls/regcontrol.c | 13 +++++--- reactos/lib/user32/windows/defwnd.c | 5 +-- reactos/lib/user32/windows/draw.c | 15 +++++++-- reactos/lib/user32/windows/window.c | 7 ++-- reactos/subsys/win32k/ntuser/painting.c | 3 +- reactos/subsys/win32k/ntuser/window.c | 23 +++++++++++-- 7 files changed, 91 insertions(+), 16 deletions(-) diff --git a/reactos/lib/user32/controls/button.c b/reactos/lib/user32/controls/button.c index 211c8b32121..000b006593c 100644 --- a/reactos/lib/user32/controls/button.c +++ b/reactos/lib/user32/controls/button.c @@ -1,4 +1,4 @@ -/* $Id: button.c,v 1.6 2003/07/25 23:50:37 royce Exp $ +/* $Id: button.c,v 1.7 2003/08/15 02:51:53 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS User32 @@ -134,9 +134,11 @@ inline static void paint_button( HWND hwnd, LONG style, UINT action ) /* retrieve the button text; returned buffer must be freed by caller */ inline static WCHAR *get_button_text( HWND hwnd ) { + DbgPrint("[button] In get_button_text()\n"); INT len = GetWindowTextLengthW( hwnd ); WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ); if (buffer) GetWindowTextW( hwnd, buffer, len + 1 ); + DbgPrint("[button] TextLen %d Text = %s\n", len, buffer); return buffer; } @@ -146,6 +148,8 @@ inline static WCHAR *get_button_text( HWND hwnd ) static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { + DbgPrint("[button] ButtonWndProc called : msg %d\n", uMsg); + RECT rect; POINT pt; LONG style = GetWindowLongA( hWnd, GWL_STYLE ); @@ -169,12 +173,16 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, } case WM_ENABLE: + DbgPrint("[button] WM_ENABLE\n"); paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; case WM_CREATE: + DbgPrint("[button] WM_CREATE\n"); + if (!hbitmapCheckBoxes) { + DbgPrint("[button] Loading bitmaps\n"); BITMAP bmp; hbitmapCheckBoxes = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CHECKBOXES)); GetObjectW( hbitmapCheckBoxes, sizeof(bmp), &bmp ); @@ -184,14 +192,18 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, if (btn_type >= MAX_BTN_TYPE) return -1; /* abort */ set_button_state( hWnd, BUTTON_UNCHECKED ); + DbgPrint("[button] Done creating\n"); return 0; case WM_ERASEBKGND: + DbgPrint("[button] WM_ERASEBKGND\n"); return 1; case WM_PAINT: + DbgPrint("[button] WM_PAINT\n"); if (btnPaintFunc[btn_type]) { + DbgPrint("[button] About to draw...\n"); PAINTSTRUCT ps; HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps ); int nOldMode = SetBkMode( hdc, OPAQUE ); @@ -286,6 +298,7 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, case WM_SETTEXT: { + DbgPrint("[button] WM_SETTEXT"); /* Clear an old text here as Windows does */ HDC hdc = GetDC(hWnd); HBRUSH hbrush; @@ -316,14 +329,17 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, } case WM_SETFONT: + DbgPrint("[button] WM_SETFONT"); set_button_font( hWnd, (HFONT)wParam ); if (lParam) paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; case WM_GETFONT: + DbgPrint("[button] WM_GETFONT"); return (LRESULT)get_button_font( hWnd ); case WM_SETFOCUS: + DbgPrint("[button] WM_SETFOCUS"); if ((btn_type == BS_RADIOBUTTON || btn_type == BS_AUTORADIOBUTTON) && (GetCapture() != hWnd) && !(SendMessageW(hWnd, BM_GETCHECK, 0, 0) & BST_CHECKED)) { @@ -339,16 +355,19 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, break; case WM_KILLFOCUS: + DbgPrint("[button] WM_KILLFOCUS"); set_button_state( hWnd, get_button_state(hWnd) & ~BUTTON_HASFOCUS ); paint_button( hWnd, btn_type, ODA_FOCUS ); InvalidateRect( hWnd, NULL, TRUE ); break; case WM_SYSCOLORCHANGE: + DbgPrint("[button] WM_SYSCOLORCHANGE"); InvalidateRect( hWnd, NULL, FALSE ); break; case BM_SETSTYLE: + DbgPrint("[button] BM_SETSTYLE"); if ((wParam & 0x0f) >= MAX_BTN_TYPE) break; btn_type = wParam & 0x0f; style = (style & ~0x0f) | btn_type; @@ -517,6 +536,7 @@ static UINT BUTTON_BStoDT(DWORD style) */ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) { + DbgPrint("[button] In BUTTON_CalcLabelRect()\n"); LONG style = GetWindowLongA( hwnd, GWL_STYLE ); WCHAR *text; ICONINFO iconInfo; @@ -524,11 +544,12 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) UINT dtStyle = BUTTON_BStoDT(style); RECT r = *rc; INT n; - + /* Calculate label rectangle according to label type */ switch (style & (BS_ICON|BS_BITMAP)) { case BS_TEXT: + DbgPrint("[button] BS_TEXT\n"); if (!(text = get_button_text( hwnd ))) goto empty_rect; if (!text[0]) { @@ -540,6 +561,7 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) break; case BS_ICON: + DbgPrint("[button] BS_ICON\n"); if (!GetIconInfo((HICON)GetWindowLongA( hwnd, HIMAGE_GWL_OFFSET ), &iconInfo)) goto empty_rect; @@ -553,6 +575,7 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) break; case BS_BITMAP: + DbgPrint("[button] BS_BITMAP\n"); if (!GetObjectW( (HANDLE)GetWindowLongA( hwnd, HIMAGE_GWL_OFFSET ), sizeof(BITMAP), &bm)) goto empty_rect; @@ -562,6 +585,7 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) default: empty_rect: + DbgPrint("[button] EMPTY RECT!\n"); r.right = r.left; r.bottom = r.top; return (UINT)(LONG)-1; @@ -596,6 +620,8 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) break; } + DbgPrint("[button] Resulting rectangle = %dx%d to %dx%d\n", r.left, r.top, r.bottom, r.right); + *rc = r; return dtStyle; } @@ -626,6 +652,7 @@ static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int */ static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, RECT *rc) { + DbgPrint("[button] In BUTTON_DrawLabel()\n"); DRAWSTATEPROC lpOutputProc = NULL; LPARAM lp; WPARAM wp = 0; @@ -670,6 +697,7 @@ static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, RECT *rc) return; } + DbgPrint("[button] DrawState\n"); DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, flags); if (text) HeapFree( GetProcessHeap(), 0, text ); @@ -680,6 +708,7 @@ static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, RECT *rc) */ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) { + DbgPrint("[button] In PB_Paint()\n"); RECT rc, focus_rect, r; UINT dtFlags; HRGN hRgn; @@ -728,11 +757,15 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) focus_rect = rc; /* draw button label */ + DbgPrint("[button] About to calculate label rectangle\n"); r = rc; dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r); if (dtFlags == (UINT)-1L) + { + DbgPrint("[button] JUMPING TO CLEANUP!\n"); goto cleanup; + } if (pushedState) OffsetRect(&r, 1, 1); @@ -740,8 +773,10 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) hRgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom); SelectClipRgn(hDC, hRgn); + DbgPrint("[button] Setting text color\n"); oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) ); + DbgPrint("[button] Calling BUTTON_DrawLabel\n"); BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r); SetTextColor( hDC, oldTxtColor ); @@ -759,6 +794,8 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) SelectObject( hDC, hOldPen ); SelectObject( hDC, hOldBrush ); SetBkMode(hDC, oldBkMode); + + DbgPrint("[button] Quitting\n"); } /********************************************************************** diff --git a/reactos/lib/user32/controls/regcontrol.c b/reactos/lib/user32/controls/regcontrol.c index 2296172b413..c0fca200648 100644 --- a/reactos/lib/user32/controls/regcontrol.c +++ b/reactos/lib/user32/controls/regcontrol.c @@ -1,4 +1,4 @@ -/* $Id: regcontrol.c,v 1.7 2003/07/27 17:47:35 ekohl Exp $ +/* $Id: regcontrol.c,v 1.8 2003/08/15 02:51:53 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS User32 @@ -15,7 +15,7 @@ static void RegisterBuiltinClass(const struct builtin_class_descr *Descr) { WNDCLASSA wca; - + wca.lpszClassName = Descr->name; wca.lpfnWndProc = Descr->procA; wca.style = Descr->style; @@ -27,7 +27,8 @@ static void RegisterBuiltinClass(const struct builtin_class_descr *Descr) wca.cbClsExtra = 0; wca.cbWndExtra = Descr->extra; - RegisterClassA(&wca); + DbgPrint("Registering built-in class %s\n", wca.lpszClassName); + DbgPrint("RegisterClassA = %d\n", RegisterClassA(&wca)); } /*********************************************************************** @@ -37,7 +38,10 @@ static void RegisterBuiltinClass(const struct builtin_class_descr *Descr) */ void ControlsInit(void) { - RegisterBuiltinClass(&DIALOG_builtin_class); + DbgPrint("ControlsInit()\n"); + + RegisterBuiltinClass(&BUTTON_builtin_class); +// RegisterBuiltinClass(&DIALOG_builtin_class); #if 0 RegisterBuiltinClass(&COMBO_builtin_class); RegisterBuiltinClass(&COMBOLBOX_builtin_class); @@ -49,7 +53,6 @@ void ControlsInit(void) #endif RegisterBuiltinClass(&EDIT_builtin_class); RegisterBuiltinClass(&COMBO_builtin_class); - RegisterBuiltinClass(&BUTTON_builtin_class); RegisterBuiltinClass(&ICONTITLE_builtin_class); RegisterBuiltinClass(&STATIC_builtin_class); } diff --git a/reactos/lib/user32/windows/defwnd.c b/reactos/lib/user32/windows/defwnd.c index 7c2d24e3506..195acff19ac 100644 --- a/reactos/lib/user32/windows/defwnd.c +++ b/reactos/lib/user32/windows/defwnd.c @@ -1,4 +1,4 @@ -/* $Id: defwnd.c,v 1.63 2003/08/07 04:03:24 royce Exp $ +/* $Id: defwnd.c,v 1.64 2003/08/15 02:51:53 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -464,7 +464,8 @@ DefWndDoPaintNC(HWND hWnd, HRGN clip) ULONG ExStyle; int wFrame = 0; - Active = GetWindowLongW(hWnd, GWL_STYLE) & WIN_NCACTIVATED; + // This won't work because it conflicts with BS_BITMAP : +// Active = GetWindowLongW(hWnd, GWL_STYLE) & WIN_NCACTIVATED; Style = GetWindowLongW(hWnd, GWL_STYLE); ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE); diff --git a/reactos/lib/user32/windows/draw.c b/reactos/lib/user32/windows/draw.c index 541a5fb2df1..415471782ad 100644 --- a/reactos/lib/user32/windows/draw.c +++ b/reactos/lib/user32/windows/draw.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: draw.c,v 1.17 2003/08/14 18:30:27 silverblade Exp $ +/* $Id: draw.c,v 1.18 2003/08/15 02:51:53 silverblade Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/input.c @@ -30,6 +30,8 @@ #include #include + +#define NDEBUG #include /* GLOBALS *******************************************************************/ @@ -1638,6 +1640,8 @@ DrawStateW( // AG: Experimental, unfinished, and most likely buggy! I haven't been // able to test this - my intention was to implement some things needed // by the button control. + + DbgPrint("[draw.c] In DrawState()\n"); if ((! lpOutputFunc) && (fuFlags & DST_COMPLEX)) return FALSE; @@ -1647,9 +1651,14 @@ DrawStateW( HBITMAP MemBMP = CreateCompatibleBitmap(hdc, cx, cy); HDC MemDC = CreateCompatibleDC(hdc); - + HBITMAP OldBMP = (HBITMAP) SelectObject(MemDC, MemBMP); + // Does this work? + SetBkColor(MemDC, GetBkColor(hdc)); + // Test stuff... + FillRect(MemDC, &r, WHITE_BRUSH); + // Do drawing first if (lpOutputFunc) @@ -1674,6 +1683,8 @@ DrawStateW( SelectObject(MemDC, OldBMP); DeleteObject(MemBMP); DeleteDC(MemDC); + + DbgPrint("[draw.c] Success!\n"); return TRUE; } diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index de163284191..4ebadaaad22 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.58 2003/08/14 20:25:52 royce Exp $ +/* $Id: window.c,v 1.59 2003/08/15 02:51:53 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -489,11 +489,12 @@ CreateWindowExA(DWORD dwExStyle, HINSTANCE hInstance, LPVOID lpParam) { + DbgPrint("[window] CreateWindowExA style %d, exstyle %d, parent %d\n", dwStyle, dwExStyle, hWndParent); UNICODE_STRING WindowName; UNICODE_STRING ClassName; HWND Handle; INT sw; - + /* Register built-in controls if not already done */ if (! ControlsInitCalled) { @@ -589,6 +590,8 @@ CreateWindowExA(DWORD dwExStyle, lpParam, sw); + DbgPrint("[window] NtUserCreateWindowEx() == %d\n", Handle); + RtlFreeUnicodeString(&WindowName); if (!IS_ATOM(lpClassName)) diff --git a/reactos/subsys/win32k/ntuser/painting.c b/reactos/subsys/win32k/ntuser/painting.c index 2e46abdfcd8..63a3f251b96 100644 --- a/reactos/subsys/win32k/ntuser/painting.c +++ b/reactos/subsys/win32k/ntuser/painting.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: painting.c,v 1.26 2003/08/11 21:10:49 royce Exp $ +/* $Id: painting.c,v 1.27 2003/08/15 02:51:53 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -458,6 +458,7 @@ PaintRedrawWindow( PWINDOW_OBJECT Window, ULONG Flags, ULONG ExFlags) { + DbgPrint("[win32k.sys:painting] In PaintRedrawWindow()\n"); RECT Rect, Rect2; POINT Pt; HRGN hRgn = NULL; diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 6859da4791f..6fe99797ce2 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.91 2003/08/14 01:38:19 royce Exp $ +/* $Id: window.c,v 1.92 2003/08/15 02:51:53 silverblade Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -677,9 +677,15 @@ NtUserCreateWindowEx(DWORD dwExStyle, WindowObject->Class = ClassObject; WindowObject->ExStyle = dwExStyle; WindowObject->Style = dwStyle; + DbgPrint("1: Style is now %d\n", WindowObject->Style); + if (0 == (dwStyle & WS_CHILD)) { + WindowObject->Flags |= WIN_NCACTIVATED; + + // THIS MESSES UP BUTTONS: WIN_NCACTIVATED == BS_BITMAP ! WindowObject->Style = WindowObject->Style | WIN_NCACTIVATED; + DbgPrint("2: Style is now %d\n", WindowObject->Style); } WindowObject->x = x; WindowObject->y = y; @@ -726,9 +732,11 @@ NtUserCreateWindowEx(DWORD dwExStyle, if (!(dwStyle & WS_CHILD)) { WindowObject->Style |= WS_CLIPSIBLINGS; + DbgPrint("3: Style is now %d\n", WindowObject->Style); if (!(dwStyle & WS_POPUP)) { WindowObject->Style |= WS_CAPTION; + DbgPrint("4: Style is now %d\n", WindowObject->Style); /* FIXME: Note the window needs a size. */ } } @@ -791,6 +799,15 @@ NtUserCreateWindowEx(DWORD dwExStyle, Cs.lpszName = lpWindowName->Buffer; Cs.lpszClass = lpClassName->Buffer; Cs.dwExStyle = dwExStyle; + + // AG: For some reason these don't get set already. This might need moving + // elsewhere... What is actually done with WindowObject anyway, to retain + // its data? + DbgPrint("[win32k.window] NtUserCreateWindowEx style %d, exstyle %d, parent %d\n", Cs.style, Cs.dwExStyle, Cs.hwndParent); +// NtUserSetWindowLong(Handle, GWL_STYLE, WindowObject->Style, TRUE); +// NtUserSetWindowLong(Handle, GWL_EXSTYLE, WindowObject->ExStyle, TRUE); + // Any more? + DPRINT("NtUserCreateWindowEx(): About to send NCCREATE message.\n"); Result = W32kSendNCCREATEMessage(WindowObject->Self, &Cs); if (!Result) @@ -1616,7 +1633,8 @@ NtUserRedrawWindow return FALSE; } } - + + Status = PaintRedrawWindow ( Wnd, @@ -1626,6 +1644,7 @@ NtUserRedrawWindow 0 ); + if(!NT_SUCCESS(Status)) { /* FIXME: set last error */