wxBusyInfo interface moved to generic to make space for possible native implementatio...
[wxWidgets.git] / src / generic / busyinfo.cpp
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/stattext.h"
21 #include "wx/panel.h"
22 #include "wx/utils.h"
23 #endif
24
25 #include "wx/busyinfo.h"
26
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
36
37 wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
38 : wxFrame(parent, wxID_ANY, wxT("Busy"),
39 wxDefaultPosition, wxDefaultSize,
40 #if defined(__WXX11__)
41 wxTHICK_FRAME
42 #else
43 wxSIMPLE_BORDER
44 #endif
45 | wxFRAME_TOOL_WINDOW)
46 {
47 wxPanel *panel = new wxPanel( this );
48 wxStaticText *text = new wxStaticText(panel, wxID_ANY, message);
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();
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
65 SetBackgroundColour(wxT("WHITE"));
66 nColor = (LONG)GetBackgroundColour().GetPixel();
67
68 ::WinSetPresParam( GetHwnd()
69 ,PP_BACKGROUNDCOLOR
70 ,sizeof(LONG)
71 ,(PVOID)&nColor
72 );
73 panel->SetBackgroundColour(wxT("WHITE"));
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 );
94 text->SetBackgroundColour(wxT("WHITE"));
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
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);
110 Centre(wxBOTH);
111 #endif
112 }
113
114 wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent)
115 {
116 m_InfoFrame = new wxInfoFrame( parent, message);
117 m_InfoFrame->Show(true);
118 m_InfoFrame->Refresh();
119 m_InfoFrame->Update();
120 }
121
122 wxBusyInfo::~wxBusyInfo()
123 {
124 m_InfoFrame->Show(false);
125 m_InfoFrame->Close();
126 }
127
128 #endif // wxUSE_BUSYINFO