Changeset 38:4d6511d2441f
- Timestamp:
- 02/01/08 10:16:51
(1 year ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
Canvas
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r37 |
r38 |
|
| 4281 | 4281 | alias WINAPI.GetSysColor GetSysColor; |
|---|
| 4282 | 4282 | alias WINAPI.GetSysColorBrush GetSysColorBrush; |
|---|
| | 4283 | alias WINAPI.GetSystemDefaultUILanguage GetSystemDefaultUILanguage; |
|---|
| 4283 | 4284 | alias WINAPI.GetSystemMenu GetSystemMenu; |
|---|
| 4284 | 4285 | alias WINAPI.GetSystemMetrics GetSystemMetrics; |
|---|
| … | … | |
| 4394 | 4395 | alias WINAPI.MultiByteToWideChar MultiByteToWideChar; |
|---|
| 4395 | 4396 | alias WINAPI.NotifyWinEvent NotifyWinEvent; |
|---|
| | 4397 | alias STDWIN.OffsetRect OffsetRect; |
|---|
| 4396 | 4398 | alias WINAPI.OffsetRgn OffsetRgn; |
|---|
| 4397 | 4399 | //alias WINAPI.OleInitialize OleInitialize; |
|---|
| … | … | |
| 4413 | 4415 | alias WINAPI.PrintDlgA PrintDlgA; |
|---|
| 4414 | 4416 | alias WINAPI.PrintDlgW PrintDlgW; |
|---|
| | 4417 | alias WINAPI.PRIMARYLANGID PRIMARYLANGID; |
|---|
| 4415 | 4418 | alias WINAPI.PtInRect PtInRect; |
|---|
| 4416 | 4419 | alias WINAPI.PtInRegion PtInRegion; |
|---|
| r37 |
r38 |
|
| 132 | 132 | HPAINTBUFFER hBufferedPaint, |
|---|
| 133 | 133 | BOOL fUpdateTarget |
|---|
| | 134 | ); |
|---|
| | 135 | LANGID GetSystemDefaultUILanguage(); |
|---|
| | 136 | WORD PRIMARYLANGID( |
|---|
| | 137 | WORD lgid |
|---|
| 134 | 138 | ); |
|---|
| 135 | 139 | } |
|---|
| r31 |
r38 |
|
| 15 | 15 | import dwt.widgets.Composite; |
|---|
| 16 | 16 | |
|---|
| 17 | | class Canvas : Composite { |
|---|
| 18 | | } |
|---|
| 19 | | |
|---|
| 20 | | /++ |
|---|
| | 17 | |
|---|
| 21 | 18 | import dwt.DWT; |
|---|
| 22 | 19 | import dwt.DWTException; |
|---|
| … | … | |
| 24 | 21 | import dwt.graphics.GC; |
|---|
| 25 | 22 | import dwt.graphics.Rectangle; |
|---|
| 26 | | import dwt.internal.win32.COMPOSITIONFORM; |
|---|
| 27 | | import dwt.internal.win32.LRESULT; |
|---|
| 28 | 23 | import dwt.internal.win32.OS; |
|---|
| 29 | | import dwt.internal.win32.POINT; |
|---|
| 30 | | import dwt.internal.win32.RECT; |
|---|
| | 24 | import dwt.widgets.Caret; |
|---|
| | 25 | import dwt.widgets.Control; |
|---|
| | 26 | import dwt.widgets.Display; |
|---|
| | 27 | |
|---|
| | 28 | import dwt.dwthelper.utils; |
|---|
| 31 | 29 | |
|---|
| 32 | 30 | /** |
|---|
| … | … | |
| 50 | 48 | */ |
|---|
| 51 | 49 | |
|---|
| 52 | | public class Canvas extends Composite { |
|---|
| | 50 | public class Canvas : Composite { |
|---|
| | 51 | |
|---|
| | 52 | alias Composite.drawBackground drawBackground; |
|---|
| | 53 | |
|---|
| 53 | 54 | Caret caret; |
|---|
| 54 | 55 | |
|---|
| … | … | |
| 56 | 57 | * Prevents uninitialized instances from being created outside the package. |
|---|
| 57 | 58 | */ |
|---|
| 58 | | Canvas () { |
|---|
| | 59 | this () { |
|---|
| 59 | 60 | } |
|---|
| 60 | 61 | |
|---|
| … | … | |
| 86 | 87 | * @see Widget#getStyle |
|---|
| 87 | 88 | */ |
|---|
| 88 | | public Canvas (Composite parent, int style) { |
|---|
| | 89 | public this (Composite parent, int style) { |
|---|
| 89 | 90 | super (parent, style); |
|---|
| 90 | 91 | } |
|---|
| … | … | |
| 93 | 94 | checkWidget (); |
|---|
| 94 | 95 | if (OS.IsWindowVisible (handle)) { |
|---|
| 95 | | RECT rect = new RECT (); |
|---|
| 96 | | OS.SetRect (rect, x, y, x + width, y + height); |
|---|
| 97 | | int hDC = OS.GetDCEx (handle, 0, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS); |
|---|
| 98 | | drawBackground (hDC, rect); |
|---|
| | 96 | RECT rect; |
|---|
| | 97 | OS.SetRect (&rect, x, y, x + width, y + height); |
|---|
| | 98 | auto hDC = OS.GetDCEx (handle, null, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS); |
|---|
| | 99 | drawBackground (hDC, &rect); |
|---|
| 99 | 100 | OS.ReleaseDC (handle, hDC); |
|---|
| 100 | 101 | } |
|---|
| … | … | |
| 157 | 158 | if (gc is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 158 | 159 | if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); |
|---|
| 159 | | RECT rect = new RECT (); |
|---|
| 160 | | OS.SetRect (rect, x, y, x + width, y + height); |
|---|
| 161 | | int hDC = gc.handle; |
|---|
| | 160 | RECT rect; |
|---|
| | 161 | OS.SetRect (&rect, x, y, x + width, y + height); |
|---|
| | 162 | auto hDC = gc.handle; |
|---|
| 162 | 163 | int pixel = background is -1 ? gc.getBackground ().handle : -1; |
|---|
| 163 | | drawBackground (hDC, rect, pixel); |
|---|
| | 164 | drawBackground (hDC, &rect, pixel); |
|---|
| 164 | 165 | } |
|---|
| 165 | 166 | |
|---|
| … | … | |
| 191 | 192 | bool isFocus = caret !is null && caret.isFocusCaret (); |
|---|
| 192 | 193 | if (isFocus) caret.killFocus (); |
|---|
| 193 | | RECT sourceRect = new RECT (); |
|---|
| 194 | | OS.SetRect (sourceRect, x, y, x + width, y + height); |
|---|
| 195 | | RECT clientRect = new RECT (); |
|---|
| 196 | | OS.GetClientRect (handle, clientRect); |
|---|
| 197 | | if (OS.IntersectRect (clientRect, sourceRect, clientRect)) { |
|---|
| | 194 | RECT sourceRect; |
|---|
| | 195 | OS.SetRect (&sourceRect, x, y, x + width, y + height); |
|---|
| | 196 | RECT clientRect; |
|---|
| | 197 | OS.GetClientRect (handle, &clientRect); |
|---|
| | 198 | if (OS.IntersectRect (&clientRect, &sourceRect, &clientRect)) { |
|---|
| 198 | 199 | if (OS.IsWinCE) { |
|---|
| 199 | 200 | OS.UpdateWindow (handle); |
|---|
| 200 | 201 | } else { |
|---|
| 201 | 202 | int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; |
|---|
| 202 | | OS.RedrawWindow (handle, null, 0, flags); |
|---|
| | 203 | OS.RedrawWindow (handle, null, null, flags); |
|---|
| 203 | 204 | } |
|---|
| 204 | 205 | } |
|---|
| … | … | |
| 206 | 207 | if (findImageControl () !is null) { |
|---|
| 207 | 208 | if (OS.IsWinCE) { |
|---|
| 208 | | OS.InvalidateRect (handle, sourceRect, true); |
|---|
| | 209 | OS.InvalidateRect (handle, &sourceRect, true); |
|---|
| 209 | 210 | } else { |
|---|
| 210 | 211 | int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; |
|---|
| 211 | 212 | if (all) flags |= OS.RDW_ALLCHILDREN; |
|---|
| 212 | | OS.RedrawWindow (handle, sourceRect, 0, flags); |
|---|
| 213 | | } |
|---|
| 214 | | OS.OffsetRect (sourceRect, deltaX, deltaY); |
|---|
| | 213 | OS.RedrawWindow (handle, &sourceRect, null, flags); |
|---|
| | 214 | } |
|---|
| | 215 | OS.OffsetRect (&sourceRect, deltaX, deltaY); |
|---|
| 215 | 216 | if (OS.IsWinCE) { |
|---|
| 216 | | OS.InvalidateRect (handle, sourceRect, true); |
|---|
| | 217 | OS.InvalidateRect (handle, &sourceRect, true); |
|---|
| 217 | 218 | } else { |
|---|
| 218 | 219 | int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; |
|---|
| 219 | 220 | if (all) flags |= OS.RDW_ALLCHILDREN; |
|---|
| 220 | | OS.RedrawWindow (handle, sourceRect, 0, flags); |
|---|
| | 221 | OS.RedrawWindow (handle, &sourceRect, null, flags); |
|---|
| 221 | 222 | } |
|---|
| 222 | 223 | } else { |
|---|
| … | … | |
| 237 | 238 | */ |
|---|
| 238 | 239 | // if (all) flags |= OS.SW_SCROLLCHILDREN; |
|---|
| 239 | | OS.ScrollWindowEx (handle, deltaX, deltaY, sourceRect, null, 0, null, flags); |
|---|
| | 240 | OS.ScrollWindowEx (handle, deltaX, deltaY, &sourceRect, null, null, null, flags); |
|---|
| 240 | 241 | } |
|---|
| 241 | 242 | if (all) { |
|---|
| … | … | |
| 293 | 294 | } |
|---|
| 294 | 295 | |
|---|
| 295 | | int windowProc (int hwnd, int msg, int wParam, int lParam) { |
|---|
| | 296 | override int windowProc (HWND hwnd, int msg, int wParam, int lParam) { |
|---|
| 296 | 297 | if (msg is Display.SWT_RESTORECARET) { |
|---|
| 297 | 298 | if ((state & CANVAS) !is 0) { |
|---|
| … | … | |
| 322 | 323 | if (primaryLang is OS.LANG_KOREAN) { |
|---|
| 323 | 324 | if (caret !is null && caret.isFocusCaret ()) { |
|---|
| 324 | | POINT ptCurrentPos = new POINT (); |
|---|
| 325 | | if (OS.GetCaretPos (ptCurrentPos)) { |
|---|
| 326 | | COMPOSITIONFORM lpCompForm = new COMPOSITIONFORM (); |
|---|
| | 325 | POINT ptCurrentPos; |
|---|
| | 326 | if (OS.GetCaretPos (&ptCurrentPos)) { |
|---|
| | 327 | COMPOSITIONFORM lpCompForm; |
|---|
| 327 | 328 | lpCompForm.dwStyle = OS.CFS_POINT; |
|---|
| 328 | | lpCompForm.x = ptCurrentPos.x; |
|---|
| 329 | | lpCompForm.y = ptCurrentPos.y; |
|---|
| 330 | | int hIMC = OS.ImmGetContext (handle); |
|---|
| 331 | | OS.ImmSetCompositionWindow (hIMC, lpCompForm); |
|---|
| | 329 | lpCompForm.ptCurrentPos.x = ptCurrentPos.x; |
|---|
| | 330 | lpCompForm.ptCurrentPos.y = ptCurrentPos.y; |
|---|
| | 331 | auto hIMC = OS.ImmGetContext (handle); |
|---|
| | 332 | OS.ImmSetCompositionWindow (hIMC, &lpCompForm); |
|---|
| 332 | 333 | OS.ImmReleaseContext (handle, hIMC); |
|---|
| 333 | 334 | } |
|---|
| … | … | |
| 368 | 369 | LRESULT WM_WINDOWPOSCHANGED (int wParam, int lParam) { |
|---|
| 369 | 370 | LRESULT result = super.WM_WINDOWPOSCHANGED (wParam, lParam); |
|---|
| 370 | | if (result !is null) return result; |
|---|
| | 371 | if (result !is LRESULT.NULL) return result; |
|---|
| 371 | 372 | /* |
|---|
| 372 | 373 | * Bug in Windows. When a window with style WS_EX_LAYOUTRTL |
|---|
| … | … | |
| 383 | 384 | LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { |
|---|
| 384 | 385 | LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam); |
|---|
| 385 | | if (result !is null) return result; |
|---|
| | 386 | if (result !is LRESULT.NULL) return result; |
|---|
| 386 | 387 | /* |
|---|
| 387 | 388 | * Bug in Windows. When a window with style WS_EX_LAYOUTRTL |
|---|
| … | … | |
| 397 | 398 | |
|---|
| 398 | 399 | } |
|---|
| 399 | | ++/ |
|---|
| r31 |
r38 |
|
| 14 | 14 | |
|---|
| 15 | 15 | import dwt.widgets.Widget; |
|---|
| | 16 | import dwt.graphics.Font; |
|---|
| 16 | 17 | |
|---|
| 17 | 18 | class Caret : Widget { |
|---|
| 18 | 19 | this( Widget, int ); |
|---|
| | 20 | bool isFocusCaret () ; |
|---|
| | 21 | void killFocus () ; |
|---|
| | 22 | void setFocus () ; |
|---|
| | 23 | public void setFont (Font font) ; |
|---|
| | 24 | void setIMEFont () ; |
|---|
| | 25 | void resizeIME () ; |
|---|
| 19 | 26 | } |
|---|
| 20 | 27 | /++ |
|---|
| r36 |
r38 |
|
| 39 | 39 | |
|---|
| 40 | 40 | public abstract class Scrollable : Control { |
|---|
| | 41 | |
|---|
| | 42 | alias Control.windowProc windowProc; |
|---|
| | 43 | |
|---|
| 41 | 44 | ScrollBar horizontalBar, verticalBar; |
|---|
| 42 | 45 | |
|---|