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 » Community » Newbie corner » GridCtrl + rich texts
GridCtrl + rich texts [message #36973] Thu, 02 August 2012 14:29 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 139
Registered: December 2011
Experienced Member

Hello guys,
is it possibile to active QTF format inside GridCtrl grid?
I'd like to use Superscript['] and Subscript [,] that's working fine on layouts but not inside grid...

[` superscript]
[, subscript]

any suggestion?

thanks,
Matteo


Re: GridCtrl + rich texts [message #36980 is a reply to message #36973] Fri, 03 August 2012 18:19 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 541
Registered: November 2008
Location: France
Contributor
Hi Matteo,

Try to use 'AttrText' ( look at 'Display' in U++ help ) it will probably work (although I nerver tried )

Re: GridCtrl + rich texts [message #36982 is a reply to message #36973] Fri, 03 August 2012 21:39 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Matteo.
idkfa46 wrote on Thu, 02 August 2012 14:29

Is it possibile to active QTF format inside GridCtrl grid?

Yes, it's possible to create special GridQTFDisplay class (inherited from GridDisplay), which uses QTFDisplay Paint function.

index.php?t=getfile&id=3823&private=0

#include <GridCtrl/GridCtrl.h>
#include <RichText/RichText.h>

using namespace Upp;

class GridQTFDisplay : public GridDisplay {
public:
	virtual void Paint(Draw& w, int x, int y, int cx, int cy, const Value& val, dword style,
		Color& fg, Color& bg, Font& fnt, bool found, int fs, int fe)
	{
		QTFDisplay().Paint(w, RectC(x, y, cx, cy), val, fg, bg, style);
	}
};

class App : public TopWindow {
public:
	typedef App CLASSNAME;
	App();

	GridCtrl list;
};

App::App()
{
	Title("GridCtrl with QTF Display");
	Sizeable().Zoomable();
	const Size sz(480, 320);
	SetRect(sz); SetMinSize(sz);

	list.Chameleon();
	list.AddColumn("x", 10);
	list.AddColumn("y", 10);
	list.AddColumn("Equation", 50).SetDisplay(Single<GridQTFDisplay>()).HeaderAlignCenter();
	list.AddColumn("Equal");

	for (int i = 0, x = 1, y = 2; i <= 10; ++i, ++x, ++y)
		list.Add(x, y, Format("[= [1 (x + y)][` %d][1  = %d][` %d]]", i, x + y, i),
			pow(double(x + y), i));

	Add(list.VSizePosZ(4, 4).HSizePosZ(4, 4));
}

GUI_APP_MAIN
{
	App app;
	app.Run();
}

[Updated on: Fri, 03 August 2012 23:16]

Report message to a moderator

Re: GridCtrl + rich texts [message #36985 is a reply to message #36982] Sat, 04 August 2012 15:38 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3129
Registered: August 2008
Ultimate Member
Nice example.

I did not know it was possible.


Best regards
IƱaki
Re: GridCtrl + rich texts [message #36987 is a reply to message #36973] Sun, 05 August 2012 00:38 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 139
Registered: December 2011
Experienced Member

Oh... Thanksssssss!!!! GridQTFDisplay class and example are fantastic !!!!
Just one more stupid question....

I was trying to change column alignment (with QTFDisplay) by .alignLeft() but nothing happen ... It's always at center Sad

regards,
Matteo
Re: GridCtrl + rich texts [message #36988 is a reply to message #36987] Sun, 05 August 2012 01:53 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
idkfa46 wrote on Sun, 05 August 2012 00:38

I was trying to change column alignment (with QTFDisplay) by .AlignLeft() but nothing happen ... It's always at center

Technically, the GridQTFDisplay class forwarding GridDisplay Paint function through QTFDisplay Paint function, which doesn't use information about style variable, therefore GridCtrl align functions not applicable here.

Just use QTF paragraph formatting, e.g. "[< Left]", "[= Center]", "[> Right]", but "<" is by default (and not necessary for this case).
Now, you could understand why it was on the center.

[Updated on: Sun, 05 August 2012 02:26]

Report message to a moderator

Re: GridCtrl + rich texts [message #36990 is a reply to message #36982] Sun, 05 August 2012 12:32 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1100
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

I guess it should work for ArrayCtrl too.
I vote to move this example in the reference or examples assembly.

Luigi
Re: GridCtrl + rich texts [message #36992 is a reply to message #36990] Sun, 05 August 2012 15:51 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Luigi.
forlano wrote on Sun, 05 August 2012 12:32

I guess it should work for ArrayCtrl too.

Yes, QTFDisplayCls, which inherited from Display, could be used inside many Ctrls, which supports SetDisplay function with Display argument, e.g. ArrayCtrl, ColumnList, DropList, TreeCtrl, etc.
Toggle Spoiler

forlano wrote on Sun, 05 August 2012 12:32

I vote to move this example in the reference or examples assembly.

I agree (with some variation of contents). But this is undocumented functionality and question to developer(s) of RichText U++ package.

Edit: Fixed QTF formatted text.

[Updated on: Thu, 09 August 2012 15:43]

Report message to a moderator

Re: GridCtrl + rich texts [message #36993 is a reply to message #36973] Sun, 05 August 2012 16:23 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 139
Registered: December 2011
Experienced Member
Thank you! Working good...
Re: GridCtrl + rich texts [message #36995 is a reply to message #36993] Sun, 05 August 2012 20:49 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 541
Registered: November 2008
Location: France
Contributor
I also searched for the same function some time ago.

It sure would have saved me some precious time !!
Re: GridCtrl + rich texts [message #37000 is a reply to message #36973] Tue, 07 August 2012 02:35 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
I thought about generalized way to access Display through GridDisplay and made following example with templates:

index.php?t=getfile&id=3828&private=0

Toggle Spoiler

Edit: Replaced DisplayWithIcon with CustomDisplayWithIcon class, which draws background rectangle to fix icon drawing issue (and possibly other Display without background rectangle) on GridCtrl cell. Optimized DisplayToGrid initialization.

[Updated on: Sat, 11 August 2012 14:04]

Report message to a moderator

Re: GridCtrl + rich texts [message #37023 is a reply to message #37000] Thu, 09 August 2012 13:48 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1100
Registered: March 2006
Location: Italy
Experienced Contributor
Hello,

unfortunately I can't now test it myself, but I wonder how this class interact with the AsQtf() method of arrayCtrl.
I hope the qtf code sent in the cells will survive in qtf file to produce a nice output.

Luigi
Re: GridCtrl + rich texts [message #37024 is a reply to message #37023] Thu, 09 August 2012 15:14 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
forlano wrote on Thu, 09 August 2012 13:48

I wonder how this class interact with the AsQtf() method of ArrayCtrl.

If you meant GridDisplay based classes, then they not related to ArrayCtrl, because it uses Display based classes. Moreover, Display and GridDisplay classes used to render input Value. Therefore, they not interact with AsQtf method of ArrayCtrl.

I tested AsQtf method of ArrayCtrl with QTF formatted texts and its (correct) output works inside QTF designer of TheIDE.

Further, I tested QTF formatted texts for examples inside this topic. And I found one mistake:
[1 [* (]x + y[* )]]][` %d]

