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