Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
nsDeviceContextWin Class Reference

#include <nsDeviceContextWin.h>

Collaboration diagram for nsDeviceContextWin:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsDeviceContextWin ()
NS_IMETHOD Init (nsNativeWidget aWidget)
NS_IMETHOD CreateRenderingContext (nsIRenderingContext *&aContext)
NS_IMETHOD SupportsNativeWidgets (PRBool &aSupportsWidgets)
NS_IMETHOD GetCanonicalPixelScale (float &aScale) const
NS_IMETHOD SetCanonicalPixelScale (float aScale)
NS_IMETHOD GetScrollBarDimensions (float &aWidth, float &aHeight) const
NS_IMETHOD GetSystemFont (nsSystemFontID anID, nsFont *aFont) const
NS_IMETHOD GetDrawingSurface (nsIRenderingContext &aContext, nsIDrawingSurface *&aSurface)
NS_IMETHOD CheckFontExistence (const nsString &aFontName)
NS_IMETHOD GetDepth (PRUint32 &aDepth)
NS_IMETHOD GetPaletteInfo (nsPaletteInfo &)
NS_IMETHOD GetDeviceSurfaceDimensions (PRInt32 &aWidth, PRInt32 &aHeight)
NS_IMETHOD GetRect (nsRect &aRect)
NS_IMETHOD GetClientRect (nsRect &aRect)
NS_IMETHOD GetDeviceContextFor (nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext)
NS_IMETHOD BeginDocument (PRUnichar *aTitle, PRUnichar *aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHOD EndDocument (void)
NS_IMETHOD AbortDocument (void)
NS_IMETHOD BeginPage (void)
NS_IMETHOD EndPage (void)

Static Public Member Functions

static char * GetACPString (const nsAString &aStr)

Public Attributes

HDC mDC

Protected Member Functions

virtual ~nsDeviceContextWin ()
void CommonInit (HDC aDC)
nsresult Init (nsNativeDeviceContext aContext, nsIDeviceContext *aOrigContext)
void FindScreen (nsIScreen **outScreen)
void ComputeClientRectUsingScreen (nsRect *outRect)
void ComputeFullAreaUsingScreen (nsRect *outRect)
nsresult GetSysFontInfo (HDC aHDC, nsSystemFontID anID, nsFont *aFont) const
nsresult CopyLogFontToNSFont (HDC *aHDC, const LOGFONT *ptrLogFont, nsFont *aFont, PRBool aIsWide=PR_FALSE) const

Protected Attributes

PRBool mCachedClientRect
PRBool mCachedFullRect
nsIDrawingSurfacemSurface
PRUint32 mDepth
nsPaletteInfo mPaletteInfo
float mPixelScale
PRInt32 mWidth
PRInt32 mHeight
nsRect mClientRect
nsIDeviceContextSpecmSpec
nsCOMPtr< nsIScreenManagermScreenManager

Friends

class nsNativeThemeWin

Detailed Description

Definition at line 48 of file nsDeviceContextWin.h.


Constructor & Destructor Documentation

Definition at line 64 of file nsDeviceContextWin.cpp.

Here is the caller graph for this function:

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

Definition at line 81 of file nsDeviceContextWin.cpp.

{
  nsDrawingSurfaceWin *surf = (nsDrawingSurfaceWin *)mSurface;

  NS_IF_RELEASE(surf);    //this clears the surf pointer...
  mSurface = nsnull;

  if (NULL != mPaletteInfo.palette)
    ::DeleteObject((HPALETTE)mPaletteInfo.palette);

  if (NULL != mDC)
  {
    ::DeleteDC(mDC);
    mDC = NULL;
  }

  NS_IF_RELEASE(mSpec);
}

Member Function Documentation

Definition at line 841 of file nsDeviceContextWin.cpp.

{
  if (NULL != mDC)
  {
    if (::AbortDoc(mDC) > 0) {
      return NS_OK;
    } else {
      DISPLAY_LAST_ERROR
      PR_PL(("nsDeviceContextWin::AbortDocument - AbortDoc Error!\n"));
      return NS_ERROR_ABORT;
    }
  }

  return NS_OK;
}
NS_IMETHODIMP nsDeviceContextWin::BeginDocument ( PRUnichar aTitle,
PRUnichar aPrintToFileName,
PRInt32  aStartPage,
PRInt32  aEndPage 
)

Definition at line 749 of file nsDeviceContextWin.cpp.

{
  nsresult rv = NS_ERROR_GFX_PRINTER_STARTDOC;

  if (NULL != mDC) {
    DOCINFO docinfo;

    nsString titleStr;
    titleStr = aTitle;
    if (titleStr.Length() > DOC_TITLE_LENGTH) {
      titleStr.SetLength(DOC_TITLE_LENGTH-3);
      titleStr.AppendLiteral("...");
    }
    char *title = GetACPString(titleStr);

    char* docName = nsnull;
    nsAutoString str(aPrintToFileName);
    if (!str.IsEmpty()) {
      docName = ToNewCString(str);
    }
    docinfo.cbSize = sizeof(docinfo);
    docinfo.lpszDocName = title != nsnull?title:"Mozilla Document";

#ifdef DEBUG_rods
    docinfo.lpszOutput = "\\p.ps";

#ifdef MOZ_LAYOUTDEBUG
    // This is for overriding the above when doing the runtime checking
    char * tempFileName = nsnull;
    nsCOMPtr<nsIDebugObject>debugObj = do_GetService("@mozilla.org/debug/debugobject;1");
    if (debugObj) {
      PRBool isDoingTests;
      if (NS_SUCCEEDED(debugObj->GetDoRuntimeTests(&isDoingTests)) && isDoingTests) {
        PRUnichar * name;
        debugObj->GetPrintFileName(&name);
        if (name) {
          if (*name) {
            nsCString cStrName;
            cStrName.AssignWithConversion(name);
            tempFileName = ToNewCString(cStrName);
          }
          nsMemory::Free(name);
        }
        docinfo.lpszOutput = tempFileName;
      }
    }
#endif

#else
    docinfo.lpszOutput = docName;
#endif

    docinfo.lpszDatatype = NULL;
    docinfo.fwType = 0;

    if (::StartDoc(mDC, &docinfo) > 0) {
      rv = NS_OK;
    } else {
      DISPLAY_LAST_ERROR
      rv = NS_ERROR_GFX_PRINTER_STARTDOC;
      PR_PL(("nsDeviceContextWin::BeginDocument - StartDoc Error!\n"));
    }

    if (title != nsnull) delete [] title;
    if (docName != nsnull) nsMemory::Free(docName);

#if defined(DEBUG_rods) && defined(MOZ_LAYOUTDEBUG)
    if (tempFileName) {
      nsMemory::Free(tempFileName);
    }
#endif
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 857 of file nsDeviceContextWin.cpp.

{
  if (NULL != mDC)
  {
    if (::StartPage(mDC) > 0)
      return NS_OK;
    else {
      DISPLAY_LAST_ERROR
      PR_PL(("nsDeviceContextWin::BeginPage - StartPage Error!\n"));
      return NS_ERROR_GFX_PRINTER_STARTPAGE;
    }
  }

  return NS_OK;
}

Definition at line 571 of file nsDeviceContextWin.cpp.

{
  HWND    hwnd = (HWND)mWidget;
  HDC     hdc = ::GetDC(hwnd);
  PRBool  isthere = PR_FALSE;

  LOGFONT logFont;
  logFont.lfCharSet = DEFAULT_CHARSET;
  logFont.lfPitchAndFamily = 0;
  int outlen = WideCharToMultiByte(CP_ACP, 0, aFontName.get(), aFontName.Length() + 1,
                                   logFont.lfFaceName, sizeof(logFont.lfFaceName), nsnull, nsnull);

  // somehow the WideCharToMultiByte failed, let's try the old code
  if(0 == outlen)
    aFontName.ToCString(logFont.lfFaceName, LF_FACESIZE);

  ::EnumFontFamiliesEx(hdc, &logFont, (FONTENUMPROC)fontcallback, (LPARAM)&isthere, 0);

  ::ReleaseDC(hwnd, hdc);

  if (PR_TRUE == isthere)
    return NS_OK;
  else
    return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

void nsDeviceContextWin::CommonInit ( HDC  aDC) [protected]

Definition at line 140 of file nsDeviceContextWin.cpp.

{
  int   rasterCaps = ::GetDeviceCaps(aDC, RASTERCAPS);

  mDepth = (PRUint32)::GetDeviceCaps(aDC, BITSPIXEL);
  mPaletteInfo.isPaletteDevice = RC_PALETTE == (rasterCaps & RC_PALETTE);
  mPaletteInfo.sizePalette = (PRUint16)::GetDeviceCaps(aDC, SIZEPALETTE);
  mPaletteInfo.numReserved = (PRUint16)::GetDeviceCaps(aDC, NUMRESERVED);

  mWidth = ::GetDeviceCaps(aDC, HORZRES);
  mHeight = ::GetDeviceCaps(aDC, VERTRES);

  mPixelsToTwips = (float)NSIntPointsToTwips(72) / ((float)::GetDeviceCaps(aDC, LOGPIXELSY));
  if (::GetDeviceCaps(aDC, TECHNOLOGY) == DT_RASDISPLAY)
  {
    // Ensure that, for screens, pixels-to-twips is an integer
    mPixelsToTwips = NSToIntRound(mPixelsToTwips);

    // init the screen manager and compute our client rect based on the
    // screen objects. We'll save the result 
    nsresult ignore;
    mScreenManager = do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore);   
  } // if this dc is not a print device
  mTwipsToPixels = 1.0 / mPixelsToTwips;

  DeviceContextImpl::CommonInit();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 170 of file nsDeviceContextWin.cpp.

{
  // we always need to recompute the clientRect
  // because the window may have moved onto a different screen. In the single
  // monitor case, we only need to do the computation if we haven't done it
  // once already, and remember that we have because we're assured it won't change.
  nsCOMPtr<nsIScreen> screen;
  FindScreen ( getter_AddRefs(screen) );
  if ( screen ) {
    PRInt32 x, y, width, height;
    screen->GetAvailRect ( &x, &y, &width, &height );
  
    // convert to device units
    outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
    outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
    outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
    outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);

    mCachedClientRect = PR_TRUE;
    mClientRect = *outRect;
  }

} // ComputeClientRectUsingScreen

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 196 of file nsDeviceContextWin.cpp.

{
  // if we have more than one screen, we always need to recompute the clientRect
  // because the window may have moved onto a different screen. In the single
  // monitor case, we only need to do the computation if we haven't done it
  // once already, and remember that we have because we're assured it won't change.
  nsCOMPtr<nsIScreen> screen;
  FindScreen ( getter_AddRefs(screen) );
  if ( screen ) {
    PRInt32 x, y, width, height;
    screen->GetRect ( &x, &y, &width, &height );
  
    // convert to device units
    outRect->y = NSToIntRound(y * mDevUnitsToAppUnits);
    outRect->x = NSToIntRound(x * mDevUnitsToAppUnits);
    outRect->width = NSToIntRound(width * mDevUnitsToAppUnits);
    outRect->height = NSToIntRound(height * mDevUnitsToAppUnits);

    mWidth = width;
    mHeight = height;
    mCachedFullRect = PR_TRUE;
  }
 
} // ComputeFullRectUsingScreen

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDeviceContextWin::CopyLogFontToNSFont ( HDC *  aHDC,
const LOGFONT *  ptrLogFont,
nsFont aFont,
PRBool  aIsWide = PR_FALSE 
) const [protected]

Definition at line 324 of file nsDeviceContextWin.cpp.

{
  PRUnichar name[LF_FACESIZE];
  name[0] = 0;
  if (aIsWide)
    memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*2);
  else {
    MultiByteToWideChar(CP_ACP, 0, ptrLogFont->lfFaceName,
      strlen(ptrLogFont->lfFaceName) + 1, name, sizeof(name)/sizeof(name[0]));
  }
  aFont->name = name;

  // Do Style
  aFont->style = NS_FONT_STYLE_NORMAL;
  if (ptrLogFont->lfItalic)
  {
    aFont->style = NS_FONT_STYLE_ITALIC;
  }
  // XXX What about oblique?

  aFont->variant = NS_FONT_VARIANT_NORMAL;

  // Do Weight
  aFont->weight = (ptrLogFont->lfWeight == FW_BOLD ? 
            NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL);

  // Do decorations
  aFont->decorations = NS_FONT_DECORATION_NONE;
  if (ptrLogFont->lfUnderline)
  {
    aFont->decorations |= NS_FONT_DECORATION_UNDERLINE;
  }
  if (ptrLogFont->lfStrikeOut)
  {
    aFont->decorations |= NS_FONT_DECORATION_LINE_THROUGH;
  }

  // Do Point Size
  //
  // The lfHeight is in pixel and it needs to be adjusted for the
  // device it will be "displayed" on
  // Screens and Printers will differe in DPI
  //
  // So this accounts for the difference in the DeviceContexts
  // The mPixelScale will be a "1" for the screen and could be
  // any value when going to a printer, for example mPixleScale is
  // 6.25 when going to a 600dpi printer.
  // round, but take into account whether it is negative
  float pixelHeight = -ptrLogFont->lfHeight;
  if (pixelHeight < 0) {
    HFONT hFont = ::CreateFontIndirect(ptrLogFont);
    if (!hFont)
      return NS_ERROR_OUT_OF_MEMORY;
    HGDIOBJ hObject = ::SelectObject(*aHDC, hFont);
    TEXTMETRIC tm;
    ::GetTextMetrics(*aHDC, &tm);
    ::SelectObject(*aHDC, hObject);
    ::DeleteObject(hFont);
    pixelHeight = tm.tmAscent;
  }

  float pointSize = pixelHeight * mPixelScale * 72 / ::GetDeviceCaps(*aHDC, LOGPIXELSY);

  // we have problem on Simplified Chinese system because the system report
  // the default font size is 8. but if we use 8, the text display very
  // Ugly. force it to be at 9 on that system (cp936), but leave other sizes alone.
  if ((pointSize < 9) && 
      (936 == ::GetACP())) 
    pointSize = 9;

  aFont->size = NSFloatPointsToTwips(pointSize);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 247 of file nsDeviceContextWin.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

  nsIRenderingContext *pContext;
  nsresult             rv;
  nsDrawingSurfaceWin  *surf;

  rv = CallCreateInstance(kRCCID, &pContext);

  if ( (NS_SUCCEEDED(rv)) && (nsnull != pContext))
  {
    surf = new nsDrawingSurfaceWin();

    if (nsnull != surf)
    {
      rv = surf->Init(mDC);

      if (NS_OK == rv)
        rv = pContext->Init(this, surf);
    }
    else
      rv = NS_ERROR_OUT_OF_MEMORY;
  }
  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:

Definition at line 825 of file nsDeviceContextWin.cpp.

{
  if (NULL != mDC)
  {
    if (::EndDoc(mDC) > 0) {
      return NS_OK;
    } else {
      DISPLAY_LAST_ERROR
      PR_PL(("nsDeviceContextWin::EndDocument - EndDoc Error!\n"));
      return NS_ERROR_GFX_PRINTER_ENDDOC;
    }
  }

  return NS_OK;
}

Definition at line 873 of file nsDeviceContextWin.cpp.

{
  if (NULL != mDC)
  {
    if (::EndPage(mDC) > 0) {
      return NS_OK;
    } else {
      DISPLAY_LAST_ERROR
      PR_PL(("nsDeviceContextWin::EndPage - EndPage Error!\n"));
      return NS_ERROR_GFX_PRINTER_ENDPAGE;
    }
  }

  return NS_OK;
}
void nsDeviceContextWin::FindScreen ( nsIScreen **  outScreen) [protected]

Definition at line 228 of file nsDeviceContextWin.cpp.

{
  // now then, if we have more than one screen, we need to find which screen this
  // window is on.
  HWND window = NS_REINTERPRET_CAST(HWND, mWidget);
  if ( window ) {
    RECT globalPosition;
    ::GetWindowRect ( window, &globalPosition ); 
    if ( mScreenManager )
      mScreenManager->ScreenForRect ( globalPosition.left, globalPosition.top, 
                                       globalPosition.right - globalPosition.left,
                                       globalPosition.bottom - globalPosition.top, outScreen );
  }

} // FindScreen

Here is the caller graph for this function:

char * nsDeviceContextWin::GetACPString ( const nsAString &  aStr) [static]

Definition at line 890 of file nsDeviceContextWin.cpp.

{
   int acplen = aStr.Length() * 2 + 1;
   char * acp = new char[acplen];
   if(acp)
   {
      int outlen = ::WideCharToMultiByte( CP_ACP, 0, 
                      PromiseFlatString(aStr).get(), aStr.Length(),
                      acp, acplen, NULL, NULL);
      if ( outlen > 0)
         acp[outlen] = '\0';  // null terminate
   }
   return acp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 299 of file nsDeviceContextWin.cpp.

{
  aScale = mPixelScale;
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 670 of file nsDeviceContextWin.cpp.

{
  if ( mSpec )
  {
    // we have a printer device
    aRect.x = 0;
    aRect.y = 0;
    aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
    aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
  }
  else
    ComputeClientRectUsingScreen ( &aRect );

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 597 of file nsDeviceContextWin.cpp.

{
  aDepth = mDepth;
  return NS_OK;
}

Definition at line 691 of file nsDeviceContextWin.cpp.

{
  nsDeviceContextWin* devConWin = new nsDeviceContextWin(); //ref count 0 
  if (devConWin != nsnull) {
    // this will ref count it
    nsresult rv = devConWin->QueryInterface(NS_GET_IID(nsIDeviceContext), (void**)&aContext);
    NS_ASSERTION(NS_SUCCEEDED(rv), "This has to support nsIDeviceContext");
  } else {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  devConWin->mSpec = aDevice;
  NS_ADDREF(aDevice);
 
  char*   devicename;
  char*   drivername;

  nsDeviceContextSpecWin* devSpecWin = NS_STATIC_CAST(nsDeviceContextSpecWin*, aDevice);
  devSpecWin->GetDeviceName(devicename); // sets pointer do not free
  devSpecWin->GetDriverName(drivername); // sets pointer do not free

  HDC dc = NULL;
  LPDEVMODE devmode;
  devSpecWin->GetDevMode(devmode);
  NS_ASSERTION(devmode, "DevMode can't be NULL here");
  if (devmode) {
    dc = ::CreateDC(drivername, devicename, NULL, devmode);
  }

  return devConWin->Init(dc, this); // take ownership of the DC
}

Here is the call graph for this function:

Definition at line 626 of file nsDeviceContextWin.cpp.

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

  if ( mSpec )
  {
    // we have a printer device
    aWidth = NSToIntRound(mWidth * mDevUnitsToAppUnits);
    aHeight = NSToIntRound(mHeight * mDevUnitsToAppUnits);
  } 
  else 
  {
    nsRect area;
    ComputeFullAreaUsingScreen ( &area );
    aWidth = area.width;
    aHeight = area.height;
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 551 of file nsDeviceContextWin.cpp.

{
  if (NULL == mSurface) {
    nsRect empty(0,0,0,0); // CreateDrawingSurface(null,...) used width=0,height=0
    aContext.CreateDrawingSurface(empty, 0, mSurface);
  }

  aSurface = mSurface;
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 604 of file nsDeviceContextWin.cpp.

{
  aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
  aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
  aPaletteInfo.numReserved = mPaletteInfo.numReserved;

  if (NULL == mPaletteInfo.palette) {
#ifndef WINCE
    HWND    hwnd = (HWND)mWidget;
    HDC     hdc = ::GetDC(hwnd);
    mPaletteInfo.palette = ::CreateHalftonePalette(hdc);  
    ::ReleaseDC(hwnd, hdc);                                                     
#else
    mPaletteInfo.palette = (HPALETTE) GetStockObject(DEFAULT_PALETTE);
#endif
  }

  aPaletteInfo.palette = mPaletteInfo.palette;
                                         
  return NS_OK;
}

Definition at line 653 of file nsDeviceContextWin.cpp.

{
  if ( mSpec )
  {
    // we have a printer device
    aRect.x = 0;
    aRect.y = 0;
    aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits);
    aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits);
  }
  else
    ComputeFullAreaUsingScreen ( &aRect );

  return NS_OK;
}

Here is the call graph for this function:

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

Definition at line 313 of file nsDeviceContextWin.cpp.

{
  float scale;
  GetCanonicalPixelScale(scale);

  aWidth  = ::GetSystemMetrics(SM_CXVSCROLL) * mDevUnitsToAppUnits * scale;
  aHeight = ::GetSystemMetrics(SM_CXHSCROLL) * mDevUnitsToAppUnits * scale;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsDeviceContextWin::GetSysFontInfo ( HDC  aHDC,
nsSystemFontID  anID,
nsFont aFont 
) const [protected]

Definition at line 399 of file nsDeviceContextWin.cpp.

{
  HGDIOBJ hGDI;

  LOGFONT logFont;
  LOGFONT* ptrLogFont = NULL;

#ifdef WINCE
  hGDI = ::GetStockObject(SYSTEM_FONT);
  if (hGDI == NULL)
    return NS_ERROR_UNEXPECTED;
  
  if (::GetObject(hGDI, sizeof(logFont), &logFont) > 0)
    ptrLogFont = &logFont;
#else

  NONCLIENTMETRICS ncm;

  BOOL status;
  if (anID == eSystemFont_Icon) 
  {
    status = ::SystemParametersInfo(SPI_GETICONTITLELOGFONT,
                                  sizeof(logFont),
                                  (PVOID)&logFont,
                                  0);
  }
  else
  {
    ncm.cbSize = sizeof(NONCLIENTMETRICS);
    status = ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 
                                     sizeof(ncm),  
                                     (PVOID)&ncm, 
                                     0);
  }

  if (!status)
  {
    return NS_ERROR_FAILURE;
  }

  switch (anID)
  {
    // Caption in CSS is NOT the same as Caption on Windows
    //case eSystemFont_Caption: 
    //  ptrLogFont = &ncm.lfCaptionFont;
    //  break;

    case eSystemFont_Icon: 
      ptrLogFont = &logFont;
      break;

    case eSystemFont_Menu: 
      ptrLogFont = &ncm.lfMenuFont;
      break;

    case eSystemFont_MessageBox: 
      ptrLogFont = &ncm.lfMessageFont;
      break;

    case eSystemFont_SmallCaption: 
      ptrLogFont = &ncm.lfSmCaptionFont;
      break;

    case eSystemFont_StatusBar: 
    case eSystemFont_Tooltips: 
      ptrLogFont = &ncm.lfStatusFont;
      break;

    case eSystemFont_Widget:

    case eSystemFont_Window:      // css3
    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:
    case eSystemFont_Caption: 
      hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
      if (hGDI != NULL)
      {
        if (::GetObject(hGDI, sizeof(logFont), &logFont) > 0)
        { 
          ptrLogFont = &logFont;
        }
      }
      break;
  } // switch 

#endif // WINCE

  if (nsnull == ptrLogFont)
  {
    return NS_ERROR_FAILURE;
  }

  aFont->systemFont = PR_TRUE;

  return CopyLogFontToNSFont(&aHDC, ptrLogFont, aFont);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 503 of file nsDeviceContextWin.cpp.

{
  nsresult status = NS_OK;

  switch (anID) {
    case eSystemFont_Caption: 
    case eSystemFont_Icon: 
    case eSystemFont_Menu: 
    case eSystemFont_MessageBox: 
    case eSystemFont_SmallCaption: 
    case eSystemFont_StatusBar: 
    case eSystemFont_Tooltips: 
    case eSystemFont_Widget:

    case eSystemFont_Window:      // css3
    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:
    {
      HWND  hwnd;
      HDC   tdc;

      if (nsnull == mDC)
      {
        hwnd = (HWND)mWidget;
        tdc = ::GetDC(hwnd);
      }
      else
        tdc = mDC;

      status = GetSysFontInfo(tdc, anID, aFont);

      if (nsnull == mDC)
        ::ReleaseDC(hwnd, tdc);

      break;
    }
  }

  return status;
}

Here is the call graph for this function:

Definition at line 100 of file nsDeviceContextWin.cpp.

{
  mWidget = aWidget;

  HWND  hwnd = (HWND)aWidget;
  HDC   hdc = ::GetDC(hwnd);

  CommonInit(hdc);

  ::ReleaseDC(hwnd, hdc);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsDeviceContextWin::Init ( nsNativeDeviceContext  aContext,
nsIDeviceContext aOrigContext 
) [protected]

Definition at line 116 of file nsDeviceContextWin.cpp.

{
  float origscale, newscale;
  float t2d, a2d;

  mDC = (HDC)aContext;

  CommonInit(mDC);


  newscale = TwipsToDevUnits();
  origscale = aOrigContext->TwipsToDevUnits();

  mPixelScale = newscale / origscale;

  t2d = aOrigContext->TwipsToDevUnits();
  a2d = aOrigContext->AppUnitsToDevUnits();

  mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels;
  mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits;

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 305 of file nsDeviceContextWin.cpp.

Definition at line 289 of file nsDeviceContextWin.cpp.

{
  if (nsnull == mDC)
    aSupportsWidgets = PR_TRUE;
  else
    aSupportsWidgets = PR_FALSE;

  return NS_OK;
}

Friends And Related Function Documentation

friend class nsNativeThemeWin [friend]

Definition at line 94 of file nsDeviceContextWin.h.


Member Data Documentation

Definition at line 108 of file nsDeviceContextWin.h.

Definition at line 109 of file nsDeviceContextWin.h.

Definition at line 117 of file nsDeviceContextWin.h.

Definition at line 123 of file nsDeviceContextWin.h.

Definition at line 112 of file nsDeviceContextWin.h.

Definition at line 116 of file nsDeviceContextWin.h.

Definition at line 113 of file nsDeviceContextWin.h.

Definition at line 114 of file nsDeviceContextWin.h.

Definition at line 120 of file nsDeviceContextWin.h.

Definition at line 118 of file nsDeviceContextWin.h.

Definition at line 111 of file nsDeviceContextWin.h.

Definition at line 115 of file nsDeviceContextWin.h.


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