Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Attributes
nsDeviceContextMac Class Reference

#include <nsDeviceContextMac.h>

Collaboration diagram for nsDeviceContextMac:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsDeviceContextMac ()
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD Init (nsNativeWidget aNativeWidget)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD CreateRenderingContext (nsIRenderingContext *&aContext)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD SupportsNativeWidgets (PRBool &aSupportsWidgets)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD GetScrollBarDimensions (float &aWidth, float &aHeight) const
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD GetSystemFont (nsSystemFontID anID, nsFont *aFont) const
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD CheckFontExistence (const nsString &aFontName)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD GetDepth (PRUint32 &aDepth)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD GetDeviceSurfaceDimensions (PRInt32 &aWidth, PRInt32 &aHeight)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD GetRect (nsRect &aRect)
 
See documentation in nsIDeviceContext.h
NS_IMETHOD GetClientRect (nsRect &aRect)
 
See documentation in nsIDeviceContext.h
NS_IMETHOD GetDeviceContextFor (nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext)
NS_IMETHOD BeginDocument (PRUnichar *aTitle, PRUnichar *aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD EndDocument (void)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD AbortDocument (void)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD BeginPage (void)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
NS_IMETHOD EndPage (void)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
PRBool IsPrinter ()

Static Public Member Functions

static void InitFontInfoList ()
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
static bool GetMacFontNumber (const nsString &aFontName, short &fontNum)
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
static PRUint32 GetScreenResolution ()
 
See documentation in nsIDeviceContext.h 12/9/98 dwc

Static Public Attributes

static nsHashtable * gFontInfoList = nsnull

Protected Member Functions

virtual ~nsDeviceContextMac ()
 
See documentation in nsIDeviceContext.h 12/9/98 dwc
virtual nsresult CreateFontAliasTable ()
void FindScreenForSurface (nsIScreen **outScreen)

Protected Attributes

Rect mPageRect
nsCOMPtr< nsIDeviceContextSpecmSpec
GrafPtr mOldPort
nsCOMPtr< nsIScreenManagermScreenManager
nsCOMPtr< nsIScreenmPrimaryScreen

Static Private Attributes

static PRUint32 mPixelsPerInch = 96
static PRUint32 sNumberOfScreens = 0

Detailed Description

Definition at line 54 of file nsDeviceContextMac.h.


Constructor & Destructor Documentation


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 75 of file nsDeviceContextMac.cpp.

  : DeviceContextImpl(),
    mOldPort(nsnull)
{
}

Here is the caller graph for this function:

nsDeviceContextMac::~nsDeviceContextMac ( ) [protected, virtual]


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 85 of file nsDeviceContextMac.cpp.

{
}

Member Function Documentation


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 725 of file nsDeviceContextMac.cpp.

{
    return EndDocument();
}

Here is the call graph for this function:

NS_IMETHODIMP nsDeviceContextMac::BeginDocument ( PRUnichar aTitle,
PRUnichar aPrintToFileName,
PRInt32  aStartPage,
PRInt32  aEndPage 
)


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 695 of file nsDeviceContextMac.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
    if (printingContext)
        rv = printingContext->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage);
    return rv;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 735 of file nsDeviceContextMac.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
    if (printingContext)
        rv = printingContext->BeginPage();
    return rv;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 458 of file nsDeviceContextMac.cpp.