which I fixed to:
[1 [* (]x + y[* )]][` %d]

[Updated on: Thu, 09 August 2012 15:43]

Report message to a moderator

Re: GridCtrl + rich texts [message #37026 is a reply to message #37024] Thu, 09 August 2012 19:17 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1100
Registered: March 2006
Location: Italy
Experienced Contributor
Sender Ghost wrote on Thu, 09 August 2012 15:14

forlano wrote on Thu, 09 August 2012 13:48

I wonder how this class interact with the AsQtf() method of ArrayCtrl.

If you meant GridDisplay based classes, then they not related to ArrayCtrl, because it uses Display based classes. Moreover, Display and GridDisplay classes used to render input Value. Therefore, they not interact with AsQtf method of ArrayCtrl.

I tested AsQtf method of ArrayCtrl with QTF formatted texts and its (correct) output works inside QTF designer of TheIDE.

Further, I tested QTF formatted texts for examples inside this topic. And I found one mistake:
[1 [* (]x + y[* )]]][` %d]

which I fixed to:
[1 [* (]x + y[* )]][` %d]



I meant the class equivalent of GridDisplay but for ArrayCtrl. There we have for free the AsQtf method. So what we will see on the screen will be rendered in a qtf document as well. If I have understood it should work.

Thanks,
Luigi

Re: GridCtrl + rich texts [message #37028 is a reply to message #37026] Thu, 09 August 2012 20:42 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
forlano wrote on Thu, 09 August 2012 19:17

I meant the class equivalent of GridDisplay but for ArrayCtrl. There we have for free the AsQtf method. So what we will see on the screen will be rendered in a qtf document as well.

Sorry about my wrong guess. Seems like, I thought about reply message instead of this one first.
forlano wrote on Thu, 09 August 2012 19:17

If I have understood it should work.

Paraphrasing, yes, the QTFDisplayCls class (also) works inside ArrayCtrl and its correct input Value creates correct output inside AsQtf method.
By input Value I meant QTF formatted text. Without QTFDisplayCls you will see not preprocessed QTF formatted text, but inside QTF designer you will see preprocessed output without reference to applied (or not applied) QTFDisplayCls class.

index.php?t=getfile&id=3830&private=0

I fixed some issues after your message.
Thank you too.

[Updated on: Thu, 09 August 2012 22:01]

Report message to a moderator

Re: GridCtrl + rich texts [message #37029 is a reply to message #37028] Thu, 09 August 2012 22:09 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1100
Registered: March 2006
Location: Italy
Experienced Contributor
Nice job Sender! Very Happy

I hope to include it in my app very soon.

Thanks,
Luigi
Re: GridCtrl + rich texts -- Array Control [message #50394 is a reply to message #36992] Sun, 14 October 2018 10:19 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 220
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

I am using this very old thread.

I want to have colors in grid and array controls. Want to use QTFDisplay.

ArrayCtrl example

#include <CtrlLib/CtrlLib.h>
#include <RichText/RichText.h>

using namespace Upp;

class App : public TopWindow {
public:
	typedef App CLASSNAME;
	App();

	ArrayCtrl list;
};

App::App()
{
	Title("ArrayCtrl with QTF Display");
	Sizeable().Zoomable();
	const Size sz(480, 340);
	SetRect(sz); SetMinSize(sz);

	list.AutoHideSb();
	list.SetLineCy(Draw::GetStdFont().GetCy() + 8);
	list.AddColumn("QTF");
	list.AddColumn("QTF Display").SetDisplay(QTFDisplay());

	const String qtf("[@G [1 [* (]x + y[* )]][` %d]]");
	for (int i = 0; i <= 10; ++i) {
		const String text(Format(qtf, i));
		list.Add(text, text);
		DUMP(text);
	}

	Add(list.VSizePosZ(4, 4).HSizePosZ(4, 4));
}

