Commit da5b3f2f authored by blakeross%telocity.com's avatar blakeross%telocity.com
Browse files

Fix 46174: widgets don't use Appearance Manager variation color in mac classic...

Fix 46174: widgets don't use Appearance Manager variation color in mac classic theme.  r=ben sr=blizzard
parent 38504ea3
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -85,7 +85,14 @@ public:
    eColor_windowtext,
    eColor_windowtext,


    // Colors which will hopefully become CSS3
    // Colors which will hopefully become CSS3
    eColor__moz_field
    eColor__moz_field,
    eColor__moz_dragtargetzone,				//used to highlight valid regions to drop something onto

    //colours needed by Mac Classic skin
    eColor__moz_mac_focusring,				//ring around text fields and lists
    eColor__moz_mac_menuselect,				//colour used when mouse is over a menu item
    eColor__moz_mac_menushadow,				//colour used to do shadows on menu items
    eColor__moz_mac_menutextselect			//colour used to display text while mouse is over a menu item
    
    
  } nsColorID;
  } nsColorID;


+70 −4
Original line number Original line Diff line number Diff line
@@ -112,12 +112,13 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
    //
    //
    // css2 system colors http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
    // css2 system colors http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
    //
    //
    // Right now, the majority of these colors are just guesses since they are
    // It's really hard to effectively map these to the Appearance Manager properly,
    // modeled word for word after the win32 system colors and don't have any 
    // since they are modeled word for word after the win32 system colors and don't have any 
    // real counterparts in the Mac world. I'm sure we'll be tweaking these for 
    // real counterparts in the Mac world. I'm sure we'll be tweaking these for 
    // years to come. 
    // years to come. 
    //
    //
    // Thanks to mpt26@student.canterbury.ac.nz for the hardcoded values ;)
    // Thanks to mpt26@student.canterbury.ac.nz for the hardcoded values that form the defaults
    //	if querying the Appearance Manager fails ;)
    //
    //
    
    
    case eColor_buttontext:
    case eColor_buttontext:
@@ -231,6 +232,25 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
    case eColor__moz_field:
    case eColor__moz_field:
		aColor = NS_RGB(0xff,0xff,0xff);
		aColor = NS_RGB(0xff,0xff,0xff);
        break;
        break;
    case eColor__moz_dragtargetzone:
		//default to lavender if not available
		res = GetMacBrushColor(kThemeBrushDragHilite, aColor, NS_RGB(0x63,0x63,0xCE));
	    break;
	case eColor__moz_mac_focusring:
		//default to lavender if not available
		res = GetMacBrushColor(kThemeBrushFocusHighlight, aColor, NS_RGB(0x63,0x63,0xCE));
	    break;
	case eColor__moz_mac_menuselect:
		//get this colour by querying variation table, ows. default to Platinum/Lavendar
		res = GetMacAccentColor(eColorOffset_mac_accentregularshadow, aColor, NS_RGB(0x63,0x63,0xCE));
	    break;
	case eColor__moz_mac_menushadow:
		res = GetMacBrushColor(kThemeBrushBevelActiveDark, aColor, NS_RGB(0x88,0x88,0x88));
	    break;	        
	case eColor__moz_mac_menutextselect:
		//default to white, which is what Platinum uses, if not available		
		res = GetMacTextColor(kThemeTextColorMenuItemSelected, aColor, NS_RGB(0xFF,0xFF,0xFF));
	    break;	    
    default:
    default:
        NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about");
        NS_WARNING("Someone asked nsILookAndFeel for a color I don't know about");
        aColor = NS_RGB(0xff,0xff,0xff);
        aColor = NS_RGB(0xff,0xff,0xff);
@@ -271,6 +291,52 @@ NS_IMETHODIMP nsLookAndFeel::GetMacTextColor(const PRInt32 aTextType, nscolor &
	
	
}
}


