void Application_set_font( Handle self, Font font) { if ( !opt_InPaint) my-> first_that( self, (void*)font_notify, &font); apc_font_pick( self, &font, & var-> font); if ( opt_InPaint) apc_gp_set_font ( self, &var-> font); }
Font * Drawable_font_match( char * dummy, Font * source, Font * dest, Bool pick) { if ( pick) apc_font_pick( nilHandle, source, dest); else Drawable_font_add( nilHandle, source, dest); return dest; }
Bool window_subsystem_init( char * error_buf) { WNDCLASSW wc; HDC dc; HBITMAP hbm; OSVERSIONINFO os = { sizeof( OSVERSIONINFO)}; guts. version = GetVersion(); GetVersionEx( &os); guts. alloc_utf8_to_wchar_visual = (( os.dwMajorVersion > 5) || (os.dwMajorVersion == 5 && os.dwMinorVersion > 1)) ? alloc_utf8_to_wchar_visual : alloc_utf8_to_wchar; guts. mainThreadId = GetCurrentThreadId(); guts. errorMode = SetErrorMode( SEM_FAILCRITICALERRORS); guts. desktopWindow = GetDesktopWindow(); memset( &wc, 0, sizeof( wc)); wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wc.lpfnWndProc = ( WNDPROC) generic_app_handler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = guts. instance; wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION); wc.hCursor = LoadCursor( NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)NULL; wc.lpszClassName = L"GenericApp"; RegisterClassW( &wc); memset( &wc, 0, sizeof( wc)); wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wc.lpfnWndProc = ( WNDPROC) generic_frame_handler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = guts. instance; wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION); wc.hCursor = LoadCursor( NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)NULL; wc.lpszClassName = L"GenericFrame"; RegisterClassW( &wc); memset( &wc, 0, sizeof( wc)); wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wc.lpfnWndProc = ( WNDPROC) generic_view_handler; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = guts. instance; wc.hIcon = LoadIcon( guts. instance, IDI_APPLICATION); wc.hCursor = NULL; // LoadCursor( NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)NULL; wc.lpszClassName = L"Generic"; RegisterClassW( &wc); stylusMan = hash_create(); fontMan = hash_create(); patMan = hash_create(); menuMan = hash_create(); imageMan = hash_create(); regnodeMan = hash_create(); create_font_hash(); { LOGBRUSH b = { BS_HOLLOW, 0, 0}; Font f; hPenHollow = CreatePen( PS_NULL, 0, 0); hBrushHollow = CreateBrushIndirect( &b); hPatHollow. dotsCount = 0; hPatHollow. dotsPtr = nil; FONTSTRUCSIZE = (char *)(&(f. name)) - (char *)(&f); } if (!( dc = dc_alloc())) return false; guts. displayResolution. x = GetDeviceCaps( dc, LOGPIXELSX); guts. displayResolution. y = GetDeviceCaps( dc, LOGPIXELSY); { LOGFONT lf; HFONT sfont; // getting most common font name memset( &lf, 0, sizeof( lf)); lf. lfCharSet = OEM_CHARSET; lf. lfOutPrecision = OUT_DEFAULT_PRECIS; lf. lfClipPrecision = CLIP_DEFAULT_PRECIS; lf. lfQuality = PROOF_QUALITY; lf. lfPitchAndFamily = DEFAULT_PITCH; sfont = SelectObject( dc, CreateFontIndirect( &lf)); GetTextFace( dc, 256, guts. defaultSystemFont); // getting common fixed font name lf. lfHeight = 320; lf. lfPitchAndFamily = FIXED_PITCH; DeleteObject( SelectObject( dc, CreateFontIndirect( &lf))); GetTextFace( dc, 256, guts. defaultFixedFont); // getting common variable font name lf. lfPitchAndFamily = VARIABLE_PITCH; DeleteObject( SelectObject( dc, CreateFontIndirect( &lf))); GetTextFace( dc, 256, guts. defaultVariableFont); DeleteObject( SelectObject( dc, sfont)); // getting system font presets memset( &guts. windowFont, 0, sizeof( Font)); strcpy( guts. windowFont. name, DEFAULT_WIDGET_FONT); guts. windowFont. size = DEFAULT_WIDGET_FONT_SIZE; guts. windowFont. width = guts. windowFont. height = C_NUMERIC_UNDEF; #ifdef FONT_CHECK guts. windowFont. size = 12; #endif apc_font_pick( nilHandle, &guts. windowFont, &guts. windowFont); guts. ncmData. cbSize = sizeof( NONCLIENTMETRICS); SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( NONCLIENTMETRICS), ( PVOID) &guts. ncmData, 0); font_logfont2font( &guts. ncmData. lfMenuFont, &guts. menuFont, &guts. displayResolution); font_logfont2font( &guts. ncmData. lfMessageFont, &guts. msgFont, &guts. displayResolution); font_logfont2font( &guts. ncmData. lfCaptionFont, &guts. capFont, &guts. displayResolution); } memset( &guts. displayBMInfo, 0, sizeof( guts. displayBMInfo)); guts. displayBMInfo. bmiHeader. biSize = sizeof( BITMAPINFO); if ( !( hbm = GetCurrentObject( dc, OBJ_BITMAP))) { apiErr; dc_free(); return false; } if ( !GetDIBits( dc, hbm, 0, 0, NULL, &guts. displayBMInfo, DIB_PAL_COLORS)) { guts. displayBMInfo. bmiHeader. biBitCount = GetDeviceCaps( dc, BITSPIXEL); guts. displayBMInfo. bmiHeader. biPlanes = GetDeviceCaps( dc, PLANES); } dc_free(); guts. insertMode = true; guts. iconSizeSmall. x = GetSystemMetrics( SM_CXSMICON); guts. iconSizeSmall. y = GetSystemMetrics( SM_CYSMICON); guts. iconSizeLarge. x = GetSystemMetrics( SM_CXICON); guts. iconSizeLarge. y = GetSystemMetrics( SM_CYICON); guts. pointerSize. x = GetSystemMetrics( SM_CXCURSOR); guts. pointerSize. y = GetSystemMetrics( SM_CYCURSOR); list_create( &guts. transp, 8, 8); list_create( &guts. files, 8, 8); list_create( &guts. sockets, 8, 8); // selecting locale layout, more or less latin-like { char buf[ KL_NAMELENGTH * 2] = ""; HKL current = GetKeyboardLayout( 0); int i, j, size = GetKeyboardLayoutList( 0, nil); HKL * kl = ( HKL *) malloc( sizeof( HKL) * size); guts. keyLayout = nil; if ( !GetKeyboardLayoutName( buf)) apiErr; for ( j = 0; j < ( sizeof( keyLayouts) / sizeof( char*)); j++) { if ( strncmp( buf + 4, keyLayouts[ j], 4) == 0) { guts. keyLayout = current; goto found_1; } } if ( kl) { GetKeyboardLayoutList( size, kl); for ( i = 0; i < size; i++) { ActivateKeyboardLayout( kl[ i], 0); if ( !GetKeyboardLayoutName( buf)) apiErr; for ( j = 0; j < ( sizeof( keyLayouts) / sizeof( char*)); j++) { if ( strncmp( buf + 4, keyLayouts[ j], 4) == 0) { guts. keyLayout = kl[ i]; goto found_2; } } } found_2:; ActivateKeyboardLayout( current, 0); } found_1:; free( kl); } guts. currentKeyState = guts. keyState; memset( guts. emptyKeyState, 0, sizeof( guts. emptyKeyState)); guts. smDblClk. x = GetSystemMetrics( SM_CXDOUBLECLK); guts. smDblClk. y = GetSystemMetrics( SM_CYDOUBLECLK); return true; }
void Window_set_menu_font( Handle self, Font font) { apc_font_pick( self, &font, &var-> menuFont); if ( var-> menu) apc_menu_set_font( var-> menu, &var-> menuFont); }