wxCoolBar (wxMSW Only)

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Avi
Super wx Problem Solver
Super wx Problem Solver
Posts: 398
Joined: Mon Aug 30, 2004 9:27 pm
Location: Tel-Aviv, Israel

wxCoolBar (wxMSW Only)

Post by Avi » Tue May 31, 2005 6:44 pm

http://www.planet-berlin-it.de/wx/wxcoolbar/

Found that somebody linked to it on the other forum, and thought some of you people will find it usefull! :)
What wxCoolBar is ...
wxCoolBar is a wrapper around the mickeysoft rebar control for use with the famous wxWidgets gui library. So developers can easily add the nice looking toolbars known from ms ie or other applications to their existing wxWidgets apps. Only if compiled against wxMSW on Win<95 of course.
Without wxCoolBar:
Image

With wxCoolBar:
Image

MartinSfromB
Knows some wx things
Knows some wx things
Posts: 42
Joined: Wed Nov 24, 2004 9:04 am
Location: Berlin, Germany
Contact:

Post by MartinSfromB » Mon Jun 13, 2005 1:23 pm

Solved problems of wxCoolBar with Win2k!

Just test it and send more bug reports and feature requests! :D

http://www.planet-berlin-it.de

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath » Mon Jun 13, 2005 5:58 pm

Hi Martin,
It seems VC++ is choking with some of the code.
Have a look at line number,

701: wxAcceleratorEntry entries1[count];
711: wxAcceleratorEntry entries[arr.GetCount()];

I fixed the problem by creating the entries using new and delete them after the for loop like

Code: Select all

	wxAcceleratorEntry *entries1= new wxAcceleratorEntry[count];
       int count = m_menubar->GetMenu(i)->CopyAccels(entries1);
       for (int c = 0; c < count; c++)
       {
        arr.Add(entries1[c]);
       }
	   delete []entries1;
and

Code: Select all

     wxAcceleratorEntry *entries = new wxAcceleratorEntry[arr.GetCount()];
     for (unsigned i = 0; i < arr.GetCount(); i++)
     {
        entries[i] = arr[i];
     }
     wxAcceleratorTable accel(arr.GetCount(), entries);
     GetParentFrame()->SetAcceleratorTable(accel); 
    delete []entries;
I also found that using wxDevC++ generated code, it will be hard to use the outer level sizer directly to remove and add the child controls. In the enable toolbar function, instead of the Outer Sizer variable, I use
GetSizer() function to manipulate the Sizer. Hope this will be useful to people using VC++.

Thank you so much for providing this wonder component. I'm sure it gives a great face lift to the applications created with wxWidgets.

-Guru Kathiresan[/code]

MartinSfromB
Knows some wx things
Knows some wx things
Posts: 42
Joined: Wed Nov 24, 2004 9:04 am
Location: Berlin, Germany
Contact:

Post by MartinSfromB » Tue Jun 14, 2005 6:11 am

I will have a look at this in the afternoon.
Key-Navigation an behaviour of menubar are not finished yet. There is a lot to do till release 1.0 :-)
Thanks for working on it!

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Mon Jun 20, 2005 1:37 am

hi,

im using wxwidgets 2.6.1, and apparently mingw chokes on line #200 of wxCoolBar.cpp in the provided sample. ("no match for operator [] in childrec[c]"). Am i missing something, or is this release not fine tuned for 2.6.1?

Thanks,
joel

MartinSfromB
Knows some wx things
Knows some wx things
Posts: 42
Joined: Wed Nov 24, 2004 9:04 am
Location: Berlin, Germany
Contact:

Post by MartinSfromB » Mon Jun 20, 2005 11:45 am

Sorry, i can't find any childrec[c] in wxCoolBar.cpp, so i don't know what could be the problem.

For myself i'm working with mingw and the actual cvs-version of wxWidgets. I Tested wxCoolBar with 2.5.4, 2.6.0, 2.6.1. Sorry.

tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag » Mon Jun 20, 2005 1:09 pm

MartinSfromB wrote:Sorry, i can't find any childrec[c] in wxCoolBar.cpp, so i don't know what could be the problem.

For myself i'm working with mingw and the actual cvs-version of wxWidgets. I Tested wxCoolBar with 2.5.4, 2.6.0, 2.6.1. Sorry.
it works pretty well with wxMSW2.6.1 here by me,
thanks for this cool code !

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Mon Jun 20, 2005 10:16 pm

hmmm might be my libraries.... but miraculously this time it compiled.... weird.... but thanks anyway :D

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Tue Oct 04, 2005 2:54 pm

