implemented basic drawing of carets

svn path=/trunk/; revision=6349
This commit is contained in:
Thomas Bluemel 2003-10-17 20:31:56 +00:00
parent fb9b3cb9c2
commit 04b57ad0bd
7 changed files with 99 additions and 20 deletions

View file

@ -158,7 +158,6 @@ NtUserCallNextHookEx(
#define NOPARAM_ROUTINE_REGISTER_PRIMITIVE 0xffff0001 /* Private ROS */
#define NOPARAM_ROUTINE_DESTROY_CARET 0xffff0002
#define NOPARAM_ROUTINE_SWITCHCARETSHOWING 0xffff0003
DWORD
STDCALL
NtUserCallNoParam(
@ -171,6 +170,7 @@ NtUserCallNoParam(
#define ONEPARAM_ROUTINE_SWAPMOUSEBUTTON 0x05
#define ONEPARAM_ROUTINE_SETCARETBLINKTIME 0x06
#define ONEPARAM_ROUTINE_GETCARETINFO 0x07
#define ONEPARAM_ROUTINE_SWITCHCARETSHOWING 0x08
DWORD
STDCALL
NtUserCallOneParam(

View file

@ -15,5 +15,17 @@ typedef struct _USER32_THREAD_DATA
PUSER32_THREAD_DATA User32GetThreadData();
VOID DeleteFrameBrushes(VOID);
/* a copy of this structure is in subsys/win32k/include/caret.h */
typedef struct _THRDCARETINFO
{
HWND hWnd;
HBITMAP Bitmap;
POINT Pos;
SIZE Size;
BYTE Visible;
BYTE Showing;
} THRDCARETINFO, *PTHRDCARETINFO;
VOID DeleteFrameBrushes(VOID);
void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);

View file

@ -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: caret.c,v 1.2 2003/10/16 22:07:37 weiden Exp $
/* $Id: caret.c,v 1.3 2003/10/17 20:31:56 weiden Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/caret.c
@ -34,6 +34,33 @@
/* FUNCTIONS *****************************************************************/
void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo)
{
HDC hDC, hComp;
hDC = GetDC(hWnd);
if(hDC)
{
if(CaretInfo->Bitmap && GetBitmapDimensionEx(CaretInfo->Bitmap, &CaretInfo->Size))
{
hComp = CreateCompatibleDC(hDC);
if(hComp)
{
SelectObject(hComp, CaretInfo->Bitmap);
BitBlt(hDC, CaretInfo->Pos.x, CaretInfo->Pos.y, CaretInfo->Size.cx, CaretInfo->Size.cy, hComp, 0, 0, SRCINVERT);
DeleteDC(hComp);
}
else
PatBlt(hDC, CaretInfo->Pos.x, CaretInfo->Pos.y, CaretInfo->Size.cx, CaretInfo->Size.cy, DSTINVERT);
}
else
{
PatBlt(hDC, CaretInfo->Pos.x, CaretInfo->Pos.y, CaretInfo->Size.cx, CaretInfo->Size.cy, DSTINVERT);
}
ReleaseDC(hWnd, hDC);
}
}
/*
* @implemented
*/

View file

@ -1,4 +1,4 @@
/* $Id: defwnd.c,v 1.98 2003/10/16 22:07:37 weiden Exp $
/* $Id: defwnd.c,v 1.99 2003/10/17 20:31:56 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@ -2268,12 +2268,15 @@ User32DefWindowProc(HWND hWnd,
case WM_SYSTIMER:
{
THRDCARETINFO CaretInfo;
switch(wParam)
{
case 0xffff: /* Caret timer */
/* switch showing byte in win32k */
NtUserCallNoParam(NOPARAM_ROUTINE_SWITCHCARETSHOWING);
/* FIXME - get the caret information and draw the caret */
/* switch showing byte in win32k and get information about the caret */
if(NtUserCallOneParam((DWORD)&CaretInfo, ONEPARAM_ROUTINE_SWITCHCARETSHOWING) && (CaretInfo.hWnd == hWnd))
{
DrawCaret(hWnd, &CaretInfo);
}
break;
}
break;

View file

@ -7,6 +7,7 @@
#define IDCARETTIMER (0xffff)
#define ThrdCaretInfo(x) (PTHRDCARETINFO)((PW32THREAD)(x + 1))
/* a copy of this structure is in lib/user32/include/user32.h */
typedef struct _THRDCARETINFO
{
HWND hWnd;
@ -27,7 +28,10 @@ BOOL FASTCALL
IntSetCaretPos(int X, int Y);
BOOL FASTCALL
IntSwitchCaretShowing(VOID);
IntSwitchCaretShowing(PVOID Info);
VOID FASTCALL
IntDrawCaret(HWND hWnd);
#endif /* __WIN32K_CARET_H */

View file

@ -1,4 +1,4 @@
/* $Id: caret.c,v 1.2 2003/10/16 22:07:37 weiden Exp $
/* $Id: caret.c,v 1.3 2003/10/17 20:31:56 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -15,14 +15,28 @@
#include <include/window.h>
#include <include/caret.h>
#include <include/timer.h>
#include <include/callback.h>
#define NDEBUG
#include <debug.h>
BOOL FASTCALL
IntHideCaret(PTHRDCARETINFO CaretInfo)
{
if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
{
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
CaretInfo->Showing = 0;
return TRUE;
}
return FALSE;
}
BOOL FASTCALL
IntDestroyCaret(PW32THREAD Win32Thread)
{
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(Win32Thread);
IntHideCaret(CaretInfo);
RtlZeroMemory(CaretInfo, sizeof(THRDCARETINFO));
return TRUE;
}
@ -48,8 +62,11 @@ IntSetCaretPos(int X, int Y)
{
if(CaretInfo->Pos.x != X || CaretInfo->Pos.y != Y)
{
IntHideCaret(CaretInfo);
CaretInfo->Showing = 0;
CaretInfo->Pos.x = X;
CaretInfo->Pos.y = Y;
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
IntSetTimer(CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
}
return TRUE;
@ -59,19 +76,32 @@ IntSetCaretPos(int X, int Y)
}
BOOL FASTCALL
IntSwitchCaretShowing(VOID)
IntSwitchCaretShowing(PVOID Info)
{
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread);
if(CaretInfo->hWnd)
{
CaretInfo->Showing = (CaretInfo->Showing ? 0 : 1);
MmCopyToCaller(Info, CaretInfo, sizeof(THRDCARETINFO));
return TRUE;
}
return FALSE;
}
VOID FASTCALL
IntDrawCaret(HWND hWnd)
{
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread);
if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing)
{
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
CaretInfo->Showing = 1;
}
}
BOOL
@ -102,6 +132,9 @@ NtUserCreateCaret(
IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE);
CaretInfo = ThrdCaretInfo(WindowObject->OwnerThread->Win32Thread);
IntHideCaret(CaretInfo);
CaretInfo->hWnd = hWnd;
if(hBitmap)
{
@ -183,10 +216,8 @@ NtUserHideCaret(
if(CaretInfo->Visible)
{
IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE);
if(CaretInfo->Showing)
{
/* FIXME send another WM_SYSTIMER message to hide the cursor */
}
IntHideCaret(CaretInfo);
CaretInfo->Visible = 0;
CaretInfo->Showing = 0;
}
@ -229,7 +260,10 @@ NtUserShowCaret(
if(!CaretInfo->Visible)
{
CaretInfo->Visible = 1;
CaretInfo->Showing = 0;
if(!CaretInfo->Showing)
{
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
}
IntSetTimer(hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
}

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.20 2003/10/16 22:07:37 weiden Exp $
/* $Id: misc.c,v 1.21 2003/10/17 20:31:56 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -63,10 +63,6 @@ NtUserCallNoParam(DWORD Routine)
Result = (DWORD)IntDestroyCaret(PsGetCurrentThread()->Win32Thread);
break;
case NOPARAM_ROUTINE_SWITCHCARETSHOWING:
Result = (DWORD)IntSwitchCaretShowing();
break;
default:
DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam\n");
SetLastWin32Error(ERROR_INVALID_PARAMETER);
@ -144,6 +140,9 @@ NtUserCallOneParam(
ObDereferenceObject(WinStaObject);
return Result;
case ONEPARAM_ROUTINE_SWITCHCARETSHOWING:
return (DWORD)IntSwitchCaretShowing((PVOID)Param);
case ONEPARAM_ROUTINE_SETCARETBLINKTIME:
return (DWORD)IntSetCaretBlinkTime((UINT)Param);