Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions | Variables
nsPrintingPromptService.cpp File Reference
#include "nsPrintingPromptService.h"
#include "nsCOMPtr.h"
#include "nsIPrintingPromptService.h"
#include "nsIFactory.h"
#include "nsIDOMWindow.h"
#include "nsReadableUtils.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIServiceManager.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWindowWatcher.h"
#include "nsIPrintSettingsMac.h"
#include "nsComponentResContext.h"
#include "nsWatchTask.h"
#include "nsPrintProgress.h"
#include "nsPrintProgressParams.h"
#include "nsIWebProgressListener.h"
#include <Printing.h>
#include <Dialogs.h>
#include <Appearance.h>
#include <Resources.h>

Go to the source code of this file.

Classes

struct  dialog_item_struct
struct  append_item_list_struct

Defines

#define DITL_ADDITIONS   128

Typedefs

typedef struct dialog_item_struct DialogItem
typedef struct dialog_item_structDialogItemPtr
typedef struct
dialog_item_struct ** 
DialogItemHandle
typedef struct
append_item_list_struct 
ItemList
typedef struct
append_item_list_struct
ItemListPtr
typedef struct
append_item_list_struct ** 
ItemListHandle

Enumerations

enum  {
  ePrintSelectionCheckboxID = 1, ePrintFrameAsIsCheckboxID, ePrintSelectedFrameCheckboxID, ePrintAllFramesCheckboxID,
  eDrawFrameID
}

Functions

static pascal void MyBBoxDraw (WindowPtr theWindow, short aItemNo)
 
this is a drawing procedure for the user item.
static pascal void MyJobItems (DialogPtr aDialog, short aItemNo)
 
this is the dialog hook, takes care of setting the dialog items dc 12/02/98
static PRInt32 AppendToDialog (TPPrDlg aDialog, PRInt32 aDITLID)
 
Append DITL items to the dialog dc 05/04/2001
static pascal TPPrDlg MyJobDlgInit (THPrint aHPrint)
 
Initialize the print dialogs additional items dc 05/04/2001

Variables

static const char * kPrintProgressDialogURL = "chrome://global/content/printProgress.xul"
static TPPrDlg gPrtJobDialog
static long prFirstItem
static PItemUPP prPItemProc
static PRBool gPrintSelection
static PItemUPP gPrtJobDialogItemProc
static UserItemUPP gDrawListUPP = nsnull
static nsIPrintSettingsgPrintSettings = nsnull

Class Documentation

struct dialog_item_struct

Definition at line 88 of file nsPrintingPromptService.cpp.

Class Members
Rect bounds
char data
Handle handle
char type
struct append_item_list_struct

Definition at line 95 of file nsPrintingPromptService.cpp.

Collaboration diagram for append_item_list_struct:
Class Members
DialogItem items
short max_index

Define Documentation

Definition at line 78 of file nsPrintingPromptService.cpp.


Typedef Documentation


Enumeration Type Documentation

anonymous enum
Enumerator:
ePrintSelectionCheckboxID 
ePrintFrameAsIsCheckboxID 
ePrintSelectedFrameCheckboxID 
ePrintAllFramesCheckboxID 
eDrawFrameID 

Definition at line 80 of file nsPrintingPromptService.cpp.


Function Documentation

static PRInt32 AppendToDialog ( TPPrDlg  aDialog,
PRInt32  aDITLID 
) [static]


Append DITL items to the dialog dc 05/04/2001

Definition at line 214 of file nsPrintingPromptService.cpp.

{
  short           firstItem;
  ItemListHandle  myAppendDITLH;
  ItemListHandle  dlg_Item_List;

  dlg_Item_List = (ItemListHandle)((DialogPeek)aDialog)->items;
  firstItem = (**dlg_Item_List).max_index+2;

  nsComponentResourceContext resContext;
  if (resContext.BecomeCurrent()) { // destructor restores
    myAppendDITLH = (ItemListHandle)::GetResource('DITL', aDITLID);
    NS_ASSERTION(myAppendDITLH, "Failed to get DITL items");
    if (myAppendDITLH) {
      ::AppendDITL((DialogPtr)aDialog, (Handle)myAppendDITLH, appendDITLBottom);
      ::ReleaseResource((Handle) myAppendDITLH);
    }
  }

  return firstItem;
}

Here is the caller graph for this function:

static pascal void MyBBoxDraw ( WindowPtr  theWindow,
short  aItemNo 
) [static]


this is a drawing procedure for the user item.

. this draws a box around the frameset radio buttons dc 12/02/98

Definition at line 117 of file nsPrintingPromptService.cpp.

{
  short   itemType;
  Rect    itemBox;
  Handle  itemH;

  ::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem + eDrawFrameID-1, &itemType, &itemH, &itemBox);
  
  // use appearance if possible
  if ((long)DrawThemeSecondaryGroup != kUnresolvedCFragSymbolAddress)
    ::DrawThemeSecondaryGroup(&itemBox, kThemeStateActive);
  else
    ::FrameRect(&itemBox);
}

Here is the caller graph for this function:

static pascal TPPrDlg MyJobDlgInit ( THPrint  aHPrint) [static]


Initialize the print dialogs additional items dc 05/04/2001

Definition at line 241 of file nsPrintingPromptService.cpp.

