Allow ANSI charset in font enumeration.

Added ability not to close the wineconsole on console object
destruction.
This commit is contained in:
Eric Pouech 2002-05-21 18:05:16 +00:00 committed by Alexandre Julliard
parent 9259cfa855
commit 0587a47235
4 changed files with 56 additions and 40 deletions

View File

@ -409,25 +409,23 @@ static int CALLBACK font_enum(const LOGFONT* lf, const TEXTMETRIC* tm,
DWORD FontType, LPARAM lParam) DWORD FontType, LPARAM lParam)
{ {
struct dialog_info* di = (struct dialog_info*)lParam; struct dialog_info* di = (struct dialog_info*)lParam;
HDC hdc;
WCUSER_DumpLogFont("font", lf, FontType); WCUSER_DumpLogFont("DlgFamily: ", lf, FontType);
if (WCUSER_ValidateFont(di->data, lf) && (hdc = GetDC(di->hDlg))) if (WCUSER_ValidateFont(di->data, lf))
{ {
if (FontType & RASTER_FONTTYPE) if (FontType & RASTER_FONTTYPE)
{ {
di->nFont = 0; di->nFont = 0;
EnumFontFamilies(hdc, lf->lfFaceName, font_enum_size2, (LPARAM)di); EnumFontFamilies(PRIVATE(di->data)->hMemDC, lf->lfFaceName, font_enum_size2, (LPARAM)di);
} }
else else
di->nFont = 1; di->nFont = 1;
if (di->nFont) if (di->nFont)
{ {
SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_ADDSTRING, SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_ADDSTRING,
0, (LPARAM)lf->lfFaceName); 0, (LPARAM)lf->lfFaceName);
} }
ReleaseDC(di->hDlg, hdc);
} }
return 1; return 1;
@ -552,24 +550,19 @@ static BOOL select_font(struct dialog_info* di)
*/ */
static BOOL fill_list_size(struct dialog_info* di, BOOL doInit) static BOOL fill_list_size(struct dialog_info* di, BOOL doInit)
{ {
HDC hdc;
int idx; int idx;
WCHAR lfFaceName[LF_FACESIZE]; WCHAR lfFaceName[LF_FACESIZE];
idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L); idx = SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETCURSEL, 0L, 0L);
if (idx < 0) return FALSE; if (idx < 0) return FALSE;
hdc = GetDC(di->hDlg);
if (!hdc) return FALSE;
SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETTEXT, idx, (LPARAM)lfFaceName); SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_GETTEXT, idx, (LPARAM)lfFaceName);
SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_RESETCONTENT, 0L, 0L); SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_SIZE, LB_RESETCONTENT, 0L, 0L);
if (di->font) HeapFree(GetProcessHeap(), 0, di->font); if (di->font) HeapFree(GetProcessHeap(), 0, di->font);
di->nFont = 0; di->nFont = 0;
di->font = NULL; di->font = NULL;
EnumFontFamilies(hdc, lfFaceName, font_enum_size, (LPARAM)di); EnumFontFamilies(PRIVATE(di->data)->hMemDC, lfFaceName, font_enum_size, (LPARAM)di);
ReleaseDC(di->hDlg, hdc);
if (doInit) if (doInit)
{ {
@ -601,14 +594,8 @@ static BOOL fill_list_size(struct dialog_info* di, BOOL doInit)
*/ */
static BOOL fill_list_font(struct dialog_info* di) static BOOL fill_list_font(struct dialog_info* di)
{ {
HDC hdc;
hdc = GetDC(di->hDlg);
if (!hdc) return FALSE;
SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L); SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_RESETCONTENT, 0L, 0L);
EnumFontFamilies(hdc, NULL, font_enum, (LPARAM)di); EnumFontFamilies(PRIVATE(di->data)->hMemDC, NULL, font_enum, (LPARAM)di);
ReleaseDC(di->hDlg, hdc);
if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING, if (SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SELECTSTRING,
(WPARAM)-1, (LPARAM)di->config->face_name) == LB_ERR) (WPARAM)-1, (LPARAM)di->config->face_name) == LB_ERR)
SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L); SendDlgItemMessage(di->hDlg, IDC_FNT_LIST_FONT, LB_SETCURSEL, 0L, 0L);

View File

