|
Lines 55-60
Link Here
|
| 55 |
* @noextend This class is not intended to be subclassed by clients. |
55 |
* @noextend This class is not intended to be subclassed by clients. |
| 56 |
*/ |
56 |
*/ |
| 57 |
public class Text extends Scrollable { |
57 |
public class Text extends Scrollable { |
|
|
58 |
int /*long*/ toolbarHandle; |
| 58 |
int tabs, oldStart, oldEnd; |
59 |
int tabs, oldStart, oldEnd; |
| 59 |
boolean doubleClick, ignoreModify, ignoreVerify, ignoreCharacter; |
60 |
boolean doubleClick, ignoreModify, ignoreVerify, ignoreCharacter; |
| 60 |
String message; |
61 |
String message; |
|
Lines 90-95
Link Here
|
| 90 |
LIMIT = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF; |
91 |
LIMIT = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF; |
| 91 |
DELIMITER = "\r\n"; |
92 |
DELIMITER = "\r\n"; |
| 92 |
} |
93 |
} |
|
|
94 |
static final int /*long*/ ToolBarProc; |
| 95 |
static final TCHAR ToolBarClass = new TCHAR (0, OS.TOOLBARCLASSNAME, true); |
| 96 |
static { |
| 97 |
WNDCLASS lpWndClass = new WNDCLASS (); |
| 98 |
OS.GetClassInfo (0, ToolBarClass, lpWndClass); |
| 99 |
ToolBarProc = lpWndClass.lpfnWndProc; |
| 100 |
} |
| 93 |
|
101 |
|
| 94 |
static final int /*long*/ EditProc; |
102 |
static final int /*long*/ EditProc; |
| 95 |
static final TCHAR EditClass = new TCHAR (0, "EDIT", true); |
103 |
static final TCHAR EditClass = new TCHAR (0, "EDIT", true); |
|
Lines 158-163
Link Here
|
| 158 |
|
166 |
|
| 159 |
int /*long*/ callWindowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*long*/ lParam) { |
167 |
int /*long*/ callWindowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*long*/ lParam) { |
| 160 |
if (handle == 0) return 0; |
168 |
if (handle == 0) return 0; |
|
|
169 |
if (hwnd == toolbarHandle) { |
| 170 |
return OS.CallWindowProc (ToolBarProc, hwnd, msg, wParam, lParam); |
| 171 |
} |
| 161 |
boolean redraw = false; |
172 |
boolean redraw = false; |
| 162 |
switch (msg) { |
173 |
switch (msg) { |
| 163 |
case OS.WM_ERASEBKGND: { |
174 |
case OS.WM_ERASEBKGND: { |
|
Lines 267-272
Link Here
|
| 267 |
} |
278 |
} |
| 268 |
|
279 |
|
| 269 |
void createHandle () { |
280 |
void createHandle () { |
|
|
281 |
if ((style & SWT.SEARCH) != 0) { |
| 282 |
int bits = OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS | OS.WS_CLIPCHILDREN; |
| 283 |
bits |= OS.CCS_NODIVIDER | OS.CCS_NORESIZE;// | OS.TBSTYLE_LIST | OS.TBSTYLE_FLAT; |
| 284 |
// if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) bits |= OS.TBSTYLE_TRANSPARENT; |
| 285 |
int /*long*/ hwndParent = parent.handle; |
| 286 |
int exBits = OS.WS_EX_NOINHERITLAYOUT; |
| 287 |
if ((style & SWT.RIGHT_TO_LEFT) != 0) exBits |= OS.WS_EX_LAYOUTRTL; |
| 288 |
toolbarHandle = OS.CreateWindowEx ( |
| 289 |
exBits, |
| 290 |
ToolBarClass, |
| 291 |
null, |
| 292 |
bits, |
| 293 |
OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, |
| 294 |
hwndParent, |
| 295 |
0, |
| 296 |
OS.GetModuleHandle (null), |
| 297 |
null); |
| 298 |
if (toolbarHandle == 0) error (SWT.ERROR_NO_HANDLES); |
| 299 |
// Image cancelImage = new Image (display, "C:\\silenio\\workspace-clean\\org.eclipse.swt.snippets\\src\\org\\eclipse\\swt\\snippets\\eclipse.png"); |
| 300 |
// Image searchImage = new Image (display, "C:\\silenio\\workspace-clean\\org.eclipse.swt.snippets\\src\\org\\eclipse\\swt\\snippets\\eclipse.png"); |
| 301 |
|
| 302 |
/* Set the button struct, bitmap and button sizes */ |
| 303 |
// Rectangle bounds = searchImage.getBounds(); |
| 304 |
OS.SendMessage (toolbarHandle, OS.TB_BUTTONSTRUCTSIZE, TBBUTTON.sizeof, 0); |
| 305 |
// OS.SendMessage (toolbarHandle, OS.TB_SETBITMAPSIZE, 0, 0); |
| 306 |
// OS.SendMessage (toolbarHandle, OS.TB_SETBUTTONSIZE, 0, 0); |
| 307 |
|
| 308 |
/* Set the extended style bits */ |
| 309 |
bits = OS.TBSTYLE_EX_MIXEDBUTTONS; |
| 310 |
if (OS.COMCTL32_MAJOR >= 6) bits |= OS.TBSTYLE_EX_DOUBLEBUFFER; |
| 311 |
OS.SendMessage (toolbarHandle, OS.TB_SETEXTENDEDSTYLE, 0, bits); |
| 312 |
|
| 313 |
int /*long*/ imageList = OS.ImageList_Create (16, 16, OS.ILC_COLOR32, 2, 2); |
| 314 |
OS.SendMessage (toolbarHandle, OS.TB_SETIMAGELIST, 0, imageList); |
| 315 |
|
| 316 |
// OS.SendMessage (toolbarHandle, OS.TB_SETBUTTONSIZE, 16, 16); |
| 317 |
|
| 318 |
TBBUTTON lpButton = new TBBUTTON (); |
| 319 |
lpButton.idCommand = 1; |
| 320 |
lpButton.fsStyle = (byte) (OS.BTNS_BUTTON | OS.BTNS_AUTOSIZE); |
| 321 |
lpButton.fsState = (byte) OS.TBSTATE_ENABLED; |
| 322 |
lpButton.iBitmap = 5;//imageList.add(cancelImage); |
| 323 |
OS.SendMessage (toolbarHandle, OS.TB_INSERTBUTTON, 0, lpButton); |
| 324 |
lpButton.idCommand = 2; |
| 325 |
lpButton.fsStyle = (byte) OS.BTNS_SEP; |
| 326 |
OS.SendMessage (toolbarHandle, OS.TB_INSERTBUTTON, 0, lpButton); |
| 327 |
lpButton.idCommand = 3; |
| 328 |
lpButton.fsStyle = (byte) (OS.BTNS_BUTTON | OS.BTNS_AUTOSIZE); |
| 329 |
lpButton.fsState = (byte) OS.TBSTATE_ENABLED;; |
| 330 |
lpButton.iBitmap = 12;//imageList.add(searchImage); |
| 331 |
OS.SendMessage (toolbarHandle, OS.TB_INSERTBUTTON, 0, lpButton); |
| 332 |
|
| 333 |
OS.SendMessage(toolbarHandle, OS.TB_LOADIMAGES, OS.IDB_STD_SMALL_COLOR, OS.HINST_COMMCTRL); |
| 334 |
// OS.SendMessage(toolbarHandle, OS.WM_USER + 87, 0, 0); |
| 335 |
|
| 336 |
// OS.SendMessage (toolbarHandle, OS.TB_SETBUTTONSIZE, 20, 20); |
| 337 |
|
| 338 |
|
| 339 |
// TBBUTTONINFO info = new TBBUTTONINFO (); |
| 340 |
// info.cbSize = TBBUTTONINFO.sizeof; |
| 341 |
// info.dwMask = OS.TBIF_STYLE; |
| 342 |
// info.fsStyle = (byte) (OS.BTNS_AUTOSIZE); |
| 343 |
// OS.SendMessage (toolbarHandle, OS.TB_SETBUTTONINFO, 1, info); |
| 344 |
// OS.SendMessage (toolbarHandle, OS.TB_SETBUTTONINFO, 3, info); |
| 345 |
|
| 346 |
bits = OS.GetWindowLong (toolbarHandle, OS.GWL_STYLE); |
| 347 |
if ((bits & OS.WS_CHILD) != 0) { |
| 348 |
OS.SetWindowLongPtr (toolbarHandle, OS.GWLP_ID, toolbarHandle); |
| 349 |
} |
| 350 |
if (OS.IsDBLocale && hwndParent != 0) { |
| 351 |
int /*long*/ hIMC = OS.ImmGetContext (hwndParent); |
| 352 |
OS.ImmAssociateContext (toolbarHandle, hIMC); |
| 353 |
OS.ImmReleaseContext (hwndParent, hIMC); |
| 354 |
} |
| 355 |
} |
| 270 |
super.createHandle (); |
356 |
super.createHandle (); |
| 271 |
OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0); |
357 |
OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0); |
| 272 |
if ((style & SWT.READ_ONLY) != 0) { |
358 |
if ((style & SWT.READ_ONLY) != 0) { |
|
Lines 574-579
Link Here
|
| 574 |
return OS.GetSysColor ((bits & OS.ES_READONLY) != 0 ? OS.COLOR_3DFACE : OS.COLOR_WINDOW); |
660 |
return OS.GetSysColor ((bits & OS.ES_READONLY) != 0 ? OS.COLOR_3DFACE : OS.COLOR_WINDOW); |
| 575 |
} |
661 |
} |
| 576 |
|
662 |
|
|
|
663 |
void deregister () { |
| 664 |
super.deregister (); |
| 665 |
if (toolbarHandle != 0) display.removeControl (toolbarHandle); |
| 666 |
} |
| 667 |
|
| 577 |
boolean dragDetect (int /*long*/ hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) { |
668 |
boolean dragDetect (int /*long*/ hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) { |
| 578 |
if (filter) { |
669 |
if (filter) { |
| 579 |
int [] start = new int [1], end = new int [1]; |
670 |
int [] start = new int [1], end = new int [1]; |
|
Lines 1332-1337
Link Here
|
| 1332 |
OS.SendMessage (handle, OS.WM_PASTE, 0, 0); |
1423 |
OS.SendMessage (handle, OS.WM_PASTE, 0, 0); |
| 1333 |
} |
1424 |
} |
| 1334 |
|
1425 |
|
|
|
1426 |
void register () { |
| 1427 |
super.register(); |
| 1428 |
if (toolbarHandle != 0) display.addControl (toolbarHandle, this); |
| 1429 |
} |
| 1430 |
|
| 1335 |
void releaseWidget () { |
1431 |
void releaseWidget () { |
| 1336 |
super.releaseWidget (); |
1432 |
super.releaseWidget (); |
| 1337 |
message = null; |
1433 |
message = null; |
|
Lines 2042-2047
Link Here
|
| 2042 |
OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0); |
2138 |
OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0); |
| 2043 |
} |
2139 |
} |
| 2044 |
|
2140 |
|
|
|
2141 |
void subclass () { |
| 2142 |
super.subclass(); |
| 2143 |
if (toolbarHandle != 0) { |
| 2144 |
int /*long*/ oldProc = ToolBarProc; |
| 2145 |
int /*long*/ newProc = display.windowProc; |
| 2146 |
if (oldProc == newProc) return; |
| 2147 |
OS.SetWindowLongPtr (toolbarHandle, OS.GWLP_WNDPROC, newProc); |
| 2148 |
} |
| 2149 |
} |
| 2150 |
|
| 2151 |
int /*long*/ topHandle () { |
| 2152 |
return toolbarHandle != 0 ? toolbarHandle : handle; |
| 2153 |
} |
| 2154 |
|
| 2155 |
void unsubclass () { |
| 2156 |
if (toolbarHandle != 0) { |
| 2157 |
int /*long*/ newProc = ToolBarProc; |
| 2158 |
int /*long*/ oldProc = display.windowProc; |
| 2159 |
if (oldProc == newProc) return; |
| 2160 |
OS.SetWindowLongPtr (toolbarHandle, OS.GWLP_WNDPROC, newProc); |
| 2161 |
} |
| 2162 |
super.unsubclass(); |
| 2163 |
} |
| 2164 |
|
| 2045 |
String verifyText (String string, int start, int end, Event keyEvent) { |
2165 |
String verifyText (String string, int start, int end, Event keyEvent) { |
| 2046 |
if (ignoreVerify) return string; |
2166 |
if (ignoreVerify) return string; |
| 2047 |
Event event = new Event (); |
2167 |
Event event = new Event (); |
|
Lines 2115-2120
Link Here
|
| 2115 |
return mbcsTotal; |
2235 |
return mbcsTotal; |
| 2116 |
} |
2236 |
} |
| 2117 |
|
2237 |
|
|
|
2238 |
int /*long*/ widgetParent () { |
| 2239 |
if (toolbarHandle != 0) return toolbarHandle; |
| 2240 |
return super.widgetParent (); |
| 2241 |
} |
| 2242 |
|
| 2118 |
int widgetStyle () { |
2243 |
int widgetStyle () { |
| 2119 |
int bits = super.widgetStyle () | OS.ES_AUTOHSCROLL; |
2244 |
int bits = super.widgetStyle () | OS.ES_AUTOHSCROLL; |
| 2120 |
if ((style & SWT.PASSWORD) != 0) bits |= OS.ES_PASSWORD; |
2245 |
if ((style & SWT.PASSWORD) != 0) bits |= OS.ES_PASSWORD; |
|
Lines 2154-2159
Link Here
|
| 2154 |
} |
2279 |
} |
| 2155 |
|
2280 |
|
| 2156 |
int /*long*/ windowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*long*/ lParam) { |
2281 |
int /*long*/ windowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*long*/ lParam) { |
|
|
2282 |
if (toolbarHandle != 0 && hwnd == toolbarHandle) { |
| 2283 |
switch (msg) { |
| 2284 |
// case OS.WM_ERASEBKGND: |
| 2285 |
// drawBackground (wParam); |
| 2286 |
// return 1; |
| 2287 |
case OS.WM_MOVE: { |
| 2288 |
sendEvent (SWT.Move); |
| 2289 |
return 0; |
| 2290 |
} |
| 2291 |
case OS.WM_SIZE: { |
| 2292 |
int /*long*/ code = callWindowProc (hwnd, OS.WM_SIZE, wParam, lParam); |
| 2293 |
sendEvent (SWT.Resize); |
| 2294 |
if (isDisposed ()) return 0; |
| 2295 |
RECT rect = new RECT (); |
| 2296 |
OS.GetClientRect (hwnd, rect); |
| 2297 |
int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; |
| 2298 |
|
| 2299 |
int width = rect.right - rect.left; |
| 2300 |
RECT itemRect = new RECT (); |
| 2301 |
int index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, 1, 0); |
| 2302 |
OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, itemRect); |
| 2303 |
System.out.println((itemRect.right - itemRect.left) + " " + (itemRect.bottom - itemRect.top)); |
| 2304 |
|
| 2305 |
width -= (itemRect.right - itemRect.left); |
| 2306 |
int x = itemRect.right - itemRect.left; |
| 2307 |
index = (int)/*64*/OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, 3, 0); |
| 2308 |
OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, itemRect); |
| 2309 |
width -= (itemRect.right - itemRect.left); |
| 2310 |
SetWindowPos (handle, 0, x, 0, width, rect.bottom - rect.top, flags); |
| 2311 |
|
| 2312 |
TBBUTTONINFO info = new TBBUTTONINFO (); |
| 2313 |
info.cbSize = TBBUTTONINFO.sizeof; |
| 2314 |
info.dwMask = OS.TBIF_SIZE; |
| 2315 |
info.cx = (short)width; |
| 2316 |
OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, 2, info); |
| 2317 |
// OS.SendMessage (hwnd, OS.TB_AUTOSIZE, 0, 0); |
| 2318 |
return code; |
| 2319 |
} |
| 2320 |
case OS.WM_NCPAINT: { |
| 2321 |
LRESULT result = wmNCPaint (hwnd, wParam, lParam); |
| 2322 |
if (result != null) return result.value; |
| 2323 |
break; |
| 2324 |
} |
| 2325 |
case OS.WM_PRINT: { |
| 2326 |
LRESULT result = wmPrint (hwnd, wParam, lParam); |
| 2327 |
if (result != null) return result.value; |
| 2328 |
break; |
| 2329 |
} |
| 2330 |
// case OS.WM_COMMAND: |
| 2331 |
// case OS.WM_NOTIFY: |
| 2332 |
// case OS.WM_SYSCOLORCHANGE: { |
| 2333 |
// return OS.SendMessage (handle, msg, wParam, lParam); |
| 2334 |
// } |
| 2335 |
} |
| 2336 |
return callWindowProc (hwnd, msg, wParam, lParam); |
| 2337 |
} |
| 2338 |
|
| 2157 |
if (msg == OS.EM_UNDO) { |
2339 |
if (msg == OS.EM_UNDO) { |
| 2158 |
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); |
2340 |
int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); |
| 2159 |
if ((bits & OS.ES_MULTILINE) == 0) { |
2341 |
if ((bits & OS.ES_MULTILINE) == 0) { |
|
Lines 2401-2406
Link Here
|
| 2401 |
return wmClipboard (OS.WM_PASTE, wParam, lParam); |
2583 |
return wmClipboard (OS.WM_PASTE, wParam, lParam); |
| 2402 |
} |
2584 |
} |
| 2403 |
|
2585 |
|
|
|
2586 |
LRESULT WM_SIZE (int /*long*/ wParam, int /*long*/ lParam) { |
| 2587 |
|
| 2588 |
return super.WM_SIZE(wParam, lParam); |
| 2589 |
} |
| 2590 |
|
| 2404 |
LRESULT WM_UNDO (int /*long*/ wParam, int /*long*/ lParam) { |
2591 |
LRESULT WM_UNDO (int /*long*/ wParam, int /*long*/ lParam) { |
| 2405 |
LRESULT result = super.WM_UNDO (wParam, lParam); |
2592 |
LRESULT result = super.WM_UNDO (wParam, lParam); |
| 2406 |
if (result != null) return result; |
2593 |
if (result != null) return result; |