]> git.saurik.com Git - wxWidgets.git/blob - src/generic/busyinfo.cpp
Fix for wxMac when the tree doesn't have the focus and the
[wxWidgets.git] / src / generic / busyinfo.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: busyinfo.cpp
3 // Purpose: Information window when app is busy
4 // Author: Vaclav Slavik
5 // Copyright: (c) 1999 Vaclav Slavik
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #include "wx/wxprec.h"
10
11 #ifdef __BORLANDC__
12 #pragma hdrstop
13 #endif
14
15 #if wxUSE_BUSYINFO
16
17 #include "wx/stattext.h"
18 #include "wx/panel.h"
19 #include "wx/utils.h"
20 #include "wx/busyinfo.h"
21
22
23 wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
24 : wxFrame(parent, wxID_ANY, wxT("Busy"),
25 wxDefaultPosition, wxDefaultSize,
26 #if defined(__WXX11__)
27 wxTHICK_FRAME
28 #else
29 wxSIMPLE_BORDER
30 #endif
31 | wxFRAME_TOOL_WINDOW)
32 {
33 wxPanel *panel = new wxPanel( this );
34 wxStaticText *text = new wxStaticText(panel, wxID_ANY, message);
35
36 panel->SetCursor(*wxHOURGLASS_CURSOR);
37 text->SetCursor(*wxHOURGLASS_CURSOR);
38
39 // make the frame of at least the standard size (400*80) but big enough
40 // for the text we show
41 wxSize sizeText = text->GetBestSize();
42 #ifdef __WXPM__
43 int nX = 0;
44 int nY = 0;
45 int nWidth = 0;
46 int nHeight = 0;
47 int nParentHeight = parent->GetClientSize().y;
48 int nParentWidth = parent->GetClientSize().x;
49 int nColor;
50
51 SetBackgroundColour(wxT("WHITE"));
52 nColor = (LONG)GetBackgroundColour().GetPixel();
53
54 ::WinSetPresParam( GetHwnd()
55 ,PP_BACKGROUNDCOLOR
56 ,sizeof(LONG)
57 ,(PVOID)&nColor
58 );
59 panel->SetBackgroundColour(wxT("WHITE"));
60 nColor = (LONG)panel->GetBackgroundColour().GetPixel();
61
62 ::WinSetPresParam( GetHwndOf(panel)
63 ,PP_BACKGROUNDCOLOR
64 ,sizeof(LONG)
65 ,(PVOID)&nColor
66 );
67 nWidth = wxMax(sizeText.x, 340) + 60;
68 nHeight = wxMax(sizeText.y, 40) + 40;
69 nX = (nParentWidth - nWidth) / 2;
70 nY = (nParentHeight / 2) - (nHeight / 2);
71 nY = nParentHeight - (nY + nHeight);
72 ::WinSetWindowPos( m_hFrame
73 ,HWND_TOP
74 ,nX
75 ,nY
76 ,nWidth
77 ,nHeight
78 ,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE
79 );
80 text->SetBackgroundColour(wxT("WHITE"));
81 nColor = (LONG)text->GetBackgroundColour().GetPixel();
82
83 ::WinSetPresParam( GetHwndOf(text)
84 ,PP_BACKGROUNDCOLOR
85 ,sizeof(LONG)
86 ,(PVOID)&nColor
87 );
88 text->Center(wxBOTH);
89 #else
90 SetClientSize(wxMax(sizeText.x, 340) + 60, wxMax(sizeText.y, 40) + 40);
91
92 // need to size the panel correctly first so that text->Centre() works
93 panel->SetSize(GetClientSize());
94
95 text->Centre(wxBOTH);
96 Centre(wxBOTH);
97 #endif
98 }
99
100 wxBusyInfo::wxBusyInfo(const wxString& message, wxWindow *parent)
101 {
102 m_InfoFrame = new wxInfoFrame( parent, message);
103 m_InfoFrame->Show(true);
104 m_InfoFrame->Refresh();
105 m_InfoFrame->Update();
106 }
107
108 wxBusyInfo::~wxBusyInfo()
109 {
110 m_InfoFrame->Show(false);
111 m_InfoFrame->Close();
112 }
113
114 #endif
115 // wxUSE_BUSYINFO
116