#define _CRT_SECURE_NO_WARNINGS // get rid of warnings preventing compilation
#include "MainFrame.h"
#include <wx/wx.h>
#include "TopicQuestionsFrame.h"
#include "FlashcardsFrame.h"
#include "PopQuizFrame.h"
#include "LeaderboardFrame.h"
#include "CustomisationFrame.h"
#include "ClassroomFrame.h"
#include "FriendsFrame.h"
#include <windows.h>
#include "FrameUtilities.h"
MainFrame::MainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title) {
wxPanel* panel = new wxPanel(this); // creates the panel which the controls will be attached to
this->SetClientSize(800, 800);
this->SetMinSize(GetSize());
this->SetMaxSize(GetSize());
// image handling
wxImage::AddHandler(new wxPNGHandler());
wxBitmap image_bitmap("E:/Coding/Pro 7/Images/backgroundfinal.png", wxBITMAP_TYPE_PNG);
// this tells the program where to fetch the image files
wxBitmap friends_button_bitmap("E:/Coding/Pro 7/Images/friendstab.png", wxBITMAP_TYPE_PNG);
wxBitmap classroom_button_bitmap("E:/Coding/Pro 7/Images/classroomtab.png", wxBITMAP_TYPE_PNG);
this->SetBackgroundColour("#c2cbc6"); // this sets the background colour of the window to the given hex code
// background and button images
wxStaticBitmap* background_gui = new wxStaticBitmap(this, wxID_ANY, image_bitmap, wxPoint(0, 0));
wxBitmapButton* friends_tab = new wxBitmapButton(panel, wxID_ANY, friends_button_bitmap, wxPoint(660, 10), wxSize(102, 92));
wxBitmapButton* classroom = new wxBitmapButton(panel, wxID_ANY, classroom_button_bitmap, wxPoint(60, 10), wxSize(102, 92));
// font
wxFont streak_font(36, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
// buttons
wxButton* topic_questions = new wxButton(panel, wxID_ANY, "Topic Questions", wxPoint(300, 125), wxSize(245, 85));
wxButton* flashcards = new wxButton(panel, wxID_ANY, "Flashcards", wxPoint(300, 245), wxSize(245, 85));
wxButton* pop_quiz = new wxButton(panel, wxID_ANY, "Pop Quiz", wxPoint(300, 365), wxSize(245, 85));
wxButton* customisation = new wxButton(panel, wxID_ANY, "Customisation", wxPoint(300, 485), wxSize(245, 85));
wxButton* leaderboard = new wxButton(panel, wxID_ANY, "Leaderboard", wxPoint(300, 605), wxSize(245, 85));
// binds
topic_questions->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 1); // CreateFrame is called with the current frame, evt and the integer id 1
}); // which allows it to be uniquely identified
// FrameUtilities:: tells the file where to call the function from.
flashcards->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 2);
});
pop_quiz->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 2);
});
customisation->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 2);
});
leaderboard->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 2);
});
classroom->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 2);
});
friends_tab->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
FrameUtilities::CreateFrame(this, evt, 2);
});
// text
wxStaticText* daily_streak = new wxStaticText(this, wxID_ANY, "52", wxPoint(395, 10));
daily_streak->SetFont(streak_font);
}
这是框架首次加载时的外观。 这是我将鼠标悬停在所有按钮上后的框架的外观。
您不能具有重叠的控件,而
wxBitmapButtons
则与wxStaticBitmap
相同,因此您不能将
wxStaticBitmap