Bug 78498 - Carbonize PPEmbed - adding new files. r=pinkerton/sr=sfraser

This commit is contained in:
ccarlen%netscape.com 2001-08-18 01:57:33 +00:00
Родитель 6264032f3e
Коммит 139f20b5c0
10 изменённых файлов: 696 добавлений и 0 удалений

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

@ -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 <ccarlen@netscape.com>
*/
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<LWindow>(
+ // ResType_PPob,
+ // kMyWindowID );
+
template <class T>
static T* ReanimateObjects(
OSType inResType,
- ResIDT inResID);
+ ResIDT inResID)
+ {
+ T* theObject = static_cast<T*>( 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<LWindow>(
-// ResType_PPob,
-// kMyWindowID );
-
-template <class T> T*
-UReanimator::ReanimateObjects(
- OSType inResType,
- ResIDT inResID)
-{
- T* theObject = static_cast<T*>( ReadObjects(inResType, inResID) );
-
- if (sConstructionFailed) { // Construction failed for some object
- delete theObject; // Delete partial object hierarchy
- theObject = nil;
- }
-
- return theObject;
-}
PP_End_Namespace_PowerPlant

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

@ -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 <ccarlen@netscape.com>
*/
#include "CIconServicesIcon.h"
#include <Processes.h>
//*****************************************************************************
// 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;
}
}

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

@ -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 <ccarlen@netscape.com>
*/
#ifndef __CIconServicesIcon_h__
#define __CIconServicesIcon_h__
#include <LControl.h>
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__

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

@ -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 <ccarlen@netscape.com>
*/
#ifndef __CarbonCompatibility_h
#define __CarbonCompatibility_h
// Some PowerPlant compatibility macros
#if __PowerPlant__ >= 0x02108000
#define Compat_GetMacWindow GetMacWindow
#else
#define Compat_GetMacWindow GetMacPort
#endif
#endif

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

@ -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 <ccarlen@netscape.com>
*/
// Configuration flags used by all targets
#ifndef __PPEmbedConfig_h
#define __PPEmbedConfig_h
#define USE_PROFILES 1
#endif

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

@ -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 <ccarlen@netscape.com>
*/
#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

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

@ -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 <ccarlen@netscape.com>
*/
#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

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

@ -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 <ccarlen@netscape.com>
*/
//--------------------------------------------------------------------------------
//
// 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"

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

@ -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 <ccarlen@netscape.com>
*/
#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 <ControlDefinitions.h>
#endif
// include powerplant headers
#if wantDebugging
#include <PP_DebugHeaders.cp>
#else
#include <PP_ClassHeaders.cp>
#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__

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

@ -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 <ccarlen@netscape.com>
*/
//--------------------------------------------------------------------------------
//
// 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"