4 * Copyright 1993 David Metcalfe
12 /* #define DEBUG_CARET */
32 static BOOL LockCaret
;
34 static void CARET_HideCaret();
37 /*****************************************************************
40 WORD
CARET_Callback(HWND hwnd
, WORD msg
, WORD timerid
, LONG ctime
)
46 dprintf_caret(stddeb
,"CARET_Callback: id=%d: LockCaret=%d, hidden=%d, on=%d\n",
47 timerid
, LockCaret
, Caret
.hidden
, Caret
.on
);
48 if (!LockCaret
&& (!Caret
.hidden
|| Caret
.on
))
50 Caret
.on
= (Caret
.on
? FALSE
: TRUE
);
51 hdc
= GetDC(Caret
.hwnd
);
52 if (Caret
.bitmap
== (HBITMAP
)0 || Caret
.bitmap
== (HBITMAP
)1)
53 hBrush
= CreateSolidBrush(Caret
.color
);
55 hBrush
= CreatePatternBrush(Caret
.bitmap
);
56 SelectObject(hdc
, (HANDLE
)hBrush
);
57 SetROP2(hdc
, R2_NOTXORPEN
);
58 rgn
= CreateRectRgn(Caret
.x
, Caret
.y
,
59 Caret
.x
+ Caret
.width
,
60 Caret
.y
+ Caret
.height
);
61 FillRgn(hdc
, rgn
, hBrush
);
62 DeleteObject((HANDLE
)rgn
);
63 DeleteObject((HANDLE
)hBrush
);
64 ReleaseDC(Caret
.hwnd
, hdc
);
70 /*****************************************************************
74 static void CARET_HideCaret()
81 hdc
= GetDC(Caret
.hwnd
);
82 if (Caret
.bitmap
== (HBITMAP
)0 || Caret
.bitmap
== (HBITMAP
)1)
83 hBrush
= CreateSolidBrush(Caret
.color
);
85 hBrush
= CreatePatternBrush(Caret
.bitmap
);
86 SelectObject(hdc
, (HANDLE
)hBrush
);
87 SetROP2(hdc
, R2_NOTXORPEN
);
88 rgn
= CreateRectRgn(Caret
.x
, Caret
.y
,
89 Caret
.x
+ Caret
.width
,
90 Caret
.y
+ Caret
.height
);
91 FillRgn(hdc
, rgn
, hBrush
);
92 DeleteObject((HANDLE
)rgn
);
93 DeleteObject((HANDLE
)hBrush
);
94 ReleaseDC(Caret
.hwnd
, hdc
);
97 /*****************************************************************
100 static void CARET_Initialize()
102 DWORD WineProc
,Win16Proc
,Win32Proc
;
103 static int initialized
=0;
106 WineProc
=(DWORD
)CARET_Callback
;
107 Win16Proc
=(DWORD
)GetWndProcEntry16("CARET_Callback");
108 Win32Proc
=(DWORD
)RELAY32_GetEntryPoint(
109 RELAY32_GetBuiltinDLL("WINPROCS32"),"CARET_Callback",0);
110 ALIAS_RegisterAlias(WineProc
,Win16Proc
,Win32Proc
);
116 /*****************************************************************
117 * CreateCaret (USER.163)
120 BOOL
CreateCaret(HWND hwnd
, HBITMAP bitmap
, INT width
, INT height
)
122 if (!hwnd
) return FALSE
;
125 /* if cursor already exists, destroy it */
129 if (bitmap
&& bitmap
!= (HBITMAP
)1)
130 Caret
.bitmap
= bitmap
;
135 Caret
.width
= GetSystemMetrics(SM_CXBORDER
);
138 Caret
.height
= height
;
140 Caret
.height
= GetSystemMetrics(SM_CYBORDER
);
147 if (bitmap
== (HBITMAP
)1)
148 Caret
.color
= GetSysColor(COLOR_GRAYTEXT
);
150 Caret
.color
= GetSysColor(COLOR_WINDOWTEXT
);
156 Caret
.timerid
= SetSystemTimer( (HWND
)0, 0, Caret
.timeout
,
157 (FARPROC
)GetWndProcEntry16("CARET_Callback"));
159 dprintf_caret(stddeb
,"CreateCaret: hwnd="NPFMT
", timerid=%d\n",
160 hwnd
, Caret
.timerid
);
165 /*****************************************************************
166 * DestroyCaret (USER.164)
171 /* if (!Caret.hwnd) return;
173 dprintf_caret(stddeb
,"DestroyCaret: timerid=%d\n", Caret
.timerid
);
175 KillSystemTimer( (HWND
)0, Caret
.timerid
);
180 Caret
.hwnd
= 0; /* cursor marked as not existing */
185 /*****************************************************************
186 * SetCaretPos (USER.165)
189 void SetCaretPos(short x
, short y
)
191 if (!Caret
.hwnd
) return;
193 dprintf_caret(stddeb
,"SetCaretPos: x=%d, y=%d\n", x
, y
);
204 /*****************************************************************
205 * HideCaret (USER.166)
208 void HideCaret(HWND hwnd
)
210 if (!Caret
.hwnd
) return;
211 if (hwnd
&& (Caret
.hwnd
!= hwnd
)) return;
222 /*****************************************************************
223 * ShowCaret (USER.167)
226 void ShowCaret(HWND hwnd
)
228 if (!Caret
.hwnd
) return;
229 if (hwnd
&& (Caret
.hwnd
!= hwnd
)) return;
231 dprintf_caret(stddeb
,"ShowCaret: hidden=%d\n", Caret
.hidden
);
237 /*****************************************************************
238 * SetCaretBlinkTime (USER.168)
241 void SetCaretBlinkTime(WORD msecs
)
243 if (!Caret
.hwnd
) return;
247 KillSystemTimer( (HWND
)0, Caret
.timerid
);
248 Caret
.timeout
= msecs
;
249 Caret
.timerid
= SetSystemTimer( (HWND
)0, 0, Caret
.timeout
,
250 (FARPROC
)GetWndProcEntry16("CARET_Callback"));
254 /*****************************************************************
255 * GetCaretBlinkTime (USER.169)
258 WORD
GetCaretBlinkTime()
260 if (!Caret
.hwnd
) return 0;
261 return Caret
.timeout
;
265 /*****************************************************************
266 * GetCaretPos (USER.183)
269 void GetCaretPos(LPPOINT pt
)
271 if (!Caret
.hwnd
|| !pt
) return;