{
  PRInt32 i;
  short   itemType;
  Handle  itemH;
  Rect    itemBox;
  PRBool  isOn;
  PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone;

  prFirstItem = AppendToDialog(gPrtJobDialog, DITL_ADDITIONS);

  if (gPrintSettings) {
    gPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
    gPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI);
  }

  ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+ePrintSelectionCheckboxID-1, &itemType, &itemH, &itemBox);
  if ( isOn ) {
    ::HiliteControl((ControlHandle)itemH, 0);
  } else {
    ::HiliteControl((ControlHandle)itemH, 255); 
  }
  
  gPrintSelection = PR_FALSE;
  ::SetControlValue((ControlHandle) itemH, gPrintSelection);

  if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) {
    for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){
      ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox);
      ::SetControlValue((ControlHandle) itemH, (i==4));
      ::HiliteControl((ControlHandle)itemH, 0);
    }
  }
  else if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) {
    for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){
      ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox);
      ::SetControlValue((ControlHandle) itemH, (i==4));
      if ( i == 3){
        ::HiliteControl((ControlHandle)itemH, 255);
      }
    }
  }
  else {
    for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){
      ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox);
      ::SetControlValue((ControlHandle) itemH, FALSE);
      ::HiliteControl((ControlHandle)itemH, 255); 
    }
  }
  
  // attach our handler
  prPItemProc = gPrtJobDialog->pItemProc;
  gPrtJobDialog->pItemProc = gPrtJobDialogItemProc = NewPItemUPP(MyJobItems);


  // attach a draw routine
  gDrawListUPP = NewUserItemProc(MyBBoxDraw);
  ::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem+eDrawFrameID-1, &itemType, &itemH, &itemBox);
  ::SetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem+eDrawFrameID-1, itemType, (Handle)gDrawListUPP, &itemBox);

  return gPrtJobDialog;
}

Here is the call graph for this function:

static pascal void MyJobItems ( DialogPtr  aDialog,
short  aItemNo 
) [static]


this is the dialog hook, takes care of setting the dialog items dc 12/02/98

Definition at line 137 of file nsPrintingPromptService.cpp.

{
short   myItem, firstItem, i, itemType;
short   value;
Rect    itemBox;
Handle  itemH;

  firstItem = prFirstItem;
  
  myItem = aItemNo-firstItem+1;
  if (myItem>0) {
    switch (myItem) {
      case ePrintSelectionCheckboxID:
        ::GetDialogItem(aDialog, firstItem, &itemType, &itemH, &itemBox);
        gPrintSelection = !gPrintSelection;
        ::SetControlValue((ControlHandle)itemH, gPrintSelection);
        break;

      case ePrintFrameAsIsCheckboxID:
      case ePrintSelectedFrameCheckboxID:
      case ePrintAllFramesCheckboxID:
        for (i=ePrintFrameAsIsCheckboxID; i<=ePrintAllFramesCheckboxID; i++){
          ::GetDialogItem(aDialog, firstItem+i-1, &itemType, &itemH, &itemBox);
          ::SetControlValue((ControlHandle)itemH, i==myItem);
        }
        break;
        
      default:
        break;
    }
  } else {
    // chain to standard Item handler
    CallPItemProc(prPItemProc, aDialog, aItemNo);
    
    if (((TPPrDlg)aDialog)->fDone)
    {
      // cleanup and set the print options to what we want
      if (gPrintSettings)
      {
        // print selection
        ::GetDialogItem(aDialog, firstItem+ePrintSelectionCheckboxID-1, &itemType, &itemH, &itemBox);
        value = ::GetControlValue((ControlHandle)itemH);
        if (1==value){
          gPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection);
        } else {
          gPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages);
        }
        
        // print frames as is
        ::GetDialogItem(aDialog, firstItem+ePrintFrameAsIsCheckboxID-1, &itemType, &itemH, &itemBox);
        value = ::GetControlValue((ControlHandle)itemH);
        if (1==value){
          gPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
        }
        
        // selected frame
        ::GetDialogItem(aDialog, firstItem+ePrintSelectedFrameCheckboxID-1, &itemType, &itemH, &itemBox);
        value = ::GetControlValue((ControlHandle)itemH);
        if (1==value){
          gPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame);
        }
        
        // print all frames
        ::GetDialogItem(aDialog, firstItem+ePrintAllFramesCheckboxID-1, &itemType, &itemH, &itemBox);
        value = ::GetControlValue((ControlHandle)itemH);
        if (1==value){
          gPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep);
        }        
      }
    }
  }
}

Here is the caller graph for this function:


Variable Documentation

UserItemUPP gDrawListUPP = nsnull [static]

Definition at line 108 of file nsPrintingPromptService.cpp.

Definition at line 106 of file nsPrintingPromptService.cpp.

Definition at line 109 of file nsPrintingPromptService.cpp.

TPPrDlg gPrtJobDialog [static]

Definition at line 103 of file nsPrintingPromptService.cpp.

PItemUPP gPrtJobDialogItemProc [static]

Definition at line 107 of file nsPrintingPromptService.cpp.

const char* kPrintProgressDialogURL = "chrome://global/content/printProgress.xul" [static]

Definition at line 69 of file nsPrintingPromptService.cpp.

long prFirstItem [static]

Definition at line 104 of file nsPrintingPromptService.cpp.

PItemUPP prPItemProc [static]

Definition at line 105 of file nsPrintingPromptService.cpp.