]> git.saurik.com Git - wxWidgets.git/blame - src/generic/busyinfo.cpp
Fixed printf-related warnings
[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"
d0285203 27#include "wx/generic/stattextg.h"
5526e819 28
b7ba00e7
WS
29class WXDLLEXPORT wxInfoFrame : public wxFrame
30{
31public:
32 wxInfoFrame(wxWindow *parent, const wxString& message);
33
34private:
c0c133e1 35 wxDECLARE_NO_COPY_CLASS(wxInfoFrame);
b7ba00e7
WS
36};
37
5526e819
VS
38
39wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
ca65c044 40 : wxFrame(parent, wxID_ANY, wxT("Busy"),
21977bac 41 wxDefaultPosition, wxDefaultSize,
868741e9 42#if defined(__WXX11__)
1c067fe3 43 wxRESIZE_BORDER
868741e9 44#else
68b767bf 45 wxSIMPLE_BORDER
868741e9 46#endif
e1215210 47 | wxFRAME_TOOL_WINDOW | wxSTAY_ON_TOP)
5526e819 48{
21977bac 49 wxPanel *panel = new wxPanel( this );
f5d59096 50#ifdef __WXGTK__
d0285203
RR
51 wxGenericStaticText *text = new wxGenericStaticText(panel, wxID_ANY, message);
52#else
ca65c044 53 wxStaticText *text = new wxStaticText(panel, wxID_ANY, message);
d0285203 54#endif
21977bac
VZ
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();
94640e04
DW
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
18ed8e00 71 SetBackgroundColour(wxT("WHITE"));
94640e04
DW
72 nColor = (LONG)GetBackgroundColour().GetPixel();
73
74 ::WinSetPresParam( GetHwnd()
75 ,PP_BACKGROUNDCOLOR
76 ,sizeof(LONG)
77 ,(PVOID)&nColor
78 );
18ed8e00 79 panel->SetBackgroundColour(wxT("WHITE"));
94640e04
DW
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 );
18ed8e00 100 text->SetBackgroundColour(wxT("WHITE"));
94640e04
DW
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
21977bac
VZ
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);
5526e819 116 Centre(wxBOTH);
94640e04 117#endif
5526e819
VS
118}
119
21977bac 120wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent)
5526e819 121{
e1215210 122 m_InfoFrame = new wxInfoFrame(parent, message);
ca65c044 123 m_InfoFrame->Show(true);
d1af991f 124 m_InfoFrame->Refresh();
0b634ddd 125 m_InfoFrame->Update();
5526e819
VS
126}
127
5526e819
VS
128wxBusyInfo::~wxBusyInfo()
129{
ca65c044 130 m_InfoFrame->Show(false);
d1af991f 131 m_InfoFrame->Close();
5526e819
VS
132}
133
b7ba00e7 134#endif // wxUSE_BUSYINFO