2 * a GUI application for displaying a console
4 * Copyright 2001 Eric Pouech
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "winecon_user.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
28 WINE_DECLARE_DEBUG_CHANNEL(wc_font);
30 /* mapping console colors to RGB values */
31 COLORREF WCUSER_ColorMap[16] =
33 RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0x80), RGB(0x00, 0x80, 0x00), RGB(0x00, 0x80, 0x80),
34 RGB(0x80, 0x00, 0x00), RGB(0x80, 0x00, 0x80), RGB(0x80, 0x80, 0x00), RGB(0x80, 0x80, 0x80),
35 RGB(0xC0, 0xC0, 0xC0), RGB(0x00, 0x00, 0xFF), RGB(0x00, 0xFF, 0x00), RGB(0x00, 0xFF, 0xFF),
36 RGB(0xFF, 0x00, 0x00), RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xFF),
39 /******************************************************************
42 * Fills the Mem DC with current cells values
44 static void WCUSER_FillMemDC(const struct inner_data* data, int upd_tp, int upd_bm)
52 /* no font has been set up yet, don't worry about filling the bitmap,
53 * we'll do it once a font is chosen
55 if (!PRIVATE(data)->hFont) return;
57 if (!(line = HeapAlloc(GetProcessHeap(), 0, data->curcfg.sb_width * sizeof(WCHAR))))
58 {WINE_ERR("OOM\n"); return;}
60 hOldFont = SelectObject(PRIVATE(data)->hMemDC, PRIVATE(data)->hFont);
61 for (j = upd_tp; j <= upd_bm; j++)
63 cell = &data->cells[j * data->curcfg.sb_width];
64 for (i = 0; i < data->curcfg.sb_width; i++)
66 attr = cell[i].Attributes;
67 SetBkColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[(attr>>4)&0x0F]);
68 SetTextColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[attr&0x0F]);
69 for (k = i; k < data->curcfg.sb_width && cell[k].Attributes == attr; k++)
71 line[k - i] = cell[k].Char.UnicodeChar;
73 TextOut(PRIVATE(data)->hMemDC, i * data->curcfg.cell_width, j * data->curcfg.cell_height,
78 SelectObject(PRIVATE(data)->hMemDC, hOldFont);
79 HeapFree(GetProcessHeap(), 0, line);
82 /******************************************************************
85 * Either the font geometry or the sb geometry has changed. we need to recreate the
88 static void WCUSER_NewBitmap(struct inner_data* data, BOOL fill)
93 if (!data->curcfg.sb_width || !data->curcfg.sb_height ||
94 !PRIVATE(data)->hFont || !(hDC = GetDC(PRIVATE(data)->hWnd)))
96 hnew = CreateCompatibleBitmap(hDC,
97 data->curcfg.sb_width * data->curcfg.cell_width,
98 data->curcfg.sb_height * data->curcfg.cell_height);
99 ReleaseDC(PRIVATE(data)->hWnd, hDC);
100 hold = SelectObject(PRIVATE(data)->hMemDC, hnew);
102 if (PRIVATE(data)->hBitmap)
104 if (hold == PRIVATE(data)->hBitmap)
105 DeleteObject(PRIVATE(data)->hBitmap);
107 WINE_FIXME("leak\n");
109 PRIVATE(data)->hBitmap = hnew;
111 WCUSER_FillMemDC(data, 0, data->curcfg.sb_height - 1);
114 /******************************************************************
115 * WCUSER_ResizeScreenBuffer
119 static void WCUSER_ResizeScreenBuffer(struct inner_data* data)
121 WCUSER_NewBitmap(data, FALSE);
124 /******************************************************************
127 * Set a new position for the cursor
129 static void WCUSER_PosCursor(const struct inner_data* data)
131 if (PRIVATE(data)->hWnd != GetFocus() || !data->curcfg.cursor_visible) return;
133 SetCaretPos((data->cursor.X - data->curcfg.win_pos.X) * data->curcfg.cell_width,
134 (data->cursor.Y - data->curcfg.win_pos.Y) * data->curcfg.cell_height);
135 ShowCaret(PRIVATE(data)->hWnd);
138 /******************************************************************
141 * Sets a new shape for the cursor
143 void WCUSER_ShapeCursor(struct inner_data* data, int size, int vis, BOOL force)
145 if (force || size != data->curcfg.cursor_size)
147 if (data->curcfg.cursor_visible && PRIVATE(data)->hWnd == GetFocus()) DestroyCaret();
148 if (PRIVATE(data)->cursor_bitmap) DeleteObject(PRIVATE(data)->cursor_bitmap);
149 PRIVATE(data)->cursor_bitmap = (HBITMAP)0;
152 int w16b; /* number of byets per row, aligned on word size */
156 w16b = ((data->curcfg.cell_width + 15) & ~15) / 8;
157 ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, w16b * data->curcfg.cell_height);
158 if (!ptr) {WINE_ERR("OOM\n"); return;}
159 nbl = max((data->curcfg.cell_height * size) / 100, 1);
160 for (j = data->curcfg.cell_height - nbl; j < data->curcfg.cell_height; j++)
162 for (i = 0; i < data->curcfg.cell_width; i++)
164 ptr[w16b * j + (i / 8)] |= 0x80 >> (i & 7);
167 PRIVATE(data)->cursor_bitmap = CreateBitmap(data->curcfg.cell_width,
168 data->curcfg.cell_height, 1, 1, ptr);
169 HeapFree(GetProcessHeap(), 0, ptr);
171 data->curcfg.cursor_size = size;
172 data->curcfg.cursor_visible = -1;
175 vis = (vis) ? TRUE : FALSE;
176 if (force || vis != data->curcfg.cursor_visible)
178 data->curcfg.cursor_visible = vis;
179 if (PRIVATE(data)->hWnd == GetFocus())
183 CreateCaret(PRIVATE(data)->hWnd, PRIVATE(data)->cursor_bitmap,
184 data->curcfg.cell_width, data->curcfg.cell_height);
185 WCUSER_PosCursor(data);
195 /******************************************************************
196 * INECON_ComputePositions
198 * Recomputes all the components (mainly scroll bars) positions
200 void WCUSER_ComputePositions(struct inner_data* data)
205 /* compute window size from desired client size */
207 r.right = data->curcfg.win_width * data->curcfg.cell_width;
208 r.bottom = data->curcfg.win_height * data->curcfg.cell_height;
212 ShowWindow(PRIVATE(data)->hWnd, SW_HIDE);
216 AdjustWindowRect(&r, GetWindowLong(PRIVATE(data)->hWnd, GWL_STYLE), FALSE);
219 if (data->curcfg.sb_width > data->curcfg.win_width)
221 dy = GetSystemMetrics(SM_CYHSCROLL);
222 SetScrollRange(PRIVATE(data)->hWnd, SB_HORZ, 0,
223 data->curcfg.sb_width - data->curcfg.win_width, FALSE);
224 SetScrollPos(PRIVATE(data)->hWnd, SB_HORZ, 0, FALSE); /* FIXME */
225 ShowScrollBar(PRIVATE(data)->hWnd, SB_HORZ, TRUE);
229 ShowScrollBar(PRIVATE(data)->hWnd, SB_HORZ, FALSE);
232 if (data->curcfg.sb_height > data->curcfg.win_height)
234 dx = GetSystemMetrics(SM_CXVSCROLL);
235 SetScrollRange(PRIVATE(data)->hWnd, SB_VERT, 0,
236 data->curcfg.sb_height - data->curcfg.win_height, FALSE);
237 SetScrollPos(PRIVATE(data)->hWnd, SB_VERT, 0, FALSE); /* FIXME */
238 ShowScrollBar(PRIVATE(data)->hWnd, SB_VERT, TRUE);
242 ShowScrollBar(PRIVATE(data)->hWnd, SB_VERT, FALSE);
245 SetWindowPos(PRIVATE(data)->hWnd, 0, 0, 0, r.right - r.left + dx, r.bottom - r.top + dy,
246 SWP_NOMOVE|SWP_NOZORDER|SWP_SHOWWINDOW);
247 WCUSER_ShapeCursor(data, data->curcfg.cursor_size, data->curcfg.cursor_visible, TRUE);
248 WCUSER_PosCursor(data);
251 /******************************************************************
254 * Sets the title to the wine console
256 static void WCUSER_SetTitle(const struct inner_data* data)
260 if (WINECON_GetConsoleTitle(data->hConIn, buffer, sizeof(buffer)))
261 SetWindowText(PRIVATE(data)->hWnd, buffer);
264 void WCUSER_DumpLogFont(const char* pfx, const LOGFONT* lf, DWORD ft)
266 WINE_TRACE_(wc_font)("%s %s%s%s%s\n"
267 "\tlf.lfHeight=%ld lf.lfWidth=%ld lf.lfEscapement=%ld lf.lfOrientation=%ld\n"
268 "\tlf.lfWeight=%ld lf.lfItalic=%u lf.lfUnderline=%u lf.lfStrikeOut=%u\n"
269 "\tlf.lfCharSet=%u lf.lfOutPrecision=%u lf.lfClipPrecision=%u lf.lfQuality=%u\n"
270 "\tlf->lfPitchAndFamily=%u lf.lfFaceName=%s\n",
272 (ft & RASTER_FONTTYPE) ? "raster" : "",
273 (ft & TRUETYPE_FONTTYPE) ? "truetype" : "",
274 ((ft & (RASTER_FONTTYPE|TRUETYPE_FONTTYPE)) == 0) ? "vector" : "",
275 (ft & DEVICE_FONTTYPE) ? "|device" : "",
276 lf->lfHeight, lf->lfWidth, lf->lfEscapement, lf->lfOrientation,
277 lf->lfWeight, lf->lfItalic, lf->lfUnderline, lf->lfStrikeOut, lf->lfCharSet,
278 lf->lfOutPrecision, lf->lfClipPrecision, lf->lfQuality, lf->lfPitchAndFamily,
279 wine_dbgstr_w(lf->lfFaceName));
282 void WCUSER_DumpTextMetric(const TEXTMETRIC* tm, DWORD ft)
284 WINE_TRACE_(wc_font)("%s%s%s%s\n"
285 "\ttmHeight=%ld tmAscent=%ld tmDescent=%ld tmInternalLeading=%ld tmExternalLeading=%ld\n"
286 "\ttmAveCharWidth=%ld tmMaxCharWidth=%ld tmWeight=%ld tmOverhang=%ld\n"
287 "\ttmDigitizedAspectX=%ld tmDigitizedAspectY=%ld\n"
288 "\ttmFirstChar=%d tmLastChar=%d tmDefaultChar=%d tmBreakChar=%d\n"
289 "\ttmItalic=%u tmUnderlined=%u tmStruckOut=%u tmPitchAndFamily=%u tmCharSet=%u\n",
290 (ft & RASTER_FONTTYPE) ? "raster" : "",
291 (ft & TRUETYPE_FONTTYPE) ? "truetype" : "",
292 ((ft & (RASTER_FONTTYPE|TRUETYPE_FONTTYPE)) == 0) ? "vector" : "",
293 (ft & DEVICE_FONTTYPE) ? "|device" : "",
294 tm->tmHeight, tm->tmAscent, tm->tmDescent, tm->tmInternalLeading, tm->tmExternalLeading, tm->tmAveCharWidth,
295 tm->tmMaxCharWidth, tm->tmWeight, tm->tmOverhang, tm->tmDigitizedAspectX, tm->tmDigitizedAspectY,
296 tm->tmFirstChar, tm->tmLastChar, tm->tmDefaultChar, tm->tmBreakChar, tm->tmItalic, tm->tmUnderlined, tm->tmStruckOut,
297 tm->tmPitchAndFamily, tm->tmCharSet);
300 /******************************************************************
305 BOOL WCUSER_AreFontsEqual(const struct config_data* config, const LOGFONT* lf)
307 return lf->lfHeight == config->cell_height &&
308 lf->lfWeight == config->font_weight &&
309 !lf->lfItalic && !lf->lfUnderline && !lf->lfStrikeOut &&
310 !lstrcmp(lf->lfFaceName, config->face_name);
315 struct inner_data* data;
319 /******************************************************************
320 * WCUSER_ValidateFontMetric
322 * Returns true if the font described in tm is usable as a font for the renderer
324 BOOL WCUSER_ValidateFontMetric(const struct inner_data* data, const TEXTMETRIC* tm, DWORD fontType)
328 if (fontType & RASTER_FONTTYPE)
329 ret = (tm->tmMaxCharWidth * data->curcfg.win_width < GetSystemMetrics(SM_CXSCREEN) &&
330 tm->tmHeight * data->curcfg.win_height < GetSystemMetrics(SM_CYSCREEN));
331 return ret && !tm->tmItalic && !tm->tmUnderlined && !tm->tmStruckOut &&
332 (tm->tmCharSet == DEFAULT_CHARSET || tm->tmCharSet == ANSI_CHARSET);
335 /******************************************************************
336 * WCUSER_ValidateFont
338 * Returns true if the font family described in lf is usable as a font for the renderer
340 BOOL WCUSER_ValidateFont(const struct inner_data* data, const LOGFONT* lf)
342 return (lf->lfPitchAndFamily & 3) == FIXED_PITCH &&
343 /* (lf->lfPitchAndFamily & 0xF0) == FF_MODERN && */
344 (lf->lfCharSet == DEFAULT_CHARSET || lf->lfCharSet == ANSI_CHARSET);
347 /******************************************************************
348 * get_first_font_enum_2
349 * get_first_font_enum
351 * Helper functions to get a decent font for the renderer
353 static int CALLBACK get_first_font_enum_2(const LOGFONT* lf, const TEXTMETRIC* tm,
354 DWORD FontType, LPARAM lParam)
356 struct font_chooser* fc = (struct font_chooser*)lParam;
358 WCUSER_DumpTextMetric(tm, FontType);
359 if (WCUSER_ValidateFontMetric(fc->data, tm, FontType))
363 /* Use the default sizes for the font (this is needed, especially for
364 * TrueType fonts, so that we get a decent size, not the max size)
366 mlf.lfWidth = fc->data->curcfg.cell_width;
367 mlf.lfHeight = fc->data->curcfg.cell_height;
368 if (WCUSER_SetFont(fc->data, &mlf))
370 WCUSER_DumpLogFont("InitChoosing: ", &mlf, FontType);
372 /* since we've modified the current config with new font information,
373 * set this information as the new default.
375 fc->data->defcfg.cell_width = fc->data->curcfg.cell_width;
376 fc->data->defcfg.cell_height = fc->data->curcfg.cell_height;
377 lstrcpyW(fc->data->defcfg.face_name, fc->data->curcfg.face_name);
378 /* Force also its writing back to the registry so that we can get it
381 WINECON_RegSave(&fc->data->defcfg);
388 static int CALLBACK get_first_font_enum(const LOGFONT* lf, const TEXTMETRIC* tm,
389 DWORD FontType, LPARAM lParam)
391 struct font_chooser* fc = (struct font_chooser*)lParam;
393 WCUSER_DumpLogFont("InitFamily: ", lf, FontType);
394 if (WCUSER_ValidateFont(fc->data, lf))
396 EnumFontFamilies(PRIVATE(fc->data)->hMemDC, lf->lfFaceName,
397 get_first_font_enum_2, lParam);
398 return !fc->done; /* we just need the first matching one... */
403 /******************************************************************
406 * get the relevant information from the font described in lf and store them
409 HFONT WCUSER_CopyFont(struct config_data* config, HWND hWnd, const LOGFONT* lf)
413 HFONT hFont, hOldFont;
416 if (!(hDC = GetDC(hWnd))) return (HFONT)0;
417 if (!(hFont = CreateFontIndirect(lf))) goto err1;
419 hOldFont = SelectObject(hDC, hFont);
420 GetTextMetrics(hDC, &tm);
423 * the current freetype engine (at least 2.0.x with x <= 8) and its implementation
424 * in Wine don't return adequate values for fixed fonts
425 * In Windows, those fonts are expectes to return the same value for
426 * - the average width
427 * - the largest width
428 * - the width of all characters in the font
429 * This isn't true in Wine. As a temporary workaound, we get as the width of the
430 * cell, the width of the first character in the font, after checking that all
431 * characters in the font have the same width (I hear paranoïa coming)
432 * when this gets fixed, the should be using tm.tmAveCharWidth or tm.tmMaxCharWidth
435 GetCharWidth32(hDC, tm.tmFirstChar, tm.tmFirstChar, &w);
436 for (i = tm.tmFirstChar + 1; i <= tm.tmLastChar; i += sizeof(buf) / sizeof(buf[0]))
440 l = min(tm.tmLastChar - i, sizeof(buf) / sizeof(buf[0]) - 1);
441 GetCharWidth32(hDC, i, i + l, buf);
442 for (j = 0; j <= l; j++)
446 WINE_WARN("Non uniform cell width: [%d]=%d [%d]=%d\n"
447 "This may be caused by old freetype libraries, >= 2.0.8 is recommended\n",
448 i + j, buf[j], tm.tmFirstChar, w);
453 SelectObject(hDC, hOldFont);
454 ReleaseDC(hWnd, hDC);
456 config->cell_width = w;
457 config->cell_height = tm.tmHeight + tm.tmExternalLeading;
458 config->font_weight = tm.tmWeight;
459 lstrcpy(config->face_name, lf->lfFaceName);
463 if (hDC && hOldFont) SelectObject(hDC, hOldFont);
464 if (hFont) DeleteObject(hFont);
466 if (hDC) ReleaseDC(hWnd, hDC);
471 /******************************************************************
476 void WCUSER_FillLogFont(LOGFONT* lf, const WCHAR* name, UINT height, UINT weight)
478 lf->lfHeight = height;
480 lf->lfEscapement = 0;
481 lf->lfOrientation = 0;
482 lf->lfWeight = weight;
483 lf->lfItalic = FALSE;
484 lf->lfUnderline = FALSE;
485 lf->lfStrikeOut = FALSE;
486 lf->lfCharSet = DEFAULT_CHARSET;
487 lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
488 lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
489 lf->lfQuality = DEFAULT_QUALITY;
490 lf->lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
491 lstrcpy(lf->lfFaceName, name);
494 /******************************************************************
497 * sets logfont as the new font for the console
499 BOOL WCUSER_SetFont(struct inner_data* data, const LOGFONT* logfont)
503 if (PRIVATE(data)->hFont != 0 && WCUSER_AreFontsEqual(&data->curcfg, logfont))
506 hFont = WCUSER_CopyFont(&data->curcfg, PRIVATE(data)->hWnd, logfont);
507 if (!hFont) {WINE_ERR("wrong font\n"); return FALSE;}
509 if (PRIVATE(data)->hFont) DeleteObject(PRIVATE(data)->hFont);
510 PRIVATE(data)->hFont = hFont;
512 WCUSER_ComputePositions(data);
513 WCUSER_NewBitmap(data, TRUE);
514 InvalidateRect(PRIVATE(data)->hWnd, NULL, FALSE);
515 UpdateWindow(PRIVATE(data)->hWnd);
520 /******************************************************************
523 * create a hFont from the settings saved in registry...
524 * (called on init, assuming no font has been created before)
526 static BOOL WCUSER_InitFont(struct inner_data* data)
528 struct font_chooser fc;
530 WINE_TRACE_(wc_font)("=> %s\n", wine_dbgstr_wn(data->curcfg.face_name, -1));
531 if (data->curcfg.face_name[0] != '\0' &&
532 data->curcfg.cell_height != 0 &&
533 data->curcfg.font_weight != 0)
537 WCUSER_FillLogFont(&lf, data->curcfg.face_name,
538 data->curcfg.cell_height, data->curcfg.font_weight);
539 if (PRIVATE(data)->hFont != 0) WINE_FIXME("Oh strange\n");
541 if (WCUSER_SetFont(data, &lf))
543 WCUSER_DumpLogFont("InitReuses: ", &lf, 0);
548 /* try to find an acceptable font */
549 WINE_WARN("Couldn't match the font from registry... trying to find one\n");
552 EnumFontFamilies(PRIVATE(data)->hMemDC, NULL, get_first_font_enum, (LPARAM)&fc);
553 if (!fc.done) WINE_WARN("Couldn't find a decent font, aborting\n");
557 /******************************************************************
560 * Get a cell from the a relative coordinate in window (takes into
561 * account the scrolling)
563 static COORD WCUSER_GetCell(const struct inner_data* data, LPARAM lParam)
567 c.X = data->curcfg.win_pos.X + (short)LOWORD(lParam) / data->curcfg.cell_width;
568 c.Y = data->curcfg.win_pos.Y + (short)HIWORD(lParam) / data->curcfg.cell_height;
573 /******************************************************************
574 * WCUSER_GetSelectionRect
576 * Get the selection rectangle
578 static void WCUSER_GetSelectionRect(const struct inner_data* data, LPRECT r)
580 r->left = (min(PRIVATE(data)->selectPt1.X, PRIVATE(data)->selectPt2.X) - data->curcfg.win_pos.X) * data->curcfg.cell_width;
581 r->top = (min(PRIVATE(data)->selectPt1.Y, PRIVATE(data)->selectPt2.Y) - data->curcfg.win_pos.Y) * data->curcfg.cell_height;
582 r->right = (max(PRIVATE(data)->selectPt1.X, PRIVATE(data)->selectPt2.X) + 1 - data->curcfg.win_pos.X) * data->curcfg.cell_width;
583 r->bottom = (max(PRIVATE(data)->selectPt1.Y, PRIVATE(data)->selectPt2.Y) + 1 - data->curcfg.win_pos.Y) * data->curcfg.cell_height;
586 /******************************************************************
587 * WCUSER_SetSelection
591 static void WCUSER_SetSelection(const struct inner_data* data, HDC hRefDC)
596 WCUSER_GetSelectionRect(data, &r);
597 hDC = hRefDC ? hRefDC : GetDC(PRIVATE(data)->hWnd);
600 if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible)
601 HideCaret(PRIVATE(data)->hWnd);
604 ReleaseDC(PRIVATE(data)->hWnd, hDC);
605 if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible)
606 ShowCaret(PRIVATE(data)->hWnd);
610 /******************************************************************
611 * WCUSER_MoveSelection
615 static void WCUSER_MoveSelection(struct inner_data* data, COORD c1, COORD c2, BOOL final)
620 WCUSER_GetSelectionRect(data, &r);
621 hDC = GetDC(PRIVATE(data)->hWnd);
624 if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible)
625 HideCaret(PRIVATE(data)->hWnd);
628 PRIVATE(data)->selectPt1 = c1;
629 PRIVATE(data)->selectPt2 = c2;
632 WCUSER_GetSelectionRect(data, &r);
634 ReleaseDC(PRIVATE(data)->hWnd, hDC);
635 if (PRIVATE(data)->hWnd == GetFocus() && data->curcfg.cursor_visible)
636 ShowCaret(PRIVATE(data)->hWnd);
641 PRIVATE(data)->has_selection = TRUE;
645 /******************************************************************
646 * WCUSER_CopySelectionToClipboard
648 * Copies the current selection into the clipboard
650 static void WCUSER_CopySelectionToClipboard(const struct inner_data* data)
656 w = abs(PRIVATE(data)->selectPt1.X - PRIVATE(data)->selectPt2.X) + 2;
657 h = abs(PRIVATE(data)->selectPt1.Y - PRIVATE(data)->selectPt2.Y) + 1;
659 if (!OpenClipboard(PRIVATE(data)->hWnd)) return;
662 hMem = GlobalAlloc(GMEM_MOVEABLE, (w * h) * sizeof(WCHAR));
663 if (hMem && (p = GlobalLock(hMem)))
668 c.X = min(PRIVATE(data)->selectPt1.X, PRIVATE(data)->selectPt2.X);
669 c.Y = min(PRIVATE(data)->selectPt1.Y, PRIVATE(data)->selectPt2.Y);
671 for (y = 0; y < h; y++, c.Y++)
673 ReadConsoleOutputCharacter(data->hConOut, &p[y * w], w - 1, c, NULL);
674 p[y * w + w - 1] = (y < h - 1) ? '\n' : '\0';
677 SetClipboardData(CF_UNICODETEXT, hMem);
682 /******************************************************************
683 * WCUSER_PasteFromClipboard
687 static void WCUSER_PasteFromClipboard(struct inner_data* data)
692 if (!OpenClipboard(PRIVATE(data)->hWnd)) return;
693 h = GetClipboardData(CF_UNICODETEXT);
694 if (h && (ptr = GlobalLock(h)))
696 int i, len = GlobalSize(h) / sizeof(WCHAR);
701 ir[0].EventType = KEY_EVENT;
702 ir[0].Event.KeyEvent.wRepeatCount = 0;
703 ir[0].Event.KeyEvent.dwControlKeyState = 0;
704 ir[0].Event.KeyEvent.bKeyDown = TRUE;
706 /* generate the corresponding input records */
707 for (i = 0; i < len; i++)
709 /* FIXME: the modifying keys are not generated (shift, ctrl...) */
710 sh = VkKeyScan(ptr[i]);
711 ir[0].Event.KeyEvent.wVirtualKeyCode = LOBYTE(sh);
712 ir[0].Event.KeyEvent.wVirtualScanCode = MapVirtualKey(LOBYTE(sh), 0);
713 ir[0].Event.KeyEvent.uChar.UnicodeChar = ptr[i];
716 ir[1].Event.KeyEvent.bKeyDown = FALSE;
718 WriteConsoleInput(data->hConIn, ir, 2, &n);
725 /******************************************************************
730 static void WCUSER_Refresh(const struct inner_data* data, int tp, int bm)
732 WCUSER_FillMemDC(data, tp, bm);
733 if (data->curcfg.win_pos.Y <= bm && data->curcfg.win_pos.Y + data->curcfg.win_height >= tp)
738 r.right = data->curcfg.win_width * data->curcfg.cell_width;
739 r.top = (tp - data->curcfg.win_pos.Y) * data->curcfg.cell_height;
740 r.bottom = (bm - data->curcfg.win_pos.Y + 1) * data->curcfg.cell_height;
741 InvalidateRect(PRIVATE(data)->hWnd, &r, FALSE);
742 UpdateWindow(PRIVATE(data)->hWnd);
746 /******************************************************************
751 static void WCUSER_Paint(const struct inner_data* data)
755 BeginPaint(PRIVATE(data)->hWnd, &ps);
757 data->curcfg.win_width * data->curcfg.cell_width,
758 data->curcfg.win_height * data->curcfg.cell_height,
759 PRIVATE(data)->hMemDC,
760 data->curcfg.win_pos.X * data->curcfg.cell_width,
761 data->curcfg.win_pos.Y * data->curcfg.cell_height,
763 if (PRIVATE(data)->has_selection)
764 WCUSER_SetSelection(data, ps.hdc);
765 EndPaint(PRIVATE(data)->hWnd, &ps);
768 /******************************************************************
773 static void WCUSER_Scroll(struct inner_data* data, int pos, BOOL horz)
777 SetScrollPos(PRIVATE(data)->hWnd, SB_HORZ, pos, TRUE);
778 data->curcfg.win_pos.X = pos;
782 SetScrollPos(PRIVATE(data)->hWnd, SB_VERT, pos, TRUE);
783 data->curcfg.win_pos.Y = pos;
785 InvalidateRect(PRIVATE(data)->hWnd, NULL, FALSE);
788 /******************************************************************
793 static BOOL WCUSER_FillMenu(HMENU hMenu, BOOL sep)
796 HINSTANCE hInstance = GetModuleHandle(NULL);
799 if (!hMenu) return FALSE;
801 /* FIXME: error handling & memory cleanup */
802 hSubMenu = CreateMenu();
803 if (!hSubMenu) return FALSE;
805 LoadString(hInstance, IDS_MARK, buff, sizeof(buff) / sizeof(WCHAR));
806 InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_MARK, buff);
807 LoadString(hInstance, IDS_COPY, buff, sizeof(buff) / sizeof(WCHAR));
808 InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_COPY, buff);
809 LoadString(hInstance, IDS_PASTE, buff, sizeof(buff) / sizeof(WCHAR));
810 InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PASTE, buff);
811 LoadString(hInstance, IDS_SELECTALL, buff, sizeof(buff) / sizeof(WCHAR));
812 InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SELECTALL, buff);
813 LoadString(hInstance, IDS_SCROLL, buff, sizeof(buff) / sizeof(WCHAR));
814 InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SCROLL, buff);
815 LoadString(hInstance, IDS_SEARCH, buff, sizeof(buff) / sizeof(WCHAR));
816 InsertMenu(hSubMenu, -1, MF_BYPOSITION|MF_STRING, IDS_SEARCH, buff);
818 if (sep) InsertMenu(hMenu, -1, MF_BYPOSITION|MF_SEPARATOR, 0, NULL);
819 LoadString(hInstance, IDS_EDIT, buff, sizeof(buff) / sizeof(WCHAR));
820 InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING|MF_POPUP, (UINT_PTR)hSubMenu, buff);
821 LoadString(hInstance, IDS_DEFAULT, buff, sizeof(buff) / sizeof(WCHAR));
822 InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_DEFAULT, buff);
823 LoadString(hInstance, IDS_PROPERTY, buff, sizeof(buff) / sizeof(WCHAR));
824 InsertMenu(hMenu, -1, MF_BYPOSITION|MF_STRING, IDS_PROPERTY, buff);
829 /******************************************************************
832 * Creates the window for the rendering
834 static LRESULT WCUSER_Create(HWND hWnd, LPCREATESTRUCT lpcs)
836 struct inner_data* data;
839 data = lpcs->lpCreateParams;
840 SetWindowLong(hWnd, 0L, (DWORD)data);
841 PRIVATE(data)->hWnd = hWnd;
843 data->curcfg.cursor_size = 101; /* invalid value, will trigger a complete cleanup */
845 hSysMenu = GetSystemMenu(hWnd, FALSE);
846 if (!hSysMenu) return 0;
847 PRIVATE(data)->hPopMenu = CreatePopupMenu();
848 if (!PRIVATE(data)->hPopMenu) return 0;
850 WCUSER_FillMenu(hSysMenu, TRUE);
851 WCUSER_FillMenu(PRIVATE(data)->hPopMenu, FALSE);
853 PRIVATE(data)->hMemDC = CreateCompatibleDC(0);
854 if (!PRIVATE(data)->hMemDC) {WINE_ERR("no mem dc\n");return 0;}
856 data->curcfg.quick_edit = FALSE;
860 /******************************************************************
861 * WCUSER_SetMenuDetails
863 * Grays / ungrays the menu items according to their state
865 static void WCUSER_SetMenuDetails(const struct inner_data* data, HMENU hMenu)
867 if (!hMenu) {WINE_ERR("Issue in getting menu bits\n");return;}
869 EnableMenuItem(hMenu, IDS_COPY,
870 MF_BYCOMMAND|(PRIVATE(data)->has_selection ? MF_ENABLED : MF_GRAYED));
871 EnableMenuItem(hMenu, IDS_PASTE,
872 MF_BYCOMMAND|(IsClipboardFormatAvailable(CF_UNICODETEXT)
873 ? MF_ENABLED : MF_GRAYED));
874 EnableMenuItem(hMenu, IDS_SCROLL, MF_BYCOMMAND|MF_GRAYED);
875 EnableMenuItem(hMenu, IDS_SEARCH, MF_BYCOMMAND|MF_GRAYED);
878 /******************************************************************
879 * CUSER_GetCtrlKeyState
881 * Get the console bit mask equivalent to the VK_ status in keyState
883 static DWORD WCUSER_GetCtrlKeyState(BYTE* keyState)
887 GetKeyboardState(keyState);
888 if (keyState[VK_SHIFT] & 0x80) ret |= SHIFT_PRESSED;
889 if (keyState[VK_CONTROL] & 0x80) ret |= LEFT_CTRL_PRESSED; /* FIXME: gotta choose one */
890 if (keyState[VK_LCONTROL] & 0x80) ret |= LEFT_CTRL_PRESSED;
891 if (keyState[VK_RCONTROL] & 0x80) ret |= RIGHT_CTRL_PRESSED;
892 if (keyState[VK_LMENU] & 0x80) ret |= LEFT_ALT_PRESSED;
893 if (keyState[VK_RMENU] & 0x80) ret |= RIGHT_ALT_PRESSED;
894 if (keyState[VK_CAPITAL] & 0x01) ret |= CAPSLOCK_ON;
895 if (keyState[VK_NUMLOCK] & 0x01) ret |= NUMLOCK_ON;
896 if (keyState[VK_SCROLL] & 0x01) ret |= SCROLLLOCK_ON;
901 /******************************************************************
902 * WCUSER_HandleSelectionKey
904 * Handles keys while selecting an area
906 static void WCUSER_HandleSelectionKey(struct inner_data* data, BOOL down,
907 WPARAM wParam, LPARAM lParam)
910 DWORD state = WCUSER_GetCtrlKeyState(keyState) & ~(CAPSLOCK_ON|NUMLOCK_ON|SCROLLLOCK_ON);
921 PRIVATE(data)->has_selection = FALSE;
922 WCUSER_SetSelection(data, 0);
923 WCUSER_CopySelectionToClipboard(data);
926 c1 = PRIVATE(data)->selectPt1;
927 c2 = PRIVATE(data)->selectPt2;
929 if (c1.X < data->curcfg.sb_width && c2.X < data->curcfg.sb_width)
931 WCUSER_MoveSelection(data, c1, c2, FALSE);
935 c1 = PRIVATE(data)->selectPt1;
936 c2 = PRIVATE(data)->selectPt2;
938 if (c1.X >= 0 && c2.X >= 0)
940 WCUSER_MoveSelection(data, c1, c2, FALSE);
944 c1 = PRIVATE(data)->selectPt1;
945 c2 = PRIVATE(data)->selectPt2;
947 if (c1.Y >= 0 && c2.Y >= 0)
949 WCUSER_MoveSelection(data, c1, c2, FALSE);
953 c1 = PRIVATE(data)->selectPt1;
954 c2 = PRIVATE(data)->selectPt2;
956 if (c1.X < data->curcfg.sb_height && c2.X < data->curcfg.sb_height)
958 WCUSER_MoveSelection(data, c1, c2, FALSE);
967 c1 = PRIVATE(data)->selectPt1;
968 c2 = PRIVATE(data)->selectPt2;
970 if (c2.X < data->curcfg.sb_width)
972 WCUSER_MoveSelection(data, c1, c2, FALSE);
976 c1 = PRIVATE(data)->selectPt1;
977 c2 = PRIVATE(data)->selectPt2;
981 WCUSER_MoveSelection(data, c1, c2, FALSE);
985 c1 = PRIVATE(data)->selectPt1;
986 c2 = PRIVATE(data)->selectPt2;
990 WCUSER_MoveSelection(data, c1, c2, FALSE);
994 c1 = PRIVATE(data)->selectPt1;
995 c2 = PRIVATE(data)->selectPt2;
997 if (c2.X < data->curcfg.sb_height)
999 WCUSER_MoveSelection(data, c1, c2, FALSE);
1007 /******************************************************************
1008 * WCUSER_GenerateKeyInputRecord
1010 * generates input_record from windows WM_KEYUP/WM_KEYDOWN messages
1012 static void WCUSER_GenerateKeyInputRecord(struct inner_data* data, BOOL down,
1013 WPARAM wParam, LPARAM lParam, BOOL sys)
1018 static WCHAR last; /* keep last char seen as feed for key up message */
1021 ir.EventType = KEY_EVENT;
1022 ir.Event.KeyEvent.bKeyDown = down;
1023 ir.Event.KeyEvent.wRepeatCount = LOWORD(lParam);
1024 ir.Event.KeyEvent.wVirtualKeyCode = wParam;
1026 ir.Event.KeyEvent.wVirtualScanCode = HIWORD(lParam) & 0xFF;
1028 ir.Event.KeyEvent.uChar.UnicodeChar = 0;
1029 ir.Event.KeyEvent.dwControlKeyState = WCUSER_GetCtrlKeyState(keyState);
1030 if (lParam & (1L << 24)) ir.Event.KeyEvent.dwControlKeyState |= ENHANCED_KEY;
1031 if (sys) ir.Event.KeyEvent.dwControlKeyState |= LEFT_ALT_PRESSED; /* FIXME: gotta choose one */
1033 if (!(ir.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
1037 switch (ToUnicode(wParam, HIWORD(lParam), keyState, buf, 2, 0))
1040 /* FIXME... should generate two events... */
1050 ir.Event.KeyEvent.uChar.UnicodeChar = last; /* FIXME HACKY... and buggy 'coz it should be a stack, not a single value */
1051 if (!down) last = 0;
1054 WriteConsoleInput(data->hConIn, &ir, 1, &n);
1057 /******************************************************************
1058 * WCUSER_GenerateMouseInputRecord
1062 static void WCUSER_GenerateMouseInputRecord(struct inner_data* data, COORD c,
1063 WPARAM wParam, DWORD event)
1069 /* MOUSE_EVENTs shouldn't be sent unless ENABLE_MOUSE_INPUT is active */
1070 if (!GetConsoleMode(data->hConIn, &mode) || !(mode & ENABLE_MOUSE_INPUT))
1073 ir.EventType = MOUSE_EVENT;
1074 ir.Event.MouseEvent.dwMousePosition = c;
1075 ir.Event.MouseEvent.dwButtonState = 0;
1076 if (wParam & MK_LBUTTON) ir.Event.MouseEvent.dwButtonState |= FROM_LEFT_1ST_BUTTON_PRESSED;
1077 if (wParam & MK_MBUTTON) ir.Event.MouseEvent.dwButtonState |= FROM_LEFT_2ND_BUTTON_PRESSED;
1078 if (wParam & MK_RBUTTON) ir.Event.MouseEvent.dwButtonState |= RIGHTMOST_BUTTON_PRESSED;
1079 ir.Event.MouseEvent.dwControlKeyState = WCUSER_GetCtrlKeyState(keyState);
1080 ir.Event.MouseEvent.dwEventFlags = event;
1082 WriteConsoleInput(data->hConIn, &ir, 1, &n);
1085 /******************************************************************
1090 static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1092 struct inner_data* data = (struct inner_data*)GetWindowLong(hWnd, 0);
1097 return WCUSER_Create(hWnd, (LPCREATESTRUCT)lParam);
1099 PRIVATE(data)->hWnd = 0;
1107 if (PRIVATE(data)->has_selection)
1108 WCUSER_HandleSelectionKey(data, uMsg == WM_KEYDOWN, wParam, lParam);
1110 WCUSER_GenerateKeyInputRecord(data, uMsg == WM_KEYDOWN, wParam, lParam, FALSE);
1114 WCUSER_GenerateKeyInputRecord(data, uMsg == WM_SYSKEYDOWN, wParam, lParam, TRUE);
1116 case WM_LBUTTONDOWN:
1117 if (data->curcfg.quick_edit)
1119 if (PRIVATE(data)->has_selection)
1121 PRIVATE(data)->has_selection = FALSE;
1122 WCUSER_SetSelection(data, 0);
1126 PRIVATE(data)->selectPt1 = PRIVATE(data)->selectPt2 = WCUSER_GetCell(data, lParam);
1127 SetCapture(PRIVATE(data)->hWnd);
1128 WCUSER_SetSelection(data, 0);
1129 PRIVATE(data)->has_selection = TRUE;
1134 WCUSER_GenerateMouseInputRecord(data, WCUSER_GetCell(data, lParam), wParam, 0);
1138 if (data->curcfg.quick_edit)
1140 if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection &&
1141 (wParam & MK_LBUTTON))
1143 WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam), FALSE);
1148 WCUSER_GenerateMouseInputRecord(data, WCUSER_GetCell(data, lParam), wParam, MOUSE_MOVED);
1152 if (data->curcfg.quick_edit)
1154 if (GetCapture() == PRIVATE(data)->hWnd && PRIVATE(data)->has_selection &&
1155 (wParam& MK_LBUTTON))
1157 WCUSER_MoveSelection(data, PRIVATE(data)->selectPt1, WCUSER_GetCell(data, lParam), TRUE);
1162 WCUSER_GenerateMouseInputRecord(data, WCUSER_GetCell(data, lParam), wParam, 0);
1165 case WM_RBUTTONDOWN:
1166 if ((wParam & (MK_CONTROL|MK_SHIFT)) == data->curcfg.menu_mask)
1170 GetWindowRect(hWnd, &r);
1171 WCUSER_SetMenuDetails(data, PRIVATE(data)->hPopMenu);
1172 TrackPopupMenu(PRIVATE(data)->hPopMenu, TPM_LEFTALIGN|TPM_TOPALIGN,
1173 r.left + LOWORD(lParam), r.top + HIWORD(lParam), 0, hWnd, NULL);
1177 WCUSER_GenerateMouseInputRecord(data, WCUSER_GetCell(data, lParam), wParam, 0);
1181 /* no need to track for rbutton up when opening the popup... the event will be
1182 * swallowed by TrackPopupMenu */
1183 WCUSER_GenerateMouseInputRecord(data, WCUSER_GetCell(data, lParam), wParam, 0);
1186 /* FIXME: should we scroll too ? */
1187 WCUSER_GenerateMouseInputRecord(data, WCUSER_GetCell(data, lParam), wParam, MOUSE_WHEELED);
1190 if (data->curcfg.cursor_visible)
1192 CreateCaret(PRIVATE(data)->hWnd, PRIVATE(data)->cursor_bitmap,
1193 data->curcfg.cell_width, data->curcfg.cell_height);
1194 WCUSER_PosCursor(data);
1198 if (data->curcfg.cursor_visible)
1203 int pos = data->curcfg.win_pos.X;
1205 switch (LOWORD(wParam))
1207 case SB_PAGEUP: pos -= 8; break;
1208 case SB_PAGEDOWN: pos += 8; break;
1209 case SB_LINEUP: pos--; break;
1210 case SB_LINEDOWN: pos++; break;
1211 case SB_THUMBTRACK: pos = HIWORD(wParam); break;
1214 if (pos < 0) pos = 0;
1215 if (pos > data->curcfg.sb_width - data->curcfg.win_width)
1216 pos = data->curcfg.sb_width - data->curcfg.win_width;
1217 if (pos != data->curcfg.win_pos.X)
1219 ScrollWindow(hWnd, (data->curcfg.win_pos.X - pos) * data->curcfg.cell_width, 0,
1221 data->curcfg.win_pos.X = pos;
1222 SetScrollPos(hWnd, SB_HORZ, pos, TRUE);
1224 WCUSER_PosCursor(data);
1225 WINECON_NotifyWindowChange(data);
1231 int pos = data->curcfg.win_pos.Y;
1233 switch (LOWORD(wParam))
1235 case SB_PAGEUP: pos -= 8; break;
1236 case SB_PAGEDOWN: pos += 8; break;
1237 case SB_LINEUP: pos--; break;
1238 case SB_LINEDOWN: pos++; break;
1239 case SB_THUMBTRACK: pos = HIWORD(wParam); break;
1242 if (pos < 0) pos = 0;
1243 if (pos > data->curcfg.sb_height - data->curcfg.win_height)
1244 pos = data->curcfg.sb_height - data->curcfg.win_height;
1245 if (pos != data->curcfg.win_pos.Y)
1247 ScrollWindow(hWnd, 0, (data->curcfg.win_pos.Y - pos) * data->curcfg.cell_height,
1249 data->curcfg.win_pos.Y = pos;
1250 SetScrollPos(hWnd, SB_VERT, pos, TRUE);
1252 WCUSER_PosCursor(data);
1253 WINECON_NotifyWindowChange(data);
1261 WCUSER_GetProperties(data, FALSE);
1264 WCUSER_GetProperties(data, TRUE);
1267 return DefWindowProc(hWnd, uMsg, wParam, lParam);
1274 WCUSER_GetProperties(data, FALSE);
1277 WCUSER_GetProperties(data, TRUE);
1280 PRIVATE(data)->selectPt1.X = PRIVATE(data)->selectPt1.Y = 0;
1281 PRIVATE(data)->selectPt2.X = PRIVATE(data)->selectPt2.Y = 0;
1282 WCUSER_SetSelection(data, 0);
1283 PRIVATE(data)->has_selection = TRUE;
1286 if (PRIVATE(data)->has_selection)
1288 PRIVATE(data)->has_selection = FALSE;
1289 WCUSER_SetSelection(data, 0);
1290 WCUSER_CopySelectionToClipboard(data);
1294 WCUSER_PasteFromClipboard(data);
1297 PRIVATE(data)->selectPt1.X = PRIVATE(data)->selectPt1.Y = 0;
1298 PRIVATE(data)->selectPt2.X = (data->curcfg.sb_width - 1) * data->curcfg.cell_width;
1299 PRIVATE(data)->selectPt2.Y = (data->curcfg.sb_height - 1) * data->curcfg.cell_height;
1300 WCUSER_SetSelection(data, 0);
1301 PRIVATE(data)->has_selection = TRUE;
1305 WINE_FIXME("Unhandled yet command: %x\n", wParam);
1308 return DefWindowProc(hWnd, uMsg, wParam, lParam);
1311 case WM_INITMENUPOPUP:
1312 if (!HIWORD(lParam)) return DefWindowProc(hWnd, uMsg, wParam, lParam);
1313 WCUSER_SetMenuDetails(data, GetSystemMenu(PRIVATE(data)->hWnd, FALSE));
1316 return DefWindowProc(hWnd, uMsg, wParam, lParam);
1321 /******************************************************************
1322 * WCUSER_DeleteBackend
1326 void WCUSER_DeleteBackend(struct inner_data* data)
1328 if (!PRIVATE(data)) return;
1329 if (PRIVATE(data)->hMemDC) DeleteDC(PRIVATE(data)->hMemDC);
1330 if (PRIVATE(data)->hWnd) DestroyWindow(PRIVATE(data)->hWnd);
1331 if (PRIVATE(data)->hFont) DeleteObject(PRIVATE(data)->hFont);
1332 if (PRIVATE(data)->cursor_bitmap) DeleteObject(PRIVATE(data)->cursor_bitmap);
1333 if (PRIVATE(data)->hBitmap) DeleteObject(PRIVATE(data)->hBitmap);
1334 HeapFree(GetProcessHeap(), 0, PRIVATE(data));
1337 /******************************************************************
1342 static int WCUSER_MainLoop(struct inner_data* data)
1348 switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT))
1351 if (!WINECON_GrabChanges(data) && data->curcfg.exit_on_die)
1354 case WAIT_OBJECT_0+1:
1355 switch (GetMessage(&msg, 0, 0, 0))
1357 case -1: /* the event handle became invalid, so exit */
1359 case 0: /* WM_QUIT has been posted */
1362 DispatchMessage(&msg);
1367 WINE_ERR("got pb\n");
1374 /******************************************************************
1375 * WCUSER_InitBackend
1377 * Initialisation part II: creation of window.
1380 BOOL WCUSER_InitBackend(struct inner_data* data)
1382 static WCHAR wClassName[] = {'W','i','n','e','C','o','n','s','o','l','e','C','l','a','s','s',0};
1386 data->private = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct inner_data_user));
1387 if (!data->private) return FALSE;
1389 data->fnMainLoop = WCUSER_MainLoop;
1390 data->fnPosCursor = WCUSER_PosCursor;
1391 data->fnShapeCursor = WCUSER_ShapeCursor;
1392 data->fnComputePositions = WCUSER_ComputePositions;
1393 data->fnRefresh = WCUSER_Refresh;
1394 data->fnResizeScreenBuffer = WCUSER_ResizeScreenBuffer;
1395 data->fnSetTitle = WCUSER_SetTitle;
1396 data->fnScroll = WCUSER_Scroll;
1397 data->fnDeleteBackend = WCUSER_DeleteBackend;
1400 wndclass.lpfnWndProc = WCUSER_Proc;
1401 wndclass.cbClsExtra = 0;
1402 wndclass.cbWndExtra = sizeof(DWORD);
1403 wndclass.hInstance = GetModuleHandle(NULL);
1404 wndclass.hIcon = LoadIcon(0, IDI_WINLOGO);
1405 wndclass.hCursor = LoadCursor(0, IDC_ARROW);
1406 wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
1407 wndclass.lpszMenuName = NULL;
1408 wndclass.lpszClassName = wClassName;
1410 RegisterClass(&wndclass);
1412 CreateWindow(wndclass.lpszClassName, NULL,
1413 WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_HSCROLL|WS_VSCROLL,
1414 CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, 0, 0, wndclass.hInstance, data);
1415 if (!PRIVATE(data)->hWnd) return FALSE;
1417 /* force update of current data */
1418 if (!WINECON_GrabChanges(data)) return FALSE;
1420 if (!WCUSER_InitFont(data)) return FALSE;