More rollover stuff and pure virtual interfaces in CRDFToolbarItem to get rid of LView reliance in base class.

This commit is contained in:
pinkerton%netscape.com 1998-10-05 20:56:03 +00:00
Родитель c48b103646
Коммит c5c547b0bb
2 изменённых файлов: 113 добавлений и 32 удалений

Просмотреть файл

@ -26,11 +26,17 @@
// CRDFSeparator - a separator bar
// CRDFURLBar - the url bar w/ proxy icon
//
// I apologize profusely for the poor design and amount of copied code
// from CButton. We had to do this is about a week from start to finish
// about a month _after_ the feature-complete deadline. If you don't like
// the code, deal (pinkerton).
//
#include "CRDFToolbarItem.h"
#include "CToolbarModeManager.h"
#include "UGraphicGizmos.h"
#include "UGAAppearance.h"
#include "URDFUtilities.h"
extern RDF_NCVocab gNavCenter; // RDF vocab struct for NavCenter
@ -41,28 +47,15 @@ CRDFToolbarItem :: CRDFToolbarItem ( HT_Resource inNode )
{
Assert_(mNode != NULL);
}
CRDFToolbarItem :: ~CRDFToolbarItem ( )
{
}
// a strawman drawing routine for testing purposes only
void
CRDFToolbarItem :: DrawSelf ( )
{
Rect localRect;
CalcLocalFrameRect ( localRect );
::FrameRect ( &localRect );
}
#pragma mark -
@ -73,7 +66,6 @@ CRDFPushButton :: CRDFPushButton ( HT_Resource inNode )
mTitleAlignment(kAlignCenterBottom), mGraphicAlignment(kAlignCenterTop),
mOvalWidth(8), mOvalHeight(8)
{
DebugStr("\pCreating a CRDFPushButton");
}
@ -81,8 +73,6 @@ CRDFPushButton :: CRDFPushButton ( HT_Resource inNode )
CRDFPushButton :: ~CRDFPushButton ( )
{
}
@ -224,11 +214,17 @@ CRDFPushButton :: DrawButtonContent ( )
void
CRDFPushButton :: DrawButtonTitle ( )
{
StColorPenState savedState;
StColorPenState::Normalize();
if (IsTrackInside() || GetValue() == Button_On)
::OffsetRect(&mCachedTitleFrame, 1, 1);
if ( IsMouseInFrame() )
URDFUtilities::SetupForegroundTextColor ( HTNode(), gNavCenter->viewRolloverColor, kThemeIconLabelTextColor ) ;
else
URDFUtilities::SetupForegroundTextColor ( HTNode(), gNavCenter->viewFGColor, kThemeIconLabelTextColor ) ;
char* title = HT_GetNodeName(HTNode());
UGraphicGizmos::PlaceStringInRect(LStr255(title), mCachedTitleFrame, teCenter, teCenter);
@ -245,7 +241,7 @@ void
CRDFPushButton :: DrawButtonGraphic ( )
{
char* url = NULL;
PRBool success = HT_GetTemplateData ( HTNode(), gNavCenter->RDF_largeIcon, HT_COLUMN_STRING, &url );
PRBool success = HT_GetTemplateData ( HTNode(), gNavCenter->toolbarEnabledIcon, HT_COLUMN_STRING, &url );
if ( success && url ) {
// setup where we should draw
@ -291,8 +287,15 @@ CRDFPushButton :: DrawButtonOutline ( )
UGAAppearance::sGAHiliteContentTint);
}
// Now draw GA button bevel
UGAAppearance::DrawGAButtonBevelTint(mCachedButtonFrame);
// Now draw GA button bevel, but only if HT hasn't specified a rollover color
StColorPenState thePenSaver;
thePenSaver.Normalize();
if ( URDFUtilities::SetupForegroundColor(HTNode(), gNavCenter->viewRolloverColor, kThemeIconLabelTextColor) ) {
::PenSize(2,2);
::FrameRoundRect(&mCachedButtonFrame, mOvalWidth, mOvalHeight);
}
else
UGAAppearance::DrawGAButtonBevelTint(mCachedButtonFrame);
} // DrawButtonOutline
@ -309,17 +312,16 @@ CRDFPushButton :: DrawButtonHilited ( )
StDeviceLoop theLoop ( mCachedButtonFrame );
Int16 depth;
Rect frame = mCachedButtonFrame;
// Draw face of button first
while ( theLoop.NextDepth ( depth ))
if ( depth >= 4 ) // don't do anything for black and white
{
{
Rect frame = mCachedButtonFrame;
::InsetRect(&frame, 1, 1);
// Do we need to do this very slight darkening?
UGraphicGizmos::LowerRoundRectColorVolume(frame, 4, 4, UGAAppearance::sGASevenGrayLevels);
::InsetRect(&frame, -1, -1);
}
}
// Now draw GA pressed button bevel
UGAAppearance::DrawGAButtonPressedBevelTint(mCachedButtonFrame);
@ -380,7 +382,7 @@ CRDFPushButton :: MouseLeave( )
Rect portRect;
CalcPortFrameRect(portRect);
StRegion buttonRgnPort(portRect);
StClipRgnState savedClip(buttonRgnPort);
// StClipRgnState savedClip(buttonRgnPort); ///¥¥¥ grrr, this doesn't work
GetSuperView()->Draw(NULL);
Draw(NULL);
@ -388,13 +390,28 @@ CRDFPushButton :: MouseLeave( )
}
//
// HotSpotAction
//
// Called when the mouse is clicked w/in this control
//
void
CRDFPushButton :: HotSpotAction(short /* inHotSpot */, Boolean inCurrInside, Boolean inPrevInside)
{
if (inCurrInside != inPrevInside) {
SetTrackInside(inCurrInside);
Draw(NULL);
}
} // HotSpotAction
#pragma mark -
CRDFSeparator :: CRDFSeparator ( HT_Resource inNode )
: CRDFToolbarItem(inNode)
{
DebugStr("\pCreating a CRDFSeparator");
}
@ -407,13 +424,23 @@ CRDFSeparator :: ~CRDFSeparator ( )
}
// a strawman drawing routine for testing purposes only
void
CRDFSeparator :: DrawSelf ( )
{
Rect localRect;
CalcLocalFrameRect ( localRect );
::FrameRect ( &localRect );
}
#pragma mark -
CRDFURLBar :: CRDFURLBar ( HT_Resource inNode )
: CRDFToolbarItem(inNode)
{
DebugStr("\pCreating a CRDFURLBar");
}
@ -425,3 +452,14 @@ CRDFURLBar :: ~CRDFURLBar ( )
}
// a strawman drawing routine for testing purposes only
void
CRDFURLBar :: DrawSelf ( )
{
Rect localRect;
CalcLocalFrameRect ( localRect );
::FrameRect ( &localRect );
}