how do we get the rebar to resize?

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath » Tue Oct 04, 2005 5:47 pm

lowjoel wrote:how do we get the rebar to resize?
How did you added the Coolbar to the Frame ? I first dropped a top level BoxSizer and set it to vertical alignment and then added yet another BoxSizer where the actual widgets are loaded. Then in GUI code construction, I prepend the Toolbar object; This makes the Toolbar and the secondary Sizers to be children of the TopLevel Sizer. So the Code looks something like :

Code: Select all

bool TPMainFrm::EnableCoolBar()
{
#if defined (__WXMSW__)
	m_coolBar = new wxCoolBar(this,-1);
	SetToolBar(NULL);
	SetMenuBar(NULL);
	m_coolBar->AddBand(WxMenuBar1);
	m_coolBar->AddBand(WxToolBar1, true);
	GetSizer()->Prepend(m_coolBar, 0, wxGROW|wxALL,0);
	GetSizer()->Layout();
	return true;
#else
	return false;
#endif
}
-Guru

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Tue Oct 04, 2005 10:16 pm

the second sizer is within the coolbar? You have the ctor code?

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath » Mon Oct 10, 2005 6:40 pm

lowjoel wrote:the second sizer is within the coolbar? You have the ctor code?
Joel,
Here is the ctor. Hope this will be helpful.

-Guru Kathiresan

Code: Select all

void JoelTestFrm::CreateGUIControls(void)
{
    //Do not add custom Code here
    //wx-devcpp designer will remove them.
    //Add the custom code before or after the Blocks
    ////GUI Items Creation Start

	wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
	this->SetSizer(WxBoxSizer1);
	this->SetAutoLayout(TRUE);

	wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
	WxBoxSizer1->Add(WxBoxSizer2,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);

	WxListCtrl1 = new wxListCtrl(this, ID_WXLISTCTRL1, wxPoint(-11,-17), wxSize(394,127), wxLC_REPORT);
	WxListCtrl1->InsertColumn(0,_("Two"),wxLIST_FORMAT_LEFT,150 );
	WxListCtrl1->InsertColumn(0,_("One"),wxLIST_FORMAT_LEFT,218 );
	WxBoxSizer2->Add(WxListCtrl1,0,wxALIGN_CENTER_VERTICAL | wxALL,5);

	WxToolBar1 = new wxToolBar(this, ID_WXTOOLBAR1, wxPoint(0,0), wxSize(412,29), wxTB_TEXT);

	wxBitmap WxToolButton1_BITMAP (wxNullBitmap);
	wxBitmap WxToolButton1_DISABLE_BITMAP (wxNullBitmap);
	WxToolBar1->AddTool(ID_WXTOOLBUTTON1, _("One"), WxToolButton1_BITMAP, WxToolButton1_DISABLE_BITMAP, wxITEM_NORMAL, _(""), _(""));

	wxBitmap WxToolButton2_BITMAP (wxNullBitmap);
	wxBitmap WxToolButton2_DISABLE_BITMAP (wxNullBitmap);
	WxToolBar1->AddTool(ID_WXTOOLBUTTON2, _("Two"), WxToolButton2_BITMAP, WxToolButton2_DISABLE_BITMAP, wxITEM_NORMAL, _(""), _(""));

	WxMenuBar1 =  new wxMenuBar();
	wxMenu *ID_MNU_FILE_1007_Mnu_Obj = new wxMenu(0);
	WxMenuBar1->Append(ID_MNU_FILE_1007_Mnu_Obj, _("File"));
	
	wxMenu *ID_MNU_HELP_1008_Mnu_Obj = new wxMenu(0);
	WxMenuBar1->Append(ID_MNU_HELP_1008_Mnu_Obj, _("Help"));
	
	
	this->SetMenuBar(WxMenuBar1);

	WxToolBar1->Realize();
	this->SetToolBar(WxToolBar1);
	GetSizer()->Fit(this);
	GetSizer()->SetSizeHints(this);
	this->SetTitle(_("JoelTest"));
	this->Center();
	this->SetIcon(wxNullIcon);
	
    ////GUI Items Creation End
    EnableCoolBar();
}

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Thu Oct 13, 2005 11:00 am

Somehow that yeilds this: <img src="http://joelsplace.sg/wxCoolBar.png" alt="wxCoolBar">

gururamnath
Moderator
Moderator
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Post by gururamnath » Thu Oct 13, 2005 8:10 pm

I think I misunderstood the question. Sorry.

-Guru Kathiresan

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Fri Oct 14, 2005 11:54 am

its ok ;)

Post Reply