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 » Custom/Weird Array Setup
Re: Custom/Weird Array Setup [message #46247 is a reply to message #46246] Fri, 01 April 2016 21:38 Go to previous messageGo to previous message
Lance is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: VC++ on Linux?
Next Topic: upp-mingw-9671 with win\upp9628 SOLVED
Goto Forum:
  


Current Time: Thu Jun 06 14:56:33 CEST 2024

Total time taken to generate the page: 0.01942 seconds