GUI_APP_MAIN
{
	App app;
	app.Run();
}


const String qtf("[@G [1 [* (]x + y[* )]][` %d]]"); "[@G ...]" Gives correct forground color.
"[$G ...] this will not render background Color

index.php?t=getfile&id=5675&private=0


Warm Regards

Deepak
Re: GridCtrl + rich texts [message #50395 is a reply to message #36982] Sun, 14 October 2018 13:34 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 220
Registered: July 2011
Location: Bangalore
Experienced Member
Sender Ghost wrote on Sat, 04 August 2012 01:09
Hello, Matteo.
idkfa46 wrote on Thu, 02 August 2012 14:29
Is it possibile to active QTF format inside GridCtrl grid?

Yes, it's possible to create special GridQTFDisplay class (inherited from GridDisplay), which uses QTFDisplay Paint function.

index.php?t=getfile&id=3823&private=0

#include <GridCtrl/GridCtrl.h>
#include <RichText/RichText.h>

using namespace Upp;

class GridQTFDisplay : public GridDisplay {
public:
	virtual void Paint(Draw& w, int x, int y, int cx, int cy, const Value& val, dword style,
		Color& fg, Color& bg, Font& fnt, bool found, int fs, int fe)
	{
		QTFDisplay().Paint(w, RectC(x, y, cx, cy), val, fg, bg, style);
	}
};

class App : public TopWindow {
public:
	typedef App CLASSNAME;
	App();

	GridCtrl list;
};

App::App()
{
	Title("GridCtrl with QTF Display");
	Sizeable().Zoomable();
	const Size sz(480, 320);
	SetRect(sz); SetMinSize(sz);

	list.Chameleon();
	list.AddColumn("x", 10);
	list.AddColumn("y", 10);
	list.AddColumn("Equation", 50).SetDisplay(Single<GridQTFDisplay>()).HeaderAlignCenter();
	list.AddColumn("Equal");

	for (int i = 0, x = 1, y = 2; i <= 10; ++i, ++x, ++y)
		list.Add(x, y, Format("[= [1 (x + y)][` %d][1  = %d][` %d]]", i, x + y, i),
			pow(double(x + y), i));

	Add(list.VSizePosZ(4, 4).HSizePosZ(4, 4));
}

GUI_APP_MAIN
{
	App app;
	app.Run();
}


In this example also QTF color not working. All other attributes working.
[@G ...] and [$Y ...]




Warm Regards

Deepak
Re: GridCtrl + rich texts [message #50396 is a reply to message #50395] Mon, 15 October 2018 11:43 Go to previous message
deep is currently offline  deep
Messages: 220
Registered: July 2011
Location: Bangalore
Experienced Member
Hi
I have done this. Which is working for me for GridCtrl.

It is not elegant but working.

Color in QFT must be given as "[@(nn.nn.nn) " or "[$(nn.nn.nn) "

class Gridqtfdisplay : public GridDisplay
{

	public:
		virtual void Paint ( Draw& w, int x, int y, int cx, int cy, const Value& val, dword style,
				Color& fg, Color& bg, Font& fnt, bool found, int fs, int fe )
		{
			String s;
			s = val;
			RegExp r1 ( "(\\[([\\@\\$])\\((\\d+)\\.(\\d+)\\.(\\d+)\\))", RegExp::UNICODE );

			while ( r1.GlobalMatch ( s ) )
			{

				if ( r1[1] == "@" )
					fg = Color ( StrInt ( r1[2] ), StrInt ( r1[3] ), StrInt ( r1[4] ) );

				if ( r1[1] == "$" )
					bg = Color ( StrInt ( r1[2] ), StrInt ( r1[3] ), StrInt ( r1[4] ) );
			}

			QTFDisplay().Paint ( w, RectC ( x, y, cx, cy ), val, fg, bg, style );
		}
};


Warm Regards

Deepak
Previous Topic: MoveableAndDeepCopyOption inherite to use a VectorMap ?
Next Topic: Adjusting the Z order of a dialog window?
Goto Forum:
  


Current Time: Thu Jun 04 06:25:35 CEST 2020

Total time taken to generate the page: 0.01920 seconds