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!
Trigunflame
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Feb 16, 2006 8:36 pm

Linker Error

Post by Trigunflame » Fri Feb 17, 2006 9:46 am

I Keep getting a linker error with this code, any ideas?

release/obj/window.obj:window.cpp:(.text+0x1e4): undefined reference to `wxCoolBar::wxCoolBar(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&)'
release/obj/window.obj:window.cpp:(.text+0x26e): undefined reference to `wxCoolBar::AddBand(wxWindow*, bool, wxString, bool)'
release/obj/window.obj:window.cpp:(.text+0x2d9): undefined reference to `wxCoolBar::AddBand(wxWindow*, bool, wxString, bool)'
collect2: ld returned 1 exit status

make.exe: *** [release/vbcp.exe] Error 1

Code: Select all

/*
 * @author Dusty Burns (Trigunflame@charter.net)
 * @copyright 2006-2007 Dusty Burns
 * @version $Id$
 */

#include "vbcp.h"
#include "window.h"

// Primary Window Frame
vbcp_window::vbcp_window(wxWindow* parent, int id, const wxString& title, 
    const wxPoint& pos, const wxSize& size, long style):
    wxFrame(parent, id, title, pos, size, W_STYLE)
{
    // Set Icon
    wxIcon _icon;
    _icon.CopyFromBitmap(wxBitmap(wxT(W_ICON), wxBITMAP_TYPE_ANY));
    SetIcon(_icon);
    
    // Set Window Size
    SetSize(wxSize(W_SIZE));
    SetMinSize(wxSize(W_MSIZE));
    SetFocus();
    
    // Setup Window
    SetupStatusBar();
    SetupGuiBars();
    SetupPage();
}

// Setup Coolbar
void vbcp_window::EnableCoolBar()
{
    wxCoolBar* _coolbar = new wxCoolBar(this, -1); 
    SetToolBar(NULL);
    SetMenuBar(NULL);
    _coolbar->AddBand(menubar);
    _coolbar->AddBand(toolbar, true);
    sizer_1->Prepend(_coolbar, 0, wxGROW|wxALL,0);
    sizer_1->Layout();
}

// Status Bar
void vbcp_window::SetupStatusBar()
{
    // Create Statusbar
    statusbar = CreateStatusBar(1, wxST_SIZEGRIP);
    
    // Set Status Bar
    int statusbar_widths[] = { -1 };
    statusbar->SetStatusWidths(1, statusbar_widths);
    const wxString statusbar_fields[] = {
        wxT("frame_1_statusbar")
    };
    for(int i = 0; i < statusbar->GetFieldsCount(); ++i) {
        statusbar->SetStatusText(statusbar_fields[i], i);
    }   
}

// Setup Status/Toolbar
void vbcp_window::SetupGuiBars()
{
    // Create Sizer
    wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
    SetAutoLayout(true);
    SetSizer(sizer_1);
    
    // Create Menubar
    menubar = new wxMenuBar();

    // Menu Category File
    wxMenu* menu_file = new wxMenu();
        // Menu Exit
        wxMenuItem* menu_exit = new wxMenuItem(menu_file, M_FILE_EXIT_ID, 
            _(M_FILE_EXIT_T), _T(M_FILE_EXIT_I), wxITEM_NORMAL);
        menu_exit->SetBitmap(wxBitmap(_T(M_FILE_EXIT_IMAGE), M_IMAGE_TYPE));
        menu_file->Append(menu_exit);
    
    // Menu Category Help
    wxMenu* menu_help = new wxMenu();
        // Menu About
        wxMenuItem* menu_about = new wxMenuItem(menu_help, M_HELP_ABOUT_ID, 
            _(M_HELP_ABOUT_T), _T(M_HELP_ABOUT_I), wxITEM_NORMAL);
        menu_about->SetBitmap(wxBitmap(_T(M_HELP_ABOUT_IMAGE), wxBITMAP_TYPE_PNG));
        menu_help->Append(menu_about);

    // Set Menu
    menubar->Append(menu_file, wxT(MC_FILE));
    menubar->Append(menu_help, wxT(MC_HELP));
    SetMenuBar(menubar);
    
    // Create Toolbar
    toolbar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, T_STYLE);
    toolbar->SetToolBitmapSize(wxSize(T_IMAGE_SIZE));
    
    // Connect
    toolbar->AddTool(T_CONNECT_ID, wxT(T_CONNECT_T), wxBitmap(_T(T_CONNECT_IMAGE), 
        wxBITMAP_TYPE_PNG), wxNullBitmap, wxITEM_NORMAL, wxT(T_CONNECT_I), wxT(T_CONNECT_I));
    
    // Disconnect
    toolbar->AddTool(T_DISCONNECT_ID, wxT(T_DISCONNECT_T), wxBitmap(_T(T_DISCONNECT_IMAGE), 
        wxBITMAP_TYPE_PNG), wxNullBitmap, wxITEM_NORMAL, wxT(T_DISCONNECT_I), wxT(T_DISCONNECT_I));
    
    // Spacer
    toolbar->AddSeparator();
    
    // Reload Local
    toolbar->AddTool(T_RELOADLOCAL_ID, wxT(T_RELOADLOCAL_T), wxBitmap(_T(T_RELOADLOCAL_IMAGE), 
        wxBITMAP_TYPE_PNG), wxNullBitmap, wxITEM_NORMAL, wxT(T_RELOADLOCAL_I), wxT(T_RELOADLOCAL_I));
    
    // Download Remote
    toolbar->AddTool(T_DOWNLOADREMOTE_ID, wxT(T_DOWNLOADREMOTE_T), wxBitmap(_T(T_DOWNLOADREMOTE_IMAGE), 
        wxBITMAP_TYPE_PNG), wxNullBitmap, wxITEM_NORMAL, wxT(T_DOWNLOADREMOTE_I), wxT(T_DOWNLOADREMOTE_I));
    
    // Spacer
    toolbar->AddSeparator();
    
    // Edit Settings
    toolbar->AddTool(T_EDITSETTINGS_ID, wxT(T_EDITSETTINGS_T), wxBitmap(_T(T_EDITSETTINGS_IMAGE), 
        wxBITMAP_TYPE_PNG), wxNullBitmap, wxITEM_NORMAL, wxT(T_EDITSETTINGS_I), wxT(T_EDITSETTINGS_I));

    // Set Toolbar
    toolbar->Realize();
    SetToolBar(toolbar);
    
    // CoolBar
    EnableCoolBar();
}

// Setup Page
void vbcp_window::SetupPage()
{
    // Vbulletion Options Notebook
    nb_vb_options = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, 0);
        // Vbulletin Options
        nbp_vb_options = new wxPanel(nb_vb_options, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        
    // User System Notebook
    nb_user_system = new wxNotebook(nb_vb_options, -1, wxDefaultPosition, wxDefaultSize, 0);
        // Users
        nbp_users = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Groups
        nbp_groups = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Titles
        nbp_titles = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Ranks
        nbp_ranks = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Reputation
        nbp_reputation = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Profile Fields
        nbp_profile_fields = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);

    // Maintenance Notebook
    nb_maintenance = new wxNotebook(nb_vb_options, -1, wxDefaultPosition, wxDefaultSize, 0);
        // Sheduled Tasks
        nbp_scheduled_tasks = new wxPanel(nb_maintenance, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Plugin System
        nbp_plugin_system = new wxPanel(nb_maintenance, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Statistics and Logs
        nbp_statistics_and_logs = new wxPanel(nb_maintenance, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        // Miscellaneous
        nbp_miscellaneous = new wxPanel(nb_maintenance, -1, wxDefaultPosition, wxDefaultSize, W_N_STYLE);
        
    // Spacer
    spacer_1 = new wxStaticLine(this, -1);
    sizer_1->Add(spacer_1, 0, wxEXPAND, 0);
    
    // Add User Pages
    nb_user_system->AddPage(nbp_users, wxT("Users"));
    nb_user_system->AddPage(nbp_groups, wxT("Groups"));
    nb_user_system->AddPage(nbp_titles, wxT("Titles"));
    nb_user_system->AddPage(nbp_ranks, wxT("Ranks"));
    nb_user_system->AddPage(nbp_reputation, wxT("Reputation"));
    nb_user_system->AddPage(nbp_profile_fields, wxT("Profile Fields"));
    
    // Add Maintenance Pages
    nb_maintenance->AddPage(nbp_scheduled_tasks, wxT("Scheduled Tasks"));
    nb_maintenance->AddPage(nbp_plugin_system, wxT("Plugin System"));
    nb_maintenance->AddPage(nbp_statistics_and_logs, wxT("Statistics and Logs"));
    nb_maintenance->AddPage(nbp_miscellaneous, wxT("Miscellaneous"));
    
    // Add Vbulletin Options Pages
    nb_vb_options->AddPage(nbp_vb_options, wxT("Vbulletin Options"));
    
    // Add Other Notebooks
    nb_vb_options->AddPage(nb_user_system, wxT("User System"));
    nb_vb_options->AddPage(nb_maintenance, wxT("Maintenance"));
    
    // Pack & Display All Notebooks
    sizer_1->Add(nb_vb_options, 1, wxEXPAND, 0);
    
    // Setup Layout
    Layout();
    Centre();
}

// Close Application
void vbcp_window::OnCloseWindow(wxCloseEvent& event)
{
    Destroy();
    vbcp_window_opened = 0;
    wxTheApp->OnExit();
}

// Close Application
void vbcp_window::OnMenuExit(wxCommandEvent& event)
{
    Close();
}

// About
void vbcp_window::OnMenuAbout(wxCommandEvent& event)
{
    wxMessageBox(_("About"));
}

// Register Callbacks
BEGIN_EVENT_TABLE(vbcp_window, wxFrame)
    // Close Events
    EVT_CLOSE(vbcp_window::OnCloseWindow)
    // Menu Events
    EVT_MENU(M_FILE_EXIT_ID, vbcp_window::OnMenuExit)
    EVT_MENU(M_HELP_ABOUT_ID, vbcp_window::OnMenuAbout)
END_EVENT_TABLE()

Trigunflame
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Feb 16, 2006 8:36 pm

Post by Trigunflame » Fri Feb 17, 2006 9:55 am

Update, i fixed that.. which a proper linkage; however im now getting a crash.

Trigunflame
In need of some credit
In need of some credit
Posts: 7
Joined: Thu Feb 16, 2006 8:36 pm

Post by Trigunflame » Fri Feb 17, 2006 10:57 am

Ok Fixed that error, but now the menubar/toolbar wont expand like it should..

Code: Select all

/*
 * @author Dusty Burns (Trigunflame@charter.net)
 * @copyright 2006-2007 Dusty Burns
 * @version $Id$
 */

#include "vbcp.h"
#include "window.h"

// Primary Window Frame
vbcp_window::vbcp_window(wxWindow* parent, int id, const wxString& title, 
    const wxPoint& pos, const wxSize& size, long style):
    wxFrame(parent, id, title, pos, size, W_STYLE)
{
    nb_vb_options = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize, 0);
    nb_user_system = new wxNotebook(nb_vb_options, -1, wxDefaultPosition, wxDefaultSize, 0);
    nb_maintenance = new wxNotebook(nb_vb_options, -1, wxDefaultPosition, wxDefaultSize, 0);
    
    menubar = new wxMenuBar();
    SetMenuBar(menubar);
    
    wxMenu* menu_file = new wxMenu();
    menu_file->Append(60001, wxT("Exit"), wxT("Exit Now"), wxITEM_NORMAL);
    menubar->Append(menu_file, wxT("File"));
    wxMenu* menu_help = new wxMenu();
    menu_help->Append(60003, wxT("About"), wxT("About"), wxITEM_NORMAL);
    menubar->Append(menu_help, wxT("Help"));
    
    statusbar = CreateStatusBar(1, wxST_SIZEGRIP);
    
    toolbar = new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_FLAT|wxTB_DOCKABLE);
    SetToolBar(toolbar);
    
    toolbar->SetToolBitmapSize(wxSize(32, 32));
    toolbar->AddTool(50000, wxT("Connect"), wxBitmap(wxT("C:\\c++\\vbcp\\icons\\go.png"), wxBITMAP_TYPE_ANY), wxNullBitmap, wxITEM_NORMAL, wxT("Connect"), wxT(""));
    toolbar->AddTool(50001, wxT("Disconnect"), wxBitmap(wxT("C:\\c++\\vbcp\\icons\\stop.png"), wxBITMAP_TYPE_ANY), wxNullBitmap, wxITEM_NORMAL, wxT("Disconnect"), wxT(""));
    toolbar->AddSeparator();
    toolbar->AddTool(50002, wxT("ReloadLocal"), wxBitmap(wxT("C:\\c++\\vbcp\\icons\\reload.png"), wxBITMAP_TYPE_ANY), wxNullBitmap, wxITEM_NORMAL, wxT("Reload Local Configuration"), wxT(""));
    toolbar->AddTool(50003, wxT("DownloadRemote"), wxBitmap(wxT("C:\\c++\\vbcp\\icons\\downloads.png"), wxBITMAP_TYPE_ANY), wxNullBitmap, wxITEM_NORMAL, wxT("Download Remote Config"), wxT(""));
    toolbar->AddSeparator();
    toolbar->AddTool(50004, wxT("EditSettings"), wxBitmap(wxT("C:\\c++\\vbcp\\icons\\properties.png"), wxBITMAP_TYPE_ANY), wxNullBitmap, wxITEM_NORMAL, wxT("Edit Settings"), wxT(""));
    toolbar->Realize();
    spacer = new wxStaticLine(this, -1);
    
    nbp_vb_options = new wxPanel(nb_vb_options, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL|wxCLIP_CHILDREN);
    nbp_users = new wxPanel(nb_user_system, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL|wxCLIP_CHILDREN);
    nbp_scheduled_tasks = new wxPanel(nb_maintenance, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL|wxCLIP_CHILDREN);



    // begin wxGlade: vbcptopframe::set_properties
    SetTitle(wxT("Vbulletin Admin Panel"));
    wxIcon _icon;
    _icon.CopyFromBitmap(wxBitmap(wxT("C:\\c++\\vbcp\\vbcp.ico"), wxBITMAP_TYPE_ANY));
    SetIcon(_icon);
    SetSize(wxSize(577, 460));
    SetFocus();
    int statusbar_widths[] = { -1 };
    statusbar->SetStatusWidths(1, statusbar_widths);
    const wxString statusbar_fields[] = {
        wxT("frame_1_statusbar")
    };
    for(int i = 0; i < statusbar->GetFieldsCount(); ++i) {
        statusbar->SetStatusText(statusbar_fields[i], i);
    }


    // begin wxGlade: vbcptopframe::do_layout
    sizer_2 = new wxBoxSizer(wxVERTICAL);
    SetAutoLayout(true);
    SetSizer(sizer_2);
    
    //sizer_2->Add(spacer, 0, wxEXPAND, 0);
    
    nb_user_system->AddPage(nbp_users, wxT("Users"));
    nb_maintenance->AddPage(nbp_scheduled_tasks, wxT("Scheduled Tasks"));
    
    nb_vb_options->AddPage(nbp_vb_options, wxT("Vbulletin Options"));
    nb_vb_options->AddPage(nb_user_system, wxT("User System"));
    nb_vb_options->AddPage(nb_maintenance, wxT("Maintenance"));
    
    sizer_2->Add(nb_vb_options, 1, wxEXPAND, 0);
    
    GetSizer()->Fit(this);
    GetSizer()->SetSizeHints(this);
    Layout();
    Centre();
    
        EnableCoolBars();
}

// Enable Coolbars
void vbcp_window::EnableCoolBars()
{
    coolbar = new wxCoolBar(this,-1);
    SetToolBar(NULL);
    SetMenuBar(NULL);
    coolbar->AddBand(menubar);
    coolbar->AddBand(toolbar, true);
    GetSizer()->Prepend(coolbar, 0, wxEXPAND, 0);
    GetSizer()->Layout(); 
}

// Close Application
void vbcp_window::OnCloseWindow(wxCloseEvent& event)
{
    Destroy();
    vbcp_window_opened = 0;
    wxTheApp->OnExit();
}

// Close Application
void vbcp_window::OnMenuExit(wxCommandEvent& event)
{
    Close();
}

// About
void vbcp_window::OnMenuAbout(wxCommandEvent& event)
{
    wxMessageBox(_("About"));
}

// Register Callbacks
BEGIN_EVENT_TABLE(vbcp_window, wxFrame)
    // Close Events
    EVT_CLOSE(vbcp_window::OnCloseWindow)
    // Menu Events
    EVT_MENU(M_FILE_EXIT_ID, vbcp_window::OnMenuExit)
    EVT_MENU(M_HELP_ABOUT_ID, vbcp_window::OnMenuAbout)
END_EVENT_TABLE()

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

Post by gururamnath » Thu Mar 09, 2006 9:29 am

Trigunflame wrote:Ok Fixed that error, but now the menubar/toolbar wont expand like it should..
I have seen the problem with expansion only when the code is compile with Vc++6.0. if you use mingw or vc++2003, it works fine.

-Guru Kathiresan

Post Reply