Page 1 of 1

Erratic plugin toolbar

Posted: Mon Aug 29, 2011 11:37 pm
by GlenboLake
The toolbar created by my plugin is displaying some extremely erratic behavior. Here's my CreateToolBar method:

Code: Select all

clToolBar *MyPlugin::CreateToolBar(wxWindow *parent)
{
	// Support both toolbars icon size
	int size = m_mgr->GetToolbarIconSize();

	clToolBar *tb(NULL);
	if (m_mgr->AllowToolbar())
	{
		tb = new clToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, clTB_DEFAULT_STYLE);
		tb->SetToolBitmapSize(wxSize(size, size));

		BitmapLoader *bitmapLoader = m_mgr->GetStdIcons();

		if (size == 24)
		{
			tb->AddTool(XRCID("generate_code"), wxT("Generate C code"), bitmapLoader->LoadBitmap(wxT("toolbars/24/myplugin/generate")), wxT("Generate C code"));
		}
		else
		{
			tb->AddTool(XRCID("generate_code"), wxT("Generate C code"), bitmapLoader->LoadBitmap(wxT("toolbars/16/myplugin/generate")), wxT("Generate C code"));
		}
		tb->Realize();
	}

	m_mgr->GetTheApp()->Connect(XRCID("generate_code"), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(MyPlugin::OnGenerate), NULL, (wxEvtHandler*)this);

	return tb;
}
Inside Runtime/codelite-icons.zip, I have added generate.png in the toolbars/<size>/myplugin folder, and have added the appropriate line to manifest.ini, so the button I'm indicating shows up just fine. However, the toolbar extends itself far beyond the size of that button. When I try to move other toolbars around it, it doesn't work quite right. Here are some images to explain. They're pretty wide, but I added url tags so you can click through to the full image. My toolbar is the one with the Image icon.

Here is the overly large toolbar:
Image

Here is what happens when I try to move the CodeFormatter toolbar (visible all the way at the right) to the location of the thin black rectangle:
Image

I'm clueless as to why this is happening.

Re: Erratic plugin toolbar

Posted: Mon Aug 29, 2011 11:50 pm
by eranif
I don't see anything problematic with your code. My guess is that there is a glitch with wxAUI layout code.
To "force" reset the layout: "View -> Restore default layout"

See if it helps
Eran

Re: Erratic plugin toolbar

Posted: Tue Aug 30, 2011 12:18 am
by GlenboLake
That did the trick! Many thanks.