【发布时间】:2019-04-16 08:50:45
【问题描述】:
我正在创建带有用户界面的简单 C++ 应用程序。我已经编写了具有所需机制的自己的类,现在我必须使用 wxWidgets 显示它的一些组件。 MyApp 包含该类的对象,但在处理事件时MyFrame 中也需要它们。如果不将指向该对象的指针传递给MyFrame 并在MyApp::OnInit 函数中实现所有内容,那会更舒服。这可能吗?
// should contain informations about game state, players, gameboard, etc
class MyApp : public wxApp {
GameBoard gb;
Player player;
bool lightTheme;
public:
virtual bool OnInit();
};
// should contain only window layout, button events, etc
class MyFrame : public wxFrame {
GameBoard *gb;
Player *player;
bool *lightTheme;
std::vector<wxStaticBitmap*> cardImages;
// some events here
void displayImages(wxGridSizer*);
public:
MyFrame(GameBoard*, Player*, bool*);
};
【问题讨论】:
标签: c++ user-interface wxwidgets