Removing ifdefs for TARGET_CARBON code. Using inline functions in Universal Headers and nsCarbonHeaders.h.

This commit is contained in:
pinkerton%netscape.com 2000-01-11 05:20:12 +00:00
Родитель 1b1155e2f6
Коммит 1d26b9e828
10 изменённых файлов: 55 добавлений и 289 удалений

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

@ -23,6 +23,8 @@
#include "nsComboBox.h" #include "nsComboBox.h"
#include "nsMenu.h" #include "nsMenu.h"
#include <StringCompare.h> #include <StringCompare.h>
#include "nsCarbonHelpers.h"
#if TARGET_CARBON #if TARGET_CARBON
#include <ControlDefinitions.h> #include <ControlDefinitions.h>
#endif #endif
@ -88,19 +90,7 @@ NS_IMETHODIMP nsComboBox::Create(nsIWidget *aParent,
{ {
StartDraw(); StartDraw();
::InsertMenu(mMenuHandle, hierMenu); ::InsertMenu(mMenuHandle, hierMenu);
// ::SetControlData(mControl, kControlNoPart, kControlPopupButtonMenuHandleTag, sizeof(mMenuHandle), (Ptr)&mMenuHandle); SetControlPopupMenuStuff ( mControl, mMenuHandle, mMenuID );
// ::SetControlData(mControl, kControlNoPart, kControlPopupButtonMenuIDTag, sizeof(mMenuID), (Ptr)&mMenuID);
#if TARGET_CARBON
::SetControlPopupMenuHandle ( mControl, mMenuHandle );
::SetControlPopupMenuID ( mControl, mMenuID );
#else
PopupPrivateData* popupData = (PopupPrivateData*)*((*mControl)->contrlData);
if (popupData)
{
popupData->mHandle = mMenuHandle;
popupData->mID = mMenuID;
}
#endif
::SetControlMinimum(mControl, 0); ::SetControlMinimum(mControl, 0);
::SetControlMaximum(mControl, 0); ::SetControlMaximum(mControl, 0);
::SetControlValue(mControl, 0); ::SetControlValue(mControl, 0);

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

@ -25,6 +25,7 @@
#include <StandardFile.h> #include <StandardFile.h>
#include <ICAPI.h> #include <ICAPI.h>
#include "nsMacControl.h" #include "nsMacControl.h"
#include "nsCarbonHelpers.h"
#include "nsFileSpec.h" #include "nsFileSpec.h"
@ -302,13 +303,8 @@ nsFileWidget :: PutFile ( Str255 & inTitle, Str255 & inDefaultName, FSSpec* outS
} // if user clicked OK } // if user clicked OK
} // if can get dialog options } // if can get dialog options
if ( eventProc ) { if ( eventProc )
#if TARGET_CARBON
::DisposeNavEventUPP(eventProc); ::DisposeNavEventUPP(eventProc);
#else
::DisposeRoutineDescriptor(eventProc);
#endif
}
return retVal; return retVal;
@ -376,13 +372,8 @@ nsFileWidget :: GetFile ( Str255 & inTitle, /* filter list here later */ FSSpec*
} // if user clicked OK } // if user clicked OK
} // if can get dialog options } // if can get dialog options
if ( eventProc ) { if ( eventProc )
#if TARGET_CARBON
::DisposeNavEventUPP(eventProc); ::DisposeNavEventUPP(eventProc);
#else
::DisposeRoutineDescriptor(eventProc);
#endif
}
return retVal; return retVal;
@ -447,13 +438,8 @@ nsFileWidget :: GetFolder ( Str255 & inTitle, FSSpec* outSpec )
} // if user clicked OK } // if user clicked OK
} // if can get dialog options } // if can get dialog options
if ( eventProc ) { if ( eventProc )
#if TARGET_CARBON
::DisposeNavEventUPP(eventProc); ::DisposeNavEventUPP(eventProc);
#else
::DisposeRoutineDescriptor(eventProc);
#endif
}
return retVal; return retVal;

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

@ -21,6 +21,8 @@
*/ */
#include "nsLookAndFeel.h" #include "nsLookAndFeel.h"
#include "nsCarbonHelpers.h"
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID); static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
@ -82,12 +84,7 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
if (thePort) if (thePort)
{ {
RGBColor macColor; RGBColor macColor;
#if TARGET_CARBON ::GetPortHiliteColor(thePort,&macColor);
GetPortHiliteColor(thePort,&macColor);
#else
GrafVars** grafVars = (GrafVars**)((CGrafPtr)thePort)->grafVars;
macColor = (*grafVars)->rgbHiliteColor;
#endif
aColor = NS_RGB(macColor.red>>8, macColor.green>>8, macColor.blue>>8); aColor = NS_RGB(macColor.red>>8, macColor.green>>8, macColor.blue>>8);
} }
else else

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

@ -172,11 +172,7 @@ PRBool nsMacControl::OnPaint(nsPaintEvent &aEvent)
nsRect bounds = mBounds; nsRect bounds = mBounds;
bounds.x = bounds. y = 0; bounds.x = bounds. y = 0;
nsRectToMacRect(bounds, macRect); nsRectToMacRect(bounds, macRect);
#if TARGET_CARBON
::ValidWindowRect(mWindowPtr, &macRect); ::ValidWindowRect(mWindowPtr, &macRect);
#else
::ValidRect(&macRect);
#endif
} }
return PR_FALSE; return PR_FALSE;
} }

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

