From f4dbc31508d429fcaad02572cfa4d40d7aeac842 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Wed, 5 Aug 1998 02:54:32 +0000 Subject: [PATCH] More stuff for RDF properties as well as fixing color parsing. git-svn-id: svn://10.0.0.236/trunk@7308 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cmd/macfe/rdfui/URDFUtilities.cp | 35 ++++++++++++++++-------- mozilla/cmd/macfe/rdfui/URDFUtilities.h | 5 ++-- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/mozilla/cmd/macfe/rdfui/URDFUtilities.cp b/mozilla/cmd/macfe/rdfui/URDFUtilities.cp index da9bd318b2f..68e919d2b74 100644 --- a/mozilla/cmd/macfe/rdfui/URDFUtilities.cp +++ b/mozilla/cmd/macfe/rdfui/URDFUtilities.cp @@ -189,11 +189,11 @@ URDFUtilities :: GetColor ( HT_Resource inNode, void* inHTToken, RGBColor* outCo if ( inNode && inHTToken ) { char* color = NULL; - PRBool success = HT_GetNodeData ( inNode, inHTToken, HT_COLUMN_STRING, &color ); + PRBool success = HT_GetTemplateData ( inNode, inHTToken, HT_COLUMN_STRING, &color ); if ( success && color ) { uint8 red, green, blue; - if ( XP_ColorNameToRGB(color, &red, &green, &blue) == 0 ) { - *outColor = UGraphics::MakeRGBColor(red, green, blue);\ + if ( LO_ParseRGB(color, &red, &green, &blue) ) { + *outColor = UGraphics::MakeRGBColor(red, green, blue); usingHTColor = true; } } @@ -208,21 +208,34 @@ URDFUtilities :: GetColor ( HT_Resource inNode, void* inHTToken, RGBColor* outCo // PropertyValueBool // // Gets the value of the given token and determines if it is "[Y|y]es" or "[N|n]o" based -// on the first character. Returns the appropriate boolean value (yes = true). +// on the first character. Returns the appropriate boolean value (yes = true). If the +// property is not specified (or not specified correctly) return the default value. // bool -URDFUtilities :: PropertyValueBool ( HT_Resource inNode, void* inHTToken ) +URDFUtilities :: PropertyValueBool ( HT_Resource inNode, void* inHTToken, bool inDefaultValue ) { - char* value = NULL; + bool retVal = inDefaultValue; - PRBool success = HT_GetNodeData ( inNode, inHTToken, HT_COLUMN_STRING, &value ); - if ( success && value ) - return (*value == 'y' || *value == 'Y') ? true : false; - - return false; + if ( inNode && inHTToken ) { + char* value = NULL; + + PRBool success = HT_GetTemplateData ( inNode, inHTToken, HT_COLUMN_STRING, &value ); + if ( success && value ) { + switch ( *value ) { + case 'Y': case 'y': + retVal = true; + break; + case 'N': case 'n': + retVal = false; + } + } + } + + return retVal; } // PropertyValueBool + // // LaunchNode // LaunchURL diff --git a/mozilla/cmd/macfe/rdfui/URDFUtilities.h b/mozilla/cmd/macfe/rdfui/URDFUtilities.h index 6598d9f52ed..286a256d14d 100644 --- a/mozilla/cmd/macfe/rdfui/URDFUtilities.h +++ b/mozilla/cmd/macfe/rdfui/URDFUtilities.h @@ -51,8 +51,9 @@ class URDFUtilities static bool SetupForegroundTextColor ( HT_Resource inNode, void* inHTToken, ThemeTextColor inBrush ) ; static bool GetColor ( HT_Resource inNode, void* inHTToken, RGBColor * outColor ) ; - // true if property is "yes", false if value is "no" - static bool PropertyValueBool ( HT_Resource inNode, void* inHTToken ); + // true if property is "yes", false if value is "no", and the default if the property is + // not (or incorrectly) specified + static bool PropertyValueBool ( HT_Resource inNode, void* inHTToken, bool inDefaultValue ); // call these before starting to load any URLs. HT may know how to handle them mo-better. static bool LaunchNode ( HT_Resource inNode ) ;