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 » ArrayCtrl, HeaderCtrl & GridCtrl » Cells appearance and text alignment
Cells appearance and text alignment [message #25189] Sat, 13 February 2010 17:22 Go to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
I've got 2 small problems shown in attached image.
Is there a symple way to do it ?

Ciao

Max
index.php?t=getfile&id=2256&private=0
  • Attachment: ArrayCtrl.jpg
    (Size: 41.28KB, Downloaded 701 times)
Re: Cells appearance and text alignment [message #25190 is a reply to message #25189] Sat, 13 February 2010 18:45 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
mdelfede wrote on Sat, 13 February 2010 17:22


Is there a symple way to do it ?


Yes, there is.
Just use AttrText struct:
ArrayCtrl list;

list.AddColumn("x1 (cm)").HeaderTab().SetAlign(ALIGN_RIGHT);
list.AddColumn();

for (int i = 0; i < 10; ++i)
{
	const String data(AsString(i));
	list.Add(AttrText(data).Align(ALIGN_RIGHT), AttrText(data).Paper(SColorFace()).Ink(SBlack()));
}
Re: Cells appearance and text alignment [message #25193 is a reply to message #25190] Sat, 13 February 2010 19:11 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Hi, thanx again Smile

But I forgot to mention 2 stuffs :

1) I'd like to keep previous value in cell, just hide them
when they shouldn't be selectable
2) I'm using embedded editfields, which isn't maybe a good idea
(just used because of checks on valid characters...)

Anyways, if I've read well the docs, using AttrText makes it difficult to read back value from arrayctrl.

Maybe I'll try it anyways Smile

Ciao

Max
Re: Cells appearance and text alignment [message #25195 is a reply to message #25193] Sat, 13 February 2010 19:27 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Wellm first problem solved with SetDisplay() and NoEdit() :

class _StaticDisplay : public Display
{
	public:
	
	virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
	{
		StdDisplay().Paint(w, r, q, SColorText(), SColorFace, 0);
	}
};

Display const &StaticDisplay(void)
{
	static _StaticDisplay disp;
	
	return (Display const &)disp;
}

......................
loads.AddColumn("").Margin(0).SetDisplay(StaticDisplay()).NoEdit();



Ciao

Max
Re: Cells appearance and text alignment [message #25196 is a reply to message #25193] Sat, 13 February 2010 19:33 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
mdelfede wrote on Sat, 13 February 2010 19:11


Anyways, if I've read well the docs, using AttrText makes it difficult to read back value from arrayctrl.


Not really. The AttrText struct is "raw value type" in ArrayCtrl.
For previous example you can use following code to display it:
int index = list.GetCursor();

AttrText data = ValueTo<AttrText>(list.Get(index, 1));

PromptOK(AsString(data.text));


After read your third message here:
Yes, there is other possibilities like using Display.
May be, hard tools are relative for this complex task.

[Updated on: Sat, 13 February 2010 19:46]

Report message to a moderator

Re: Cells appearance and text alignment [message #25198 is a reply to message #25196] Sat, 13 February 2010 20:12 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Now, last problem (I hope !)

All works, but I can't disable/enable editing with an embedded control for selected cell(s).
Any way to do it ?

Ciao

Max


Re: Cells appearance and text alignment [message #25201 is a reply to message #25198] Sat, 13 February 2010 20:33 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
mdelfede wrote on Sat, 13 February 2010 20:12


All works, but I can't disable/enable editing with an embedded control for selected cell(s).
Any way to do it ?


Try to use SetCtrl method of ArrayCtrl. Assign disabled and enabled ctrls to cells.
Also read about SetFormat and SetConvert methods for checks on valid characters.
Re: Cells appearance and text alignment [message #25202 is a reply to message #25201] Sat, 13 February 2010 20:47 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Hi Sender Ghost,

Sender Ghost wrote on Sat, 13 February 2010 20:33

mdelfede wrote on Sat, 13 February 2010 20:12


All works, but I can't disable/enable editing with an embedded control for selected cell(s).
Any way to do it ?


Try to use SetCtrl method of ArrayCtrl. Assign disabled and enabled ctrls to cells.
Also read about SetFormat and SetConvert methods for checks on valid characters.


Thank you, but it seems to me quite complicated... I must then keep an external array of controls in sync with ArrayCtrl when adding/removing rows.
It would be better to have this in ArrayCtrl.h :

Ctrl &GetEmbeddedCtrl(int i, int j) { return *GetCtrl(i, j).ctrl; }


I added it and it works fine, allowing enable/disable of embedded controls :

arrayCtrl.GetEmbeddedCtrl(line, col).Disable();
arrayCtrl.GetEmbeddedCtrl(line, col).Enable();


Mirek, would it be possible to have it added to main tree ?
The name is not the best, but GetCtrl() (which would be better...) is already used as a private function.

If not possible, it would be also enough a Enable(i, j)/Disable(i, j) pair, to allow single cell control of editing.

Last possibility.... make GetCtrl() protected, so I can derive from ArrayCtrl, if all above isnt' acceptable... Now it's private Smile

Ciao

Max

[Updated on: Sat, 13 February 2010 20:51]

Report message to a moderator

Re: Cells appearance and text alignment [message #25203 is a reply to message #25202] Sat, 13 February 2010 21:05 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Here the final (wanted!) result :

index.php?t=getfile&id=2259&private=0
  • Attachment: ArrayCtrl.jpg
    (Size: 30.03KB, Downloaded 593 times)
Re: Cells appearance and text alignment [message #25213 is a reply to message #25203] Sun, 14 February 2010 13:59 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
I guess, you need to redesign control flow of your program.
As example I made simplified version of the program from your screenshot. You can find sources in attachments.

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

[Updated on: Sun, 14 February 2010 14:22]

Report message to a moderator

Re: Cells appearance and text alignment [message #25219 is a reply to message #25213] Sun, 14 February 2010 18:12 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
Mhhhh... quite interesting solution indeed Smile
Even if I prefere the embedded ctrl solution, because of better editing (imo...) with a single click on ctrl.

But I like your way... have to think about.

Thanx again, Sender Ghost Smile

Ciao

Max
Re: Cells appearance and text alignment [message #25304 is a reply to message #25193] Tue, 16 February 2010 20:56 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mdelfede wrote on Sat, 13 February 2010 13:11

Hi, thanx again Smile

But I forgot to mention 2 stuffs :

1) I'd like to keep previous value in cell, just hide them
when they shouldn't be selectable



Note: You can combine two "indicies" into single cell (one for value, another bool for 'hide'). Then display this compound value.

Mirek
Previous Topic: How to Setup ArrayCtrl colors ?
Next Topic: GridCtrl large data set from DB
Goto Forum:
  


Current Time: Fri Mar 29 13:37:16 CET 2024

Total time taken to generate the page: 0.01308 seconds