]> git.saurik.com Git - wxWidgets.git/blob - src/generic/busyinfo.cpp
missing commit
[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/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 #include "wx/generic/stattextg.h"
28
29 class WXDLLEXPORT wxInfoFrame : public wxFrame
30 {
31 public:
32 wxInfoFrame(wxWindow *parent, const wxString& message);
33
34 private:
35 wxDECLARE_NO_COPY_CLASS(wxInfoFrame);
36 };
37
38
39 wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
40 : wxFrame(parent, wxID_ANY, wxT("Busy"),
41 wxDefaultPosition, wxDefaultSize,
42 #if defined(__WXX11__)
43 wxRESIZE_BORDER
44 #else
45 wxSIMPLE_BORDER
46 #endif
47 | wxFRAME_TOOL_WINDOW | wxSTAY_ON_TOP)
48 {
49 wxPanel *panel = new wxPanel( this );
50 #ifdef __WXGTK__
51 wxGenericStaticText *text = new wxGenericStaticText(panel, wxID_ANY, message);
52 #else
53 wxStaticText *text = new wxStaticText(panel, wxID_ANY, message);
54 #endif
55
56 panel->SetCursor(*wxHOURGLASS_CURSOR);
57 text->SetCursor(*wxHOURGLASS_CURSOR);
58
59 // make the frame of at least the standard size (400*80) but big enough
60 // for the text we show
61 wxSize sizeText = text->GetBestSize();
62 #ifdef __WXPM__
63 int nX = 0;
64 int nY = 0;
65 int nWidth = 0;
66 int nHeight = 0;
67 int nParentHeight = parent->GetClientSize().y;
68 int nParentWidth = parent->GetClientSize().x;
69 int nColor;
70
71 SetBackgroundColour(wxT("WHITE"));
72 nColor = (LONG)GetBackgroundColour().GetPixel();
73
74 ::WinSetPresParam( GetHwnd()
75 ,PP_BACKGROUNDCOLOR
76 ,sizeof(LONG)
77 ,(PVOID)&nColor
78 );
79 panel->SetBackgroundColour(wxT("WHITE"));
80 nColor = (LONG)panel->GetBackgroundColour().GetPixel();
81
82 ::WinSetPresParam( GetHwndOf(panel)
83 ,PP_BACKGROUNDCOLOR
84 ,sizeof(LONG)
85 ,(PVOID)&nColor
86 );
87 nWidth = wxMax(sizeText.x, 340) + 60;
88 nHeight = wxMax(sizeText.y, 40) + 40;
89 nX = (nParentWidth - nWidth) / 2;
90 nY = (nParentHeight / 2) - (nHeight / 2);
91 nY = nParentHeight - (nY + nHeight);
92 ::WinSetWindowPos( m_hFrame
93 ,HWND_TOP
94 ,nX
95 ,nY
96 ,nWidth
97 ,nHeight
98 ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
99 );
100 text->SetBackgroundColour(wxT("WHITE"));
101 nColor = (LONG)text->GetBackgroundColour().GetPixel();
102
103 ::WinSetPresParam( GetHwndOf(text)
104 ,PP_BACKGROUNDCOLOR
105 ,sizeof(LONG)
106 ,(PVOID)&nColor
107 );
108 text->Center(wxBOTH);
109 #else
110 SetClientSize(wxMax(sizeText.x, 340) + 60, wxMax(sizeText.y, 40) + 40);
111
112 // need to size the panel correctly first so that text->Centre() works
113 panel->SetSize(GetClientSize());
114
115 text->Centre(wxBOTH);
116 Centre(wxBOTH);
117 #endif
118 }
119
120 wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent)
121 {
122 m_InfoFrame = new wxInfoFrame(parent, message);
123 m_InfoFrame->Show(true);
124 m_InfoFrame->Refresh();
125 m_InfoFrame->Update();
126 }
127
128 wxBusyInfo::~wxBusyInfo()
129 {
130 m_InfoFrame->Show(false);
131 m_InfoFrame->Close();
132 }
133
134 #endif // wxUSE_BUSYINFO