Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes
CPageSetupMarginsDlg Class Reference

#include <PageSetupDlg.h>

Collaboration diagram for CPageSetupMarginsDlg:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { IDD = IDD_PPAGE_MARGINS }

Public Member Functions

 CPageSetupMarginsDlg ()
const wchar_t *constGetHeaderFooterValues (size_t &aNumValues) const
const TCHAR *constGetHeaderFooterOptions (size_t &aNumOptions) const
void Init (nsIPrintSettings *aPrintSettings)
void SetComboIndex (int aID, const wchar_t *szValue)
void Apply (nsIPrintSettings *aPrintSettings)
LRESULT OnInitDialog (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
LRESULT OnHeaderFooterChange (WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)

Public Attributes

nsString mHdrLeft
nsString mHdrCenter
nsString mHdrRight
nsString mFtrLeft
nsString mFtrCenter
nsString mFtrRight

Detailed Description

Definition at line 191 of file PageSetupDlg.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
IDD 

Definition at line 201 of file PageSetupDlg.h.


Constructor & Destructor Documentation

Definition at line 208 of file PageSetupDlg.h.

    {
    }

Member Function Documentation

void CPageSetupMarginsDlg::Apply ( nsIPrintSettings aPrintSettings) [inline]

Definition at line 319 of file PageSetupDlg.h.

    {
        TCHAR szBuf[128];
        const size_t kBufSize = sizeof(szBuf) / sizeof(szBuf[0]);

        GetDlgItemText(IDC_MARGIN_TOP, szBuf, kBufSize);
        aPrintSettings->SetMarginTop(_tstof(szBuf));
        GetDlgItemText(IDC_MARGIN_LEFT, szBuf, kBufSize);
        aPrintSettings->SetMarginLeft(_tstof(szBuf));
        GetDlgItemText(IDC_MARGIN_BOTTOM, szBuf, kBufSize);
        aPrintSettings->SetMarginBottom(_tstof(szBuf));
        GetDlgItemText(IDC_MARGIN_RIGHT, szBuf, kBufSize);
        aPrintSettings->SetMarginRight(_tstof(szBuf));

        aPrintSettings->SetHeaderStrLeft(mHdrLeft.get());
        aPrintSettings->SetHeaderStrCenter(mHdrCenter.get());
        aPrintSettings->SetHeaderStrRight(mHdrRight.get());
        aPrintSettings->SetFooterStrLeft(mFtrLeft.get());
        aPrintSettings->SetFooterStrCenter(mFtrCenter.get());
        aPrintSettings->SetFooterStrRight(mFtrRight.get());
    }

Here is the call graph for this function:

Here is the caller graph for this function:

const TCHAR* const* CPageSetupMarginsDlg::GetHeaderFooterOptions ( size_t &  aNumOptions) const [inline]

Definition at line 226 of file PageSetupDlg.h.

    {
        static const TCHAR *szOptions[] =
        {
            _T("-- Blank --"),
            _T("Title"),
            _T("URL"),
            _T("Date/Time"),
            _T("Page #"),
            _T("Page # of #"),
            _T("Custom...")
        };
        aNumOptions = sizeof(szOptions) / sizeof(szOptions[0]);
        return szOptions;
    }

Here is the caller graph for this function:

const wchar_t* const* CPageSetupMarginsDlg::GetHeaderFooterValues ( size_t &  aNumValues) const [inline]

Definition at line 212 of file PageSetupDlg.h.

    {
        static const wchar_t *szValues[] = {
            L"",
            L"&T",
            L"&U",
            L"&D",
            L"&P",
            L"&PT"
        };
        aNumValues = sizeof(szValues) / sizeof(szValues[0]);
        return szValues;
    }

Here is the caller graph for this function:

void CPageSetupMarginsDlg::Init ( nsIPrintSettings aPrintSettings) [inline]

Definition at line 242 of file PageSetupDlg.h.

    {
        double top = 0.0;
        double left = 0.0;
        double right = 0.0;
        double bottom = 0.0;
        aPrintSettings->GetMarginTop(&top);
        aPrintSettings->GetMarginLeft(&left);
        aPrintSettings->GetMarginRight(&right);
        aPrintSettings->GetMarginBottom(&bottom);

        // Get the margins
        TCHAR szBuf[16];
        _stprintf(szBuf, _T("%5.2f"), top);
        SetDlgItemText(IDC_MARGIN_TOP, szBuf);
        _stprintf(szBuf, _T("%5.2f"), left);
        SetDlgItemText(IDC_MARGIN_LEFT, szBuf);
        _stprintf(szBuf, _T("%5.2f"), right);
        SetDlgItemText(IDC_MARGIN_RIGHT, szBuf);
        _stprintf(szBuf, _T("%5.2f"), bottom);
        SetDlgItemText(IDC_MARGIN_BOTTOM, szBuf);

        // Get the header & footer settings
        PRUnichar* uStr = nsnull;
        aPrintSettings->GetHeaderStrLeft(&uStr);
        mHdrLeft = uStr;
        SetComboIndex(IDC_HDR_LEFT, uStr);
        if (uStr != nsnull) nsMemory::Free(uStr);

        aPrintSettings->GetHeaderStrCenter(&uStr);
        mHdrCenter = uStr;
        SetComboIndex(IDC_HDR_MIDDLE, uStr);
        if (uStr != nsnull) nsMemory::Free(uStr);

        aPrintSettings->GetHeaderStrRight(&uStr);
        mHdrRight = uStr;
        SetComboIndex(IDC_HDR_RIGHT, uStr);
        if (uStr != nsnull) nsMemory::Free(uStr);

        aPrintSettings->GetFooterStrLeft(&uStr);
        mFtrLeft = uStr;
        SetComboIndex(IDC_FTR_LEFT, uStr);
        if (uStr != nsnull) nsMemory::Free(uStr);

        aPrintSettings->GetFooterStrCenter(&uStr);
        mFtrCenter = uStr;
        SetComboIndex(IDC_FTR_MIDDLE, uStr);
        if (uStr != nsnull) nsMemory::Free(uStr);

        aPrintSettings->GetFooterStrRight(&uStr);
        mFtrRight = uStr;
        SetComboIndex(IDC_FTR_RIGHT, uStr);
        if (uStr != nsnull) nsMemory::Free(uStr);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

LRESULT CPageSetupMarginsDlg::OnHeaderFooterChange ( WORD  wNotifyCode,
WORD  wID,
HWND  hWndCtl,
BOOL bHandled 
) [inline]

Definition at line 360 of file PageSetupDlg.h.

    {
        if (wNotifyCode != CBN_SELCHANGE)
        {
            bHandled = FALSE;
            return 0;
        }

        // One of the header / footer combos has changed, so set the string
        // to the updated value.

        nsString *pStr = nsnull;
        switch (wID)
        {
        case IDC_HDR_LEFT:   pStr = &mHdrLeft;   break;
        case IDC_HDR_MIDDLE: pStr = &mHdrCenter; break;
        case IDC_HDR_RIGHT:  pStr = &mHdrRight;  break;
        case IDC_FTR_LEFT:   pStr = &mFtrLeft;   break;
        case IDC_FTR_MIDDLE: pStr = &mFtrCenter; break;
        case IDC_FTR_RIGHT:  pStr = &mFtrRight;  break;
        }
        if (!pStr)
        {
            return 0;
        }

        size_t nValues;
        const wchar_t * const * szValues = GetHeaderFooterValues(nValues);

        int nCurSel = SendDlgItemMessage(wID, CB_GETCURSEL);
        if (nCurSel == nValues) // Custom...
        {
            CCustomFieldDlg dlg(*pStr);
            if (dlg.DoModal() == IDOK)
            {
                *pStr = dlg.m_field;
            }
            // Update combo in case their custom value is not custom at all
            // For example, if someone opens the custom dlg and types "&P"
            // (i.e. "Page #"), we should select that since it is already a
            // choice in the combo.
            SetComboIndex(wID, pStr->get());
        }
        else
        {
            *pStr = szValues[nCurSel];
        }

        return 0;
    }

Here is the call graph for this function:

LRESULT CPageSetupMarginsDlg::OnInitDialog ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
) [inline]

Definition at line 341 of file PageSetupDlg.h.

    {
        size_t nOptions;
        const TCHAR * const *szOptions = GetHeaderFooterOptions(nOptions);

        // Fill out the drop down choices
        for (size_t i = 0; i < nOptions; ++i)
        {
            const TCHAR *szOption = szOptions[i];
            SendDlgItemMessage(IDC_HDR_LEFT, CB_ADDSTRING, 0, LPARAM(szOption));
            SendDlgItemMessage(IDC_HDR_MIDDLE, CB_ADDSTRING, 0, LPARAM(szOption));
            SendDlgItemMessage(IDC_HDR_RIGHT, CB_ADDSTRING, 0, LPARAM(szOption));
            SendDlgItemMessage(IDC_FTR_LEFT, CB_ADDSTRING, 0, LPARAM(szOption));
            SendDlgItemMessage(IDC_FTR_MIDDLE, CB_ADDSTRING, 0, LPARAM(szOption));
            SendDlgItemMessage(IDC_FTR_RIGHT, CB_ADDSTRING, 0, LPARAM(szOption));
        }
        return 0;
    }

Here is the call graph for this function:

void CPageSetupMarginsDlg::SetComboIndex ( int  aID,
const wchar_t *  szValue 
) [inline]

Definition at line 297 of file PageSetupDlg.h.

    {
        size_t nValues;
        const wchar_t * const * szValues = GetHeaderFooterValues(nValues);

        int nCurSel = 0;
        if (szValue[0] != L'\0')
        {
            while (nCurSel < nValues)
            {
                if (wcscmp(szValue, szValues[nCurSel]) == 0)
                {
                    break;
                }
                ++nCurSel;
            }
            // nCurSel might contain nValues but that just means the
            // Custom... field gets selected.
        }
        SendDlgItemMessage(aID, CB_SETCURSEL, nCurSel);
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 198 of file PageSetupDlg.h.

Definition at line 197 of file PageSetupDlg.h.

Definition at line 199 of file PageSetupDlg.h.

Definition at line 195 of file PageSetupDlg.h.

Definition at line 194 of file PageSetupDlg.h.

Definition at line 196 of file PageSetupDlg.h.


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