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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Porting a Delphi Application
Re: Porting a Delphi Application [message #11616 is a reply to message #11610] Wed, 19 September 2007 12:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 19 September 2007 05:07

On the other hand ToolButton doesn't refresh if I call Check(false) after it has been set to true if it is not inserted into a ToolBar. I get the distinct feeling that ToolButton was no intended to be used on it's own.



Your distinct feeling is correct Wink

Quote:


And AFAIK there is no GetCheck or other method to verify if it is checked or not. ButtonOption has such capabilities.



Yes. ToolButton is specifically dedicated to be used with ToolBar and there you never access the button instance.

Mirek
Re: Porting a Delphi Application [message #11619 is a reply to message #11616] Wed, 19 September 2007 12:49 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Well I still need a button with a flat skin and random position. I'll try some experimets with multiple ToolBars and if they don't work maybe I'll fork ButtonOption to have an optional flat skin.
Re: Porting a Delphi Application [message #11623 is a reply to message #11619] Wed, 19 September 2007 14:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
cbpporter wrote on Wed, 19 September 2007 06:49

Well I still need a button with a flat skin and random position. I'll try some experimets with multiple ToolBars and if they don't work maybe I'll fork ButtonOption to have an optional flat skin.


Well,

1) Maybe you can just use chameleon to skin ButtonOption. ("SetStyle").

2) "Was intended" does not mean that ToolButton cannot be extended for other uses.

Mirek
Re: Porting a Delphi Application [message #11628 is a reply to message #11623] Wed, 19 September 2007 20:32 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
I have a little problem with XML loading. I couldn't find any documentation on the site so I looked at the provided examples and the Xml loader source code. Everything seems pretty straightforward and the examples work.

But I need something a little different. I need to keep the entire Xml tree in memory and populate several different trees (consider these trees as "View" and the Xml as the "model" with data computed on base of the Xml by traversing the Xml saved in the memory (multiple times). I also need to modify the Xml and save it.

So I used the ParseXml function to obtain an XmlNode, and used GetCount and assorted functions to traverse recursively it's children. For the first "view" I tried a simple mapping of the structure into a TreeCtrl. But as hard as I tried, I could get anything except a tree with an empty root and a child which has the filename as a child.

Which is the proper way to load a Xml like in the XmlView example, but by maintaining a copy of the Xml in memory?
Re: Porting a Delphi Application [message #11632 is a reply to message #11628] Wed, 19 September 2007 21:42 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
Check AddressBookXML2 example app.
Re: Porting a Delphi Application [message #11633 is a reply to message #11632] Wed, 19 September 2007 21:49 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
zsolt wrote on Wed, 19 September 2007 21:42

Check AddressBookXML2 example app.

I did. I guess I have to do more in depth debugging of why it doesn't work.

On the other hand, I changed a method in ToolButton and the control now refreshes itself when Check status is updated. A further optimisation could be to check if it's parent is a ToolBar, and don't refresh in that case.

Bar::Item& ToolButton::Check(bool check)
{
	if (checked != check)
	{
		checked = check;
		Refresh();
	}
	return *this;
}


Re: Porting a Delphi Application [message #11636 is a reply to message #11633] Wed, 19 September 2007 22:26 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Nevermind my problem with Xml. It was my fault. I used:
XmlNode node = ParseXML(filename);

instead of:
String d = LoadFile(filename);
XmlNode node = ParseXML(d);


The ParseXml declaration has a char* parameter named s, and I thought if was the filename.
Re: Porting a Delphi Application [message #11655 is a reply to message #11636] Thu, 20 September 2007 18:24 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Does anybody have any experience installing and using Cairo under windows to render into a control? I would use built-in functions, but I need something powerful and Mirek said that the graphic libs are not that powerful anyway.
Re: Porting a Delphi Application [message #11656 is a reply to message #11475] Thu, 20 September 2007 19:37 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
There been some experiments with AGG, search the forum.
(And I'm not sure if AGG will suffice to your needs)

I don't remember reading in forums about anyone trying to use Cairo inside Upp.
Re: Porting a Delphi Application [message #11690 is a reply to message #11656] Fri, 21 September 2007 20:12 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Well compiling Cairo under U++ sure is hell, I couldn’t get any significant progress so I decided to use the precompiled Windows dll and try to integrate that into U++ control drawing. But before that I have some problems with accessing TreeControl items.
I am trying to insert an TreeNodes with the key as the tag name of a xml tag and the value as the actual XmlNode. On WhenSel I need to obtain that XmlNode and create an object based on it's content.

But I get a dynamic_cast exception when I try to do this.

void MainWindow::Load(int parent, const XmlNode& p)
{
	int t = xml.Add(parent, CBPImages::Move(), p.GetTag(), p);
	for (int i = 0; i < p.GetCount(); i++)
		Load(t, p[i]);
}

void MainWindow::Load(const char *filename)
{
	try 
	{
		XmlNode node = ParseXML(LoadFile(filename));
		int t = xml.Add(0, CBPImages::Move(), "Image", node);
		for (int i = 0; i < node.GetCount(); i++)
			Load(t, node[i]);
	}
	catch (XmlError e)
	{
		PromptOK("XMLError");
	}
}

void MainWindow::SelectItem()
{
	const XmlNode& node = ValueTo<XmlNode>(xml.GetValue());
	lbl.SetLabel(node.GetTag());
}

Re: Porting a Delphi Application [message #11695 is a reply to message #11690] Sat, 22 September 2007 00:22 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
You cannot add XmlNode directly this way - it is not a Value compatible type.

What indeed happens is that XmlNode -> Value conversion is in fact XmlNode -> operator bool() -> Value. So in fact, you are storing into tree a bool value that indicates whether XmlNode contains subnodes...

Then, later, bool cannot be converted to XmlNode -> dynamic cast error.

Mirek
Re: Porting a Delphi Application [message #11696 is a reply to message #11695] Sat, 22 September 2007 00:25 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1405
Registered: September 2007
Ultimate Contributor
Actually I did some testing and I'm reasonably sure that it is converted to a String (Value::ToString). Did IsType check and ValueTo<String> returns the key in the TreeCtrl.

So how could I store some extra info into nodes?
Re: Porting a Delphi Application [message #11697 is a reply to message #11696] Sat, 22 September 2007 01:39 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Soerry, my mistake, you are right. You are getting the key value back, which was added as GetTag. The XmlNode bool was added into value (the think which is about to be displayed).

Well, you can add almost anything as Value key to the TreeCtrl. See Value related reference examples.

Mirek
Previous Topic: How to write a dll using Ultimate++?
Next Topic: embedded configuration data/values in self for a executable
Goto Forum:
  


Current Time: Sat Jun 15 15:49:17 CEST 2024

Total time taken to generate the page: 0.02238 seconds