From e557c2564a880ab784d351e8a23aa190233c21e5 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Thu, 1 Oct 1998 21:38:31 +0000 Subject: [PATCH] toolbars now draw correctly in all windows (not just in 2nd on up) and respect HT background url property. git-svn-id: svn://10.0.0.236/trunk@11694 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cmd/macfe/gui/CRDFToolbar.cp | 73 ++++++++++++++++++++++++++-- mozilla/cmd/macfe/gui/CRDFToolbar.h | 15 +++++- 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/mozilla/cmd/macfe/gui/CRDFToolbar.cp b/mozilla/cmd/macfe/gui/CRDFToolbar.cp index 3a70592bda1..1a118b5de69 100644 --- a/mozilla/cmd/macfe/gui/CRDFToolbar.cp +++ b/mozilla/cmd/macfe/gui/CRDFToolbar.cp @@ -21,8 +21,17 @@ #include #include "htrdf.h" +#include "vocab.h" // provides tokens needed in lookup functions + // ...and because vocab.h mistakenly does not declare these, we must +extern RDF_NCVocab gNavCenter; +extern RDF_CoreVocab gCoreVocab; + /* + The functions |pane_params_from|, |view_params_from|, and |is_docked| should be + within an anonymous namespace. + */ + static SPaneInfo pane_params_from( HT_View /*ht_view*/, LView* pp_superview ) @@ -36,7 +45,7 @@ pane_params_from( HT_View /*ht_view*/, LView* pp_superview ) info.width = superview_size.width; info.height = 24; // NO! Get this value from the |HT_View|. - info.visible = true; + info.visible = false; // we'll get shown when bar is added. info.enabled = true; SBooleanRect bindings = { true, true, true, false }; @@ -87,6 +96,11 @@ CRDFToolbar::CRDFToolbar( HT_View ht_view, LView* pp_superview ) assert( _ht_view ); // There must be an |HT_View|... assert( !HT_GetViewFEData(_ht_view) ); // ...and it must not be linked to any other FE object. + // the toolbar can stream in at any time, so we need to make sure that the container gets + // updated even after it has been initialized. Setting the |available| flag to false ensures + // that the container will update correctly when it sees this toolbar. + SetAvailable(false); + HT_SetViewFEData(_ht_view, this); // TO BE FIXED: 1103 needs a better name and visibility @@ -98,7 +112,9 @@ CRDFToolbar::CRDFToolbar( HT_View ht_view, LView* pp_superview ) LView* view = UReanimator::CreateView(1104, this, window); // create the CToolbarPatternBevelView view->ResizeFrameBy(-12, 0, false); #endif - } + + notice_background_changed(); +} CRDFToolbar::~CRDFToolbar() { @@ -108,7 +124,56 @@ CRDFToolbar::~CRDFToolbar() } void -CRDFToolbar::HandleNotification( HT_Notification, HT_Resource, HT_Event, void*, uint32 ) +CRDFToolbar::Draw( RgnHandle inSuperDrawRgnH ) { - // ... + // We don't like the way |CDragBar| does it + LView::Draw(inSuperDrawRgnH); } + +void +CRDFToolbar::DrawSelf() + { + Rect frame; + if ( CalcLocalFrameRect(frame) ) + { + Point top_left = { frame.top, frame.left }; + DrawImage(top_left, kTransformNone, frame.right-frame.left, frame.bottom-frame.top); + } + // Note: I don't want |CDragBar::DrawSelf()|s behavior, and |LView| doesn't implement + // |DrawSelf|, so, nothing else to do here. + } + +void +CRDFToolbar::ImageIsReady() + { + Refresh(); + } + +void +CRDFToolbar::DrawStandby( const Point&, const IconTransformType ) const + { + // TO BE WRITTEN + } + +void +CRDFToolbar::HandleNotification( HT_Notification, HT_Resource, HT_Event event, void*, uint32 ) + { + switch ( event ) + { + case HT_EVENT_NODE_VPROP_CHANGED: + notice_background_changed(); + break; + } + } + +void +CRDFToolbar::notice_background_changed() + { + char* cp = 0; + if ( HT_GetTemplateData(HT_TopNode(_ht_view), gNavCenter->viewBGURL, HT_COLUMN_STRING, &cp) ) + SetImageURL(string(cp)); + else + SetImageURL("file:///Incoming/bk.gif"); + Refresh(); + } + diff --git a/mozilla/cmd/macfe/gui/CRDFToolbar.h b/mozilla/cmd/macfe/gui/CRDFToolbar.h index cece76fe2f9..b295861ba66 100644 --- a/mozilla/cmd/macfe/gui/CRDFToolbar.h +++ b/mozilla/cmd/macfe/gui/CRDFToolbar.h @@ -19,12 +19,14 @@ #pragma once #include "CDragBar.h" // ...is a base class +#include "CImageIconMixin.h" // ...is a base class #include "CRDFNotificationHandler.h" // ...is a base class class CRDFToolbar : public CDragBar, + public CTiledImageMixin, public CRDFNotificationHandler /* @@ -42,10 +44,21 @@ class CRDFToolbar CRDFToolbar( const CRDFToolbar& ); // DON'T IMPLEMENT CRDFToolbar& operator=( const CRDFToolbar& ); // DON'T IMPLEMENT + public: // ...for |LPane|, |LView|, |CDragBar|... + virtual void Draw( RgnHandle ); + virtual void DrawSelf(); - public: // ...overriding the appropriate methods of |CRDFNotificationHandler| + protected: // ...for |CTiledImageMixin| + virtual void ImageIsReady(); + virtual void DrawStandby( const Point&, const IconTransformType ) const; + + + public: // ...for |CRDFNotificationHandler| virtual void HandleNotification( HT_Notification, HT_Resource, HT_Event, void*, uint32 ); + protected: + void notice_background_changed(); + private: HT_View _ht_view; };