NS_IMETHODIMP nsLookAndFeel::GetMacAccentColor(	const nsMacAccentColorOffset aAccent, 
												nscolor & aColor,
												const nscolor & aDefaultColor)
{
	nsresult res = NS_OK;
	OSStatus err = noErr;
	ColorTable colourTable;
	CTabPtr ctPointer = &colourTable;
	CTabHandle ctHandle = &ctPointer;
	CTabHandle *colors = &ctHandle;
	RGBColor *macColor;		

	err = ::GetThemeAccentColors(colors);
	if (err == themeHasNoAccentsErr) {
		//fine, theme doesn't support accents, use default
		res = NS_OK;
		aColor = aDefaultColor;
	} else if (err != noErr || ! colors) {
		res = NS_ERROR_FAILURE;
		aColor = aDefaultColor;
	} else {
		if ((**colors)->ctSize == 
				(eColorOffset_mac_accentdarkestshadow - eColorOffset_mac_accentlightesthighlight +1)) {
			//if the size is 7 then its likely to be a standard Platinum variation, so lets use it
			macColor = &((**colors)->ctTable[aAccent].rgb);
			aColor = NS_RGB(macColor->red>>8, macColor->green>>8, macColor->blue>>8);
			res = NS_OK;		
		} else if ((**colors)->ctSize == -1) {
			//this is probably the high contrast Black & White Platinum variation
			//so lets be high contrast
			res = NS_OK;
			if (aAccent <= eColorOffset_mac_accentface) {
				aColor = NS_RGB(0xFF,0xFF,0xFF);
			} else {
				aColor = NS_RGB(0x00,0x00,0x00);
			}
		//else if ( ?? )  // add aqua support here?
		} else {
			//some other size we've never heard of, no idea what to do with it
			res = NS_ERROR_FAILURE;
			aColor = aDefaultColor;
		}
	}
	return res;
}

NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
{
{
    nsresult res = NS_OK;
    nsresult res = NS_OK;
+16 −0
Original line number Original line Diff line number Diff line
@@ -48,9 +48,25 @@ public:
#endif
#endif


protected:
protected:

 typedef enum {
  
    //theme accent variation colours on Mac OS,
    //offsets into Platinum theme variation colour table
    eColorOffset_mac_accentlightesthighlight,
    eColorOffset_mac_accentregularhighlight,
    eColorOffset_mac_accentface,
    eColorOffset_mac_accentlightshadow,
    eColorOffset_mac_accentregularshadow,
    eColorOffset_mac_accentdarkshadow,
    eColorOffset_mac_accentdarkestshadow
  } nsMacAccentColorOffset;


  nsCOMPtr<nsILookAndFeel> mXPLookAndFeel;
  nsCOMPtr<nsILookAndFeel> mXPLookAndFeel;
  NS_IMETHOD GetMacBrushColor(const PRInt32 aBrushType, nscolor & aColor, const nscolor & aDefaultColor);
  NS_IMETHOD GetMacBrushColor(const PRInt32 aBrushType, nscolor & aColor, const nscolor & aDefaultColor);
  NS_IMETHOD GetMacTextColor(const PRInt32 aTextType, nscolor & aColor, const nscolor & aDefaultColor);
  NS_IMETHOD GetMacTextColor(const PRInt32 aTextType, nscolor & aColor, const nscolor & aDefaultColor);
  NS_IMETHOD GetMacAccentColor(const nsMacAccentColorOffset aAccent, nscolor & aColor, const nscolor & aDefaultColor);
};
};


#endif
#endif
+10 −0
Original line number Original line Diff line number Diff line
@@ -170,6 +170,16 @@ nsLookAndFeelColorPref nsXPLookAndFeel::sColorPrefs[] =
    eColor_windowtext, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
    eColor_windowtext, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
  { "ui.-moz-field",
  { "ui.-moz-field",
    eColor__moz_field, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
    eColor__moz_field, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
  { "ui.-moz-dragtargetzone",
    eColor__moz_dragtargetzone, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
  { "ui.-moz-mac-focusring",
    eColor__moz_mac_focusring, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
  { "ui.-moz-mac-menuselect",
    eColor__moz_mac_menushadow, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },
  { "ui.-moz-mac-menutextshadow",
    eColor__moz_mac_menutextselect, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },     
  { "ui.-moz-mac-menutextselect",
    eColor__moz_mac_menutextselect, PR_FALSE, nsLookAndFeelTypeColor, (nscolor)0 },       
};
};


PRBool nsXPLookAndFeel::sInitialized = PR_FALSE;
PRBool nsXPLookAndFeel::sInitialized = PR_FALSE;