@ -30,6 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
static const WCHAR wszConsole[] = {'C','o','n','s','o','l','e',0}; static const WCHAR wszConsole[] = {'C','o','n','s','o','l','e',0};
static const WCHAR wszCursorSize[] = {'C','u','r','s','o','r','S','i','z','e',0}; static const WCHAR wszCursorSize[] = {'C','u','r','s','o','r','S','i','z','e',0};
static const WCHAR wszCursorVisible[] = {'C','u','r','s','o','r','V','i','s','i','b','l','e',0}; static const WCHAR wszCursorVisible[] = {'C','u','r','s','o','r','V','i','s','i','b','l','e',0};
static const WCHAR wszExitOnDie[] = {'E','x','i','t','O','n','D','i','e',0};
static const WCHAR wszFaceName[] = {'F','a','c','e','N','a','m','e',0}; static const WCHAR wszFaceName[] = {'F','a','c','e','N','a','m','e',0};
static const WCHAR wszFontSize[] = {'F','o','n','t','S','i','z','e',0}; static const WCHAR wszFontSize[] = {'F','o','n','t','S','i','z','e',0};
static const WCHAR wszFontWeight[] = {'F','o','n','t','W','e','i','g','h','t',0}; static const WCHAR wszFontWeight[] = {'F','o','n','t','W','e','i','g','h','t',0};
@ -64,6 +65,11 @@ BOOL WINECON_RegLoad(struct config_data* cfg)
val = 1; val = 1;
cfg->cursor_visible = val; cfg->cursor_visible = val;
count = sizeof(val);
if (!hConKey || RegQueryValueEx(hConKey, wszExitOnDie, 0, &type, (char*)&val, &count))
val = 1;
cfg->exit_on_die = val;
count = sizeof(cfg->face_name); count = sizeof(cfg->face_name);
if (!hConKey || RegQueryValueEx(hConKey, wszFaceName, 0, &type, (char*)&cfg->face_name, &count)) if (!hConKey || RegQueryValueEx(hConKey, wszFaceName, 0, &type, (char*)&cfg->face_name, &count))
cfg->face_name[0] = 0; cfg->face_name[0] = 0;
@ -139,6 +145,9 @@ BOOL WINECON_RegSave(const struct config_data* cfg)
val = cfg->cursor_visible; val = cfg->cursor_visible;
RegSetValueEx(hConKey, wszCursorVisible, 0, REG_DWORD, (char*)&val, sizeof(val)); RegSetValueEx(hConKey, wszCursorVisible, 0, REG_DWORD, (char*)&val, sizeof(val));
val = cfg->exit_on_die;
RegSetValueEx(hConKey, wszExitOnDie, 0, REG_DWORD, (char*)&val, sizeof(val));
RegSetValueEx(hConKey, wszFaceName, 0, REG_SZ, (char*)&cfg->face_name, sizeof(cfg->face_name)); RegSetValueEx(hConKey, wszFaceName, 0, REG_SZ, (char*)&cfg->face_name, sizeof(cfg->face_name));
val = MAKELONG(cfg->cell_width, cfg->cell_height); val = MAKELONG(cfg->cell_width, cfg->cell_height);

View File

