Пример #1
0
DRIVER_ERROR Job::Cleanup()
{
    // Client isn't required to call NewPage at end of last page, so
    // we may need to eject a page now.
    DRIVER_ERROR    err = NO_ERROR;

/*
 *  Let the encapsulator cleanup, such as sending previous page if speed mech
 *  is enabled.
 */

    if (m_pEncap) {
        err = m_pEncap->Cleanup();
    }

    if (err != NO_ERROR) {
        return err;
    }

    if (m_bDataSent || err != NO_ERROR) {
        NewPage();
    }

    // Tell printer that job is over.
    if (m_pEncap) {
        m_pEncap->EndJob();
    }//end if
    return NO_ERROR;
}
Пример #2
0
static  void    SplitValue( void *ptr, int size, int part_1 ) {
//=============================================================

// Split value across pages.

    memcpy( ObjPtr, ptr, part_1 );
    PageFlags |= PF_DIRTY;
    NewPage();
    memcpy( ObjPtr, (char *)ptr + part_1, size - part_1 );
    PageFlags |= PF_DIRTY;
    ObjPtr += size - part_1;
}
Пример #3
0
void    OutByte( byte val ) {
//===========================

// Output a byte to object memory.

    if( ( ProgSw & ( PS_ERROR | PS_DONT_GENERATE ) ) == 0 ) {
        if( ObjEnd - ObjPtr < sizeof( byte ) ) {
            NewPage();
        }
        *(byte *)ObjPtr = val;
        ObjPtr += sizeof( byte );
        PageFlags |= PF_DIRTY;
    }
}
CFreetypeFontFace::CFreetypeFontFace(const TString &name, const TString &file, int32_t size, int32_t dpi/*= -1*/)
    : CFontFace(name)
    , m_pFont(CResourceManager::GetInstance()->GetResource<CFont>(file))
    , m_uCurrX(0)
    , m_uCurrY(0)
    , m_nDpi(dpi)
    , m_nLineHeight(0)
    , m_nAscender(0)
    , m_pRelatedRenderTarget(nullptr)
{
    m_nSize = size;
    NewPage();
    ApplyFTSize();
}
Пример #5
0
void    OutObjPtr( obj_ptr val ) {
//================================

// Output object code pointer to object memory.

    if( ( ProgSw & ( PS_ERROR | PS_DONT_GENERATE ) ) == 0 ) {
        if( ObjEnd - ObjPtr < sizeof( obj_ptr ) ) {
            if( ObjPtr < ObjEnd ) {   // value overlaps pages
                SplitValue( &val, sizeof( obj_ptr ), ObjEnd - ObjPtr );
                return;
            }
            NewPage();
        }
        *(obj_ptr *)ObjPtr = val;
        ObjPtr += sizeof( obj_ptr );
        PageFlags |= PF_DIRTY;
    }
}
Пример #6
0
void    OutConst32( signed_32 val ) {
//===================================

// Output 32-bit constant to object memory.

    if( ( ProgSw & ( PS_ERROR | PS_DONT_GENERATE ) ) == 0 ) {
        if( ObjEnd - ObjPtr < sizeof( signed_32 ) ) {
            if( ObjPtr < ObjEnd ) {   // value overlaps pages
                SplitValue( &val, sizeof( signed_32 ), ObjEnd - ObjPtr );
                return;
            }
            NewPage();
        }
        *(signed_32 *)ObjPtr = val;
        ObjPtr += sizeof( signed_32 );
        PageFlags |= PF_DIRTY;
    }
}
Пример #7
0
void    OutU16( unsigned_16 val ) {
//=================================

// Output 16-bit value to object memory.

    if( ( ProgSw & ( PS_ERROR | PS_DONT_GENERATE ) ) == 0 ) {
        if( ObjEnd - ObjPtr < sizeof( unsigned_16 ) ) {
            if( ObjPtr < ObjEnd ) {   // value overlaps pages
                SplitValue( &val, sizeof( unsigned_16 ), ObjEnd - ObjPtr );
                return;
            }
            NewPage();
        }
        *(unsigned_16 *)ObjPtr = val;
        ObjPtr += sizeof( unsigned_16 );
        PageFlags |= PF_DIRTY;
    }
}
Пример #8
0
void SeView::dropEvent(QDropEvent * e)
{
    QString str, tmp;
    bool lastPage = false;
    if (e->mimeData()->hasFormat("page/magic"))
    {
        e->setDropAction(Qt::MoveAction);
        e->accept();
        // HACK to prevent strange Qt4 cursor behaviour after dropping. It's examined by Trolltech now - PV.
        // It's the one and only reason why to include QApplication here.
        // But sadly this destroys our normal Cursors
        // Fixed at least in Qt-4.4.2
//		QApplication::restoreOverrideCursor();
        str = e->mimeData()->text();
        ClearPix();
        if (str.startsWith("1"))
        {
            int a = rowAt(e->pos().y());
            int b = columnAt(e->pos().x());
            int p;
            tmp = str.remove(0,1);
            if ((a == -1) || (b == -1))
                return;
            if (a == rowCount()-1)
            {
                emit NewPage(MaxC+1, tmp);
                return;
            }
            p = GetPage(a, b, &lastPage);
            if (columnCount() == 1)
            {
                if ((a % 2) == 0)
                    emit NewPage(p, tmp);
                else
                {
                    emit UseTemp(tmp, p);
                    QTableWidgetItem* ite = item(a, b);
                    if (ite == 0)
                        return;
                    if (ite->type() == 1002)
                    {
                        SeItem* it = (SeItem*)ite;
                        it->pageName = tmp;
                    }
                }
                return;
            }
            else
            {
                if ((b % 2) == 0)
                {
                    if (lastPage)
                        emit NewPage(p+1, tmp);
                    else
                        emit NewPage(p, tmp);
                }
                else
                {
                    emit UseTemp(tmp, p);
                    QTableWidgetItem* ite = item(a, b);
                    if (ite == 0)
                        return;
                    if (ite->type() == 1002)
                    {
                        SeItem* it = (SeItem*)ite;
                        it->pageName = tmp;
                    }
                }
                return;
            }
        }
        if (str.startsWith("2"))
        {
            int st = str.indexOf(" ");
            int en = str.indexOf(" ", st+1);
            tmp = str.mid(en+1);
            int dr = str.mid(st, en-st).toInt();
            int a = rowAt(e->pos().y());
            int b = columnAt(e->pos().x());
            int p;
            if ((a == -1) || (b == -1))
                return;
            QTableWidgetItem* ite = item(a, b);
            p = GetPage(a, b, &lastPage);
            if (a == rowCount()-1)
            {
                emit movePage(dr, p+1);
                return;
            }
            if (columnCount() == 1)
            {
                if ((a % 2) == 0)
                    emit movePage(dr, p);
                else
                {
                    emit UseTemp(tmp, p);
                    if (ite == 0)
                        return;
                    SeItem* it = (SeItem*)ite;
                    it->pageName = tmp;
                }
                return;
            }
            else
            {
                if ((b % 2) == 0)
                    emit movePage(dr, lastPage ? p+1 : p);
                else
                {
                    emit UseTemp(tmp, p);
                    if (ite == 0)
                        return;
                    if (ite->type() == 1002)
                    {
                        SeItem* it = (SeItem*)ite;
                        it->pageName = tmp;
                    }
                }
                return;
            }
        }
    }
}
Пример #9
0
bool wxSTEditorNotebook::HandleMenuEvent(wxCommandEvent &event)
{
    wxSTERecursionGuard guard(m_rGuard_HandleMenuEvent);
    if (guard.IsInside()) return false;

    int n_page = (int)GetPageCount();
    int win_id = event.GetId();

    switch (win_id)
    {
        case wxID_NEW:
        {
            NewPage();
            return true;
        }
        case wxID_OPEN:
        {
            LoadFiles();
            return true;
        }
        case wxID_SAVEAS:
        {
            wxSTEditor *editor = GetEditor();
            if (!editor) return true; // event handled, but we couldn't do anything with it.

            if (!editor->IsFileFromDisk())
            {
                editor->SaveFile(true);
            }
            else
            {
                wxFileName selectedFileName;
                wxString   selectedFileEncoding;
                bool       selected_file_bom = false;

                bool ok = editor->SaveFileDialog(true, wxEmptyString, &selectedFileName, &selectedFileEncoding, &selected_file_bom);
                if (!ok) return true; // they probably canceled the dialog

                if (selectedFileName == editor->GetFileName())
                {
                    // They want to save to the same filename, update current editor.
                    editor->SaveFile(selectedFileName, selectedFileEncoding, selected_file_bom);
                    return true;
                }
                else
                {
                    // Make a new editor for the new filename, leave the original editor as is.
                    wxSTEditorSplitter *splitter = CreateSplitter(wxID_ANY);
                    wxCHECK_MSG(splitter, true, wxT("Invalid splitter"));
                    wxSTEditor *newEditor = splitter->GetEditor();
                    wxCHECK_MSG(newEditor, true, wxT("Invalid splitter editor"));

                    // Make this new editor identical to the original one
                    // these are probably not necessary
                    //splitter->GetEditor()->SetOptions(editor->GetOptions());
                    //splitter->GetEditor()->RegisterPrefs(editor->GetEditorPrefs());
                    //splitter->GetEditor()->RegisterStyles(editor->GetEditorStyles());
                    //splitter->GetEditor()->RegisterLangs(editor->GetEditorLangs());

                    newEditor->SetLanguage(editor->GetLanguageId());
                    newEditor->SetFileName(editor->GetFileName());
                    newEditor->SetFileEncoding(editor->GetFileEncoding());
                    newEditor->SetFileBOM(editor->GetFileBOM());

                    newEditor->SetText(editor->GetText());
                    newEditor->ColouriseDocument();
                    newEditor->GotoPos(editor->PositionFromLine(editor->LineFromPosition(editor->GetCurrentPos())));
                    newEditor->GotoPos(editor->GetCurrentPos());
                    newEditor->ScrollToLine(editor->GetFirstVisibleLine());

                    // if we can save it, then add it to the notebook
                    if (newEditor->SaveFile(selectedFileName, selectedFileEncoding, selected_file_bom))
                    {
                        if (!InsertEditorSplitter(-1, splitter, true))
                            splitter->Destroy();
                    }
                    else
                        splitter->Destroy(); // problem saving, delete new editor
                }
            }
            return true;
        }
        case ID_STN_SAVE_ALL:
        {
            SaveAllFiles();
            return true;
        }
        case ID_STN_CLOSE_PAGE:
        {
            if ((GetSelection() != -1) && GetEditor(GetSelection()))
            {
                ClosePage(GetSelection(), true);
            }
            return true;
        }
        case ID_STN_CLOSE_ALL:
        {
            if (wxYES == wxMessageBox(_("Close all pages?"), _("Confim closing all pages"),
                                   wxICON_QUESTION|wxYES_NO, this))
            {
                CloseAllPages(true, -1);
            }
            return true;
        }
        case ID_STN_CLOSE_ALL_OTHERS:
        {
            CloseAllPages(true, GetSelection());
            return true;
        }
        case ID_STN_WIN_PREVIOUS:
        {
            if ((GetPageCount() > 0) && (GetSelection() - 1 >= 0))
                SetSelection(GetSelection() - 1);
            else if (GetPageCount() > 0)
                SetSelection((int)GetPageCount() - 1);
            return true;
        }
        case ID_STN_WIN_NEXT:
        {
            if ((GetPageCount() > 0) && (GetSelection() + 1 < (int)GetPageCount()))
                SetSelection(GetSelection() + 1);
            else if (GetPageCount() > 0)
                SetSelection(0);
            return true;
        }
        case ID_STN_WINDOWS:
        {
            wxSTEditorWindowsDialog(this, _("Windows"));
            return true;
        }
        case ID_STE_PASTE_NEW:
        {
            wxString text;
            if (wxSTEditor::GetClipboardText(&text))
            {
                NewPage();
                wxSTEditor* editor = GetEditor();
                if (editor)
                {
                    editor->SetText(text);
                    editor->SetModified(false);
                }
            }
            return true;
        }
        default:
        {
            if ((win_id >= ID_STN_GOTO_PAGE_START) && (win_id < ID_STN_GOTO_PAGE_START+n_page))
            {
                SetSelection(win_id - ID_STN_GOTO_PAGE_START);
                return true;
            }
            else if ((win_id >= ID_STN_CLOSE_PAGE_START) && (win_id < ID_STN_CLOSE_PAGE_START+n_page))
            {
                ClosePage(win_id - ID_STN_CLOSE_PAGE_START);
                return true;
            }
            break;
        }
    }
    return false;
}
Пример #10
0
int KPropertyBase::AddPage(LPSTR Name)
{
	_PropertyPage NewPage(Name);
	m_vecPage.push_back(NewPage);
	return ((int)m_vecPage.size()-1);
}
Пример #11
0
int CLitePrint::PrintText (HLTFONT font, CString strText, EAlign Format, BOOL bAutoLF, int left)
{
	int		lx = m_info.m_Margins.left;
	SIZE	Size,SubTextSize;
	int		Width = m_info.m_DimDraw.cx-m_info.m_Margins.left-m_info.m_Margins.right;
    int     abstand;
	div_t	div_result;
	int		nLoop;
	CString	strSubText,strTemp;
	int		pos,count,pos2;

	SetActiveFont(font);
	
	// calculate the place whicht the text needs
	if (strText == "") 
		GetTextExtentPoint32 (m_DC.GetSafeHdc(), _T("A"), 1, &Size);
	else
		GetTextExtentPoint32 (m_DC.GetSafeHdc(), strText, strText.GetLength(), &Size);
	
	if (Size.cx > Width)
	{
		div_result = div( (int) Size.cx, Width );
		nLoop = div_result.quot;

		if (div_result.rem > 0)
			nLoop++;
		strSubText = "";
	}
	else
	{
		nLoop = 1;
		strSubText = strText;
	}

	count = 1;
	pos = 0;
	for (int i=0;i<nLoop;i++)
	{
		if (nLoop > 1)
		{
			do 
			{
				strSubText = strText.Mid(pos,count);
				GetTextExtentPoint32 (m_DC.GetSafeHdc(), strSubText, strSubText.GetLength(), &SubTextSize);
				count++;
			} 
			while (SubTextSize.cx < Width && ( (pos+count) <= strText.GetLength() )) ;

			if ( ( (pos+count) <= strText.GetLength() ) && (strSubText.Right(0) != ' ' ) )
			{
				pos2 = strSubText.ReverseFind (' ');
				if ( (strSubText.GetLength () - pos2) <= MAXCHARS )
				{
					pos2++;
					pos = pos + (count - 1);				
					count = 1;				
					pos = pos - (strSubText.GetLength () - pos2);
					strTemp = strSubText.Mid(0,pos2);
					strSubText = strTemp;
				}
				else
				{
					pos = pos + (count - 1);
					count = 1;
				}
			}
			else
			{
				pos = pos + (count - 1);
				count = 1;
			}
		}
		
		// should the text be centered?
		if (Format == FORMAT_CENTER)
			// page-width minus string-width divieded through 2
			lx += Width/2 - Size.cx/2;
		// should the text be right-sided?
		else if (Format == FORMAT_RIGHT)
			// paper-width minus string-width
			lx += Width - Size.cx;

		// consider the desired distance from the left margin
		lx += left;

		// before we print the text, examine whether we not perhaps already touched bottom 
		// side. Then a new side must created.
		if (!m_info.m_IsHF) 
		{
			abstand = m_info.m_y+Size.cy+CALCY(m_info.m_LnSpc);
			if (abstand > m_info.m_DimDraw.cy-m_info.m_Margins.bottom) 
			{ //-CALCY(m_info.m_Margins.bottom)
				m_info.m_IsHF = true;
				m_info.m_Page++;
				if (m_info.m_HFPrinting) 
					m_funcHeadline (this,m_info.m_Page-1,false);
				NewPage();
				if (m_info.m_HFPrinting) 
					m_funcHeadline(this,m_info.m_Page,true);
				m_info.m_IsHF = false;
			}
		}
		
		// now print the text...
		m_DC.TextOut(lx,m_info.m_y,strSubText);
		if (bAutoLF) 
			m_info.m_y += Size.cy + CALCY(m_info.m_LnSpc);
	}
	return (lx+Size.cx)%Width;
}
Пример #12
0
void CLitePrint::AddTableRecord (HLTFONT font, CString strText)
{
	int		lx = m_info.m_Margins.left,text_lx = m_info.m_Margins.left;
	int		distancex = 0;
	SIZE	Size;
	int		Width = m_info.m_DimDraw.cx-m_info.m_Margins.left-m_info.m_Margins.right;
    int     abstand;	
	int		nFirst;
	CString	strSubText;
	int		pos,count,i,TableSize;
	CRgn	rgn1;
	CRect	rect,oldclip;
	SetActiveFont(font);
	TableSize = 0;
	for (i = 0; i<(int)m_tb.m_TableCols.size();++i)
		TableSize = TableSize + m_tb.m_TableCols[i].colSize;
	CPen	newPen;
	newPen.CreatePen (PS_SOLID, m_tb.m_PenWidth, RGB(0,0,0));
	CPen* 	oldPen = m_DC.SelectObject (&newPen);
	pos = 0;
	nFirst = 0;
	count = 0;
	
	while ( pos != -1)
	{
		pos = strText.Find('|',nFirst);

		if (pos == -1)		
			strSubText = strText.Mid(nFirst,strText.GetLength () );
		else
			strSubText = strText.Mid(nFirst, pos - nFirst);
	
		// calculate the place which the text needs
		if (strSubText == "") 
			GetTextExtentPoint32 (m_DC.GetSafeHdc(), _T("A"), 1, &Size);
		else
			GetTextExtentPoint32 (m_DC.GetSafeHdc(), strSubText, strSubText.GetLength(), &Size);

		// should the text be centered?
		if ( (m_tb.m_TableCols[count].colAlign == FORMAT_CENTER) /*&& (Size.cx < m_tb.m_TableColsSize[count])*/ )
			// page-width minus string-width divieded through 2
			text_lx = lx + (m_tb.m_TableCols[count].colSize/2 - Size.cx/2);
		// should the text be right-sided?
		else if ( (m_tb.m_TableCols[count].colAlign == FORMAT_RIGHT) /*&& (Size.cx < m_tb.m_TableColsSize[count])*/ ) 
			// paper-width minus string-width
			text_lx = lx + m_tb.m_TableCols[count].colSize - Size.cx;
	
		// consider the desired distance from the left margin
		if (count > 0)
		{
			text_lx += m_tb.m_TableBorderSize;
			lx += m_tb.m_TableBorderSize;
		}
		else if ((m_tb.m_TableCols[count].colAlign != FORMAT_LEFT) || (m_tb.m_VLine))
		{

			text_lx += m_tb.m_TableBorderSize / 4;
			lx += m_tb.m_TableBorderSize / 4;
		}

		// before we print the text, examine whether we not perhaps already touched bottom 
		// side. Then a new side must created.
		if (!m_info.m_IsHF) 
		{
			abstand = m_info.m_y+Size.cy+CALCY(m_info.m_LnSpc);
			if (abstand > m_info.m_DimDraw.cy-m_info.m_Margins.bottom) 
			{ //-CALCY(m_info.m_Margins.bottom)
				m_tb.SavePrintState();
				m_info.m_IsHF = true;
				m_info.m_Page++;
				if (m_info.m_HFPrinting) 
					m_funcHeadline (this,m_info.m_Page-1,false);
				NewPage();
				if (m_info.m_HFPrinting) 
					m_funcHeadline(this,m_info.m_Page,true);
				m_info.m_IsHF = false;
				m_tb.RestorePrintState();
			}
		}

		// now print the text...
	    m_DC.GetClipBox (&oldclip);
		
		rect.top = m_info.m_y;
		rect.bottom = rect.top + Size.cy + CALCY(m_info.m_LnSpc);
		rect.left = lx; 
		rect.right = lx + m_tb.m_TableCols[count].colSize;
		rgn1.CreateRectRgnIndirect (&rect);

		m_DC.SelectClipRgn (&rgn1);
		m_DC.TextOut(text_lx,m_info.m_y,strSubText);
		rgn1.DeleteObject ();
		rgn1.CreateRectRgnIndirect (&oldclip);
		m_DC.SelectClipRgn (&rgn1);
		rgn1.DeleteObject ();

		if (m_tb.m_VLine)
		{
			if (count > 0)
			{
				m_DC.MoveTo (lx - (m_tb.m_TableBorderSize / 2), m_info.m_y - CALCY(m_info.m_LnSpc));
				m_DC.LineTo (lx - (m_tb.m_TableBorderSize / 2), m_info.m_y + CALCY(m_info.m_LnSpc) + Size.cy);

				m_DC.MoveTo (lx + (m_tb.m_TableBorderSize / 2) + m_tb.m_TableCols[count].colSize, m_info.m_y - CALCY(m_info.m_LnSpc));
				m_DC.LineTo (lx + (m_tb.m_TableBorderSize / 2) + m_tb.m_TableCols[count].colSize, m_info.m_y + CALCY(m_info.m_LnSpc) + Size.cy);
			}
			else
			{
				m_DC.MoveTo (lx - (m_tb.m_TableBorderSize / 4), m_info.m_y - CALCY(m_info.m_LnSpc));
				m_DC.LineTo (lx - (m_tb.m_TableBorderSize / 4), m_info.m_y + CALCY(m_info.m_LnSpc) + Size.cy);

				m_DC.MoveTo (lx + (m_tb.m_TableBorderSize / 2) + m_tb.m_TableCols[count].colSize, m_info.m_y - CALCY(m_info.m_LnSpc));
				m_DC.LineTo (lx + (m_tb.m_TableBorderSize / 2) + m_tb.m_TableCols[count].colSize, m_info.m_y + CALCY(m_info.m_LnSpc) + Size.cy);

			}
		}
		
		lx += m_tb.m_TableCols[count].colSize;
		text_lx = lx;

		if (pos != -1)
			pos++;
		nFirst = pos;
		count++;

	}// while
	if (m_tb.m_HLine)
	{
		m_info.m_y -= CALCY(m_info.m_LnSpc);
		m_DC.MoveTo (m_info.m_Margins.left + distancex, m_info.m_y);
		m_DC.LineTo (m_info.m_Margins.left + distancex + TableSize + (m_tb.m_TableBorderSize *  count) - (m_tb.m_TableBorderSize / 4), m_info.m_y);

		m_info.m_y += CALCY(m_info.m_LnSpc*2) + Size.cy;
		m_DC.MoveTo (m_info.m_Margins.left + distancex, m_info.m_y);
		m_DC.LineTo (m_info.m_Margins.left + + distancex + TableSize + (m_tb.m_TableBorderSize *  count) - (m_tb.m_TableBorderSize / 4), m_info.m_y);

		m_info.m_y += CALCY(m_info.m_LnSpc);
	}
	m_DC.SelectObject (oldPen);
}
Пример #13
0
BOOL
PrintLine(
    IN HANDLE PrinterDC,
    IN LPTSTR LineBuffer
    )

