Back to index

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

#include <nsToolkitBase.h>

Inheritance diagram for nsToolkitBase:
Inheritance graph
[legend]
Collaboration diagram for nsToolkitBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsToolkitBase ()
virtual ~nsToolkitBase ()
void Init (in PRThread aThread)
 Initialize this toolkit with aThread.

Static Public Member Functions

NS_DECL_ISUPPORTS static
NS_DECL_NSITOOLKIT void 
PostSleepWakeNotification (const char *aNotification)

Protected Member Functions

virtual nsresult InitEventQueue (PRThread *aThread)=0
nsresult RegisterForSleepWakeNotifcations ()
void RemoveSleepWakeNotifcations ()

Static Protected Member Functions

static int QuartzChangedCallback (const char *pref, void *data)
static void SetupQuartzRendering ()

Protected Attributes

bool mInited
CFRunLoopSourceRef mSleepWakeNotificationRLS
io_object_t mPowerNotifier

Detailed Description

Definition at line 49 of file nsToolkitBase.h.


Constructor & Destructor Documentation

Definition at line 75 of file nsToolkitBase.cpp.

Definition at line 82 of file nsToolkitBase.cpp.

{
  RemoveSleepWakeNotifcations();
  // Remove the TLS reference to the toolkit...
  PR_SetThreadPrivate(gToolkitTLSIndex, nsnull);
}

Here is the call graph for this function:


Member Function Documentation

void nsIToolkit::Init ( in PRThread  aThread) [inherited]

Initialize this toolkit with aThread.

Parameters:
aThreadThe thread passed in runs the message pump. NULL can be passed in, in which case a new thread gets created and a message pump will run in that thread

Here is the caller graph for this function:

virtual nsresult nsToolkitBase::InitEventQueue ( PRThread aThread) [protected, pure virtual]

Implemented in nsToolkit, and nsToolkit.

void nsToolkitBase::PostSleepWakeNotification ( const char *  aNotification) [static]

Definition at line 200 of file nsToolkitBase.cpp.

{
  nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1");
  if (observerService)
  {
    observerService->NotifyObservers(nsnull, aNotification, nsnull);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsToolkitBase::QuartzChangedCallback ( const char *  pref,
void data 
) [static, protected]

Definition at line 118 of file nsToolkitBase.cpp.

{
  SetupQuartzRendering();
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 210 of file nsToolkitBase.cpp.

{
  IONotificationPortRef   notifyPortRef;

  NS_ASSERTION(!mSleepWakeNotificationRLS, "Already registered for sleep/wake");

  gRootPort = ::IORegisterForSystemPower(0, &notifyPortRef, ToolkitSleepWakeCallback, &mPowerNotifier);
  if (gRootPort == NULL)
  {
    NS_ASSERTION(0, "IORegisterForSystemPower failed");
    return NS_ERROR_FAILURE;
  }

  mSleepWakeNotificationRLS = ::IONotificationPortGetRunLoopSource(notifyPortRef);
  ::CFRunLoopAddSource(::CFRunLoopGetCurrent(),
                        mSleepWakeNotificationRLS,
                        kCFRunLoopDefaultMode);

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 233 of file nsToolkitBase.cpp.

{
  if (mSleepWakeNotificationRLS)
  {
    ::IODeregisterForSystemPower(&mPowerNotifier);
    ::CFRunLoopRemoveSource(::CFRunLoopGetCurrent(),
                          mSleepWakeNotificationRLS,
                          kCFRunLoopDefaultMode);

    mSleepWakeNotificationRLS = nsnull;
  }
}

Here is the caller graph for this function:

void nsToolkitBase::SetupQuartzRendering ( ) [static, protected]

Definition at line 130 of file nsToolkitBase.cpp.

{
  // from Apple's technote at http://developer.apple.com/qa/qa2001/qa1193.html
  enum {
    kQDDontChangeFlags = 0xFFFFFFFF,         // don't change anything
    kQDUseDefaultTextRendering = 0,          // bit 0
    kQDUseTrueTypeScalerGlyphs = (1 << 0),   // bit 1
    kQDUseCGTextRendering = (1 << 1),        // bit 2
    kQDUseCGTextMetrics = (1 << 2)
  };

  const int kFlagsWeUse = kQDUseCGTextRendering | kQDUseCGTextMetrics;

  // turn on quartz rendering if we find the symbol in the app framework. Just turn
  // on the bits that we need, don't turn off what someone else might have wanted. If
  // the pref isn't found, assume we want it on. That way, we have to explicitly put
  // in a pref to disable it, rather than force everyone who wants it to carry around
  // an extra pref.
  nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
  if (!prefs)
    return;

  PRBool enableQuartz = PR_TRUE;
  nsresult rv = prefs->GetBoolPref(kQuartzRenderingPref, &enableQuartz);
  UInt32 oldFlags = QDSwapTextFlags(kQDDontChangeFlags);
  if (NS_FAILED(rv) || enableQuartz) {
    QDSwapTextFlags(oldFlags | kFlagsWeUse);
    
    // the system defaults to not anti-aliasing small fonts, but some people
    // think it looks better that way. If the pref is set, turn them on
    PRBool antiAliasAllFontSizes = PR_FALSE;
    rv = prefs->GetBoolPref(kAllFontSizesPref, &antiAliasAllFontSizes);
    if (NS_SUCCEEDED(rv) && antiAliasAllFontSizes)
      SetOutlinePreferred(true);
  }
  else 
    QDSwapTextFlags(oldFlags & !kFlagsWeUse);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 75 of file nsToolkitBase.h.

io_object_t nsToolkitBase::mPowerNotifier [protected]

Definition at line 78 of file nsToolkitBase.h.

CFRunLoopSourceRef nsToolkitBase::mSleepWakeNotificationRLS [protected]

Definition at line 77 of file nsToolkitBase.h.


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