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 » Draw, Display, Images, Bitmaps, Icons » DrawImage with XOR undefined
DrawImage with XOR undefined [message #9067] Mon, 16 April 2007 15:15 Go to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
I am currently trying to use the following function from the help

Quote:


enum { EFFECT_MASK, STANDARD, GRAYED, ETCHED, XOR }

EFFECT_MASK bit mask covering all values of supported drawing effects
STANDARD Displays the image with its usual colors.
GRAYED Draws a grayed image, i.e. discards color information.
ETCHED Draws an 'etched' image outline (used e.g. in toolbars to mark 'disabled' buttons).
XOR Draws the image using the XOR bitwise operator. This is sometimes used for drag & drop where, during dragging, the desired image is being repeatedly displayed and removed using the same logical operation.


void DrawImage(const Rect& rect, const Image& img, int fx = 0)
Draws the whole image img into the rectangle rect relative to current coordinate origin.
rect Destination (output) rectangle (relative to current origin)
img Image to draw at the specified location.
fx Special drawing effects (see above).



I want to do exactly what it describes for drag and drop using XOR but when I compile I get XOR undefined. Is there something wrong with this please?

	w.DrawImage(rc1,m_image,XOR); 	
	w.DrawImage(rc2,m_image,XOR); 


Any help much appreciated.

Thanks,

Nick

p.s. I searched the upp/src for the terms XOR and ETCHED and got no hits apart from one comment. If the documentation is out of date, can anyone tell me what the current best way to do this is because I've looked through all the examples and reference and cannot find anything.


[Updated on: Mon, 16 April 2007 16:35]

Report message to a moderator

Re: DrawImage with XOR undefined [message #9070 is a reply to message #9067] Mon, 16 April 2007 17:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Mon, 16 April 2007 09:15

I am currently trying to use the following function from the help

Quote:


enum { EFFECT_MASK, STANDARD, GRAYED, ETCHED, XOR }

EFFECT_MASK bit mask covering all values of supported drawing effects
STANDARD Displays the image with its usual colors.
GRAYED Draws a grayed image, i.e. discards color information.
ETCHED Draws an 'etched' image outline (used e.g. in toolbars to mark 'disabled' buttons).
XOR Draws the image using the XOR bitwise operator. This is sometimes used for drag & drop where, during dragging, the desired image is being repeatedly displayed and removed using the same logical operation.


void DrawImage(const Rect& rect, const Image& img, int fx = 0)
Draws the whole image img into the rectangle rect relative to current coordinate origin.
rect Destination (output) rectangle (relative to current origin)
img Image to draw at the specified location.
fx Special drawing effects (see above).



I want to do exactly what it describes for drag and drop using XOR but when I compile I get XOR undefined. Is there something wrong with this please?

	w.DrawImage(rc1,m_image,XOR); 	
	w.DrawImage(rc2,m_image,XOR); 


Any help much appreciated.

Thanks,

Nick

p.s. I searched the upp/src for the terms XOR and ETCHED and got no hits apart from one comment. If the documentation is out of date, can anyone tell me what the current best way to do this is because I've looked through all the examples and reference and cannot find anything.





Sorry, obsolete documentation. Image was changed last year and required support of alpha chanel essentialy made these impossible...

Mirek
Re: DrawImage with XOR undefined [message #9071 is a reply to message #9070] Mon, 16 April 2007 18:33 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
woah! so there is no way to do what I need to do?

that's it? this functionality does not exist in upp in any form?

wow.

ok so I guess I need to sample the screen at the target rect somehow before I DrawImage and then paint it back later.

Just posting to check that this is really true: this functionality is completely abandoned.

Cheers,

Nick



Re: DrawImage with XOR undefined [message #9086 is a reply to message #9071] Tue, 17 April 2007 00:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Mon, 16 April 2007 12:33

woah! so there is no way to do what I need to do?

that's it? this functionality does not exist in upp in any form?

wow.

ok so I guess I need to sample the screen at the target rect somehow before I DrawImage and then paint it back later.

Just posting to check that this is really true: this functionality is completely abandoned.



What exactly are you trying to do?

Usually, it just OK to repaint the area... See e.g. Layout designer in TheIDE - there is a lot of dragging performed, but everything is done throught the repainting...

Mirek
Re: DrawImage with XOR undefined [message #9108 is a reply to message #9086] Tue, 17 April 2007 21:20 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
I am using RectTracker to grab a node from a TreeCtrl and drag it onto another node in order to change the tree hierarchy.

I've subclassed from RectTracker and overwritten its DrawRect routine. My only problem is that I erase the background so I need to sample it and replace it. I've tried the following approaches:

1) I can get the TreeCtrl to repaint itself but TreeCtrl::GetLineCount() falls over when I'm in the local loop so I can't ask the nodes to repaint themselves.

2) I tried refresh but it gets carried out after I draw the dragged image so even though I only refresh the rect containing the old position of the dragged node (i.e. rc1), it still erases most of the dragged node. If there was a way to refresh a rect minus another rect that would work (clipping?).

3) If I could do this by sampling the screen, I would be able to apply this method to other views in which a refresh takes a long time. However my attempts to sample the screen are so far not successful. See below:

void LayerTracker::DrawRect(Rect rc1,Rect rc2)
{	
	ViewDraw w(&GetMaster()); 
	
	w.DrawImage(rc1,m_screen);
	
	// sample screen at rc2
	ImageBuffer ib(rc2.Size());
	
	ImageBuffer buf = w;
	
	for(int i=0;i<rc2.Height();i++)
	{
		RGBA* pS = buf[rc2.top+i];
		RGBA* pB = ib[rc2.top+i];
		memcpy(pB,pS,rc2.Width());		
	}
	
	m_screen = ib;

	w.DrawImage(rc2,m_image); 

}


m_image and m_screen are or type Image. My problem is there is no conversion from ViewDraw to Image. Ideally I would use a function of this form

Image ViewDraw::GetImage(Rect rcSample)

Is there a way to sample screen pixels at present?


Nick

[Updated on: Tue, 17 April 2007 22:17]

Report message to a moderator

Re: DrawImage with XOR undefined [message #9109 is a reply to message #9108] Tue, 17 April 2007 21:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
nixnixnix wrote on Tue, 17 April 2007 15:20

I am using RectTracker to grab a node from a TreeCtrl and drag it onto another node in order to change the tree hierarchy.

I tried asking the tree control to redraw its nodes while I was in the RectTracker loop but it fell over due to some checks it performs on itself so am now thinking that the easiest way to do this is sample the screen while I'm tracking in the local loop and draw directly on the screen. Because I'm in the local loop I can't wait to refresh.

I've subclassed from RectTracker and overwritten its DrawRect routine. My only problem is that I erase the background so I need to sample it and replace it.

Another alternative would be to catch LeftDown, MouseMove and LeftUp but I like some of the default behavior or RectTracker so as long as my idea to sample the background works, am there.

Nick


I see. Well, right at the moment, I would rather tried radically different approach - make the tree out of Ctrl nodes, so that you can easily handle the drag&drop operation by them.

OTOH, I think this is a strong indication that we should do something with D&D soon...

Mirek
Re: DrawImage with XOR undefined [message #9111 is a reply to message #9109] Tue, 17 April 2007 22:13 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
oops I thought it was night in your time zone so I updated my question to make more sense - please see above as I've already tried your suggestion but GetLineCount() causes a crash.

[Updated on: Tue, 17 April 2007 22:18]

Report message to a moderator

Re: DrawImage with XOR undefined [message #9114 is a reply to message #9109] Wed, 18 April 2007 05:07 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
hmmm, I tried a callback to see if it was executed after the refresh but no luck.

Is the GetLineCount crash a bug or is it just my improper use of the function? I only ask because you have implied that I should be able to get run through the TreeCtrl's nodes and get them to redraw themselves but in order to do this I need to call GetLineCount

If there was a way of telling TreeCtrl to paint itself and all its nodes then this part of my puzzle would be over.

Cheers,

Nick

[Updated on: Wed, 18 April 2007 05:22]

Report message to a moderator

Re: DrawImage with XOR undefined [message #9120 is a reply to message #9114] Wed, 18 April 2007 11:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
This looks a little bit way too much complicated to me.

Why do not you just create a cursor instead drawing into TreeCtrl? Alternatively, if cursor would be too big, you can always drag small popup window in your local loop.

ViewDraw is reserved just for the most special situations...

Mirek

P.S.: Now I seriously see that sooner D&D is finalized, the better. We have been hesitating for too long.
Re: DrawImage with XOR undefined [message #9134 is a reply to message #9120] Wed, 18 April 2007 16:35 Go to previous message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks again Mirek,

I'll try keeping a list of the Nodes so I can access their ctrls and tell them to draw and if that doesnt work I'll try the popup window. After all this I now have a more general question but I'll start a new thread.

Cheers and thanks for helping me work through this,

Nick
Previous Topic: How to import iml from other class?
Next Topic: from window to image
Goto Forum:
  


Current Time: Fri Mar 29 00:23:39 CET 2024

Total time taken to generate the page: 0.01665 seconds