Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Can I place picture in background of page?
Can I place picture in background of page? [message #40379] Sun, 28 July 2013 23:28 Go to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Can I place picture in background layer of page?

May I create background layer in QTF format too?


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Can I place picture in background of page? [message #40391 is a reply to message #40379] Mon, 29 July 2013 19:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
sergeynikitin wrote on Sun, 28 July 2013 17:28

Can I place picture in background layer of page?



You have to paint the background, then RichText over it. I am doing this in some of apps, it is not that hard...

Quote:

I create background layer in QTF format too?


No.
Re: Can I place picture in background of page? [message #40398 is a reply to message #40391] Tue, 30 July 2013 00:20 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

My question was about print on paper ability (sorry, that not point this)...

May I draw background picture/something while prepare report?

(It will be wished ability to draw Form design or background picture).


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Can I place picture in background of page? [message #40399 is a reply to message #40398] Tue, 30 July 2013 08:14 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, the answer is the same... Smile This is what I do, print some background picture (on the printer), then draw RichText over it.

One example is this code:

struct IsWatermark : RichText::Iterator
{
	bool operator()(int pos, const RichPara& para) {
		return para.format.label == "WATERMARK";
	}
};

void DocPrint::Print(Draw& w, const RichText& text, const Rect& page, int firstpage, int lastpage,
                     int copies, bool collate, bool report)
{
	IsWatermark iwm;
	bool watermark = text.Iterate(iwm);
	RichText watermark_text;
	int wh;
	int ph = Roman(75).Info().GetHeight();
	Size pgsz = page.Size();
	if(watermark) {
		watermark_text = ParseQTF(watermark_qtf);
		wh = watermark_text.GetHeight(pgsz.cx) + ph;
	}
	firstpage = max(0, firstpage);
	int lpage = text.GetHeight(page).page;
	lastpage = min(lastpage, text.GetHeight(page).page);
	PrintPageDraw pw(w);
	Size mmsz = w.GetPageMMs();
	int x = (6000 * mmsz.cx / 254 - pgsz.cx) / 2;
	int y = (6000 * mmsz.cy / 254 - pgsz.cy) / 2;
	if(report)
		x = y = 0;
	for(int c = 0; c < (collate ? copies : 1); c++)
		for(int i = firstpage; i <= lastpage; i++)
			for(int c = 0; c < (collate ? 1 : copies); c++) {
				w.StartPage();
				PaintInfo paintinfo;
				paintinfo.indexentry = Null;
				paintinfo.hyperlink = Null;
				if(watermark) {
					pw.SetPage(0);
					paintinfo.top = PageY(0, 0);
					paintinfo.bottom = PageY(1, 0);
					w.Offset(x, 6000 * mmsz.cy / 254 - wh);
					watermark_text.Paint(pw, page, paintinfo);
					w.End();
					String pg = Format("%d / %d", i + 1, lpage + 1);
					Size psz = GetTextSize(pg, Roman(75));
					w.DrawText(x + (pgsz.cx - psz.cx) / 2, 6000 * mmsz.cy / 254 - psz.cy,
					           pg, Roman(75), Gray);
				}
				w.Offset(x, y);
				pw.SetPage(i);
				paintinfo.top = PageY(i, 0);
				paintinfo.bottom = PageY(i + 1, 0);
				text.Paint(pw, page, paintinfo);
				w.End();
				if(!IsNull(header) && i)
					pw.Page(i).DrawText(x, y + pgsz.cy + 100, header, Arial(90).Italic());
				if(!IsNull(footer) && lpage && !watermark) {
					String n = Format(footer, i + 1, lpage + 1);
					Size nsz = GetTextSize(n, Arial(90).Italic());
					pw.Page(i).DrawText(
						x + pgsz.cx - nsz.cx, y + pgsz.cy + 100,
						n, Arial(90).Italic());
				}
				w.EndPage();
			}
}


In this case, background watermark is actually another QTF, which gets repeated at the end of each page printed.

Mirek
Previous Topic: Problem with Report preview
Next Topic: [RTF format] - change tables and pictures
Goto Forum:
  


Current Time: Thu Mar 28 17:56:29 CET 2024

Total time taken to generate the page: 0.01853 seconds