]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/generic/busyinfo.cpp | |
3 | // Purpose: Information window when app is busy | |
4 | // Author: Vaclav Slavik | |
5 | // Copyright: (c) 1999 Vaclav Slavik | |
6 | // Licence: wxWindows licence | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | #include "wx/wxprec.h" | |
10 | ||
11 | #ifdef __BORLANDC__ | |
12 | #pragma hdrstop | |
13 | #endif | |
14 | ||
15 | #if wxUSE_BUSYINFO | |
16 | ||
17 | // for all others, include the necessary headers | |
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/frame.h" | |
20 | #include "wx/stattext.h" | |
21 | #include "wx/panel.h" | |
22 | #include "wx/utils.h" | |
23 | #endif | |
24 | ||
25 | #include "wx/busyinfo.h" | |
26 | #include "wx/generic/stattextg.h" | |
27 | ||
28 | class WXDLLEXPORT wxInfoFrame : public wxFrame | |
29 | { | |
30 | public: | |
31 | wxInfoFrame(wxWindow *parent, const wxString& message); | |
32 | ||
33 | private: | |
34 | wxDECLARE_NO_COPY_CLASS(wxInfoFrame); | |
35 | }; | |
36 | ||
37 | ||
38 | wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message) | |
39 | : wxFrame(parent, wxID_ANY, wxT("Busy"), | |
40 | wxDefaultPosition, wxDefaultSize, | |
41 | #if defined(__WXX11__) | |
42 | wxRESIZE_BORDER | |
43 | #else | |
44 | wxSIMPLE_BORDER | |
45 | #endif | |
46 | | wxFRAME_TOOL_WINDOW | wxSTAY_ON_TOP) | |
47 | { | |
48 | wxPanel *panel = new wxPanel( this ); | |
49 | #ifdef __WXGTK__ | |
50 | wxGenericStaticText *text = new wxGenericStaticText(panel, wxID_ANY, message); | |
51 | #else | |
52 | wxStaticText *text = new wxStaticText(panel, wxID_ANY, message); | |
53 | #endif | |
54 | ||
55 | panel->SetCursor(*wxHOURGLASS_CURSOR); | |
56 | text->SetCursor(*wxHOURGLASS_CURSOR); | |
57 | ||
58 | // make the frame of at least the standard size (400*80) but big enough | |
59 | // for the text we show | |
60 | wxSize sizeText = text->GetBestSize(); | |
61 | #ifdef __WXPM__ | |
62 | int nX = 0; | |
63 | int nY = 0; | |
64 | int nWidth = 0; | |
65 | int nHeight = 0; | |
66 | int nParentHeight = parent->GetClientSize().y; | |
67 | int nParentWidth = parent->GetClientSize().x; | |
68 | int nColor; | |
69 | ||
70 | SetBackgroundColour(wxT("WHITE")); | |
71 | nColor = (LONG)GetBackgroundColour().GetPixel(); | |
72 | ||
73 | ::WinSetPresParam( GetHwnd() | |
74 | ,PP_BACKGROUNDCOLOR | |
75 | ,sizeof(LONG) | |
76 | ,(PVOID)&nColor | |
77 | ); | |
78 | panel->SetBackgroundColour(wxT("WHITE")); | |
79 | nColor = (LONG)panel->GetBackgroundColour().GetPixel(); | |
80 | ||
81 | ::WinSetPresParam( GetHwndOf(panel) | |
82 | ,PP_BACKGROUNDCOLOR | |
83 | ,sizeof(LONG) | |
84 | ,(PVOID)&nColor | |
85 | ); | |
86 | nWidth = wxMax(sizeText.x, 340) + 60; | |
87 | nHeight = wxMax(sizeText.y, 40) + 40; | |
88 | nX = (nParentWidth - nWidth) / 2; | |
89 | nY = (nParentHeight / 2) - (nHeight / 2); | |
90 | nY = nParentHeight - (nY + nHeight); | |
91 | ::WinSetWindowPos( m_hFrame | |
92 | ,HWND_TOP | |
93 | ,nX | |
94 | ,nY | |
95 | ,nWidth | |
96 | ,nHeight | |
97 | ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | |
98 | ); | |
99 | text->SetBackgroundColour(wxT("WHITE")); | |
100 | nColor = (LONG)text->GetBackgroundColour().GetPixel(); | |
101 | ||
102 | ::WinSetPresParam( GetHwndOf(text) | |
103 | ,PP_BACKGROUNDCOLOR | |
104 | ,sizeof(LONG) | |
105 | ,(PVOID)&nColor | |
106 | ); | |
107 | text->Center(wxBOTH); | |
108 | #else | |
109 | SetClientSize(wxMax(sizeText.x, 340) + 60, wxMax(sizeText.y, 40) + 40); | |
110 | ||
111 | // need to size the panel correctly first so that text->Centre() works | |
112 | panel->SetSize(GetClientSize()); | |
113 | ||
114 | text->Centre(wxBOTH); | |
115 | Centre(wxBOTH); | |
116 | #endif | |
117 | } | |
118 | ||
119 | wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent) | |
120 | { | |
121 | m_InfoFrame = new wxInfoFrame(parent, message); | |
122 | m_InfoFrame->Show(true); | |
123 | m_InfoFrame->Refresh(); | |
124 | m_InfoFrame->Update(); | |
125 | } | |
126 | ||
127 | wxBusyInfo::~wxBusyInfo() | |
128 | { | |
129 | m_InfoFrame->Show(false); | |
130 | m_InfoFrame->Close(); | |
131 | } | |
132 | ||
133 | #endif // wxUSE_BUSYINFO |