Home » Community » Newbie corner » Custom/Weird Array Setup
Re: Custom/Weird Array Setup [message #46247 is a reply to message #46246] |
Fri, 01 April 2016 21:38 |
Lance
Messages: 533 Registered: March 2007
|
Contributor |
|
|
To save you some search into GridCtrl code. Also, text clipping added.
#include <GridCtrl/GridCtrl.h>
#include <RichText/RichText.h>
using namespace Upp;
// An adhoc protocol
// A cell will merge all consective cells right to it and with Null value.
//
// note, there is still (at least) one missing piece, the text is not clipped to cell rect
class QtfGridDisplay : 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)
{
GridCtrl *p=this->parent;
Color rbg=parent->Get(row,0)!=1? bg: (style&GD::CURSOR)? Color(0,200,85):Color(0,250,128);
int realcx=cx;
if(col!=1 && IsNull(p->Get(row,col)))
return; // the cell is merged, so no painting for it
for(int c=col+1; c<p->GetColumnCount();++c)
if(IsNull(p->Get(row,c)))
realcx+=p->GetWidth(c+2);
else
break;
w.DrawRect(x,y,realcx,cy, rbg);
w.Clip(x,y,realcx,cy);
DrawSmartText(w,x,y,realcx,String(val),fnt,fg);
w.End();
}
static QtfGridDisplay& get(){ static QtfGridDisplay d; return d; }
};
class GridHilite : public TopWindow {
public:
typedef GridHilite CLASSNAME;
GridHilite();
private:
GridCtrl grid1;
};
GridHilite::GridHilite()
{
grid1.AddHiddenColumn("bg");
grid1.AddColumn("Label");
grid1.AddColumn("Action");
grid1.AddColumn("NFC");
grid1.AddColumn("Description");
grid1.SetDisplay(QtfGridDisplay::get());
String s="\1[ [ [*+75 Set Flags]&][ [@5+75 MiguelFollowing`=true]&][ [@5+75 MiguelLeaving`=false]&][ [@5+75 MiguleWandering`=false]]]";
grid1.AddRow(1,"\1[*+75 Wander]",s).Height(GetSmartTextHeight(s,500));
//grid1.JoinCells(2,0,4,0);
grid1.AddRow(0,"","\1[*+75 Trigger]","","\1[*+75Trigger nsfwander]");
// Here are 4 plain text, I will put it in the 2nd column, and make it with hilite background;
String s1="Line 1";
String s2="grid1.VertGrid(false).HSizePosZ(2,2).VSizePosZ(2,2)";
String s3="grid1.AddColumn(\"Description\")";
String s4="OK, that's about it";
String combined=String().Cat()<<'\1'<<"[ [ [*+75 "<<DeQtf(s1)<<"]&]"
"[ [@5+75 "<<DeQtf(s2)<<"]&]" // use DeQtf to escape certain special characters
"[ [@5+75 "<<DeQtf(s3)<<"]&]" // use MainMenu->Assist->QtfDesigner to get markup strings.
"[ [@5+75 "<<DeQtf(s4)<<"]]";
grid1.AddRow(1,"",combined,Null,"\1[*+75 Here]")
.Height(GetSmartTextHeight(s,500));
grid1.VertGrid(false).HSizePosZ(2,2).VSizePosZ(2,2);
Add(grid1);
}
GUI_APP_MAIN
{
GridHilite().Run();
}
[Updated on: Fri, 01 April 2016 21:39] Report message to a moderator
|
|
|
|
|
Custom/Weird Array Setup
By: bempson on Sat, 26 March 2016 12:01
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Sat, 26 March 2016 20:28
|
|
|
Re: Custom/Weird Array Setup
By: Novo on Sat, 26 March 2016 23:22
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Sun, 27 March 2016 05:07
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Sun, 27 March 2016 10:50
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Sun, 27 March 2016 12:58
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Mon, 28 March 2016 00:52
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Mon, 28 March 2016 01:31
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Mon, 28 March 2016 09:00
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Fri, 01 April 2016 06:17
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Fri, 01 April 2016 21:20
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Fri, 01 April 2016 21:38
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Sat, 02 April 2016 11:54
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Sat, 02 April 2016 23:57
|
|
|
Re: Custom/Weird Array Setup
By: bempson on Sun, 03 April 2016 01:33
|
|
|
Re: Custom/Weird Array Setup
By: Lance on Sun, 03 April 2016 14:10
|
Goto Forum:
Current Time: Thu Jun 06 14:56:33 CEST 2024
Total time taken to generate the page: 0.01942 seconds
|