/*++

Routine Description:

    PrintLine - Send the line to the printer and keep track of page lines.

Arguments:

    PrinterDC -  HDC of the printer
    LineBuffer - The line to print

Return Value:

    BOOL - TRUE if we successfully printed the line, FALSE otherwise.

--*/

{

    int     iLen;
    int     xLeft;
    int     yTop;

    //
    // Set the first line of the report to be indented 5 spaces
    // and down one line.
    //

    xLeft = CharWidth * 5;
    yTop =  CharHt;

    //
    // Validate the Printer DC.
    //

    DbgHandleAssert( PrinterDC );

    if( PrinterDC == NULL || PrinterDC == INVALID_HANDLE_VALUE )

        return FALSE;

    //
    // Validate the buffer.
    //

    DbgPointerAssert( LineBuffer );

    if( LineBuffer == NULL )

        return FALSE;

    //
    // Check the string length.
    //

    iLen = lstrlen( LineBuffer );

    //
    // If we have data, print the line.
    //

    if ( iLen ) {

       //
       // Print the line.
       //

       TextOut( PrinterDC,
                xLeft,
                yTop * LineNumber++,
                LineBuffer,
                iLen
               );
    }

    //
    // See if we're at the end of a page
    //

    if( LineNumber >= MaxLines ) {

        NewPage( PrinterDC );

        LineNumber = 1;
    }

}