-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathArtProvider.cpp
More file actions
68 lines (58 loc) · 3.07 KB
/
ArtProvider.cpp
File metadata and controls
68 lines (58 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <wx/artprov.h>
#include <wx/app.h>
#include <wx/button.h>
#include <wx/filename.h>
#include <wx/frame.h>
#include <wx/imaglist.h>
#include <wx/panel.h>
#include <wx/settings.h>
#include <wx/statbmp.h>
#include <wx/stattext.h>
#include <wx/sysopt.h>
#include <vector>
using namespace std;
namespace ArtProviderExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "ArtProvider example"} {
wxInitAllImageHandlers();
SetClientSize({300, 290});
picture->SetSize({150, 150});
picture->SetBackgroundColour(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_WINDOW));
buttonPrevious->Enable(false);
buttonPrevious->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
if (artIDsIndex > 0) --artIDsIndex;
UpdateFrame();
});
buttonNext->Enable(false);
buttonNext->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
if (artIDsIndex < artIDs.size()) ++artIDsIndex;
UpdateFrame();
});
UpdateFrame();
}
private:
void UpdateFrame() {
picture->SetScaleMode(wxStaticBitmap::Scale_None);
picture->SetBitmap(wxArtProvider::GetBitmap(artIDs[artIDsIndex], wxART_OTHER, {128, 128}));
picture->SetSize({150, 150});
name->SetLabel(artIDs[artIDsIndex]);
buttonPrevious->Enable(artIDsIndex > 0);
buttonNext->Enable(artIDsIndex < artIDs.size() - 1);
}
size_t artIDsIndex = 0;
vector<wxArtID> artIDs {wxART_ADD_BOOKMARK, wxART_DEL_BOOKMARK, wxART_HELP_SIDE_PANEL, wxART_HELP_SETTINGS, wxART_HELP_BOOK, wxART_HELP_FOLDER, wxART_HELP_PAGE, wxART_GO_BACK, wxART_GO_FORWARD, wxART_GO_UP, wxART_GO_DOWN, wxART_GO_TO_PARENT, wxART_GO_HOME, wxART_GOTO_FIRST, wxART_GOTO_LAST, wxART_FILE_OPEN, wxART_FILE_SAVE, wxART_FILE_SAVE_AS, wxART_PRINT, wxART_HELP, wxART_TIP, wxART_REPORT_VIEW, wxART_LIST_VIEW, wxART_NEW_DIR, wxART_HARDDISK, wxART_FLOPPY, wxART_CDROM, wxART_REMOVABLE, wxART_FOLDER, wxART_FOLDER_OPEN, wxART_GO_DIR_UP, wxART_EXECUTABLE_FILE, wxART_NORMAL_FILE, wxART_TICK_MARK, wxART_CROSS_MARK, wxART_ERROR, wxART_QUESTION, wxART_WARNING, wxART_INFORMATION, wxART_MISSING_IMAGE, wxART_COPY, wxART_CUT, wxART_PASTE, wxART_DELETE, wxART_NEW, wxART_UNDO, wxART_REDO, wxART_PLUS, wxART_MINUS, wxART_CLOSE, wxART_QUIT, wxART_FIND, wxART_FIND_AND_REPLACE, wxART_FULL_SCREEN, wxART_EDIT};
wxPanel* panel = new wxPanel {this};
wxStaticBitmap* picture = new wxStaticBitmap {panel, wxID_ANY, wxNullBitmap, {75, 25}, wxDefaultSize, wxBORDER_SUNKEN};
wxStaticText* name = new wxStaticText {panel, wxID_ANY, wxEmptyString, {75, 200}, {150, wxDefaultCoord}, wxALIGN_CENTRE_HORIZONTAL};
wxButton* buttonPrevious = new wxButton {panel, wxID_ANY, "&<", {75, 240}, {75, 25}, wxBORDER_SIMPLE};
wxButton* buttonNext = new wxButton {panel, wxID_ANY, "&>", {150, 240}, {75, 25}, wxBORDER_SIMPLE};
};
class Application : public wxApp {
auto OnInit() -> bool override {
wxSystemOptions::SetOption("osx.openfiledialog.always-show-types", 1);
return (new Frame)->Show();
}
};
}
wxIMPLEMENT_APP(ArtProviderExample::Application);