{
       short fontNum;
       if (GetMacFontNumber(aFontName, fontNum))
              return NS_OK;
       else
              return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Definition at line 885 of file nsDeviceContextMac.cpp.

{
  nsresult result = NS_OK;

  if (nsnull == mFontAliasTable) {
    mFontAliasTable = new nsHashtable();
    if (nsnull != mFontAliasTable)
    {
                     nsAutoString  fontTimes;              fontTimes.AssignLiteral("Times");
                     nsAutoString  fontTimesNewRoman;      fontTimesNewRoman.AssignLiteral("Times New Roman");
                     nsAutoString  fontTimesRoman;         fontTimesRoman.AssignLiteral("Times Roman");
                     nsAutoString  fontArial;              fontArial.AssignLiteral("Arial");
                     nsAutoString  fontHelvetica;          fontHelvetica.AssignLiteral("Helvetica");
                     nsAutoString  fontCourier;            fontCourier.AssignLiteral("Courier");
                     nsAutoString  fontCourierNew;         fontCourierNew.AssignLiteral("Courier New");
                     nsAutoString  fontUnicode;            fontUnicode.AssignLiteral("Unicode");
                     nsAutoString  fontBitstreamCyberbit;  fontBitstreamCyberbit.AssignLiteral("Bitstream Cyberbit");
                     nsAutoString  fontNullStr;

      AliasFont(fontTimes, fontTimesNewRoman, fontTimesRoman, PR_FALSE);
      AliasFont(fontTimesRoman, fontTimesNewRoman, fontTimes, PR_FALSE);
      AliasFont(fontTimesNewRoman, fontTimesRoman, fontTimes, PR_FALSE);
      AliasFont(fontArial, fontHelvetica, fontNullStr, PR_FALSE);
      AliasFont(fontHelvetica, fontArial, fontNullStr, PR_FALSE);
      AliasFont(fontCourier, fontCourierNew, fontNullStr, PR_FALSE);         // changed from DeviceContextImpl
      AliasFont(fontCourierNew, fontCourier, fontNullStr, PR_FALSE);
      AliasFont(fontUnicode, fontBitstreamCyberbit, fontNullStr, PR_FALSE); // XXX ????
    }
    else {
      result = NS_ERROR_OUT_OF_MEMORY;
    }
  }
  return result;
}


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 120 of file nsDeviceContextMac.cpp.

{
#ifdef NS_PRINT_PREVIEW
  // Defer to Alt when there is one
  if (mAltDC && ((mUseAltDC & kUseAltDCFor_CREATERC_PAINT) || (mUseAltDC & kUseAltDCFor_CREATERC_REFLOW))) {
    return mAltDC->CreateRenderingContext(aContext);
  }
#endif

  nsRenderingContextMac *pContext;
  nsresult              rv;

       pContext = new nsRenderingContextMac();
  if (nsnull != pContext) {
    NS_ADDREF(pContext);

    CGrafPtr  thePort;
       ::GetPort((GrafPtr*)&thePort);

    rv = pContext->Init(this, thePort);
  }
  else
    rv = NS_ERROR_OUT_OF_MEMORY;

  if (NS_OK != rv){
    NS_IF_RELEASE(pContext);
  }
  aContext = pContext;
  return rv;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 712 of file nsDeviceContextMac.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
    if (printingContext)
        rv = printingContext->EndDocument();
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 749 of file nsDeviceContextMac.cpp.

{
    nsresult rv = NS_ERROR_FAILURE;
    nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
    if (printingContext)
        rv = printingContext->EndPage();
    return rv;
}

Here is the call graph for this function:

Definition at line 474 of file nsDeviceContextMac.cpp.

{
  // optimize for the case where we only have one monitor.
  if ( !mPrimaryScreen && mScreenManager )
    mScreenManager->GetPrimaryScreen ( getter_AddRefs(mPrimaryScreen) );  
  if ( sNumberOfScreens == 1 ) {
    NS_IF_ADDREF(*outScreen = mPrimaryScreen.get());
    return;
  }
  
  nsIWidget* widget = reinterpret_cast<nsIWidget*>(mWidget);      // PRAY!
  NS_ASSERTION ( widget, "No Widget --> No Window" );
  if ( !widget ) {
    NS_IF_ADDREF(*outScreen = mPrimaryScreen.get());              // bail out with the main screen just to be safe.
    return;
  }

#if !MOZ_WIDGET_COCOA
  // we have a widget stashed inside, get a native WindowRef out of it
       WindowRef window = reinterpret_cast<WindowRef>(widget->GetNativeData(NS_NATIVE_DISPLAY));

  StPortSetter  setter(window);

  Rect bounds;
  ::GetWindowPortBounds ( window, &bounds );

  nsresult rv = NS_OK;
  if ( mScreenManager ) {
    if ( !(bounds.top || bounds.left || bounds.bottom || bounds.right) ) {
      NS_WARNING ( "trying to find screen for sizeless window" );
      NS_IF_ADDREF(*outScreen = mPrimaryScreen.get());
    }
    else {
      // convert window bounds to global coordinates
      Point topLeft = { bounds.top, bounds.left };
      Point bottomRight = { bounds.bottom, bounds.right };
      ::LocalToGlobal ( &topLeft );
      ::LocalToGlobal ( &bottomRight );
      Rect globalWindowBounds = { topLeft.v, topLeft.h, bottomRight.v, bottomRight.h } ;
      
      mScreenManager->ScreenForRect ( globalWindowBounds.left, globalWindowBounds.top, 
                                       globalWindowBounds.bottom - globalWindowBounds.top, 
                                       globalWindowBounds.right - globalWindowBounds.left, outScreen );
    }
  }
  else
    *outScreen = nsnull;
#else
  // in cocoa, we don't have a windowPtr! bail out with the main screen
  NS_IF_ADDREF(*outScreen = mPrimaryScreen.get());
#endif
  
} // FindScreenForSurface

Here is the call graph for this function:

Here is the caller graph for this function:


See documentation in nsIDeviceContext.h

Definition at line 611 of file nsDeviceContextMac.cpp.

{
       if( mSpec ) {
         // we have a printer device
         aRect.x = aRect.y = 0;
              aRect.width = (mPageRect.right-mPageRect.left)*mDevUnitsToAppUnits;
              aRect.height = (mPageRect.bottom-mPageRect.top)*mDevUnitsToAppUnits;
       }
       else {
    // we have a screen device. find the screen that the window is on and
    // return its dimensions.
    nsCOMPtr<nsIScreen> screen;
    FindScreenForSurface ( getter_AddRefs(screen) );
    if ( screen ) {      
      PRInt32 x, y, width, height;
      screen->GetAvailRect ( &x, &y, &width, &height );
      
      aRect.y =  NSToIntRound(y * mDevUnitsToAppUnits);
      aRect.x =  NSToIntRound(x * mDevUnitsToAppUnits);
      aRect.width =  NSToIntRound(width * mDevUnitsToAppUnits);
      aRect.height =  NSToIntRound(height * mDevUnitsToAppUnits);
         }
         else {
           NS_WARNING ( "No screen for this surface. How odd" );
           aRect.x = aRect.y = aRect.width = aRect.height = 0;
         }
       }
       
       return NS_OK; 
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 419 of file nsDeviceContextMac.cpp.

{
  /*
  nsCOMPtr<nsIScreen> screen;
  FindScreenForSurface ( getter_AddRefs(screen) );
  if ( screen ) {
    PRInt32 depth;
    screen->GetPixelDepth ( &depth );
    aDepth = NS_STATIC_CAST ( PRUint32, depth );
  }
  else 
    aDepth = 1;
  */
  
  // The above seems correct, however, because of the way Mozilla 
  // rendering is set upQuickDraw will get confused when
  // blitting to a secondary screen with a different bit depth.
  // By always returning the bit depth of the primary screen, QD
  // can do the proper color mappings.
   
  if ( !mPrimaryScreen && mScreenManager )
    mScreenManager->GetPrimaryScreen ( getter_AddRefs(mPrimaryScreen) );  
    
  if(!mPrimaryScreen) {
    aDepth = 1;
    return NS_OK;
  }
   
  PRInt32 depth;
  mPrimaryScreen->GetPixelDepth ( &depth );
  aDepth = NS_STATIC_CAST ( PRUint32, depth );
    
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 648 of file nsDeviceContextMac.cpp.

{
    GrafPtr curPort; 
    double pix_Inch;
    nsDeviceContextMac *macDC;

       aContext = new nsDeviceContextMac();
  if(nsnull == aContext){
    return NS_ERROR_OUT_OF_MEMORY;
  }
  NS_ADDREF(aContext);

       macDC = (nsDeviceContextMac*)aContext;
       macDC->mSpec = aDevice;
       
       ::GetPort(&curPort);

    nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(aDevice);
    if (printingContext) {
        if (NS_FAILED(printingContext->GetPrinterResolution(&pix_Inch)))
            pix_Inch = 72.0;
        double top, left, bottom, right;
        printingContext->GetPageRect(&top, &left, &bottom, &right);
        Rect& pageRect = macDC->mPageRect;
        pageRect.top = top, pageRect.left = left;
        pageRect.bottom = bottom, pageRect.right = right;
    }


       ((nsDeviceContextMac*)aContext)->Init(curPort);

       macDC->mTwipsToPixels = pix_Inch/(float)NSIntPointsToTwips(72);
       macDC->mPixelsToTwips = 1.0f/macDC->mTwipsToPixels;
    macDC->mAppUnitsToDevUnits = macDC->mTwipsToPixels;
    macDC->mDevUnitsToAppUnits = 1.0f / macDC->mAppUnitsToDevUnits;
  
    macDC->mCPixelScale = macDC->mTwipsToPixels / mTwipsToPixels;

       //((nsDeviceContextMac*)aContext)->Init(this);
    return NS_OK;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 533 of file nsDeviceContextMac.cpp.

{
#ifdef NS_PRINT_PREVIEW
  // Defer to Alt when there is one
  if (mAltDC && (mUseAltDC & kUseAltDCFor_SURFACE_DIM)) {
    return mAltDC->GetDeviceSurfaceDimensions(outWidth, outHeight);
  }
#endif

       if( mSpec ) {
         // we have a printer device
              outWidth = (mPageRect.right-mPageRect.left)*mDevUnitsToAppUnits;
              outHeight = (mPageRect.bottom-mPageRect.top)*mDevUnitsToAppUnits;
       }
       else {
    // we have a screen device. find the screen that the window is on and
    // return its dimensions.
    nsCOMPtr<nsIScreen> screen;
    FindScreenForSurface ( getter_AddRefs(screen) );
    if ( screen ) {     
      PRInt32 width, height, ignored;
      screen->GetRect ( &ignored, &ignored, &width, &height );
      
      outWidth =  NSToIntRound(width * mDevUnitsToAppUnits);
      outHeight =  NSToIntRound(height * mDevUnitsToAppUnits);
         }
         else {
           NS_WARNING ( "No screen for this surface. How odd" );
           outHeight = 0;
           outWidth = 0;
         }
       }
       
       return NS_OK; 
}

Here is the call graph for this function:

bool nsDeviceContextMac::GetMacFontNumber ( const nsString aFontName,
short &  fontNum 
) [static]


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 872 of file nsDeviceContextMac.cpp.

{
       //¥TODO?: Maybe we shouldn't call that function so often. If nsFont could store the
       //                          fontNum, nsFontMetricsMac::SetFont() wouldn't need to call this at all.
       InitFontInfoList();
    FontNameKey key(aFontName);
       aFontNum = (short) NS_PTR_TO_INT32(gFontInfoList->Get(&key));
       return (aFontNum != 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:


See documentation in nsIDeviceContext.h

Definition at line 574 of file nsDeviceContextMac.cpp.

{
       if( mSpec ) {
         // we have a printer device
         aRect.x = 0;
         aRect.y = 0;
              aRect.width = (mPageRect.right-mPageRect.left)*mDevUnitsToAppUnits;
              aRect.height = (mPageRect.bottom-mPageRect.top)*mDevUnitsToAppUnits;
       }
       else {
    // we have a screen device. find the screen that the window is on and
    // return its top/left coordinates.
    nsCOMPtr<nsIScreen> screen;
    FindScreenForSurface ( getter_AddRefs(screen) );
    if ( screen ) {
      PRInt32 x, y, width, height;
      screen->GetRect ( &x, &y, &width, &height );
      
      aRect.y =  NSToIntRound(y * mDevUnitsToAppUnits);
      aRect.x =  NSToIntRound(x * mDevUnitsToAppUnits);
      aRect.width =  NSToIntRound(width * mDevUnitsToAppUnits);
      aRect.height =  NSToIntRound(height * mDevUnitsToAppUnits);
         }
         else {
           NS_WARNING ( "No screen for this surface. How odd" );
           aRect.x = aRect.y = aRect.width = aRect.height = 0;
         }
       }

  return NS_OK;
  
} // GetDeviceTopLeft

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 931 of file nsDeviceContextMac.cpp.

{
       static PRBool initialized = PR_FALSE;
       if (initialized)
              return mPixelsPerInch;
       initialized = PR_TRUE;

    nsresult rv;
    nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv));
    if (NS_SUCCEEDED(rv) && prefs) {
              PRInt32 intVal;
              if (NS_SUCCEEDED(prefs->GetIntPref("layout.css.dpi", &intVal)) && intVal > 0) {
                     mPixelsPerInch = intVal;
              }
#if 0
// the code here will ignore the default setting of 96dpi and
// instead force approximately 84dpi. There's no real reason for this
// and we shipped Camino0.7 with 96dpi and got no complaints. As
// a result, I'm removing it, but leaving the code for posterity.
              else {
                     short hppi, vppi;
                     ::ScreenRes(&hppi, &vppi);
                     mPixelsPerInch = hppi * 1.17f;
              }
#endif
       }

       return mPixelsPerInch;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDeviceContextMac::GetScrollBarDimensions ( float &  aWidth,
float &  aHeight 
) const


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 195 of file nsDeviceContextMac.cpp.

{
  // XXX Should we push this to widget library
  float scale;
  GetCanonicalPixelScale(scale);
  aWidth = 16 * mDevUnitsToAppUnits * scale;
  aHeight = 16 * mDevUnitsToAppUnits * scale;
  return NS_OK;
}


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 294 of file nsDeviceContextMac.cpp.

{
  nsresult status = NS_OK;

  switch (aID) {
    //---------
    // CSS System Fonts
    //
    //   Important: don't chage the code below, or make sure to preserve
    //   some compatibility with MacIE5 - developers will appreciate.
    //   Run the testcase in bug 3371 in quirks mode and strict mode.
    //---------
        // css2
    case eSystemFont_Caption:
    case eSystemFont_Icon: 
    case eSystemFont_Menu: 
    case eSystemFont_MessageBox: 
    case eSystemFont_SmallCaption: 
    case eSystemFont_StatusBar: 
        // css3
    case eSystemFont_Window:
    case eSystemFont_Document:
    case eSystemFont_Workspace:
    case eSystemFont_Desktop:
    case eSystemFont_Info:
    case eSystemFont_Dialog:
    case eSystemFont_Button:
    case eSystemFont_PullDownMenu:
    case eSystemFont_List:
    case eSystemFont_Field:
        // moz
    case eSystemFont_Tooltips:
    case eSystemFont_Widget:
      float  dev2app;
      dev2app = DevUnitsToAppUnits();

      aFont->style       = NS_FONT_STYLE_NORMAL;
      aFont->weight      = NS_FONT_WEIGHT_NORMAL;
      aFont->decorations = NS_FONT_DECORATION_NONE;

      if (aID == eSystemFont_Window ||
          aID == eSystemFont_Document) {
            aFont->name.AssignLiteral("sans-serif");
            aFont->size = NSToCoordRound(aFont->size * 0.875f); // quick hack
      }
      else if (HasAppearanceManager())
      {
        ThemeFontID fontID = kThemeViewsFont;
        switch (aID)
        {
              // css2
          case eSystemFont_Caption:       fontID = kThemeSystemFont;         break;
          case eSystemFont_Icon:          fontID = kThemeViewsFont;          break;
          case eSystemFont_Menu:          fontID = kThemeSystemFont;         break;
          case eSystemFont_MessageBox:    fontID = kThemeSmallSystemFont;    break;
          case eSystemFont_SmallCaption:  fontID = kThemeSmallEmphasizedSystemFont;  break;
          case eSystemFont_StatusBar:     fontID = kThemeSmallSystemFont;    break;
              // css3
          //case eSystemFont_Window:      = 'sans-serif'
          //case eSystemFont_Document:    = 'sans-serif'
          case eSystemFont_Workspace:     fontID = kThemeViewsFont;          break;
          case eSystemFont_Desktop:       fontID = kThemeViewsFont;          break;
          case eSystemFont_Info:          fontID = kThemeViewsFont;          break;
          case eSystemFont_Dialog:        fontID = kThemeSystemFont;         break;
          case eSystemFont_Button:        fontID = kThemePushButtonFont;     break;
          case eSystemFont_PullDownMenu:  fontID = kThemeMenuItemFont;       break;
          case eSystemFont_List:          fontID = kThemeSystemFont;         break;
          case eSystemFont_Field:         fontID = kThemeApplicationFont;    break;
              // moz
          case eSystemFont_Tooltips:      fontID = kThemeSmallSystemFont;    break;
          case eSystemFont_Widget:        fontID = kThemeSmallSystemFont;    break;
        }

        nsAutoString fontName;
        SInt16 fontSize;
        Style fontStyle;

        ScriptCode sysScript = ::GetScriptManagerVariable (smSysScript);
        nsresult rv;
        rv = GetSystemFontForScript(fontID, smRoman,
                                    fontName, fontSize, fontStyle);
        if (NS_FAILED(rv))
          fontName = NS_LITERAL_STRING("Lucida Grande");

        if (sysScript != smRoman) {
          SInt16 localFontSize;
          Style localFontStyle;
          nsAutoString localSysFontName;
          rv = GetSystemFontForScript(fontID, sysScript,
                                      localSysFontName,
                                      localFontSize, localFontStyle);
          if (NS_SUCCEEDED(rv) && !fontName.Equals(localSysFontName)) {
            fontName += NS_LITERAL_STRING(",") + localSysFontName;
            fontSize = localFontSize;
            fontStyle = localFontStyle;
          }
        }
        aFont->name = fontName;        
        aFont->size = NSToCoordRound(float(fontSize) * dev2app);

        if (fontStyle & bold)
          aFont->weight = NS_FONT_WEIGHT_BOLD;
        if (fontStyle & italic)
          aFont->style = NS_FONT_STYLE_ITALIC;
        if (fontStyle & underline)
          aFont->decorations = NS_FONT_DECORATION_UNDERLINE;
      }
      else
      {
        aFont->name.AssignLiteral("geneva");
      }
      break;

  }

  aFont->systemFont = PR_TRUE;

  return status;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 93 of file nsDeviceContextMac.cpp.

{
  // cache the screen manager service for later
  nsresult ignore;
  mScreenManager = do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore);
  NS_ASSERTION ( mScreenManager, "No screen manager, we're in trouble" );
  if ( !mScreenManager )
    return NS_ERROR_FAILURE;

  // figure out how many monitors there are.
  if ( !sNumberOfScreens )
    mScreenManager->GetNumberOfScreens(&sNumberOfScreens);

       // get resolution. Ensure that mPixelsToTwips is integral or we 
       // run into serious rounding problems.
  double pix_inch = GetScreenResolution();              //Fix2X((**thepix).hRes);
  mPixelsToTwips = nscoord(NSIntPointsToTwips(72)/(float)pix_inch);
  mTwipsToPixels = 1.0f/mPixelsToTwips;
       
  return DeviceContextImpl::Init(aNativeWidget);
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 806 of file nsDeviceContextMac.cpp.

{

       OSStatus err;
       if (!gFontInfoList) 
       {
              gFontInfoList = new nsHashtable();
              if (!gFontInfoList)
                     return;

        // use the new Font Manager enumeration API.
        ATSFontFamilyIterator iter;
        err = ::ATSFontFamilyIteratorCreate(kATSFontContextLocal,
                     NULL, NULL, // filter and its refcon
                     kATSOptionFlagsDefaultScope,
                     &iter);
        if (err != noErr)
            return;
        
              TextEncoding unicodeEncoding = ::CreateTextEncoding(kTextEncodingUnicodeDefault, 
                                                                                                         kTextEncodingDefaultVariant,
                                                                                                         kUnicodeUTF8Format);
        // enumerate all fonts.
        TECObjectRef converter = NULL;
        TextEncoding oldFontEncoding = 0;
        ATSFontFamilyRef fontFamily;
        while (::ATSFontFamilyIteratorNext(iter, &fontFamily) == noErr) {
                  // we'd like to use ATSFontFamilyGetName here, but it's ignorant of the
        // font encodings, resulting in garbage names for non-western fonts.
            Str255 fontName;
            err = ::ATSFontFamilyGetQuickDrawName(fontFamily, fontName);
            if (err != noErr || fontName[0] == 0 || fontName[1] == '.' || fontName[1] == '%')
                continue;
            TextEncoding fontEncoding;
            fontEncoding = ::ATSFontFamilyGetEncoding(fontFamily);
            if (oldFontEncoding != fontEncoding) {
                oldFontEncoding = fontEncoding;
                if (converter)
                    err = ::TECDisposeConverter(converter);
                err = ::TECCreateConverter(&converter, fontEncoding, unicodeEncoding);
                if (err != noErr)
                    continue;
            }
            // convert font name to UNICODE.
                     char unicodeFontName[sizeof(fontName)];
                     ByteCount actualInputLength, actualOutputLength;
                     err = ::TECConvertText(converter, &fontName[1], fontName[0], &actualInputLength, 
                                                                      (TextPtr)unicodeFontName , sizeof(unicodeFontName), &actualOutputLength);    
                     unicodeFontName[actualOutputLength] = 0;

                     nsString temp = NS_ConvertUTF8toUTF16(nsDependentCString(unicodeFontName));
              FontNameKey key(temp);
                     gFontInfoList->Put(&key, (void*)::FMGetFontFamilyFromATSFontFamilyRef(fontFamily));
        }
        if (converter)
            err = ::TECDisposeConverter(converter);
        err = ::ATSFontFamilyIteratorRelease(&iter);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 89 of file nsDeviceContextMac.h.

{if (nsnull != mSpec){return (PR_TRUE);}else{return (PR_FALSE);} };

Here is the caller graph for this function:


See documentation in nsIDeviceContext.h 12/9/98 dwc

Definition at line 155 of file nsDeviceContextMac.cpp.

{
  //XXX it is very critical that this not lie!! MMP
  
  // ¥¥¥ VERY IMPORTANT (pinkerton)
  // This routine should return true if the widgets behave like Win32
  // "windows", that is they paint themselves and the app never knows about
  // them or has to send them update events. We were returning false which
  // meant that raptor needed to make sure to redraw them. However, if we
  // return false, the widgets never get created because the CreateWidget()
  // call in nsView never creates the widget. If we return true (which makes
  // things work), we are lying because the controls really need those
  // precious update/repaint events.
  // 
  // The situation we need is the following:
  // - return false from SupportsNativeWidgets()
  // - Create() is called on widgets when the above case is true.
  // 
  // Raptor currently doesn't work this way and needs to be fixed.
  // (please remove this comment when this situation is rectified)
  
  if( nsnull != mSpec){
       aSupportsWidgets = PR_FALSE;
  } else {
       aSupportsWidgets = PR_TRUE;
  }
  
  //if (nsnull == mSurface)
    
  //else
   //aSupportsWidgets = PR_FALSE;

  return NS_OK;
}

Member Data Documentation

nsHashtable * nsDeviceContextMac::gFontInfoList = nsnull [static]

Definition at line 109 of file nsDeviceContextMac.h.

GrafPtr nsDeviceContextMac::mOldPort [protected]

Definition at line 102 of file nsDeviceContextMac.h.

Definition at line 100 of file nsDeviceContextMac.h.

Definition at line 114 of file nsDeviceContextMac.h.

Definition at line 104 of file nsDeviceContextMac.h.

Definition at line 103 of file nsDeviceContextMac.h.

Definition at line 101 of file nsDeviceContextMac.h.

Definition at line 115 of file nsDeviceContextMac.h.


The documentation for this class was generated from the following files: