diff --git a/embedding/browser/powerplant/ReadMe-Carbon b/embedding/browser/powerplant/ReadMe-Carbon new file mode 100644 index 000000000000..332fcc156757 --- /dev/null +++ b/embedding/browser/powerplant/ReadMe-Carbon @@ -0,0 +1,127 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + + +Build Environment +----------------- + +The Carbon targets for PPEmbed are built using PowerPlant 2.2. +Copy this into the "Carbon Support" directory which is used by +the Fizzilla build. It's name should still be "PowerPlant" + +Incompatibilities +----------------- + +Our Fizzilla build environment currently uses CW 5.3, Universal Interfaces +version 0x0341, and PowerPlant 2.2. Using the 5.3 compiler causes +problems for the compilation of PowerPlant 2.2. Modification +needs to be made to PowerPlant in order for this to work: + +1. UReanimator.h - This file uses an non-inlined template member +function. This feature is not supported by the 5.3 compiler. Move +the implementation of UReanimator::ReanimateObjects back inline +and it will compile. + +Diffs are included. Though maybe more trouble than it's worth, you can +use the patch utility under OS X to apply the diffs (if the line endings +are Unix-style). The modified versions of these files can be placed in: +mozilla/lib/mac/powerplant/overrides/ so that you don't need to modify +the originals. This directory is in the project search paths. + + +--- developer/fizzilla tools/metrowerks codewarrior/carbon support/powerplant/utility classes/ureanimator.h Thu Jul 12 10:52:43 2001 ++++ users/conrad/development/seamonkey/moz/mozilla/lib/mac/powerplant/overrides/ureanimator.h Thu Jul 12 10:53:18 2001 +@@ -24,10 +24,35 @@ + class UReanimator { + public: + ++ // ----------------------------------------------------------------------- ++ // ¥ ReanimateObjects Template Member Function ++ // ----------------------------------------------------------------------- ++ // Type-safe wrapper for creating objects from resource data ++ // ++ // Returns nil if there is a failure in creating *any* object ++ // ++ // For "T", specify the type of the first object, usually the top-level ++ // object in a hierarchy. For example, to create a LWindow: ++ // ++ // LWindow* theWindow = UReanimator::ReanimateObjects( ++ // ResType_PPob, ++ // kMyWindowID ); ++ + template + static T* ReanimateObjects( + OSType inResType, +- ResIDT inResID); ++ ResIDT inResID) ++ { ++ T* theObject = static_cast( ReadObjects(inResType, inResID) ); ++ ++ if (sConstructionFailed) { // Construction failed for some object ++ delete theObject; // Delete partial object hierarchy ++ theObject = nil; ++ } ++ ++ return theObject; ++ } ++ + + static void* ReadObjects( + OSType inResType, +@@ -54,36 +79,6 @@ + private: + static bool sConstructionFailed; + }; +- +- +-// --------------------------------------------------------------------------- +-// ¥ ReanimateObjects Template Member Function +-// --------------------------------------------------------------------------- +-// Type-safe wrapper for creating objects from resource data +-// +-// Returns nil if there is a failure in creating *any* object +-// +-// For "T", specify the type of the first object, usually the top-level +-// object in a hierarchy. For example, to create a LWindow: +-// +-// LWindow* theWindow = UReanimator::ReanimateObjects( +-// ResType_PPob, +-// kMyWindowID ); +- +-template T* +-UReanimator::ReanimateObjects( +- OSType inResType, +- ResIDT inResID) +-{ +- T* theObject = static_cast( ReadObjects(inResType, inResID) ); +- +- if (sConstructionFailed) { // Construction failed for some object +- delete theObject; // Delete partial object hierarchy +- theObject = nil; +- } +- +- return theObject; +-} + + + PP_End_Namespace_PowerPlant + diff --git a/embedding/browser/powerplant/source/CIconServicesIcon.cpp b/embedding/browser/powerplant/source/CIconServicesIcon.cpp new file mode 100644 index 000000000000..cb42986f9771 --- /dev/null +++ b/embedding/browser/powerplant/source/CIconServicesIcon.cpp @@ -0,0 +1,193 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +#include "CIconServicesIcon.h" + +#include + +//***************************************************************************** +// CIconServicesIcon +//***************************************************************************** + +OSType CIconServicesIcon::mgAppCreator; +FSSpec CIconServicesIcon::mgAppFileSpec; + +CIconServicesIcon::CIconServicesIcon(const SPaneInfo& inPaneInfo, + MessageT inValueMessage, + OSType inIconType, + SInt16 inIconResID) : + LControl(inPaneInfo, inValueMessage), + mIconType(inIconType), mIconResID(inIconResID), + mAlignmentType(kAlignAbsoluteCenter), mIconRef(nil), + mbIsPressed(false) +{ + Init(); +} + + +CIconServicesIcon::CIconServicesIcon(LStream* inStream) : + LControl(inStream), + mAlignmentType(kAlignAbsoluteCenter), mIconRef(nil), + mbIsPressed(false) +{ + *inStream >> mIconType; + *inStream >> mIconResID; + + Init(); +} + + +CIconServicesIcon::~CIconServicesIcon() +{ + ReleaseIconRef(); +} + +void CIconServicesIcon::DrawSelf() +{ + Rect iconRect; + CalcPortFrameRect(iconRect); + AdjustIconRect(iconRect); + + IconTransformType transform; + if (mbIsPressed) + transform = kTransformSelected; + else if (mEnabled != triState_On) + transform = kTransformDisabled; + else + transform = kTransformNone; + + ::PlotIconRef(&iconRect, + mAlignmentType, + transform, + kIconServicesNormalUsageFlag, + mIconRef); +} + +void CIconServicesIcon::EnableSelf() +{ + Refresh(); +} + +void CIconServicesIcon::DisableSelf() +{ + Refresh(); +} + +SInt16 CIconServicesIcon::FindHotSpot(Point inPoint) const +{ + Boolean inHotSpot = PointInHotSpot(inPoint, 0); + return inHotSpot ? 1 : 0; +} + +Boolean CIconServicesIcon::PointInHotSpot(Point inPoint, + SInt16 inHotSpot) const +{ + Point portPt = inPoint; + LocalToPortPoint(portPt); + + Rect iconRect; + CalcPortFrameRect(iconRect); + AdjustIconRect(iconRect); + + return ::PtInIconRef(&portPt, &iconRect, mAlignmentType, kIconServicesNormalUsageFlag, mIconRef); +} + +void CIconServicesIcon::HotSpotAction(SInt16 /* inHotSpot */, + Boolean inCurrInside, + Boolean inPrevInside) +{ + if (inCurrInside != inPrevInside) + { + mbIsPressed = inCurrInside; + Draw(nil); + } +} + +void CIconServicesIcon::HotSpotResult(SInt16 /* inHotSpot */) +{ + BroadcastValueMessage(); +} + +void CIconServicesIcon::Init() +{ + static bool gInitialized; + + if (!gInitialized) + { + OSErr err; + + // Since this a part of mozilla, which requires System 8.6, + // we can be sure of having this. Just in case... + long response; + err = ::Gestalt(gestaltIconUtilitiesAttr, &response); + ThrowIfError_(err); + if (!(response & gestaltIconUtilitiesHasIconServices)) + Throw_(-12345); + + ProcessSerialNumber psn; + err = ::GetCurrentProcess(&psn); + ThrowIfError_(err); + + ProcessInfoRec info; + info.processInfoLength = sizeof(info); + info.processName = nil; + info.processAppSpec = &mgAppFileSpec; + err = ::GetProcessInformation(&psn, &info); + ThrowIfError_(err); + mgAppCreator = info.processSignature; + + gInitialized = true; + } + GetIconRef(); +} + +void CIconServicesIcon::AdjustIconRect(Rect& ioRect) const +{ + ioRect.top += ((ioRect.bottom - ioRect.top) - 32) / 2; + ioRect.left += ((ioRect.right - ioRect.left) - 32) / 2; + ioRect.right = ioRect.left + 32; + ioRect.bottom = ioRect.top + 32; +} + +void CIconServicesIcon::GetIconRef() +{ + OSErr err; + IconRef iconRef; + + // We would like to first see if the icon is already registered + // But, for some reason, the following call always returns noErr and the wrong icon. + // err = ::GetIconRef(mgAppFileSpec.vRefNum, mgAppCreator, mIconType, &iconRef); + // if (err != noErr) + + err = ::RegisterIconRefFromResource(mgAppCreator, mIconType, &mgAppFileSpec, mIconResID, &iconRef); + ThrowIfError_(err); + mIconRef = iconRef; +} + +void CIconServicesIcon::ReleaseIconRef() +{ + if (mIconRef) + { + ::ReleaseIconRef(mIconRef); + mIconRef = nil; + } +} diff --git a/embedding/browser/powerplant/source/CIconServicesIcon.h b/embedding/browser/powerplant/source/CIconServicesIcon.h new file mode 100644 index 000000000000..72fae3be4514 --- /dev/null +++ b/embedding/browser/powerplant/source/CIconServicesIcon.h @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +#ifndef __CIconServicesIcon_h__ +#define __CIconServicesIcon_h__ + +#include + +class CIconServicesIcon : public LControl +{ +public: + enum { class_ID = FOUR_CHAR_CODE('CISC') }; + + CIconServicesIcon(const SPaneInfo& inPaneInfo, + MessageT inValueMessage, + OSType inIconType, + SInt16 inIconResID); + CIconServicesIcon(LStream* inStream); + + virtual ~CIconServicesIcon(); + + // LPane + virtual void DrawSelf(); + virtual void EnableSelf(); + virtual void DisableSelf(); + + // LControl + SInt16 FindHotSpot(Point inPoint) const; + Boolean PointInHotSpot(Point inPoint, + SInt16 inHotSpot) const; + void HotSpotAction(SInt16 inHotSpot, + Boolean inCurrInside, + Boolean inPrevInside); + void HotSpotResult(SInt16 inHotSpot); + + // CIconServicesIcon +protected: + void Init(); + + void AdjustIconRect(Rect& ioRect) const; + + void GetIconRef(); + void ReleaseIconRef(); + +protected: + OSType mIconType; + SInt16 mIconResID; + IconAlignmentType mAlignmentType; + + IconRef mIconRef; + bool mbIsPressed; + + static OSType mgAppCreator; + static FSSpec mgAppFileSpec; +}; + +#endif // __CIconServicesIcon_h__ diff --git a/embedding/browser/powerplant/source/CarbonCompatibility.h b/embedding/browser/powerplant/source/CarbonCompatibility.h new file mode 100644 index 000000000000..840f62c8a923 --- /dev/null +++ b/embedding/browser/powerplant/source/CarbonCompatibility.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +#ifndef __CarbonCompatibility_h +#define __CarbonCompatibility_h + +// Some PowerPlant compatibility macros +#if __PowerPlant__ >= 0x02108000 + #define Compat_GetMacWindow GetMacWindow +#else + #define Compat_GetMacWindow GetMacPort +#endif + + +#endif diff --git a/embedding/browser/powerplant/source/PPEmbedConfig.h b/embedding/browser/powerplant/source/PPEmbedConfig.h new file mode 100644 index 000000000000..8a31b0a50e37 --- /dev/null +++ b/embedding/browser/powerplant/source/PPEmbedConfig.h @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +// Configuration flags used by all targets + +#ifndef __PPEmbedConfig_h +#define __PPEmbedConfig_h + +#define USE_PROFILES 1 + +#endif diff --git a/embedding/browser/powerplant/source/PPEmbedPrefix.h b/embedding/browser/powerplant/source/PPEmbedPrefix.h new file mode 100644 index 000000000000..b64aefef1447 --- /dev/null +++ b/embedding/browser/powerplant/source/PPEmbedPrefix.h @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +#ifndef __PPEmbedPrefix_h +#define __PPEmbedPrefix_h + +// The precompiled header is built by the PowerPlant lib project +// It includes the needed mozilla configuration #defines + +#include "PPHeaders_pch" + +#include "CarbonCompatibility.h" + +// Config flags common to all builds +#include "PPEmbedConfig.h" + +#endif diff --git a/embedding/browser/powerplant/source/PPEmbedPrefix_debug.h b/embedding/browser/powerplant/source/PPEmbedPrefix_debug.h new file mode 100644 index 000000000000..5230f28c92ac --- /dev/null +++ b/embedding/browser/powerplant/source/PPEmbedPrefix_debug.h @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +#ifndef __PPEmbedPrefix_debug_h +#define __PPEmbedPrefix_debug_h + +// The precompiled header is built by the PowerPlant lib project +// It includes the needed mozilla configuration #defines + +#include "PPHeadersDebug_pch" + +#include "CarbonCompatibility.h" + +// Config flags common to all builds +#include "PPEmbedConfig.h" + +#endif diff --git a/lib/mac/PowerPlant/pch/PPHeaders.pch++ b/lib/mac/PowerPlant/pch/PPHeaders.pch++ new file mode 100644 index 000000000000..a6830d060ee3 --- /dev/null +++ b/lib/mac/PowerPlant/pch/PPHeaders.pch++ @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +//-------------------------------------------------------------------------------- +// +// Includes PPHeaders.pch.h, which generates or loads the precompiled header file. +// This file contains only the master switch for a debug or optimized build. +// Other compile flags should be set in PPHeaders.pch.h which affects both builds. +// +//-------------------------------------------------------------------------------- + +#define wantDebugging 0 + +#include "PPHeaders.pch.h" diff --git a/lib/mac/PowerPlant/pch/PPHeaders.pch.h b/lib/mac/PowerPlant/pch/PPHeaders.pch.h new file mode 100644 index 000000000000..7f08c7b437cd --- /dev/null +++ b/lib/mac/PowerPlant/pch/PPHeaders.pch.h @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +#ifndef __PPHEADERS_PCH_H__ +#define __PPHEADERS_PCH_H__ + +//-------------------------------------------------------------------------------- +// +// Source for precompiled header for mozilla PowerPlant projects +// +//-------------------------------------------------------------------------------- + +#if __option(precompile) + #if __MWERKS__ >= 0x2100 + // slightly larger but much faster generation of pch files + #pragma faster_pch_gen on + #endif + + // include mozilla prefix file + #if wantDebugging + #include "MacPrefix_debug.h" + #else + #include "MacPrefix.h" + #endif + + // PowerPlant definitions + #define PP_Uses_PowerPlant_Namespace 0 + // not available in 0x2301 compiler + #define PP_Supports_Function_Identifier 0 + + #if !defined(TARGET_CARBON) || !TARGET_CARBON + #define ACCESSOR_CALLS_ARE_FUNCTIONS 1 + #endif + + #if TARGET_CARBON + #define PP_Target_Carbon 1 + #define PP_StdDialogs_Option PP_StdDialogs_NavServicesOnly + #else + #define PP_StdDialogs_Option PP_StdDialogs_Conditional + #include + #endif + + + + // include powerplant headers + #if wantDebugging + #include + #else + #include + #endif + + // Support for automatically naming the precompiled header file ... + #if __POWERPC__ + #if wantDebugging + #pragma precompile_target "PPHeadersDebug_pch" + #else + #pragma precompile_target "PPHeaders_pch" + #endif + #else + #error "target currently unsupported" + #endif + +#else + + // Load the precompiled header file + #if __POWERPC__ + #if wantDebugging + #include "PPHeadersDebug_pch" + #else + #include "PPHeaders_pch" + #endif + #else + #error "target currently unsupported" + #endif + + +#endif + +#endif // __PPHEADERS_PCH_H__ diff --git a/lib/mac/PowerPlant/pch/PPHeadersDebug.pch++ b/lib/mac/PowerPlant/pch/PPHeadersDebug.pch++ new file mode 100644 index 000000000000..8e39b6b93285 --- /dev/null +++ b/lib/mac/PowerPlant/pch/PPHeadersDebug.pch++ @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is the Mozilla browser. + * + * The Initial Developer of the Original Code is Netscape + * Communications, Inc. Portions created by Netscape are + * Copyright (C) 1999, Mozilla. All Rights Reserved. + * + * Contributor(s): + * Conrad Carlen + */ + +//-------------------------------------------------------------------------------- +// +// Includes PPHeaders.pch.h, which generates or loads the precompiled header file. +// This file contains only the master switch for a debug or optimized build. +// Other compile flags should be set in PPHeaders.pch.h which affects both builds. +// +//-------------------------------------------------------------------------------- + +#define wantDebugging 1 + +#include "PPHeaders.pch.h"