@ -32,7 +32,10 @@
#include <TextServices.h> #include <TextServices.h>
#include <UnicodeConverter.h> #include <UnicodeConverter.h>
#include <Script.h> #include <Script.h>
#include "nsCarbonHelpers.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
//#define DEBUG_TSM //#define DEBUG_TSM
extern nsIRollupListener * gRollupListener; extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget; extern nsIWidget * gRollupWidget;
@ -415,16 +418,10 @@ PRBool nsMacEventHandler::DragEvent ( unsigned int aMessage, Point aMouseGlobal,
// convert the mouse to local coordinates. We have to do all the funny port origin // convert the mouse to local coordinates. We have to do all the funny port origin
// stuff just in case it has been changed. // stuff just in case it has been changed.
Point hitPointLocal = aMouseGlobal; Point hitPointLocal = aMouseGlobal;
#if TARGET_CARBON WindowRef wind = reinterpret_cast<WindowRef>(mTopLevelWidget->GetNativeData(NS_NATIVE_DISPLAY));
GrafPtr grafPort = reinterpret_cast<GrafPtr>(mTopLevelWidget->GetNativeData(NS_NATIVE_GRAPHIC)); ::SetPortWindowPort(wind);
::SetPort(grafPort);
Rect savePortRect; Rect savePortRect;
::GetPortBounds(grafPort, &savePortRect); ::GetWindowPortBounds(wind, &savePortRect);
#else
GrafPtr grafPort = static_cast<GrafPort*>(mTopLevelWidget->GetNativeData(NS_NATIVE_GRAPHIC));
::SetPort(grafPort);
Rect savePortRect = grafPort->portRect;
#endif
::SetOrigin(0, 0); ::SetOrigin(0, 0);
::GlobalToLocal(&hitPointLocal); ::GlobalToLocal(&hitPointLocal);
::SetOrigin(savePortRect.left, savePortRect.top); ::SetOrigin(savePortRect.left, savePortRect.top);
@ -1050,13 +1047,9 @@ PRBool nsMacEventHandler::HandleMouseDownEvent(
case inDrag: case inDrag:
{ {
Point macPoint; Point macPoint;
#if TARGET_CARBON
Rect portRect; Rect portRect;
::GetPortBounds(GetWindowPort(whichWindow), &portRect); ::GetWindowPortBounds(whichWindow, &portRect);
macPoint = topLeft(portRect); macPoint = topLeft(portRect);
#else
macPoint = topLeft(whichWindow->portRect);
#endif
::LocalToGlobal(&macPoint); ::LocalToGlobal(&macPoint);
mTopLevelWidget->MoveToGlobalPoint(macPoint.h, macPoint.v); mTopLevelWidget->MoveToGlobalPoint(macPoint.h, macPoint.v);
if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) { if (nsnull != gRollupListener && (nsnull != gRollupWidget) ) {
@ -1067,12 +1060,8 @@ PRBool nsMacEventHandler::HandleMouseDownEvent(
case inGrow: case inGrow:
{ {
#if TARGET_CARBON
Rect macRect; Rect macRect;
::GetWindowPortBounds ( whichWindow, &macRect ); ::GetWindowPortBounds ( whichWindow, &macRect );
#else
Rect macRect = whichWindow->portRect;
#endif
::LocalToGlobal(&topLeft(macRect)); ::LocalToGlobal(&topLeft(macRect));
::LocalToGlobal(&botRight(macRect)); ::LocalToGlobal(&botRight(macRect));
mTopLevelWidget->Resize(macRect.right - macRect.left + 1, macRect.bottom - macRect.top + 1, PR_FALSE); mTopLevelWidget->Resize(macRect.right - macRect.left + 1, macRect.bottom - macRect.top + 1, PR_FALSE);
@ -1139,12 +1128,8 @@ PRBool nsMacEventHandler::HandleMouseDownEvent(
// Now that we have found the partcode it is ok to actually zoom the window // Now that we have found the partcode it is ok to actually zoom the window
ZoomWindow(whichWindow, partCode, (whichWindow == FrontWindow())); ZoomWindow(whichWindow, partCode, (whichWindow == FrontWindow()));
#if TARGET_CARBON
Rect macRect; Rect macRect;
::GetWindowPortBounds(whichWindow, &macRect); ::GetWindowPortBounds(whichWindow, &macRect);
#else
Rect macRect = whichWindow->portRect;
#endif
::LocalToGlobal(&topLeft(macRect)); ::LocalToGlobal(&topLeft(macRect));
::LocalToGlobal(&botRight(macRect)); ::LocalToGlobal(&botRight(macRect));
mTopLevelWidget->Resize(macRect.right - macRect.left, macRect.bottom - macRect.top, PR_FALSE); mTopLevelWidget->Resize(macRect.right - macRect.left, macRect.bottom - macRect.top, PR_FALSE);
@ -1290,16 +1275,10 @@ void nsMacEventHandler::ConvertOSEventToMouseEvent(
// get the widget hit and the hit point inside that widget // get the widget hit and the hit point inside that widget
Point hitPoint = aOSEvent.where; Point hitPoint = aOSEvent.where;
#if TARGET_CARBON WindowRef wind = reinterpret_cast<WindowRef>(mTopLevelWidget->GetNativeData(NS_NATIVE_DISPLAY));
GrafPtr grafPort = reinterpret_cast<GrafPtr>(mTopLevelWidget->GetNativeData(NS_NATIVE_GRAPHIC)); ::SetPortWindowPort(wind);
::SetPort(grafPort);
Rect savePortRect; Rect savePortRect;
::GetPortBounds(grafPort, &savePortRect); ::GetWindowPortBounds(wind, &savePortRect);
#else
GrafPtr grafPort = static_cast<GrafPort*>(mTopLevelWidget->GetNativeData(NS_NATIVE_GRAPHIC));
::SetPort(grafPort);
Rect savePortRect = grafPort->portRect;
#endif
::SetOrigin(0, 0); ::SetOrigin(0, 0);
::GlobalToLocal(&hitPoint); ::GlobalToLocal(&hitPoint);
::SetOrigin(savePortRect.left, savePortRect.top); ::SetOrigin(savePortRect.left, savePortRect.top);
@ -1380,16 +1359,10 @@ nsresult nsMacEventHandler::HandleOffsetToPosition(long offset,Point* thePoint)
thePoint->v = mIMEPos.y; thePoint->v = mIMEPos.y;
thePoint->h = mIMEPos.x; thePoint->h = mIMEPos.x;
printf("local (x,y) = (%d, %d)\n", thePoint->h, thePoint->v); printf("local (x,y) = (%d, %d)\n", thePoint->h, thePoint->v);
#if TARGET_CARBON WindowRef wind = reinterpret_cast<WindowRef>(mTopLevelWidget->GetNativeData(NS_NATIVE_DISPLAY));
GrafPtr grafPort = reinterpret_cast<GrafPtr>(mTopLevelWidget->GetNativeData(NS_NATIVE_GRAPHIC)); ::SetPortWindowPort(wind);
::SetPort(grafPort);
Rect savePortRect; Rect savePortRect;
::GetPortBounds(grafPort, &savePortRect); ::GetWindowPortBounds(wind, &savePortRect);
#else
GrafPtr grafPort = static_cast<GrafPort*>(mTopLevelWidget->GetNativeData(NS_NATIVE_GRAPHIC));
::SetPort(grafPort);
Rect savePortRect = grafPort->portRect;
#endif
::LocalToGlobal(thePoint); ::LocalToGlobal(thePoint);
printf("global (x,y) = (%d, %d)\n", thePoint->h, thePoint->v); printf("global (x,y) = (%d, %d)\n", thePoint->h, thePoint->v);

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

@ -55,6 +55,8 @@
#include <LowMem.h> #include <LowMem.h>
#include <Devices.h> #include <Devices.h>
#include "nsCarbonHelpers.h"
#ifndef topLeft #ifndef topLeft
#define topLeft(r) (((Point *) &(r))[0]) #define topLeft(r) (((Point *) &(r))[0])
#endif #endif
@ -351,11 +353,7 @@ void nsMacMessagePump::DoUpdate(EventRecord &anEvent)
WindowPtr whichWindow = reinterpret_cast<WindowPtr>(anEvent.message) ; WindowPtr whichWindow = reinterpret_cast<WindowPtr>(anEvent.message) ;
GrafPtr savePort; GrafPtr savePort;
::GetPort(&savePort); ::GetPort(&savePort);
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
#else
::SetPort(whichWindow);
#endif
::BeginUpdate(whichWindow); ::BeginUpdate(whichWindow);
// The app can do its own updates here // The app can do its own updates here
DispatchOSEventToRaptor(anEvent, whichWindow); DispatchOSEventToRaptor(anEvent, whichWindow);
@ -395,11 +393,7 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
case inContent: case inContent:
{ {
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
#else
::SetPort(whichWindow);
#endif
if (IsWindowHilited(whichWindow)) if (IsWindowHilited(whichWindow))
DispatchOSEventToRaptor(anEvent, whichWindow); DispatchOSEventToRaptor(anEvent, whichWindow);
else else
@ -409,19 +403,11 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
case inDrag: case inDrag:
{ {
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
#else
::SetPort(whichWindow);
#endif
if (!(anEvent.modifiers & cmdKey)) if (!(anEvent.modifiers & cmdKey))
::SelectWindow(whichWindow); ::SelectWindow(whichWindow);
#if TARGET_CARBON
Rect screenRect; Rect screenRect;
::GetRegionBounds(::GetGrayRgn(), &screenRect); ::GetRegionBounds(::GetGrayRgn(), &screenRect);
#else
Rect screenRect = (**::GetGrayRgn()).rgnBBox;
#endif
::DragWindow(whichWindow, anEvent.where, &screenRect); ::DragWindow(whichWindow, anEvent.where, &screenRect);
// Dispatch the event because some windows may want to know that they have been moved. // Dispatch the event because some windows may want to know that they have been moved.
@ -431,18 +417,12 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
::GetMouse(&anEvent.where); ::GetMouse(&anEvent.where);
::LocalToGlobal(&anEvent.where); ::LocalToGlobal(&anEvent.where);
#else #else
#if TARGET_CARBON
RgnHandle strucRgn = NewRgn(); RgnHandle strucRgn = NewRgn();
::GetWindowRegion ( whichWindow, kWindowStructureRgn, strucRgn ); ::GetWindowRegion ( whichWindow, kWindowStructureRgn, strucRgn );
Rect strucRect; Rect strucRect;
::GetRegionBounds(strucRgn, &strucRect); ::GetRegionBounds(strucRgn, &strucRect);
::SetPt(&anEvent.where, strucRect.left, strucRect.top); ::SetPt(&anEvent.where, strucRect.left, strucRect.top);
::DisposeRgn ( strucRgn ); ::DisposeRgn ( strucRgn );
#else
RgnHandle strucRgn = ((WindowPeek)whichWindow)->strucRgn;
Rect* strucRect = &(*strucRgn)->rgnBBox;
::SetPt(&anEvent.where, strucRect->left, strucRect->top);
#endif
#endif #endif
DispatchOSEventToRaptor(anEvent, whichWindow); DispatchOSEventToRaptor(anEvent, whichWindow);
break; break;
@ -450,11 +430,7 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
case inGrow: case inGrow:
{ {
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
#else
::SetPort(whichWindow);
#endif
// use the cmd-key to do the opposite of the DRAW_ON_RESIZE setting. // use the cmd-key to do the opposite of the DRAW_ON_RESIZE setting.
Boolean cmdKeyDown = (anEvent.modifiers & cmdKey) != 0; Boolean cmdKeyDown = (anEvent.modifiers & cmdKey) != 0;
@ -473,12 +449,9 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
::LocalToGlobal(&newPt); ::LocalToGlobal(&newPt);
if (::DeltaPoint(oldPt, newPt)) if (::DeltaPoint(oldPt, newPt))
{ {
#if TARGET_CARBON
Rect portRect; Rect portRect;
::GetWindowPortBounds(whichWindow, &portRect); ::GetWindowPortBounds(whichWindow, &portRect);
#else
Rect portRect = whichWindow->portRect;
#endif
short width = newPt.h - origin.h; short width = newPt.h - origin.h;
short height = newPt.v - origin.v; short height = newPt.v - origin.v;
if (width < kMinWindowWidth) if (width < kMinWindowWidth)
@ -509,24 +482,17 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
} }
else else
{ {
#if TARGET_CARBON
Rect sizeRect; Rect sizeRect;
::GetRegionBounds(::GetGrayRgn(), &sizeRect); ::GetRegionBounds(::GetGrayRgn(), &sizeRect);
#else
Rect sizeRect = (**::GetGrayRgn()).rgnBBox;
#endif
sizeRect.top = kMinWindowHeight; sizeRect.top = kMinWindowHeight;
sizeRect.left = kMinWindowWidth; sizeRect.left = kMinWindowWidth;
long newSize = ::GrowWindow(whichWindow, anEvent.where, &sizeRect); long newSize = ::GrowWindow(whichWindow, anEvent.where, &sizeRect);
if (newSize != 0) if (newSize != 0)
::SizeWindow(whichWindow, newSize & 0x0FFFF, (newSize >> 16) & 0x0FFFF, true); ::SizeWindow(whichWindow, newSize & 0x0FFFF, (newSize >> 16) & 0x0FFFF, true);
::DrawGrowIcon(whichWindow); ::DrawGrowIcon(whichWindow);
#if TARGET_CARBON
Rect portRect; Rect portRect;
Point newPt = botRight(*::GetWindowPortBounds(whichWindow, &portRect)); Point newPt = botRight(*::GetWindowPortBounds(whichWindow, &portRect));
#else
Point newPt = botRight(whichWindow->portRect);
#endif
::LocalToGlobal(&newPt); ::LocalToGlobal(&newPt);
anEvent.where = newPt; // important! anEvent.where = newPt; // important!
DispatchOSEventToRaptor(anEvent, whichWindow); DispatchOSEventToRaptor(anEvent, whichWindow);
@ -536,11 +502,7 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
case inGoAway: case inGoAway:
{ {
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
#else
::SetPort(whichWindow);
#endif
if (::TrackGoAway(whichWindow, anEvent.where)) if (::TrackGoAway(whichWindow, anEvent.where))
DispatchOSEventToRaptor(anEvent, whichWindow); DispatchOSEventToRaptor(anEvent, whichWindow);
break; break;
@ -560,33 +522,22 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
Boolean sectFlag; Boolean sectFlag;
GetPort(&savePort); GetPort(&savePort);
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
Rect windRect; Rect windRect;
::GetWindowPortBounds(whichWindow, &windRect); ::GetWindowPortBounds(whichWindow, &windRect);
::EraseRect(&windRect); ::EraseRect(&windRect);
#else
SetPort(whichWindow);
EraseRect(&whichWindow->portRect);
#endif
if (partCode == inZoomOut) { if (partCode == inZoomOut) {
#if !TARGET_CARBON
WindowPeek wPeek = (WindowPeek)whichWindow;
Rect windRect = whichWindow->portRect;
#endif
LocalToGlobal((Point *)&windRect.top); LocalToGlobal((Point *)&windRect.top);
LocalToGlobal((Point *)&windRect.bottom); LocalToGlobal((Point *)&windRect.bottom);
#if TARGET_CARBON
RgnHandle structRgn = ::NewRgn(); RgnHandle structRgn = ::NewRgn();
::GetWindowRegion ( whichWindow, kWindowStructureRgn, structRgn ); ::GetWindowRegion ( whichWindow, kWindowStructureRgn, structRgn );
Rect structRgnBounds; Rect structRgnBounds;
::GetRegionBounds ( structRgn, &structRgnBounds ); ::GetRegionBounds ( structRgn, &structRgnBounds );
wTitleHeight = windRect.top - 1 - structRgnBounds.top; wTitleHeight = windRect.top - 1 - structRgnBounds.top;
::DisposeRgn ( structRgn ); ::DisposeRgn ( structRgn );
#else
wTitleHeight = windRect.top - 1 - (*(wPeek->strucRgn))->rgnBBox.top;
#endif
windRect.top -= wTitleHeight; windRect.top -= wTitleHeight;
gdNthDevice = GetDeviceList(); gdNthDevice = GetDeviceList();
while (gdNthDevice) while (gdNthDevice)
@ -612,11 +563,7 @@ void nsMacMessagePump::DoMouseDown(EventRecord &anEvent)
tempRect.top + wTitleHeight + 3, tempRect.top + wTitleHeight + 3,
tempRect.right - 64, tempRect.right - 64,
tempRect.bottom - 3); tempRect.bottom - 3);
#if TARGET_CARBON
::SetWindowStandardState ( whichWindow, &zoomRect ); ::SetWindowStandardState ( whichWindow, &zoomRect );
#else
(**(WStateDataHandle)(wPeek->dataHandle)).stdState = zoomRect;
#endif
} }
SetPort(savePort); SetPort(savePort);
@ -782,11 +729,7 @@ extern const PRInt16 kAppleMenuID; // Danger Will Robinson!!! - this currently r
void nsMacMessagePump::DoActivate(EventRecord &anEvent) void nsMacMessagePump::DoActivate(EventRecord &anEvent)
{ {
WindowPtr whichWindow = (WindowPtr)anEvent.message; WindowPtr whichWindow = (WindowPtr)anEvent.message;
#if TARGET_CARBON
::SetPortWindowPort(whichWindow); ::SetPortWindowPort(whichWindow);
#else
::SetPort(whichWindow);
#endif
if (anEvent.modifiers & activeFlag) if (anEvent.modifiers & activeFlag)
{ {
::BringToFront(whichWindow); ::BringToFront(whichWindow);

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

@ -27,6 +27,8 @@
#include <Script.h> #include <Script.h>
#include <TextServices.h> #include <TextServices.h>
#include "nsCarbonHelpers.h"
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
@ -80,15 +82,9 @@ nsMacTSMMessagePump::~nsMacTSMMessagePump()
err = AERemoveEventHandler(kTextServiceClass,kUpdateActiveInputArea,mUpdateUPP,false); err = AERemoveEventHandler(kTextServiceClass,kUpdateActiveInputArea,mUpdateUPP,false);
NS_ASSERTION(err==noErr,"nsMacTSMMessagePump::InstallTSMAEHandlers: AEInstallEventHandlers[Update] failed"); NS_ASSERTION(err==noErr,"nsMacTSMMessagePump::InstallTSMAEHandlers: AEInstallEventHandlers[Update] failed");
#if TARGET_CARBON ::DisposeAEEventHandlerUPP(mPos2OffsetUPP);
(void)DisposeAEEventHandlerUPP(mPos2OffsetUPP); ::DisposeAEEventHandlerUPP(mOffset2PosUPP);
(void)DisposeAEEventHandlerUPP(mOffset2PosUPP); ::DisposeAEEventHandlerUPP(mUpdateUPP);
(void)DisposeAEEventHandlerUPP(mUpdateUPP);
#else
(void)DisposeRoutineDescriptor(mPos2OffsetUPP);
(void)DisposeRoutineDescriptor(mOffset2PosUPP);
(void)DisposeRoutineDescriptor(mUpdateUPP);
#endif
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -280,7 +276,7 @@ pascal OSErr nsMacTSMMessagePump::UpdateHandler(const AppleEvent *theAppleEvent,
} }
#if TARGET_CARBON #if TARGET_CARBON
// ¥¥¥ Fix Me !!!!! // ¥¥¥ Fix Me! Can't access |text.dataHandle| under Carbon!!!!!
res = eventHandler->HandleUpdateInputArea((char*)textPtr,textScript,fixLength,hiliteRangePtr); res = eventHandler->HandleUpdateInputArea((char*)textPtr,textScript,fixLength,hiliteRangePtr);
#else #else
nsCAutoString mbcsText; nsCAutoString mbcsText;
@ -304,6 +300,7 @@ pascal OSErr nsMacTSMMessagePump::UpdateHandler(const AppleEvent *theAppleEvent,
// clean up // clean up
// //
#if !TARGET_CARBON #if !TARGET_CARBON
// Can't access |hiliteRangeArray.dataHandle| under Carbon!!!!!
if(hiliteRangePtr) if(hiliteRangePtr)
::HUnlock(hiliteRangeArray.dataHandle); ::HUnlock(hiliteRangeArray.dataHandle);
#endif #endif

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

@ -30,8 +30,7 @@
#include "nsIDragSession.h" #include "nsIDragSession.h"
#include "nsIDragSessionMac.h" #include "nsIDragSessionMac.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "nsCarbonHelpers.h"
#include <LowMem.h>
// Define Class IDs -- i hate having to do this // Define Class IDs -- i hate having to do this
@ -278,11 +277,7 @@ nsMacWindow::~nsMacWindow()
if (mWindowPtr) if (mWindowPtr)
{ {
if (mWindowMadeHere) if (mWindowMadeHere)
#if TARGET_CARBON
::DisposeWindow(mWindowPtr); ::DisposeWindow(mWindowPtr);
#else
::CloseWindow(mWindowPtr);
#endif
// clean up DragManager stuff // clean up DragManager stuff
::RemoveTrackingHandler ( sDragTrackingHandlerUPP, mWindowPtr ); ::RemoveTrackingHandler ( sDragTrackingHandlerUPP, mWindowPtr );
@ -411,29 +406,15 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent,
wRect.right --; wRect.right --;
wRect.bottom --; wRect.bottom --;
#endif #endif
#if TARGET_CARBON
::OffsetRect(&wRect, hOffset, vOffset + ::GetMBarHeight());
#else
if (eWindowType_popup != mWindowType) if (eWindowType_popup != mWindowType)
::OffsetRect(&wRect, hOffset, vOffset + ::LMGetMBarHeight()); ::OffsetRect(&wRect, hOffset, vOffset + ::GetMBarHeight());
else else
::OffsetRect(&wRect, hOffset, vOffset); ::OffsetRect(&wRect, hOffset, vOffset);
#endif
// HACK!!!!! This really should be part of the window manager // HACK!!!!! This really should be part of the window manager
// Make sure window bottom of window doesn't exceed max monitor size // Make sure window bottom of window doesn't exceed max monitor size
#if TARGET_CARBON
Rect tempRect; Rect tempRect;
GetRegionBounds(GetGrayRgn(), &tempRect); ::GetRegionBounds(::GetGrayRgn(), &tempRect);
#else
RgnHandle theGrayRegion = GetGrayRgn();
Rect tempRect;
SetRect(&tempRect,
(**theGrayRegion).rgnBBox.left,
(**theGrayRegion).rgnBBox.top,
(**theGrayRegion).rgnBBox.right,
(**theGrayRegion).rgnBBox.bottom);
#endif
if (wRect.bottom > tempRect.bottom) if (wRect.bottom > tempRect.bottom)
{ {
@ -441,11 +422,7 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent,
wRect.bottom -= bottomPinDelta; wRect.bottom -= bottomPinDelta;
} }
#if TARGET_CARBON
mWindowPtr = ::NewCWindow(nil, &wRect, "\p", false, wDefProcID, (WindowRef)-1, goAwayFlag, (long)nsnull); mWindowPtr = ::NewCWindow(nil, &wRect, "\p", false, wDefProcID, (WindowRef)-1, goAwayFlag, (long)nsnull);
#else
mWindowPtr = ::NewCWindow(nil, &wRect, "\p", false, wDefProcID, (GrafPort*)-1, goAwayFlag, (long)nsnull);
#endif
mWindowMadeHere = PR_TRUE; mWindowMadeHere = PR_TRUE;
} }
else else
@ -523,12 +500,14 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool bState)
{ {
if ( mAcceptsActivation ) if ( mAcceptsActivation )
{ {
Rect windowrect;
Point topleft,botright; Point topleft,botright;
::ShowWindow(mWindowPtr); ::ShowWindow(mWindowPtr);
::SelectWindow(mWindowPtr); ::SelectWindow(mWindowPtr);
windowrect = (**((WindowPeek)mWindowPtr)->contRgn).rgnBBox; RgnHandle contentRgn = NewRgn();
::GetWindowRegion ( mWindowPtr, kWindowContentRgn, contentRgn );
Rect windowrect;
::GetRegionBounds(contentRgn, &windowrect);
// on some windows (with pop ups) the ::ShowWindow will not invalidate the parent // on some windows (with pop ups) the ::ShowWindow will not invalidate the parent
// properly // properly
@ -598,17 +577,12 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
return NS_OK; return NS_OK;
} else if (mWindowMadeHere){ } else if (mWindowMadeHere){
// make sure the window stays visible // make sure the window stays visible
#if TARGET_CARBON
Rect screenRect; Rect screenRect;
::GetRegionBounds(::GetGrayRgn(), &screenRect); ::GetRegionBounds(::GetGrayRgn(), &screenRect);
Rect portBounds; Rect portBounds;
::GetWindowPortBounds(mWindowPtr, &portBounds); ::GetWindowPortBounds(mWindowPtr, &portBounds);
short windowWidth = portBounds.right - portBounds.left; short windowWidth = portBounds.right - portBounds.left;
#else
Rect screenRect = (**::GetGrayRgn()).rgnBBox;
short windowWidth = mWindowPtr->portRect.right - mWindowPtr->portRect.left;
#endif
if (((PRInt32)aX) < screenRect.left - windowWidth) if (((PRInt32)aX) < screenRect.left - windowWidth)
aX = screenRect.left - windowWidth; aX = screenRect.left - windowWidth;
else if (((PRInt32)aX) > screenRect.right) else if (((PRInt32)aX) > screenRect.right)
@ -632,12 +606,7 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
// move the window if it has not been moved yet // move the window if it has not been moved yet
// (ie. if this function isn't called in response to a DragWindow event) // (ie. if this function isn't called in response to a DragWindow event)
#if TARGET_CARBON
Point macPoint = topLeft(portBounds); Point macPoint = topLeft(portBounds);
#else
Point macPoint;
macPoint = topLeft(mWindowPtr->portRect);
#endif
::LocalToGlobal(&macPoint); ::LocalToGlobal(&macPoint);
if (macPoint.h != aX || macPoint.v != aY) if (macPoint.h != aX || macPoint.v != aY)
::MoveWindow(mWindowPtr, aX, aY, false); ::MoveWindow(mWindowPtr, aX, aY, false);
@ -664,12 +633,8 @@ NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
void nsMacWindow::MoveToGlobalPoint(PRInt32 aX, PRInt32 aY) void nsMacWindow::MoveToGlobalPoint(PRInt32 aX, PRInt32 aY)
{ {
#if TARGET_CARBON
Rect screenRect; Rect screenRect;
::GetRegionBounds(::GetGrayRgn(), &screenRect); ::GetRegionBounds(::GetGrayRgn(), &screenRect);
#else
Rect screenRect = (**::GetGrayRgn()).rgnBBox;
#endif
if (mIsDialog) { if (mIsDialog) {
aX -= kDialogMarginWidth; aX -= kDialogMarginWidth;
@ -690,12 +655,8 @@ NS_IMETHODIMP nsMacWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai
{ {
if (mWindowMadeHere) if (mWindowMadeHere)
{ {
#if TARGET_CARBON
Rect macRect; Rect macRect;
::GetWindowPortBounds ( mWindowPtr, &macRect ); ::GetWindowPortBounds ( mWindowPtr, &macRect );
#else
Rect macRect = mWindowPtr->portRect;
#endif
#ifdef WINDOW_SIZE_TWEAKING #ifdef WINDOW_SIZE_TWEAKING
macRect.right ++; macRect.right ++;
macRect.bottom ++; macRect.bottom ++;
@ -716,12 +677,8 @@ NS_IMETHODIMP nsMacWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai
NS_IMETHODIMP nsMacWindow::GetScreenBounds(nsRect &aRect) { NS_IMETHODIMP nsMacWindow::GetScreenBounds(nsRect &aRect) {
#if TARGET_CARBON
Rect screenRect; Rect screenRect;
::GetRegionBounds(::GetGrayRgn(), &screenRect); ::GetRegionBounds(::GetGrayRgn(), &screenRect);
#else
Rect screenRect = (**::GetGrayRgn()).rgnBBox;
#endif
nsRect localBounds; nsRect localBounds;

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

@ -46,6 +46,8 @@
#include "nsRegionMac.h" #include "nsRegionMac.h"
#include "nsIRollupListener.h" #include "nsIRollupListener.h"
#include "nsCarbonHelpers.h"
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
nsIRollupListener * gRollupListener = nsnull; nsIRollupListener * gRollupListener = nsnull;
@ -66,31 +68,6 @@ static void blinkRect(Rect* r);
static void blinkRgn(RgnHandle rgn); static void blinkRgn(RgnHandle rgn);
#endif #endif
#if !TARGET_CARBON
// for non-carbon builds, provide various accessors to keep the code below free of ifdefs.
inline void GetRegionBounds(RgnHandle region, Rect* rect)
{
*rect = (**region).rgnBBox;
}
inline Boolean IsRegionComplex(RgnHandle region)
{
return (**region).rgnSize != sizeof(MacRegion);
}
inline void GetWindowPortBounds(WindowRef window, Rect* rect)
{
*rect = window->portRect;
}
inline void GetPortVisibleRegion(GrafPtr port, RgnHandle visRgn)
{
::CopyRgn(port->visRgn, visRgn);
}
#endif
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
@ -332,11 +309,7 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
// Windows and GrafPorts are VERY different under Carbon, and we can no // Windows and GrafPorts are VERY different under Carbon, and we can no
// longer pass them interchagably. When we ask for a GrafPort, we cannot // longer pass them interchagably. When we ask for a GrafPort, we cannot
// return a window or vice versa. // return a window or vice versa.
#if TARGET_CARBON
retVal = (void*)::GetWindowPort(mWindowPtr); retVal = (void*)::GetWindowPort(mWindowPtr);
#else
retVal = (void*)mWindowPtr;
#endif
break; break;
case NS_NATIVE_DISPLAY: case NS_NATIVE_DISPLAY:
@ -374,11 +347,7 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
// for compatibility with 4.X, this origin is what you'd pass // for compatibility with 4.X, this origin is what you'd pass
// to SetOrigin. // to SetOrigin.
#if TARGET_CARBON
mPluginPort->port = ::GetWindowPort(mWindowPtr); mPluginPort->port = ::GetWindowPort(mWindowPtr);
#else
mPluginPort->port = CGrafPtr(mWindowPtr);
#endif
mPluginPort->portx = -point.x; mPluginPort->portx = -point.x;
mPluginPort->porty = -point.y; mPluginPort->porty = -point.y;
@ -991,31 +960,6 @@ void nsWindow::EndDraw()
NS_RELEASE(mTempRenderingContext); NS_RELEASE(mTempRenderingContext);
} }
//-------------------------------------------------------------------------
//
//
//-------------------------------------------------------------------------
PRBool nsWindow::OnPaint(nsPaintEvent &event)
{
#ifdef NOTNOW
if (debug_WantPaintFlashing() && event.rect ) {
Rect flashRect;
::SetRect ( &flashRect, event.rect->x, event.rect->y, event.rect->x + event.rect->width,
event.rect->y + event.rect->height );
::InvertRect ( &flashRect );
for (int x = 0; x < 1000000; x++) ;
::InvertRect ( &flashRect );
for (int x = 0; x < 1000000; x++) ;
::InvertRect ( &flashRect );
for (int x = 0; x < 1000000; x++) ;
::InvertRect ( &flashRect );
for (int x = 0; x < 1000000; x++) ;
}
#endif
// override this
return PR_TRUE;
}
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// //
@ -1024,10 +968,8 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
void void
nsWindow::Flash(nsPaintEvent &aEvent) nsWindow::Flash(nsPaintEvent &aEvent)
{ {
Rect flashRect;
#ifdef NS_DEBUG #ifdef NS_DEBUG
Rect flashRect;
if (debug_WantPaintFlashing() && aEvent.rect ) { if (debug_WantPaintFlashing() && aEvent.rect ) {
::SetRect ( &flashRect, aEvent.rect->x, aEvent.rect->y, aEvent.rect->x + aEvent.rect->width, ::SetRect ( &flashRect, aEvent.rect->x, aEvent.rect->y, aEvent.rect->x + aEvent.rect->width,
aEvent.rect->y + aEvent.rect->height ); aEvent.rect->y + aEvent.rect->height );
@ -1071,11 +1013,7 @@ NS_IMETHODIMP nsWindow::Update()
if (!saveUpdateRgn) if (!saveUpdateRgn)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
if(mWindowPtr) if(mWindowPtr)
#if TARGET_CARBON GetWindowUpdateRegion ( mWindowPtr, saveUpdateRgn );
::GetWindowRegion(mWindowPtr, kWindowUpdateRgn, saveUpdateRgn);
#else
::CopyRgn(((WindowRecord*)mWindowPtr)->updateRgn, saveUpdateRgn);
#endif
// draw the widget // draw the widget
StPortSetter portSetter(mWindowPtr); StPortSetter portSetter(mWindowPtr);
@ -1098,11 +1036,8 @@ NS_IMETHODIMP nsWindow::Update()
LocalToWindowCoordinate(bounds); LocalToWindowCoordinate(bounds);
Rect macRect; Rect macRect;
nsRectToMacRect(bounds, macRect); nsRectToMacRect(bounds, macRect);
#if TARGET_CARBON
::ValidWindowRect(mWindowPtr, &macRect); ::ValidWindowRect(mWindowPtr, &macRect);
#else
::ValidRect(&macRect);
#endif
reentrant = PR_FALSE; reentrant = PR_FALSE;
} }
@ -1225,13 +1160,10 @@ void nsWindow::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext)
// draw the widget // draw the widget
StartDraw(aContext); StartDraw(aContext);
if (OnPaint(paintEvent)){ // DC flashing support Support
nsEventStatus eventStatus; nsEventStatus eventStatus;
DispatchWindowEvent(paintEvent,eventStatus); DispatchWindowEvent(paintEvent,eventStatus);
if(eventStatus != nsEventStatus_eIgnore){ if(eventStatus != nsEventStatus_eIgnore)
Flash(paintEvent); Flash(paintEvent);
}
}
EndDraw(); EndDraw();
// beard: Since we clip so aggressively, drawing from front to back should work, // beard: Since we clip so aggressively, drawing from front to back should work,
@ -1368,11 +1300,7 @@ nsWindow :: ScrollBits ( Rect & inRectToScroll, PRInt32 inLeftDelta, PRInt32 inT
::UnionRgn(nonVisableRgn, updateRgn, updateRgn); ::UnionRgn(nonVisableRgn, updateRgn, updateRgn);
} }
#if TARGET_CARBON
::InvalWindowRgn(mWindowPtr, updateRgn); ::InvalWindowRgn(mWindowPtr, updateRgn);
#else
::InvalRgn(updateRgn);
#endif
} }

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

@ -152,7 +152,6 @@ public:
virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull); virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull);
virtual void EndDraw(); virtual void EndDraw();
virtual PRBool OnPaint(nsPaintEvent &event);
NS_IMETHOD Update(); NS_IMETHOD Update();
virtual void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext); virtual void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext);