-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwWxFrame.cpp
More file actions
101 lines (80 loc) · 2.22 KB
/
wWxFrame.cpp
File metadata and controls
101 lines (80 loc) · 2.22 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "wWxFrame.h"
#include "weather.h"
wxBEGIN_EVENT_TABLE(WwxFrame, wxFrame)
EVT_MENU(TEXT_QUIT, WwxFrame::OnQuit)
EVT_MENU(TEXT_SET_EDITABLE, WwxFrame::OnSetEditable)
EVT_MENU(TEXT_SET_ENABLED, WwxFrame::OnSetEnabled)
EVT_MENU(TEXT_SET, WwxFrame::OnSetText)
EVT_MENU(TEXT_CHANGE, WwxFrame::OnChangeText)
EVT_IDLE(WwxFrame::OnIdle)
wxEND_EVENT_TABLE()
WwXPanel* panelPtr = NULL;
WwxFrame::WwxFrame(const wxString& title, int x, int y) : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y))
{
SetIcon(wxICON(sample));
#if wxUSE_STATUSBAR
CreateStatusBar(2);
#endif // wxUSE_STATUSBAR
panel_ = new WwXPanel(this, 10, 10, 300, 100);
panel_->GetSizer()->Fit(this);
panelPtr = panel_;
}
void WwxFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}
void WwxFrame::OnSetEditable(wxCommandEvent& WXUNUSED(event))
{
static bool s_editable = true;
s_editable = !s_editable;
panel_->location_->SetEditable(s_editable);
panel_->data_->SetEditable(false);
panel_->label_->SetEditable(false);
}
void WwxFrame::OnSetEnabled(wxCommandEvent& WXUNUSED(event))
{
bool enabled = panel_->location_->IsEnabled();
enabled = !enabled;
panel_->location_->Enable(enabled);
panel_->data_->Enable(enabled);
}
void WwxFrame::OnButton(wxCommandEvent& ev)
{
if (panelPtr != NULL)
{
std::string locName(panelPtr->location_->GetValue().c_str());
if (locName.empty())
{
wxLogError("Location can't be empty!");
return;
}
auto& weather = Weather::getInstance();
weather.UpdateLocation(locName);
}
}
void WwxFrame::OnIdle(wxIdleEvent& event)
{
// track the window which has the focus in the status bar
static wxWindow* s_windowFocus = (wxWindow*)NULL;
wxWindow* focus = wxWindow::FindFocus();
if (focus && (focus != s_windowFocus))
{
s_windowFocus = focus;
wxString msg;
msg.Printf(
#ifdef __WXMSW__
"Focus: wxWindow = %p, HWND = %p",
#else
"Focus: wxWindow = %p",
#endif
s_windowFocus
#ifdef __WXMSW__
, s_windowFocus->GetHWND()
#endif
);
#if wxUSE_STATUSBAR
SetStatusText(msg);
#endif // wxUSE_STATUSBAR
}
event.Skip();
}