Back to index

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

#include <nsDeviceContextBeOS.h>

List of all members.

Public Member Functions

 nsDeviceContextBeOS ()
virtual ~nsDeviceContextBeOS ()
NS_IMETHOD Init (nsNativeWidget aNativeWidget)
NS_IMETHOD CreateRenderingContext (nsIRenderingContext *&aContext)
NS_IMETHOD CreateRenderingContext (nsIView *aView, nsIRenderingContext *&aContext)
NS_IMETHOD CreateRenderingContext (nsIWidget *aWidget, nsIRenderingContext *&aContext)
NS_IMETHOD SupportsNativeWidgets (PRBool &aSupportsWidgets)
NS_IMETHOD GetScrollBarDimensions (float &aWidth, float &aHeight) const
NS_IMETHOD GetSystemFont (nsSystemFontID anID, nsFont *aFont) const
NS_IMETHOD CheckFontExistence (const nsString &aFontName)
NS_IMETHOD GetDeviceSurfaceDimensions (PRInt32 &aWidth, PRInt32 &aHeight)
NS_IMETHOD GetClientRect (nsRect &aRect)
NS_IMETHOD GetRect (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 BeginPage (void)
NS_IMETHOD EndPage (void)
NS_IMETHOD GetDepth (PRUint32 &aDepth)
nsresult SetDPI (PRInt32 dpi)

Static Public Member Functions

static int prefChanged (const char *aPref, void *aClosure)

Private Member Functions

nsresult GetSystemFontInfo (const BFont *font, nsSystemFontID anID, nsFont *aFont) const

Private Attributes

PRUint32 mDepth
PRBool mWriteable
PRUint32 mNumCells
PRInt16 mScrollbarHeight
PRInt16 mScrollbarWidth
BFont mMenuFont
float mWidthFloat
float mHeightFloat
PRInt32 mWidth
PRInt32 mHeight

Static Private Attributes

static nscoord mDpi = 96

Detailed Description

Definition at line 49 of file nsDeviceContextBeOS.h.


Constructor & Destructor Documentation

Definition at line 65 of file nsDeviceContextBeOS.cpp.

  : DeviceContextImpl()
{
  mTwipsToPixels = 1.0;
  mPixelsToTwips = 1.0;
  mDepth = 0 ;
  mNumCells = 0;
  
  mWidthFloat = 0.0f; 
  mHeightFloat = 0.0f; 
  mWidth = -1; 
  mHeight = -1; 
}

Definition at line 79 of file nsDeviceContextBeOS.cpp.

{
  nsresult rv; 
  nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv); 
  if (NS_SUCCEEDED(rv))
    prefs->UnregisterCallback("layout.css.dpi", prefChanged, (void *)this); 
}

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 376 of file nsDeviceContextBeOS.cpp.

{
  return NS_OK;
}

Definition at line 386 of file nsDeviceContextBeOS.cpp.

{
  return NS_OK;
}

Definition at line 279 of file nsDeviceContextBeOS.cpp.

{
  return nsFontMetricsBeOS::FamilyExists(aFontName); 
} 

Here is the call graph for this function:

Definition at line 181 of file nsDeviceContextBeOS.cpp.

{ 
  nsIRenderingContext *pContext; 
  nsresult             rv; 
  nsDrawingSurfaceBeOS  *surf; 
  BView *w; 

  w = (BView*)mWidget;

  // to call init for this, we need to have a valid nsDrawingSurfaceBeOS created 
  pContext = new nsRenderingContextBeOS(); 
 
  if (nsnull != pContext) 
  { 
    NS_ADDREF(pContext); 
 
    // create the nsDrawingSurfaceBeOS 
    surf = new nsDrawingSurfaceBeOS(); 
 
    if (surf && w) 
    {
      // init the nsDrawingSurfaceBeOS 
      rv = surf->Init(w);
      if (NS_OK == rv)
        // Init the nsRenderingContextBeOS 
        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 58 of file nsDeviceContextBeOS.h.

{return (DeviceContextImpl::CreateRenderingContext(aView,aContext));} 

Definition at line 59 of file nsDeviceContextBeOS.h.

{return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));} 

Definition at line 381 of file nsDeviceContextBeOS.cpp.

{
  return NS_OK;
}

Definition at line 391 of file nsDeviceContextBeOS.cpp.

{
  return NS_OK;
} 

Definition at line 343 of file nsDeviceContextBeOS.cpp.

{ 
//XXX do we know if the client rect should ever differ from the screen rect? 
  return GetRect(aRect);
}

Here is the call graph for this function:

Definition at line 396 of file nsDeviceContextBeOS.cpp.

{ 
  aDepth = mDepth; 
  return NS_OK; 
} 

Definition at line 349 of file nsDeviceContextBeOS.cpp.

{
#ifdef USE_POSTSCRIPT
  static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
  
  // Create a Postscript device context 
  nsresult rv;
  nsIDeviceContextPS *dcps;
  
  rv = CallCreateInstance(kCDeviceContextPS, &dcps);

  NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context");
  
  dcps->SetSpec(aDevice);
  dcps->InitDeviceContextPS((nsIDeviceContext*)aContext, (nsIDeviceContext*)this);

  rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext), (void **)&aContext);

  NS_RELEASE(dcps);
  
  return rv;
