Example #1
0
void EditPrint::GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) {

    // initialize values
    *minPage = 0;
    *maxPage = 0;
    *selPageFrom = 0;
    *selPageTo = 0;

    // scale DC if possible
    wxDC *dc = GetDC();
    if (!dc) return;
    PrintScaling (dc);

    // get print page informations and convert to printer pixels
    wxSize ppiScr;
    GetPPIScreen (&ppiScr.x, &ppiScr.y);
    wxSize page = g_pageSetupData->GetPaperSize();
    page.x = static_cast<int> (page.x * ppiScr.x / 25.4);
    page.y = static_cast<int> (page.y * ppiScr.y / 25.4);
    m_pageRect = wxRect (0,
                         0,
                         page.x,
                         page.y);

    // get margins informations and convert to printer pixels
    wxPoint pt = g_pageSetupData->GetMarginTopLeft();
    int left = pt.x;
    int top = pt.y;
    pt = g_pageSetupData->GetMarginBottomRight();
    int right = pt.x;
    int bottom = pt.y;

    top = static_cast<int> (top * ppiScr.y / 25.4);
    bottom = static_cast<int> (bottom * ppiScr.y / 25.4);
    left = static_cast<int> (left * ppiScr.x / 25.4);
    right = static_cast<int> (right * ppiScr.x / 25.4);

    m_printRect = wxRect (left,
                          top,
                          page.x - (left + right),
                          page.y - (top + bottom));

    // count pages
    while (HasPage (*maxPage)) {
        m_printed = m_edit->FormatRange (0, m_printed, m_edit->GetLength(),
                                       dc, dc, m_printRect, m_pageRect);
        *maxPage += 1;
    }
    if (*maxPage > 0) *minPage = 1;
    *selPageFrom = *minPage;
    *selPageTo = *maxPage;
}
Example #2
0
bool EditPrint::OnPrintPage (int page) {

    wxDC *dc = GetDC();
    if (!dc) return false;

    // scale DC
    PrintScaling (dc);

    // print page
    m_edit->FormatRange(true, page == 1 ? 0 : m_pageEnds[page-2], m_pageEnds[page-1],
                                     dc, dc, m_printRect, m_pageRect);
    return true;
}
Example #3
0
bool EditPrint::OnPrintPage (int page) {

    wxDC *dc = GetDC();
    if (!dc) return false;

    // scale DC
    PrintScaling (dc);

    // print page
    if (page == 1) m_printed = 0;
    m_printed = m_edit->FormatRange (1, m_printed, m_edit->GetLength(),
                                     dc, dc, m_printRect, m_pageRect);

    return true;
}
Example #4
0
void EditPrint::GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) {

    // initialize values
    *minPage = 0;
    *maxPage = 0;
    *selPageFrom = 0;
    *selPageTo = 0;

    // scale DC if possible
    wxDC *dc = GetDC();
    if (!dc) return;
    PrintScaling (dc);

    // get print page informations and convert to printer pixels
    wxSize ppiScr;
    GetPPIScreen (&ppiScr.x, &ppiScr.y);
    wxSize page = g_pageSetupData->GetPaperSize();
    page.x = static_cast<int> (page.x * ppiScr.x / 25.4);
    page.y = static_cast<int> (page.y * ppiScr.y / 25.4);
    // In landscape mode we need to swap the width and height
    if ( g_pageSetupData->GetPrintData().GetOrientation() == wxLANDSCAPE )
    {
        wxSwap(page.x, page.y);
    }

    m_pageRect = wxRect (0,
                         0,
                         page.x,
                         page.y);

    // get margins informations and convert to printer pixels
    wxPoint pt = g_pageSetupData->GetMarginTopLeft();
    int left = pt.x;
    int top = pt.y;
    pt = g_pageSetupData->GetMarginBottomRight();
    int right = pt.x;
    int bottom = pt.y;

    top = static_cast<int> (top * ppiScr.y / 25.4);
    bottom = static_cast<int> (bottom * ppiScr.y / 25.4);
    left = static_cast<int> (left * ppiScr.x / 25.4);
    right = static_cast<int> (right * ppiScr.x / 25.4);

    m_printRect = wxRect (left,
                          top,
                          page.x - (left + right),
                          page.y - (top + bottom));

    // count pages
    m_pageEnds.Clear();
    int printed = 0;
    while ( printed < m_edit->GetLength() ) {
        printed = m_edit->FormatRange(false, printed, m_edit->GetLength(),
                                      dc, dc, m_printRect, m_pageRect);
        m_pageEnds.Add(printed);
        *maxPage += 1;
    }
    if (*maxPage > 0) *minPage = 1;
    *selPageFrom = *minPage;
    *selPageTo = *maxPage;
}
Example #5
0
//------------------------------------------------------------------------------
// void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
//------------------------------------------------------------------------------
void EditorPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom,
                                 int *selPageTo)
{
   #ifdef DEBUG_PRINTOUT
   MessageInterface::ShowMessage("EditorPrintout::GetPageInfo() entered\n");
   #endif

   // initialize values
   *minPage = 0;
   *maxPage = 0;
   *selPageFrom = 0;
   *selPageTo = 0;

   // scale DC if possible
   wxDC *dc = GetDC();
   if(!dc)
      return;

   PrintScaling(dc);

   // get print page informations and convert to printer pixels
   wxSize ppiScr;
   GetPPIScreen(&ppiScr.x, &ppiScr.y);
   wxSize page = globalPageSetupData->GetPaperSize();
   page.x = static_cast<int>(page.x * ppiScr.x / 25.4);
   page.y = static_cast<int>(page.y * ppiScr.y / 25.4);
   mPageRect = wxRect(0, 0, page.x, page.y);

   // get margins informations and convert to printer pixels
   wxPoint pt = globalPageSetupData->GetMarginTopLeft();
   int left = pt.x;
   int top = pt.y;
   pt = globalPageSetupData->GetMarginBottomRight();
   int right = pt.x;
   int bottom = pt.y;

   top = static_cast<int>(top * ppiScr.y / 25.4);
   bottom = static_cast<int>(bottom * ppiScr.y / 25.4);
   left = static_cast<int>(left * ppiScr.x / 25.4);
   right = static_cast<int>(right * ppiScr.x / 25.4);

   mPrintRect = wxRect(left, top,
                       page.x -(left + right), page.y -(top + bottom));

   // count pages
   //while (HasPage(*maxPage)) <== causing infinite loop (loj)
   if (HasPage(*maxPage))
   {
      mPagePrinted =
         mEditor->FormatRange(0, mPagePrinted, mEditor->GetLength(),
                              dc, dc, mPrintRect, mPageRect);

      #ifdef DEBUG_PRINTOUT
      MessageInterface::ShowMessage("   mPagePrinted=%d\n", mPagePrinted);
      #endif

      *maxPage += 1;
   }

   if(*maxPage > 0)
      *minPage = 1;

   *selPageFrom = *minPage;
   *selPageTo = *maxPage;

   #ifdef DEBUG_PRINTOUT
   MessageInterface::ShowMessage("EditorPrintout::GetPageInfo() exiting\n");
   #endif
}