]> git.saurik.com Git - wxWidgets.git/blame - src/generic/busyinfo.cpp
recreate the window if FSAA is requested (changeset_r54022_Fix.patch from #9145)
[wxWidgets.git] / src / generic / busyinfo.cpp
CommitLineData
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
95d00805 20 #include "wx/frame.h"
b7ba00e7
WS
21 #include "wx/stattext.h"
22 #include "wx/panel.h"
23 #include "wx/utils.h"
24#endif
25
68b767bf 26#include "wx/busyinfo.h"
5526e819 27
b7ba00e7
WS
28class WXDLLEXPORT wxInfoFrame : public wxFrame
29{
30public:
31 wxInfoFrame(wxWindow *parent, const wxString& message);
32
33private:
34 DECLARE_NO_COPY_CLASS(wxInfoFrame)
35};
36
5526e819
VS
37
38wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
ca65c044 39 : wxFrame(parent, wxID_ANY, wxT("Busy"),
21977bac 40 wxDefaultPosition, wxDefaultSize,
868741e9 41#if defined(__WXX11__)
1c067fe3 42 wxRESIZE_BORDER
868741e9 43#else
68b767bf 44 wxSIMPLE_BORDER
868741e9 45#endif
68b767bf 46 | wxFRAME_TOOL_WINDOW)
5526e819 47{
21977bac 48 wxPanel *panel = new wxPanel( this );
ca65c044 49 wxStaticText *text = new wxStaticText(panel, wxID_ANY, message);
21977bac
VZ
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();
94640e04
DW
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
18ed8e00 66 SetBackgroundColour(wxT("WHITE"));
94640e04
DW
67 nColor = (LONG)GetBackgroundColour().GetPixel();
68
69 ::WinSetPresParam( GetHwnd()
70 ,PP_BACKGROUNDCOLOR
71 ,sizeof(LONG)
72 ,(PVOID)&nColor
73 );
18ed8e00 74 panel->SetBackgroundColour(wxT("WHITE"));
94640e04
DW
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 );
18ed8e00 95 text->SetBackgroundColour(wxT("WHITE"));
94640e04
DW
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
21977bac
VZ
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);
5526e819 111 Centre(wxBOTH);
94640e04 112#endif
5526e819
VS
113}
114
21977bac 115wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent)
5526e819 116{
21977bac 117 m_InfoFrame = new wxInfoFrame( parent, message);
b2c3b766
VZ
118 if ( parent && parent->HasFlag(wxSTAY_ON_TOP) )
119 {
120 // we must have this flag to be in front of our parent if it has it
121 m_InfoFrame->SetWindowStyleFlag(wxSTAY_ON_TOP);
122 }
123
ca65c044 124 m_InfoFrame->Show(true);
d1af991f 125 m_InfoFrame->Refresh();
0b634ddd 126 m_InfoFrame->Update();
399a4fe5
VZ
127
128#ifdef __WXGTK20__
129 // FIXME: this is pretty bad, as any call to Yield(), but without it, the
130 // static text is never shown and neither gdk_display_flush() nor
131 // gdk_display_sync() nor gdk_window_process_updates() helps
132 wxMilliSleep(100);
133 wxYield();
134#endif
5526e819
VS
135}
136
5526e819
VS
137wxBusyInfo::~wxBusyInfo()
138{
ca65c044 139 m_InfoFrame->Show(false);
d1af991f 140 m_InfoFrame->Close();
5526e819
VS
141}
142
b7ba00e7 143#endif // wxUSE_BUSYINFO