@ -64,7 +64,7 @@ static void WCUSER_FillMemDC(const struct inner_data* data, int upd_tp, int upd_
for (i = 0; i < data->curcfg.sb_width; i++) for (i = 0; i < data->curcfg.sb_width; i++)
{ {
attr = cell[i].Attributes; attr = cell[i].Attributes;
SetBkColor(PRIVATE(data)->hMemDC,WCUSER_ColorMap[(attr>>4)&0x0F]); SetBkColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[(attr>>4)&0x0F]);
SetTextColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[attr&0x0F]); SetTextColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[attr&0x0F]);
for (k = i; k < data->curcfg.sb_width && cell[k].Attributes == attr; k++) for (k = i; k < data->curcfg.sb_width && cell[k].Attributes == attr; k++)
{ {
@ -90,7 +90,8 @@ static void WCUSER_NewBitmap(struct inner_data* data, BOOL fill)
HDC hDC; HDC hDC;
HBITMAP hnew, hold; HBITMAP hnew, hold;
if (!data->curcfg.sb_width || !data->curcfg.sb_height || !(hDC = GetDC(PRIVATE(data)->hWnd))) if (!data->curcfg.sb_width || !data->curcfg.sb_height ||
!PRIVATE(data)->hFont || !(hDC = GetDC(PRIVATE(data)->hWnd)))
return; return;
hnew = CreateCompatibleBitmap(hDC, hnew = CreateCompatibleBitmap(hDC,
data->curcfg.sb_width * data->curcfg.cell_width, data->curcfg.sb_width * data->curcfg.cell_width,
@ -328,7 +329,7 @@ BOOL WCUSER_ValidateFontMetric(const struct inner_data* data, const TEXTMETRIC*
ret = (tm->tmMaxCharWidth * data->curcfg.win_width < GetSystemMetrics(SM_CXSCREEN) && ret = (tm->tmMaxCharWidth * data->curcfg.win_width < GetSystemMetrics(SM_CXSCREEN) &&
tm->tmHeight * data->curcfg.win_height < GetSystemMetrics(SM_CYSCREEN)); tm->tmHeight * data->curcfg.win_height < GetSystemMetrics(SM_CYSCREEN));
return ret && !tm->tmItalic && !tm->tmUnderlined && !tm->tmStruckOut && return ret && !tm->tmItalic && !tm->tmUnderlined && !tm->tmStruckOut &&
(tm->tmCharSet == DEFAULT_CHARSET /*|| tm->tmCharSet == ANSI_CHARSET*/); (tm->tmCharSet == DEFAULT_CHARSET || tm->tmCharSet == ANSI_CHARSET);
} }
/****************************************************************** /******************************************************************
@ -355,19 +356,31 @@ static int CALLBACK get_first_font_enum_2(const LOGFONT* lf, const TEXTMETRIC* t
struct font_chooser* fc = (struct font_chooser*)lParam; struct font_chooser* fc = (struct font_chooser*)lParam;
WCUSER_DumpTextMetric(tm, FontType); WCUSER_DumpTextMetric(tm, FontType);
if (WCUSER_ValidateFontMetric(fc->data, tm, FontType))
if (WCUSER_ValidateFontMetric(fc->data, tm, FontType) &&
WCUSER_SetFont(fc->data, lf))
{ {
fc->done = 1; LOGFONT mlf = *lf;
/* since we've modified the current config with new font information,
* set it as the new default. /* Use the default sizes for the font (this is needed, especially for
* Force also its writing back to the registry so that we can get it * TrueType fonts, so that we get a decent size, not the max size)
* the next time
*/ */
fc->data->defcfg = fc->data->curcfg; mlf.lfWidth = fc->data->curcfg.cell_width;
WINECON_RegSave(&fc->data->defcfg); mlf.lfHeight = fc->data->curcfg.cell_height;
return 0; if (WCUSER_SetFont(fc->data, &mlf))
{
WCUSER_DumpLogFont("InitChoosing: ", &mlf, FontType);
fc->done = 1;
/* since we've modified the current config with new font information,
* set this information as the new default.
*/
fc->data->defcfg.cell_width = fc->data->curcfg.cell_width;
fc->data->defcfg.cell_height = fc->data->curcfg.cell_height;
lstrcpyW(fc->data->defcfg.face_name, fc->data->curcfg.face_name);
/* Force also its writing back to the registry so that we can get it
* the next time.
*/
WINECON_RegSave(&fc->data->defcfg);
return 0;
}
} }
return 1; return 1;
} }
@ -377,8 +390,7 @@ static int CALLBACK get_first_font_enum(const LOGFONT* lf, const TEXTMETRIC* tm,
{ {
struct font_chooser* fc = (struct font_chooser*)lParam; struct font_chooser* fc = (struct font_chooser*)lParam;
WCUSER_DumpLogFont("init", lf, FontType); WCUSER_DumpLogFont("InitFamily: ", lf, FontType);
if (WCUSER_ValidateFont(fc->data, lf)) if (WCUSER_ValidateFont(fc->data, lf))
{ {
EnumFontFamilies(PRIVATE(fc->data)->hMemDC, lf->lfFaceName, EnumFontFamilies(PRIVATE(fc->data)->hMemDC, lf->lfFaceName,
@ -431,7 +443,8 @@ HFONT WCUSER_CopyFont(struct config_data* config, HWND hWnd, const LOGFONT* lf)
{ {
if (buf[j] != w) if (buf[j] != w)
{ {
WINE_WARN("Non uniform cell width: [%d]=%d [%d]=%d\n", WINE_WARN("Non uniform cell width: [%d]=%d [%d]=%d\n"
"This may be caused by old freetype libraries, >= 2.0.8 is recommended\n",
i + j, buf[j], tm.tmFirstChar, w); i + j, buf[j], tm.tmFirstChar, w);
goto err; goto err;
} }
@ -515,6 +528,7 @@ static BOOL WCUSER_InitFont(struct inner_data* data)
{ {
struct font_chooser fc; struct font_chooser fc;
WINE_TRACE_(wc_font)("=> %s\n", wine_dbgstr_wn(data->curcfg.face_name, -1));
if (data->curcfg.face_name[0] != '\0' && if (data->curcfg.face_name[0] != '\0' &&
data->curcfg.cell_height != 0 && data->curcfg.cell_height != 0 &&
data->curcfg.font_weight != 0) data->curcfg.font_weight != 0)
@ -525,7 +539,11 @@ static BOOL WCUSER_InitFont(struct inner_data* data)
data->curcfg.cell_height, data->curcfg.font_weight); data->curcfg.cell_height, data->curcfg.font_weight);
if (PRIVATE(data)->hFont != 0) WINE_FIXME("Oh strange\n"); if (PRIVATE(data)->hFont != 0) WINE_FIXME("Oh strange\n");
if (WCUSER_SetFont(data, &lf)) return TRUE; if (WCUSER_SetFont(data, &lf))
{
WCUSER_DumpLogFont("InitReuses: ", &lf, 0);
return TRUE;
}
} }
/* try to find an acceptable font */ /* try to find an acceptable font */
@ -533,6 +551,7 @@ static BOOL WCUSER_InitFont(struct inner_data* data)
fc.data = data; fc.data = data;
fc.done = 0; fc.done = 0;
EnumFontFamilies(PRIVATE(data)->hMemDC, NULL, get_first_font_enum, (LPARAM)&fc); EnumFontFamilies(PRIVATE(data)->hMemDC, NULL, get_first_font_enum, (LPARAM)&fc);
if (!fc.done) WINE_WARN("Couldn't find a decent font, aborting\n");
return fc.done; return fc.done;
} }
@ -1308,10 +1327,10 @@ static LRESULT CALLBACK WCUSER_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
void WCUSER_DeleteBackend(struct inner_data* data) void WCUSER_DeleteBackend(struct inner_data* data)
{ {
if (!PRIVATE(data)) return; if (!PRIVATE(data)) return;
if (PRIVATE(data)->hMemDC) DeleteDC(PRIVATE(data)->hMemDC);
if (PRIVATE(data)->hWnd) DestroyWindow(PRIVATE(data)->hWnd); if (PRIVATE(data)->hWnd) DestroyWindow(PRIVATE(data)->hWnd);
if (PRIVATE(data)->hFont) DeleteObject(PRIVATE(data)->hFont); if (PRIVATE(data)->hFont) DeleteObject(PRIVATE(data)->hFont);
if (PRIVATE(data)->cursor_bitmap) DeleteObject(PRIVATE(data)->cursor_bitmap); if (PRIVATE(data)->cursor_bitmap) DeleteObject(PRIVATE(data)->cursor_bitmap);
if (PRIVATE(data)->hMemDC) DeleteDC(PRIVATE(data)->hMemDC);
if (PRIVATE(data)->hBitmap) DeleteObject(PRIVATE(data)->hBitmap); if (PRIVATE(data)->hBitmap) DeleteObject(PRIVATE(data)->hBitmap);
HeapFree(GetProcessHeap(), 0, PRIVATE(data)); HeapFree(GetProcessHeap(), 0, PRIVATE(data));
} }
@ -1330,8 +1349,8 @@ static int WCUSER_MainLoop(struct inner_data* data)
switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT)) switch (MsgWaitForMultipleObjects(1, &data->hSynchro, FALSE, INFINITE, QS_ALLINPUT))
{ {
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
if (!WINECON_GrabChanges(data)) if (!WINECON_GrabChanges(data) && data->curcfg.exit_on_die)
PostQuitMessage(0); PostQuitMessage(0);
break; break;
case WAIT_OBJECT_0+1: case WAIT_OBJECT_0+1:
switch (GetMessage(&msg, 0, 0, 0)) switch (GetMessage(&msg, 0, 0, 0))

View File

@ -40,6 +40,7 @@ struct config_data {
unsigned win_width; /* size (in cells) of visible part of window (width & height) */ unsigned win_width; /* size (in cells) of visible part of window (width & height) */
unsigned win_height; unsigned win_height;
COORD win_pos; /* position (in cells) of visible part of screen buffer in window */ COORD win_pos; /* position (in cells) of visible part of screen buffer in window */
BOOL exit_on_die; /* whether the wineconsole should quit if server destroys the console */
}; };
struct inner_data { struct inner_data {