#else
  return NS_ERROR_NOT_IMPLEMENTED;
#endif /* USE_POSTSCRIPT */
}

Here is the call graph for this function:

Definition at line 317 of file nsDeviceContextBeOS.cpp.

{
  if (mWidth == -1) 
    mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);

  if (mHeight == -1) 
    mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits); 
 
  aWidth = mWidth; 
  aHeight = mHeight; 
 
  return NS_OK; 
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 331 of file nsDeviceContextBeOS.cpp.

{
  PRInt32 width, height; 
  nsresult rv; 
  rv = GetDeviceSurfaceDimensions(width, height);
  aRect.x = 0;
  aRect.y = 0;
  aRect.width = width; 
  aRect.height = height; 
  return rv; 
} 

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 234 of file nsDeviceContextBeOS.cpp.

{
  float scale;
  GetCanonicalPixelScale(scale);
  aWidth = mScrollbarWidth * mPixelsToTwips * scale;
  aHeight = mScrollbarHeight * mPixelsToTwips * scale;

  return NS_OK;
}

Definition at line 244 of file nsDeviceContextBeOS.cpp.

{
  nsresult status = NS_OK;

  switch (aID) 
  {
    case eSystemFont_PullDownMenu: 
    case eSystemFont_Menu:
      status = GetSystemFontInfo(&mMenuFont, aID, aFont); 
      break;
    case eSystemFont_Caption:             // css2 bold  
      status = GetSystemFontInfo(be_bold_font, aID, aFont); 
      break;
    case eSystemFont_List:   
    case eSystemFont_Field:
    case eSystemFont_Icon : 
    case eSystemFont_MessageBox : 
    case eSystemFont_SmallCaption : 
    case eSystemFont_StatusBar : 
    case eSystemFont_Window:              // css3 
    case eSystemFont_Document: 
    case eSystemFont_Workspace: 
    case eSystemFont_Desktop: 
    case eSystemFont_Info: 
    case eSystemFont_Dialog: 
    case eSystemFont_Button: 
    case eSystemFont_Tooltips:            // moz 
    case eSystemFont_Widget: 
    default:
      status = GetSystemFontInfo(be_plain_font, aID, aFont);
  }

  return status;
}

Here is the call graph for this function:

nsresult nsDeviceContextBeOS::GetSystemFontInfo ( const BFont *  font,
nsSystemFontID  anID,
nsFont aFont 
) const [private]

Definition at line 434 of file nsDeviceContextBeOS.cpp.

