/* the worst possible thing that could happen here is for a later release of the system software to change how the default window colors are stored, which would cause this function to assume the default blue/purple colors. this is only a problem because the system then wonÕt have the colors it wants to draw window frames and controls. but this itself is ok, because the system is smart about doing this and there might even be enough shades of gray to go around. */ void initialize_system_colors( void) { CTabHandle default_wctb; default_wctb= (CTabHandle) GetResource('wctb', 0); if (default_wctb) { if ((*default_wctb)->ctSize>=12) { if ((*default_wctb)->ctTable[wHighlightColor].value==wHighlightColor&& (*default_wctb)->ctTable[wLowlightColor].value==wLowlightColor) { /* we have system seven or later with the right part codes! */ system_colors[windowLowlight]= (*default_wctb)->ctTable[wLowlightColor].rgb; system_colors[windowHighlight]= (*default_wctb)->ctTable[wHighlightColor].rgb; } } /* we canÕt dispose of this, because other people are using it */ } /* interpolate to get the two shades between the highlight and lowlight */ SetRGBColor(system_colors+window33Percent, (2*(long)system_colors[windowLowlight].red+(long)system_colors[windowHighlight].red)/3, (2*(long)system_colors[windowLowlight].green+(long)system_colors[windowHighlight].green)/3, (2*(long)system_colors[windowLowlight].blue+(long)system_colors[windowHighlight].blue)/3); SetRGBColor(system_colors+window66Percent, ((long)system_colors[windowLowlight].red+2*(long)system_colors[windowHighlight].red)/3, ((long)system_colors[windowLowlight].green+2*(long)system_colors[windowHighlight].green)/3, ((long)system_colors[windowLowlight].blue+2*(long)system_colors[windowHighlight].blue)/3); /* get the highlight color */ LMGetHiliteRGB(system_colors+highlightColor); return; }
/**************************************************************** PopInvert() inverts the given popup. ****************************************************************/ void PopInvert(DialogPtr theDialog, short itemNum) { GrafPtr savePort; short itemType; Handle itemHandle; Rect itemBox; //SysEnvRec theWorld; RGBColor SaveBack, DefaultBack, DefaultFore, saveHilite; GetPortGrafPtr(&savePort); SetPortDialogPort(theDialog); GetDialogItem(theDialog, itemNum, &itemType, &itemHandle, &itemBox); // SysEnvirons(curSysEnvVers,&theWorld); //if (!theWorld.hasColorQD) { if (ColorQDAvailable()) { InvertRect( &itemBox ); return; } GetBackColor(&SaveBack); LMGetHiliteRGB(&saveHilite); DefaultMenuColors(&DefaultFore, &DefaultBack); RGBBackColor(&DefaultBack); HiliteColor(&DefaultFore); LMSetHiliteMode(LMGetHiliteMode() & 0x7F); // clear 0th bit = pHiliteBit InvertRect( &itemBox ); HiliteColor(&saveHilite); RGBBackColor(&SaveBack); SetPortGrafPort(savePort); }
Boolean MCScreenDC::open() { owndnd = False; mouseMoveRgn = NewRgn(); SetRectRgn(mouseMoveRgn, 0, 0, 1, 1); //create a invisible window, and set port to this window //so that later on at the very first time MC select and set font //will only affect in this invisible window, not other apps on the desk top, // when MC is first started. The size of the window is random. // Rect invisibleWinRect; Rect invisibleWinRect; SetRect(&invisibleWinRect, 0, 0, 20, 20); invisibleWin = NewCWindow(nil, &invisibleWinRect, "\p", False, kUtilityWindowClass, (WindowRef)(-1L), False, 0); long response; if (Gestalt(gestaltSystemVersion, &response) == noErr) { if (response >= 0x1030 && response < 0x1040) MCantialiasedtextworkaround = True; else MCantialiasedtextworkaround = False; } SetGWorld(GetWindowPort(invisibleWin), GetMainDevice()); vis = new MCVisualInfo; devdepth = 32; black_pixel.red = black_pixel.green = black_pixel.blue = 0; //black pixel white_pixel.red = white_pixel.green = white_pixel.blue = 0xFFFF; //white pixel black_pixel.pixel = 0; white_pixel.pixel = 0xFFFFFF; redbits = greenbits = bluebits = 8; redshift = 16; greenshift = 8; blueshift = 0; vis->red_mask = 0x00FF0000; vis->green_mask = 0x0000FF00; vis->blue_mask = 0x000000FF; MCzerocolor = MCbrushcolor = white_pixel; alloccolor(MCbrushcolor); MCselectioncolor = MCpencolor = black_pixel; alloccolor(MCselectioncolor); alloccolor(MCpencolor); gray_pixel.red = gray_pixel.green = gray_pixel.blue = 0x8888; alloccolor(gray_pixel); background_pixel.red = background_pixel.green = background_pixel.blue = 0xffff; alloccolor(background_pixel); //query the system for the hilited text color, and set ours RGBColor hiliteRGB; LMGetHiliteRGB(&hiliteRGB); MChilitecolor.red = hiliteRGB.red; MChilitecolor.green = hiliteRGB.green; MChilitecolor.blue = hiliteRGB.blue; alloccolor(MChilitecolor); MCColor *syscolors = getaccentcolors(); if (syscolors != NULL) MCaccentcolor = syscolors[4]; else { MCaccentcolor.red = MCaccentcolor.green = 0x0000; MCaccentcolor.blue = 0x8080; } alloccolor(MCaccentcolor); grabbed = False; tripleclick = doubleclick = False; MCdoubletime = GetDblTime() * 1000 / 60; opened = True; mousewindow = new _Drawable; activewindow = new _Drawable; lastactivewindow = new _Drawable; mousewindow->type = activewindow->type = lastactivewindow->type = DC_WINDOW; mousewindow->handle.window = activewindow->handle.window = lastactivewindow->handle.window = 0; //get handle of application menu bar menuBar = GetMenuBar(); SetMenuBar(menuBar); //set menu bar as current menulist //create Apple menu appleMenu = NewMenu(mApple, "\p\024"); //menu title is an apple icon InsertMenuItem(appleMenu, "\pAbout...", 0); InsertMenu(appleMenu, 0); DrawMenuBar(); //draw the menu bar with the Apple menu usetemp = False; Handle tmem = Get1IndResource('TMEM', 1); if (tmem != NULL) { char *ptr = *tmem; if (*(ptr + 1)) usetemp = True; } MCtemplatescrollbar->alloccolors(); if (IsMacEmulatedLF()) // no AM MCtemplatebutton->allocicons(); // preallocate these because GetItemMark can't distinguish them submenuIDs[0] = 1; submenuIDs[checkMark] = 1; submenuIDs[diamondMark] = 1; MCcursors[PI_NONE] = nil; MCblinkrate = GetCaretTime() * 1000 / 60; MCDisplay const *t_displays; getdisplays(t_displays, false); MCwbr = t_displays[0] . workarea; //TSM - INIT TSM APPLICATION AND INSTALL REQUIRED APPLEVENT HANDLERS TSMPositionToOffsetUPP = NewAEEventHandlerUPP(TSMPositionToOffset); TSMOffsetToPositionUPP = NewAEEventHandlerUPP(TSMOffsetToPosition); TSMUpdateHandlerUPP = NewAEEventHandlerUPP(TSMUpdateHandler); TSMUnicodeNotFromInputUPP = NewAEEventHandlerUPP(TSMUnicodeNotFromInputHandler); AEInstallEventHandler(kTextServiceClass, kPos2Offset, TSMPositionToOffsetUPP, 0L , False); AEInstallEventHandler(kTextServiceClass, kOffset2Pos, TSMOffsetToPositionUPP, 0L , False); AEInstallEventHandler(kTextServiceClass, kUpdateActiveInputArea, TSMUpdateHandlerUPP, 0L , False); AEInstallEventHandler(kTextServiceClass, kUnicodeNotFromInputMethod, TSMUnicodeNotFromInputUPP, 0L , False); openIME(); dragdropUPP = NewDragReceiveHandlerUPP(DragReceiveHandler); InstallReceiveHandler(dragdropUPP, NULL, NULL); dragmoveUPP = NewDragTrackingHandlerUPP(DragTrackingHandler); InstallTrackingHandler(dragmoveUPP, NULL, NULL); s_animation_current_time = s_animation_start_time = CFAbsoluteTimeGetCurrent(); //// Dock Menu Initialization EventTypeSpec t_menu_event_specs[1]; t_menu_event_specs[0] . eventClass = kEventClassMenu; t_menu_event_specs[0] . eventKind = kEventMenuPopulate; CreateNewMenu(0, 0, &f_icon_menu); s_icon_menu_event_handler_upp = NewEventHandlerUPP((EventHandlerProcPtr)handleiconmenuevent); InstallEventHandler(GetMenuEventTarget(f_icon_menu), s_icon_menu_event_handler_upp, 1, t_menu_event_specs, NULL, NULL); t_menu_event_specs[0] . eventClass = kEventClassCommand; t_menu_event_specs[0] . eventKind = kEventCommandProcess; InstallEventHandler(GetApplicationEventTarget(), s_icon_menu_event_handler_upp, 1, t_menu_event_specs, NULL, NULL); SetApplicationDockTileMenu(f_icon_menu); //// Color Profile Initialization CMGetDefaultProfileBySpace(cmRGBData, &m_dst_profile); CMProfileLocation t_location; t_location . locType = cmPathBasedProfile; strcpy(t_location . u . pathLoc . path, "/System/Library/ColorSync/Profiles/sRGB Profile.icc"); CMOpenProfile(&m_srgb_profile, &t_location); //// return True; }
// -------------------------------------------------------------------------------------- static void drawIconListCell(ListHandle theList, const Rect *cellRect, IconListCellDataRec *theCellData, Boolean selected) { GrafPtr savedPort; CGrafPtr listPort; ThemeDrawingState savedState; Boolean active; Rect iconRect, textRect; short savedFont, savedSize; Style savedFace; CFStringRef cellName; GetPort(&savedPort); listPort = GetListPort(theList); SetPort((GrafPtr)listPort); GetThemeDrawingState(&savedState); if (selected) // we don't need to change the background { // color if this Cell isn't highlighted Pattern whitePattern; RGBColor highlightColor; GetQDGlobalsWhite(&whitePattern); // set the background pattern so that BackPat(&whitePattern); // the color is properly set as a solid color LMGetHiliteRGB(&highlightColor); RGBBackColor(&highlightColor); // set the background to the highlight color } EraseRect(cellRect); calculateDrawingBounds(cellRect, &iconRect, &textRect); // get the drawing Rects active = GetListActive(theList); // draw the IconRef using Icon Services PlotIconRef(&iconRect, kAlignNone, active ? kTransformNone : kTransformDisabled, kIconServicesNormalUsageFlag, theCellData->icon); #if TARGET_API_MAC_OS8 // draw TextEdit text in Classic #pragma unused (cellName) savedFont = GetPortTextFont(listPort); // Get/SetThemeDrawingState doesn't save or savedFace = GetPortTextFace(listPort); // restore these savedSize = GetPortTextSize(listPort); UseThemeFont(kThemeViewsFont, smCurrentScript); TETextBox(&theCellData->name[1], theCellData->name[0], &textRect, teCenter); TextFont(savedFont); TextFace(savedFace); TextSize(savedSize); #else // draw Appearance text in Carbon #pragma unused (savedFont, savedSize, savedFace) cellName = CFStringCreateWithPascalString(kCFAllocatorDefault, theCellData->name, GetApplicationTextEncoding()); DrawThemeTextBox(cellName, kThemeViewsFont, active ? kThemeStateActive : kThemeStateInactive, true, &textRect, teCenter, NULL); CFRelease(cellName); #endif SetThemeDrawingState(savedState, true); SetPort(savedPort); } // drawIconListCell