Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************
- * Name: GUIMain.cpp
- * Purpose: Code for Application Frame
- * Author: Krystian Duczek ()
- * Created: 2020-02-21
- * Copyright: Krystian Duczek ()
- * License:
- **************************************************************/
- #include "wx_pch.h"
- #include "GUIMain.h"
- #include <wx/msgdlg.h>
- #include "C:\Users\User\Desktop\Shel\Console\Shelter.h" //----need to give direct path because otherwise compiler cant see this
- #include "C:\Users\User\Desktop\Shel\Console\Shelter.cpp" //----this is weird but without this compiler cant refer to constructor or destructor
- //(*InternalHeaders(GUIFrame)
- #include <wx/bitmap.h>
- #include <wx/image.h>
- #include <wx/intl.h>
- #include <wx/string.h>
- //*)
- //helper functions
- enum wxbuildinfoformat {
- short_f, long_f };
- wxString wxbuildinfo(wxbuildinfoformat format)
- {
- wxString wxbuild(wxVERSION_STRING);
- if (format == long_f )
- {
- #if defined(__WXMSW__)
- wxbuild << _T("-Windows");
- #elif defined(__UNIX__)
- wxbuild << _T("-Linux");
- #endif
- #if wxUSE_UNICODE
- wxbuild << _T("-Unicode build");
- #else
- wxbuild << _T("-ANSI build");
- #endif // wxUSE_UNICODE
- }
- return wxbuild;
- }
- //(*IdInit(GUIFrame)
- const long GUIFrame::ID_STATICBITMAP1 = wxNewId();
- const long GUIFrame::ID_BUTTON1 = wxNewId();
- const long GUIFrame::ID_BUTTON2 = wxNewId();
- const long GUIFrame::ID_BUTTON3 = wxNewId();
- const long GUIFrame::ID_LISTBOX1 = wxNewId();
- const long GUIFrame::ID_BUTTON4 = wxNewId();
- const long GUIFrame::ID_BUTTON5 = wxNewId();
- const long GUIFrame::ID_BUTTON6 = wxNewId();
- const long GUIFrame::ID_BUTTON7 = wxNewId();
- const long GUIFrame::ID_PANEL1 = wxNewId();
- const long GUIFrame::idMenuQuit = wxNewId();
- const long GUIFrame::idMenuAbout = wxNewId();
- const long GUIFrame::ID_STATUSBAR1 = wxNewId();
- //*)
- BEGIN_EVENT_TABLE(GUIFrame,wxFrame)
- //(*EventTable(GUIFrame)
- //*)
- END_EVENT_TABLE()
- GUIFrame::GUIFrame(wxWindow* parent,wxWindowID id)
- {
- //(*Initialize(GUIFrame)
- wxBoxSizer* BoxSizer1;
- wxFlexGridSizer* FlexGridSizer1;
- wxMenu* Menu1;
- wxMenu* Menu2;
- wxMenuBar* MenuBar1;
- wxMenuItem* MenuItem1;
- wxMenuItem* MenuItem2;
- Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
- BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
- Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
- FlexGridSizer1 = new wxFlexGridSizer(0, 3, 0, 0);
- FlexGridSizer1->Add(106,57,1, wxALL|wxEXPAND, 5);
- StaticBitmap1 = new wxStaticBitmap(Panel1, ID_STATICBITMAP1, wxBitmap(wxImage(_T("C:\\Users\\User\\Desktop\\Shel\\GUI\\Logo.PNG"))), wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER, _T("ID_STATICBITMAP1"));
- FlexGridSizer1->Add(StaticBitmap1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- FlexGridSizer1->Add(0,0,1, wxALL|wxEXPAND, 5);
- Button1 = new wxButton(Panel1, ID_BUTTON1, _("See Status"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
- FlexGridSizer1->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Button2 = new wxButton(Panel1, ID_BUTTON2, _("Select Healthy Animals"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
- FlexGridSizer1->Add(Button2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Button3 = new wxButton(Panel1, ID_BUTTON3, _("Add an Animal"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3"));
- FlexGridSizer1->Add(Button3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- ListBox1 = new wxListBox(Panel1, ID_LISTBOX1, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX1"));
- FlexGridSizer1->Add(ListBox1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- FlexGridSizer1->Add(0,0,1, wxALL|wxEXPAND, 5);
- Button4 = new wxButton(Panel1, ID_BUTTON4, _("Adopt an Animal"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON4"));
- FlexGridSizer1->Add(Button4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Button5 = new wxButton(Panel1, ID_BUTTON5, _("Export Status to CSV"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON5"));
- FlexGridSizer1->Add(Button5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Button6 = new wxButton(Panel1, ID_BUTTON6, _("Export Status to TXT"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON6"));
- FlexGridSizer1->Add(Button6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Button7 = new wxButton(Panel1, ID_BUTTON7, _("Quit"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON7"));
- FlexGridSizer1->Add(Button7, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
- Panel1->SetSizer(FlexGridSizer1);
- FlexGridSizer1->Fit(Panel1);
- FlexGridSizer1->SetSizeHints(Panel1);
- BoxSizer1->Add(Panel1, 1, wxALL|wxEXPAND, 0);
- SetSizer(BoxSizer1);
- MenuBar1 = new wxMenuBar();
- Menu1 = new wxMenu();
- MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
- Menu1->Append(MenuItem1);
- MenuBar1->Append(Menu1, _("&File"));
- Menu2 = new wxMenu();
- MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
- Menu2->Append(MenuItem2);
- MenuBar1->Append(Menu2, _("Help"));
- SetMenuBar(MenuBar1);
- StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
- int __wxStatusBarWidths_1[1] = { -1 };
- int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
- StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
- StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
- SetStatusBar(StatusBar1);
- BoxSizer1->Fit(this);
- BoxSizer1->SetSizeHints(this);
- Connect(ID_BUTTON7,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&GUIFrame::OnButton7Click);
- Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&GUIFrame::OnQuit);
- Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&GUIFrame::OnAbout);
- //*)
- Shelter Sunshine;
- MYSQL* conn;
- conn = mysql_init(0); //allocation object for connection
- conn = mysql_real_connect(conn, "192.168.1.7", "donq104", "admin", "shelter", 0, NULL, 0);
- }
- //-----So i want to create a Shelter instance for example in a constructor and have access to this instance in OnButton7Click
- GUIFrame::~GUIFrame()
- {
- //(*Destroy(GUIFrame)
- //*)
- }
- bool GUIFrame::OnInit(wxCommandEvent& event)
- {
- return true;
- }
- void GUIFrame::OnQuit(wxCommandEvent& event)
- {
- Close();
- }
- void GUIFrame::OnAbout(wxCommandEvent& event)
- {
- wxString msg = wxbuildinfo(long_f);
- wxMessageBox(msg, _("Welcome to..."));
- }
- void GUIFrame::OnButton7Click(wxCommandEvent& event)
- {
- Sunshine.close(conn, Sunshine); //-----here is the problem
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement