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