wxShapeFramework: creating new shape Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

wxShapeFramework: creating new shape

Post by leiradella » Fri May 15, 2009 3:25 am

Hi All,

I want to create a new wxShapeFramework shape. I took a look at the samples and made some tests that almost worked.

The problem is that my shape is in fact a collection of other shapes. It has a wxSFRoundRectShape as it's core and 1 or more wxSFCircleShape outside the core but touching its border (see attached picture.)

My first try was to subclass a wxSFRoundRectShape and add the circles as it's children, but I couldn't make them stay outside the rectangle.

Now I'm subclassing wxSFShapeBase, and adding both the rectangle and the circles as it's children. The shape draws ok on the screen, but when I drag the rectangle or one of the circles the other shapes stay put.

How can I make a composite shape where all shapes are dragged together?

Thanks,

Andre
Attachments
node.png
node.png (3.38 KiB) Viewed 881 times

valiyuneski
Earned a small fee
Earned a small fee
Posts: 14
Joined: Thu Dec 11, 2008 3:01 pm

Post by valiyuneski » Fri May 15, 2009 7:53 am

Code: Select all

void SomeApp::ReShape(bool bMultipleRegion, int iSize)
{
	m_bMultipleRegion = bMultipleRegion;
	
	//CleanUp
	CleanUp();

	if(m_bMultipleRegion)
	{
		// Create Frame Bitmap
		wxImage pImageLeft = wxMEMORY_IMAGEEX(main_left, wxBITMAP_TYPE_PNG);
		pImageLeft.InitAlpha();
		pImageLeft.ConvertAlphaToMask();
		m_pFrameBitmapLeft = new wxBitmap(pImageLeft);
		//m_pFrameBitmapLeft->SetMask(new wxMask(*m_pFrameBitmap, *wxWHITE));
		
		wxImage pImageRight = wxMEMORY_IMAGEEX(main_right, wxBITMAP_TYPE_PNG);
		pImageRight.InitAlpha();
		pImageRight.ConvertAlphaToMask();	
		m_pFrameBitmapRight = new wxBitmap(pImageRight);
		//m_pFrameBitmapRight->SetMask(new wxMask(*m_pFrameBitmap, *wxWHITE));
			
		// Create Region From 2 PNG's
		m_pRegion = new wxRegion;
		m_pRegion->Union(*m_pFrameBitmapLeft);
		m_pRegion->Offset(m_pFrameBitmapLeft->GetWidth() + SPACING, 0);
		m_pRegion->Union(*m_pFrameBitmapRight);
	}
	else
	{
		wxImage pImage;
		if(m_iSize == SMALL)
			pImage = wxMEMORY_IMAGEEX(main_minimized, wxBITMAP_TYPE_PNG);
		else
			pImage = wxMEMORY_IMAGEEX(main_large, wxBITMAP_TYPE_PNG);

		pImage.InitAlpha();
		pImage.ConvertAlphaToMask();	
		m_pFrameBitmap = new wxBitmap(pImage);
		//m_pFrameBitmap->SetMask(new wxMask(*m_pFrameBitmap, *wxWHITE));
			
		// Create Region From 2 PNG's
		m_pRegion = new wxRegion;
		m_pRegion->Union(*m_pFrameBitmap);		
	}
	
	// Set Window Region
	SetShape(*m_pRegion);

	// Post Resize Event To OurSelves
	wxCommandEvent event(wxEVT_SIZE);
	wxPostEvent(this, event);
}
EDIT by Auria : Please use code tags

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Fri May 15, 2009 2:44 pm

Sorry, but how exactly does this help me?

Thanks,

Andre

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Sun May 17, 2009 5:31 pm

I've decided to drop wxSF in favor of wxArt2D. I've tried many things and wxSF just don't support grouping shapes together, at least without changing wxSF itself, something I'm not willing to do.

I'm not impressed with wxArt2D so far:

1. The only way to download it is via cvs which doesn't come with Windows.

2. You have to configure it with CMake which, despite all I read over the Internet, *never* worked for me. I end up editing the *ugly* CMakeLists.txt files until I manage to make the damn thing generate something I can tweak.

I've been configuring and compiling open source software for Windows for 10+ years and CMake is just as horrible as Makefiles with the difference that Makefiles are easier to customize.

Maybe it's just my lack of knowledge about CMake, or the lack of good CMake programming (?) skills of those who use it with their software, but the end result is the same: I usually drop the software in favor of another, similar one which doesn't use CMake.

Unfortunately it's not the case of wxArt2D. In fact it's my last hope before I go back to my Canvas class which already does a lot of things, so it'll be just a matter of adding drag and drop support.

Sorry for rambling here.

Cheers,

Andre

Post Reply