Просмотреть файл

@ -39,16 +39,21 @@
// The base class for things that go on toolbars. This is a virtual class
// and should never be instantiated by itself.
//
class CRDFToolbarItem : public LView
class CRDFToolbarItem
{
public:
// Frame management routines
// These MUST be implemented in every subclass. We do this so subclasses
// can inherit from the appropriate LView (such as LControl) w/out forcing
// that decision into the base class.
virtual void PutInside ( LView *inView, Boolean inOrient = true) = 0;
virtual void ResizeFrameTo ( SInt16 inWidth, SInt16 inHeight, Boolean inRefresh ) = 0;
virtual void PlaceInSuperFrameAt ( SInt32 inHoriz, SInt32 inVert, Boolean inRefresh ) = 0;
protected:
HT_Resource HTNode ( ) { return mNode; }
const HT_Resource HTNode ( ) const { return mNode; }
virtual void DrawSelf ( ) ;
private:
@ -71,7 +76,7 @@ private:
//
// It's a button, it's a slicer, it's a mulcher, it's a ....
//
class CRDFPushButton : public CRDFToolbarItem, public CImageIconMixin
class CRDFPushButton : public CRDFToolbarItem, public LControl, public CImageIconMixin
{
public:
CRDFPushButton ( HT_Resource inNode ) ;
@ -80,6 +85,16 @@ public:
void SetTrackInside(bool inInside) { mTrackInside = inInside; }
bool IsTrackInside() const { return mTrackInside; }
virtual void PutInside ( LView *inView, Boolean inOrient = true) {
LPane::PutInside(inView, inOrient);
}
virtual void ResizeFrameTo ( SInt16 inWidth, SInt16 inHeight, Boolean inRefresh ) {
LPane::ResizeFrameTo(inWidth, inHeight, inRefresh);
}
virtual void PlaceInSuperFrameAt ( SInt32 inHoriz, SInt32 inVert, Boolean inRefresh ) {
LPane::PlaceInSuperFrameAt(inHoriz, inVert, inRefresh);
}
protected:
// computations for drawing text and icon
@ -106,6 +121,8 @@ protected:
virtual void MouseWithin ( Point inPortPt, const EventRecord &inMacEvent);
virtual void MouseLeave(void);
virtual void HotSpotAction(short /* inHotSpot */, Boolean inCurrInside, Boolean inPrevInside) ;
bool IsMouseInFrame ( ) const { return mMouseInFrame; } ;
private:
@ -139,12 +156,25 @@ private:
//
// Draws a 3d-beveled vertical separator between portions of toolbars.
//
class CRDFSeparator : public CRDFToolbarItem
class CRDFSeparator : public CRDFToolbarItem, public LPane
{
public:
CRDFSeparator ( HT_Resource inNode ) ;
virtual ~CRDFSeparator ( ) ;
// Frame management routines
virtual void PutInside ( LView *inView, Boolean inOrient = true) {
LPane::PutInside(inView, inOrient);
}
virtual void ResizeFrameTo ( SInt16 inWidth, SInt16 inHeight, Boolean inRefresh ) {
LPane::ResizeFrameTo(inWidth, inHeight, inRefresh);
}
virtual void PlaceInSuperFrameAt ( SInt32 inHoriz, SInt32 inVert, Boolean inRefresh ) {
LPane::PlaceInSuperFrameAt(inHoriz, inVert, inRefresh);
}
virtual void DrawSelf ( ) ;
private:
// items cannot be passed by value because they exist in 1-to-1 correspondance
// with UI elements
@ -159,12 +189,25 @@ private:
//
// Our fabled url entry bar with page proxy icon.
//
class CRDFURLBar : public CRDFToolbarItem
class CRDFURLBar : public CRDFToolbarItem, public LView
{
public:
CRDFURLBar ( HT_Resource inNode ) ;
virtual ~CRDFURLBar ( ) ;
// Frame management routines
virtual void PutInside ( LView *inView, Boolean inOrient = true) {
LPane::PutInside(inView, inOrient);
}
virtual void ResizeFrameTo ( SInt16 inWidth, SInt16 inHeight, Boolean inRefresh ) {
LPane::ResizeFrameTo(inWidth, inHeight, inRefresh);
}
virtual void PlaceInSuperFrameAt ( SInt32 inHoriz, SInt32 inVert, Boolean inRefresh ) {
LPane::PlaceInSuperFrameAt(inHoriz, inVert, inRefresh);
}
virtual void DrawSelf ( ) ;
private:
// items cannot be passed by value because they exist in 1-to-1 correspondance
// with UI elements