{ 
  nsresult status = NS_OK; 
 
  aFont->style       = NS_FONT_STYLE_NORMAL; 
  aFont->weight      = NS_FONT_WEIGHT_NORMAL; 
  aFont->decorations = NS_FONT_DECORATION_NONE; 
  
  // do we have the default_font defined by BeOS, if not then 
  // we error out. 
  if (!theFont)
  {
    switch (anID) 
       {
      case eSystemFont_Menu:
        status = GetSystemFontInfo(&mMenuFont, anID, aFont); 
        break;
      case eSystemFont_List:
      case eSystemFont_Field:
        theFont = be_plain_font;
        break;
      case eSystemFont_Caption:
        theFont = be_bold_font;
        break;
      default:
        theFont = be_plain_font; // BeOS default font 
    }
  }
  
  if (!theFont) 
  { 
    status = NS_ERROR_FAILURE; 
  } 
  else 
  { 
    font_family family; 
    font_style style; 
    font_height height;
    uint16 face; 
 
    theFont->GetFamilyAndStyle(&family, &style);

    face = theFont->Face();
    aFont->name.Assign(NS_ConvertUTF8toUCS2(family));
    aFont->size = NSIntPixelsToTwips(uint32(theFont->Size()), mPixelsToTwips); 

    if(face & B_ITALIC_FACE)
      aFont->style = NS_FONT_STYLE_ITALIC;
    
    if(face & B_BOLD_FACE)
      aFont->weight = NS_FONT_WEIGHT_BOLD;

    if(face & B_UNDERSCORE_FACE)
      aFont->decorations |= NS_FONT_DECORATION_UNDERLINE;

    if(face & B_STRIKEOUT_FACE)
      aFont->decorations |= NS_FONT_DECORATION_LINE_THROUGH;

    aFont->systemFont = PR_TRUE;

    status = NS_OK; 
  } 
  return (status); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 87 of file nsDeviceContextBeOS.cpp.

{
  // get the screen object and its width/height 
  // XXXRight now this will only get the primary monitor. 

  nsresult ignore; 
  mWidget = aNativeWidget;
  nsCOMPtr<nsIScreenManager> sm ( do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore) ); 
  if (sm) 
  { 
    nsCOMPtr<nsIScreen> screen; 
    sm->GetPrimaryScreen(getter_AddRefs(screen)); 
    if (screen)
    { 
      PRInt32 x, y, width, height, depth; 
      screen->GetAvailRect ( &x, &y, &width, &height ); 
      screen->GetPixelDepth ( &depth ); 
      mWidthFloat = float(width); 
      mHeightFloat = float(height); 
      mDepth = NS_STATIC_CAST ( PRUint32, depth ); 
    } 
  } 
  
  static int initialized = 0; 
  if (!initialized) 
  {
    initialized = 1; 

    // Set prefVal the value of the preference "layout.css.dpi" 
    // or -1 if we can't get it. 
    // If it's negative, we pretend it's not set. 
    // If it's 0, it means force use of the operating system's logical resolution. 
    // If it's positive, we use it as the logical resolution 
    PRInt32 prefVal = -1; 
    nsresult res; 

    nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res)); 
    if (NS_SUCCEEDED(res) && prefs)
    { 
      res = prefs->GetIntPref("layout.css.dpi", &prefVal); 
      if (! NS_SUCCEEDED(res))
      { 
        prefVal = -1; 
      } 
      prefs->RegisterCallback("layout.css.dpi", prefChanged, (void *)this); 
    } 
 
    // Set OSVal to what the operating system thinks the logical resolution is. 
    // BeOS lacks monitor info, so we use fixed value for now
    PRInt32 OSVal = 85;
    if (prefVal > 0)
    { 
      // If there's a valid pref value for the logical resolution, 
      // use it. 
      mDpi = prefVal; 
    }
    else if ((prefVal == 0) || (OSVal > 96))
    { 
      // Either if the pref is 0 (force use of OS value) or the OS 
      // value is bigger than 96, use the OS value. 
      mDpi = OSVal; 
    }
    else
    { 
      // if we couldn't get the pref or it's negative, and the OS 
      // value is under 96ppi, then use 96. 
      mDpi = 96; 
    } 
  } 
 
  SetDPI(mDpi); 

  mScrollbarHeight = PRInt16(B_H_SCROLL_BAR_HEIGHT); 
  mScrollbarWidth = PRInt16(B_V_SCROLL_BAR_WIDTH); 

  menu_info info;
  get_menu_info(&info);
  mMenuFont.SetFamilyAndStyle(info.f_family,info.f_style);
  mMenuFont.SetSize(info.font_size);
  
#ifdef DEBUG 
  static PRBool once = PR_TRUE; 
  if (once)
  { 
    printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", mDpi, mTwipsToPixels, mPixelsToTwips,mDepth); 
    once = PR_FALSE; 
  } 
#endif 

  DeviceContextImpl::CommonInit();
  
  return NS_OK;
}

Here is the call graph for this function:

int nsDeviceContextBeOS::prefChanged ( const char *  aPref,
void aClosure 
) [static]

Definition at line 416 of file nsDeviceContextBeOS.cpp.

{ 
  nsDeviceContextBeOS *context = (nsDeviceContextBeOS*)aClosure; 
  nsresult rv; 
  
  if (nsCRT::strcmp(aPref, "layout.css.dpi")==0)
  {
    PRInt32 dpi; 
    nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv)); 
    rv = prefs->GetIntPref(aPref, &dpi); 
    if (NS_SUCCEEDED(rv)) 
      context->SetDPI(dpi); 
  } 
  
  return 0; 
} 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 403 of file nsDeviceContextBeOS.cpp.

{ 
  mDpi = aDpi; 
  
  int pt2t = 72; 

  mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(pt2t)) / float(aDpi))); 
  mTwipsToPixels = 1.0f / mPixelsToTwips; 
 
  // XXX need to reflow all documents 
  return NS_OK; 
} 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 226 of file nsDeviceContextBeOS.cpp.

{
  //XXX it is very critical that this not lie!! MMP
  // read the comments in the mac code for this
  aSupportsWidgets = PR_TRUE;
  return NS_OK;
}

Member Data Documentation

Definition at line 87 of file nsDeviceContextBeOS.h.

nscoord nsDeviceContextBeOS::mDpi = 96 [static, private]

Definition at line 93 of file nsDeviceContextBeOS.h.

Definition at line 98 of file nsDeviceContextBeOS.h.

Definition at line 96 of file nsDeviceContextBeOS.h.

Definition at line 92 of file nsDeviceContextBeOS.h.

Definition at line 89 of file nsDeviceContextBeOS.h.

Definition at line 90 of file nsDeviceContextBeOS.h.

Definition at line 91 of file nsDeviceContextBeOS.h.

Definition at line 97 of file nsDeviceContextBeOS.h.

Definition at line 95 of file nsDeviceContextBeOS.h.

Definition at line 88 of file nsDeviceContextBeOS.h.


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