From edd72ed9701bbc30e5f1cec130c73f717d32f76f Mon Sep 17 00:00:00 2001
From: pinkerton <pinkerton>
Date: Tue, 19 May 1998 19:16:51 +0000
Subject: [PATCH] First Checked In.

---
 lib/mac/UserInterface/CAMSavvyBevelView.cp | 137 +++++++++++++++++++++
 lib/mac/UserInterface/CAMSavvyBevelView.h  |  43 +++++++
 2 files changed, 180 insertions(+)
 create mode 100644 lib/mac/UserInterface/CAMSavvyBevelView.cp
 create mode 100644 lib/mac/UserInterface/CAMSavvyBevelView.h

diff --git a/lib/mac/UserInterface/CAMSavvyBevelView.cp b/lib/mac/UserInterface/CAMSavvyBevelView.cp
new file mode 100644
index 000000000000..311cddbbbfab
--- /dev/null
+++ b/lib/mac/UserInterface/CAMSavvyBevelView.cp
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL.  You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation.  Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
+ * Reserved.
+ */
+
+//
+// a public service announcement from pinkerton:
+// 
+// Right now this class is in a state of flux because it is drawing partially with
+// appearance, but can still draw the old way when appearance is not present. I want
+// to rip out all the non-appearance stuff at some point, but we need a way to go back
+// to the old way if appearance doesn't work out for us.
+//
+
+#ifdef PowerPlant_PCH
+#include PowerPlant_PCH
+#endif
+
+#include <Appearance.h>
+
+#include "CAMSavvyBevelView.h"
+#include "UGraphicGizmos.h"
+#include "CSharedPatternWorld.h"
+
+
+
+// ���������������������������������������������������������������������������
+//	�	
+// ���������������������������������������������������������������������������
+CAMSavvyBevelView::CAMSavvyBevelView(LStream *inStream)
+	:	CBevelView(inStream)
+{
+	ResIDT theBevelTraitsID;
+	*inStream >> theBevelTraitsID;
+	
+	ResIDT thePatternResID;
+	*inStream >> thePatternResID;
+	
+	*inStream >> mPatternOrientation;
+	
+	if ( ! UEnvironment::HasFeature(env_HasAppearance) ) {
+		UGraphicGizmos::LoadBevelTraits(theBevelTraitsID, mArithBevelColors);
+
+		mPatternWorld = CSharedPatternWorld::CreateSharedPatternWorld(thePatternResID);
+		ThrowIfNULL_(mPatternWorld);
+		mPatternWorld->AddUser(this);
+	}
+	
+}
+
+// ���������������������������������������������������������������������������
+//	�	
+// ���������������������������������������������������������������������������
+
+CAMSavvyBevelView::~CAMSavvyBevelView()
+{
+	if ( !UEnvironment::HasFeature(env_HasAppearance) )
+		mPatternWorld->RemoveUser(this);
+}
+
+// ���������������������������������������������������������������������������
+//	�	
+// ���������������������������������������������������������������������������
+
+void CAMSavvyBevelView::DrawBeveledFill(void)
+{
+	Rect theFrame;
+	CalcLocalFrameRect(theFrame);
+	
+	StClipRgnState theClipSaver(mBevelRegion);
+	if ( UEnvironment::HasFeature(env_HasAppearance) ) {
+		--theFrame.top;
+		--theFrame.left;
+		::DrawThemeWindowListViewHeader ( &theFrame, kThemeStateActive );
+	}
+	else {
+		Point theAlignment;
+		CSharedPatternWorld::CalcRelativePoint(this, CSharedPatternWorld::eOrientation_Port, theAlignment);
+		
+		CGrafPtr thePort = (CGrafPtr)GetMacPort();
+		mPatternWorld->Fill(thePort, theFrame, theAlignment);
+	}
+}
+
+// ���������������������������������������������������������������������������
+//	�	
+// ���������������������������������������������������������������������������
+
+void CAMSavvyBevelView::DrawBeveledFrame(void)
+{
+	if ( ! UEnvironment::HasFeature(env_HasAppearance) ) {
+		Rect theFrame;
+		CalcLocalFrameRect(theFrame);
+		UGraphicGizmos::BevelTintRect(theFrame, mMainBevel, 0x4000, 0x4000);
+	}
+}
+
+// ���������������������������������������������������������������������������
+//	�	
+// ���������������������������������������������������������������������������
+
+void CAMSavvyBevelView::DrawBeveledSub(const SSubBevel&	inDesc)
+{
+	Rect subFrame = inDesc.cachedLocalFrame;
+	Int16 theInsetLevel = inDesc.bevelLevel;
+
+	if (theInsetLevel == 0) {
+		ApplyForeAndBackColors();
+		::EraseRect(&subFrame);
+	}
+	else {
+		if (theInsetLevel < 0)
+			theInsetLevel = -theInsetLevel;
+					
+		::InsetRect(&subFrame, -(theInsetLevel), -(theInsetLevel));
+		if ( UEnvironment::HasFeature(env_HasAppearance) ) {
+			--subFrame.top;
+			::DrawThemeWindowListViewHeader ( &subFrame, kThemeStateActive );
+		}
+		else
+			UGraphicGizmos::BevelTintRect(subFrame, inDesc.bevelLevel, 0x4000, 0x4000);
+	}
+}
+
diff --git a/lib/mac/UserInterface/CAMSavvyBevelView.h b/lib/mac/UserInterface/CAMSavvyBevelView.h
new file mode 100644
index 000000000000..a300d6ec01b7
--- /dev/null
+++ b/lib/mac/UserInterface/CAMSavvyBevelView.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL.  You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation.  Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
+ * Reserved.
+ */
+
+#pragma once
+
+#include "CBevelView.h"
+#include "UStdBevels.h"
+
+class CSharedPatternWorld;
+
+class CAMSavvyBevelView : public CBevelView
+{
+	public:
+		enum { class_ID = 'BvPv' };
+		
+							CAMSavvyBevelView(LStream *inStream);
+		virtual				~CAMSavvyBevelView();
+			
+	protected:
+	
+		virtual	void		DrawBeveledFill(void);
+		virtual	void		DrawBeveledFrame(void);
+		virtual	void		DrawBeveledSub(const SSubBevel&	inDesc);
+
+		SBevelColorDesc		mArithBevelColors;
+		CSharedPatternWorld* mPatternWorld;
+		Int16				mPatternOrientation;
+};