void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded ) { #if !TARGET_CARBON ::MaxApplZone(); for (long i = 1; i <= inMoreMastersCalls; i++) ::MoreMasters(); if (!isEmbedded) { ::InitGraf(&qd.thePort); ::InitFonts(); ::InitMenus(); ::TEInit(); ::InitDialogs(0L); ::FlushEvents(everyEvent, 0); } long total,contig; PurgeSpace(&total, &contig); #endif ::InitCursor(); if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr) sUMASystemVersion = 0x0000 ; long theAppearance ; if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr ) { sUMAHasAppearance = true ; OSStatus status = RegisterAppearanceClient(); // If status equals appearanceProcessRegisteredErr it means the // appearance client already was registered (For example if we run // embedded, the host might have registered it). In such a case // we don't unregister it later on. if (status != appearanceProcessRegisteredErr) { // Appearance client wasn't registered yet. sUMAHasInittedAppearance = true; } if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr ) { sUMAAppearanceVersion = theAppearance ; } else { sUMAAppearanceVersion = 0x0100 ; } } if ( Gestalt( gestaltWindowMgrAttr, &sUMAWindowManagerAttr ) == noErr ) { sUMAHasWindowManager = sUMAWindowManagerAttr & gestaltWindowMgrPresent ; } #if TARGET_CARBON // Call currently implicitely done : InitFloatingWindows() ; #else if (!isEmbedded) { if ( sUMAHasWindowManager ) InitFloatingWindows() ; else InitWindows(); } #endif if ( NavServicesAvailable() ) { NavLoad() ; } long menuMgrAttr ; Gestalt( gestaltMenuMgrAttr , &menuMgrAttr ) ; if ( menuMgrAttr & gestaltMenuMgrAquaLayoutMask ) sUMAHasAquaLayout = true ; if ( TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress ) { FontFamilyID fontId ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); TXNMacOSPreferredFontDescription fontDescriptions[] = { { fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding } } ; int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ; // kTXNAlwaysUseQuickDrawTextMask might be desirable because of speed increases but it crashes the app under OS X upon key stroke #if 0 // leads to unexpected content for clients, TODO configurable OptionBits options = kTXNWantMoviesMask | kTXNWantSoundMask | kTXNWantGraphicsMask ; #else OptionBits options = 0 ; #endif #if TARGET_CARBON if ( !UMAHasAquaLayout() ) #endif { options |= kTXNAlwaysUseQuickDrawTextMask ; } TXNInitTextension(fontDescriptions, noOfFontDescriptions, options ); } UMASetSystemIsInitialized(true); }
void QFontDatabase::createDatabase() { if(db) return; db = new QFontDatabasePrivate; qfontdatabase_cleanup.set(&db); FMFontFamilyIterator it; QString foundry_name = "Mac"; if(!FMCreateFontFamilyIterator(NULL, NULL, kFMUseGlobalScopeOption, &it)) { FMFontFamily fam; QString fam_name; while(!FMGetNextFontFamily(&it, &fam)) { static Str255 n; if(FMGetFontFamilyName(fam, n) != noErr) qDebug("Qt: internal: WH0A, %s %d", __FILE__, __LINE__); if(!n[0] || n[1] == '.') //throw out ones starting with a . continue; { short fnum; ATSUFontID fond; GetFNum(n, &fnum); if(ATSUFONDtoFontID(fnum, 0, &fond) != noErr) continue; } TextEncoding encoding; FMGetFontFamilyTextEncoding(fam, &encoding); TextToUnicodeInfo uni_info; CreateTextToUnicodeInfoByEncoding(encoding, &uni_info); unsigned long len = n[0] * 2; unsigned char *buff = (unsigned char *)malloc(len); ConvertFromPStringToUnicode(uni_info, n, len, &len, (UniCharArrayPtr)buff); fam_name = ""; for(unsigned long x = 0; x < len; x+=2) { #if defined(__i386__) fam_name += QChar(buff[x], buff[x+1]); #else fam_name += QChar(buff[x+1], buff[x]); #endif } free(buff); DisposeTextToUnicodeInfo(&uni_info); QtFontFamily *family = db->family( fam_name, TRUE ); family->macFamily = fam; for(int script = 0; script < QFont::LastPrivateScript; ++script) family->scripts[script] = QtFontFamily::Supported; QtFontFoundry *foundry = family->foundry( foundry_name, TRUE ); FMFontFamilyInstanceIterator fit; if(!FMCreateFontFamilyInstanceIterator(fam, &fit)) { FMFont font; FMFontStyle font_style; FMFontSize font_size; while(!FMGetNextFontFamilyInstance(&fit, &font, &font_style, &font_size)) { bool italic = (bool)(font_style & ::italic); int weight = ((font_style & ::bold) ? QFont::Bold : QFont::Normal); QtFontStyle::Key styleKey; styleKey.italic = italic; styleKey.oblique = false; styleKey.weight = weight; QtFontStyle *style = foundry->style( styleKey, TRUE ); style->smoothScalable = TRUE; if( !italic ) { styleKey.oblique = TRUE; style = foundry->style( styleKey, TRUE ); style->smoothScalable = TRUE; styleKey.oblique = FALSE; } if(weight < QFont::DemiBold) { // Can make bolder styleKey.weight = QFont::Bold; if(italic) { style = foundry->style( styleKey, TRUE ); style->smoothScalable = TRUE; } else { styleKey.oblique = TRUE; style = foundry->style( styleKey, TRUE ); style->smoothScalable = TRUE; } } } FMDisposeFontFamilyInstanceIterator(&fit); } } FMDisposeFontFamilyIterator(&it); } }
void init_main_buttons() { short i; int indent = 0, indent2 = 0; GrafPtr old_port; Str255 fn1 = "\pGeneva"; Str255 fn3 = "\pPalatino"; Rect base_rect; if (init_once == false) { init_once = true; GetFNum(fn1,&geneva_font_num); if (geneva_font_num == 0) GetFNum(fn3,&geneva_font_num); GetPort(&old_port); SetPort(GetWindowPort(mainPtr)); TextFont(geneva_font_num); TextFace(bold); TextSize(10); SetPort(old_port); } //whole_win_rect = mainPtr->portRect; //Initialize pc_info_rect in center pc_info_rect= whole_win_rect; InsetRect(&pc_info_rect,100,100); pc_info_rect.bottom+=52; pc_info_rect.top-=25; pc_info_rect.right+=5; name_rect.left = pc_info_rect.left; name_rect.right = pc_info_rect.left + 100; name_rect.bottom = pc_info_rect.top + 15; name_rect.top = pc_info_rect.top; //Initialize pc_area_buttons pc_area_buttons[0][0].top=pc_info_rect.top; pc_area_buttons[0][0].bottom=pc_area_buttons[0][0].top + 56; for(i=0; i<6; i++) { pc_area_buttons[i][0].left = 20; pc_area_buttons[i][0].right = pc_area_buttons[0][0].left + 56; pc_area_buttons[i][2].left = 20; pc_area_buttons[i][2].right = pc_area_buttons[i][2].left + 56; pc_area_buttons[i][3].left = 20; pc_area_buttons[i][3].right = pc_area_buttons[i][3].left + 56; pc_area_buttons[i][1].left = 34; pc_area_buttons[i][1].right = pc_area_buttons[i][1].left + 28; pc_area_buttons[i][0].top = pc_area_buttons[0][0].top + 60*i; pc_area_buttons[i][0].bottom = pc_area_buttons[0][0].bottom + 60*i; pc_area_buttons[i][1].top = pc_area_buttons[i][0].top+2; pc_area_buttons[i][1].bottom = pc_area_buttons[i][2].top = pc_area_buttons[i][0].bottom - 18; pc_area_buttons[i][2].bottom = pc_area_buttons[i][3].top = pc_area_buttons[i][0].bottom - 9; pc_area_buttons[i][3].bottom = pc_area_buttons[i][0].bottom; OffsetRect(&pc_area_buttons[i][2],0,-1); OffsetRect(&pc_area_buttons[i][3],0,-2); } //Initialize the edit_rect buttons edit_rect[0][0].top = pc_info_rect.top; for(i = 0; i < 5; i++) { if(i >= 2) indent = 5; else indent = 0; if( i == 4) indent2 = 1; edit_rect[i][0].top = edit_rect[0][0].top + 66*i; edit_rect[i][0].bottom = edit_rect[i][0].top + 53; edit_rect[i][0].left = 510; edit_rect[i][0].right = edit_rect[i][0].left + 53; edit_rect[i][1].top = edit_rect[i][0].top + 11 + indent; edit_rect[i][1].bottom = edit_rect[i][0].bottom - 11 - indent; edit_rect[i][1].right = edit_rect[i][0].right - 8 +indent2; edit_rect[i][1].left = edit_rect[i][0].left + 8 + indent2; } // name_rect.left = pc_info_rect.left; // name_rect.right = pc_info_rect.left + (pc_info_rect.right - pc_info_rect.left)/4; // name_rect.bottom = pc_info_rect.top + 15; // name_rect.top = pc_info_rect.top; // if (name_rect.right == name_rect.left) { // SysBeep(50); SysBeep(50); // } //Initialize pc_race_rect pc_race_rect.top = pc_info_rect.top; pc_race_rect.bottom = name_rect.bottom; pc_race_rect.left = name_rect.right; pc_race_rect.right = pc_info_rect.left + (pc_info_rect.right - pc_info_rect.left)/2; //initialize info_area_rect info_area_rect.top = pc_info_rect.top; info_area_rect.left = pc_info_rect.left; info_area_rect.right = pc_race_rect.right; info_area_rect.bottom = pc_info_rect.bottom; /* if (name_rect.right == name_rect.left) { SysBeep(50); } */ // Initialize hp_sp_rect hp_sp_rect.top = name_rect.bottom + 1; hp_sp_rect.left = pc_info_rect.left + 1; hp_sp_rect.right = pc_race_rect.right; hp_sp_rect.bottom = hp_sp_rect.top + 12; // Initialize skill_rect skill_rect.top = hp_sp_rect.bottom + 2; skill_rect.left = pc_info_rect.left + 1; skill_rect.right = pc_race_rect.right; skill_rect.bottom = skill_rect.top + 12; //if (name_rect.right == name_rect.left) { // SysBeep(50); SysBeep(50); // } //Initialize skills_rect base_rect.top = skill_rect.bottom + 1; base_rect.left = skill_rect.left + 1; base_rect.right = name_rect.right - 1; base_rect.bottom = base_rect.top + (pc_info_rect.bottom - skill_rect.bottom)/30; for (i = 0; i < 19; i++) { pc_skills_rect[i] = base_rect; OffsetRect(&pc_skills_rect[i], (i / 10) * ((name_rect.right)-(name_rect.left)), (i % 10) * (pc_info_rect.bottom - name_rect.bottom)/30); } //Initialize status_rect status_rect.top = pc_skills_rect[9].bottom + 5; status_rect.left = pc_info_rect.left + 1; status_rect.right = pc_race_rect.right; status_rect.bottom = status_rect.top + 12; //Initialize pc_status_rect base_rect.top = status_rect.bottom + 1; base_rect.left = status_rect.left + 1; base_rect.right = name_rect.right - 1; base_rect.bottom = base_rect.top + (pc_info_rect.bottom - status_rect.bottom)/15; for (i = 0; i < 10; i++) { pc_status_rect[i] = base_rect; OffsetRect(&pc_status_rect[i], (i / 5) * ((name_rect.right)-(name_rect.left)), (i % 5) * (pc_info_rect.bottom - status_rect.bottom)/15); } //Initialize traits_rect traits_rect.top = pc_status_rect[4].bottom + 5; traits_rect.left = pc_info_rect.left + 1; traits_rect.right = pc_race_rect.right; traits_rect.bottom = traits_rect.top + 12; //Initialize pc_traits_rect base_rect.top = traits_rect.bottom - 1; base_rect.left = traits_rect.left + 1; base_rect.right = name_rect.right - 1; base_rect.bottom = base_rect.top + 10; for (i = 0; i < 16; i++) { pc_traits_rect[i] = base_rect; OffsetRect(&pc_traits_rect[i], (i / 8) * ((name_rect.right)-(name_rect.left)), (i % 8) * 9); } item_string_rects[0][0].top = pc_info_rect.top + 3; item_string_rects[0][0].left = pc_info_rect.left + (pc_info_rect.right - pc_info_rect.left)/2; item_string_rects[0][0].right = pc_info_rect.right; item_string_rects[0][0].bottom = item_string_rects[0][0].top + 12; for (i = 1; i < 24; i++) { item_string_rects[i][0] = item_string_rects[0][0]; OffsetRect(&item_string_rects[i][0],0,13 * i); } for (i = 0; i < 24; i++) { item_string_rects[i][1] = item_string_rects[i][0]; item_string_rects[i][1].right -= 14; item_string_rects[i][1].left = item_string_rects[i][1].right - 14; item_string_rects[i][2] = item_string_rects[i][0]; item_string_rects[i][2].left = item_string_rects[i][2].right - 14; } }