virtual bool EnableCloseButton(bool enable = true);
+ virtual void ShowWithoutActivating();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; };
virtual bool Show(bool show = true);
+ virtual void ShowWithoutActivating();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
virtual bool IsFullScreen() const { return m_fsIsShowing; }
virtual bool IsFullScreen() const;
virtual bool ShowFullScreen(bool show, long style);
+
+ virtual void ShowWithoutActivating();
virtual void RequestUserAttention(int flags);
virtual void ScreenToWindow( int *x, int *y );
virtual void WindowToScreen( int *x, int *y );
+ virtual bool IsActive();
bool MacGetUnifiedAppearance() const ;
virtual bool IsFullScreen() const;
virtual bool ShowFullScreen(bool show, long style);
+
+ virtual void ShowWithoutActivating();
virtual void RequestUserAttention(int flags);
virtual void WindowToScreen( int *x, int *y );
+ virtual bool IsActive();
+
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
protected :
WX_wxNSWindow m_macWindow;
virtual bool IsFullScreen() const= 0;
+ virtual void ShowWithoutActivating() { Show(true); }
+
virtual bool ShowFullScreen(bool show, long style)= 0;
virtual void RequestUserAttention(int flags) = 0;
virtual void WindowToScreen( int *x, int *y ) = 0;
+ virtual bool IsActive() = 0;
+
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
// static creation methods, must be implemented by all toolkits
virtual void WindowToScreen( int *x, int *y );
+ // FIXME: Does iPhone have a concept of inactive windows?
+ virtual bool IsActive() { return true; }
+
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
protected :
WX_UIWindow m_macWindow;
virtual void Iconize(bool iconize = true);
virtual bool IsIconized() const;
virtual void Restore();
+
+ virtual bool IsActive();
+ virtual void ShowWithoutActivating();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) ;
virtual bool IsFullScreen() const ;
// maximize the window to cover entire screen
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
+
+ // shows the window, but doesn't activate it. If the base code is being run,
+ // it means the port doesn't implement this method yet and so alert the user.
+ virtual void ShowWithoutActivating() {
+ wxFAIL_MSG("ShowWithoutActivating not implemented on this platform.");
+ }
// return true if the frame is in fullscreen mode
virtual bool IsFullScreen() const = 0;
m_iconized = nShowCmd == SW_MINIMIZE;
}
+void wxTopLevelWindowMSW::ShowWithoutActivating()
+{
+ if ( !wxWindowBase::Show(true) )
+ return false;
+
+ DoShowWindow(SW_SHOWNA);
+}
+
bool wxTopLevelWindowMSW::Show(bool show)
{
// don't use wxWindow version as we want to call DoShowWindow() ourselves
::SendBehind( m_macWindow , NULL ) ;
}
+void wxNonOwnedWindowCarbonImpl::ShowWithoutActivating()
+{
+ bool plainTransition = true;
+
+#if wxUSE_SYSTEM_OPTIONS
+ if ( wxSystemOptions::HasOption(wxMAC_WINDOW_PLAIN_TRANSITION) )
+ plainTransition = ( wxSystemOptions::GetOptionInt( wxMAC_WINDOW_PLAIN_TRANSITION ) == 1 ) ;
+#endif
+
+ if ( plainTransition )
+ ::ShowWindow( (WindowRef)m_macWindow );
+ else
+ ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
+}
+
bool wxNonOwnedWindowCarbonImpl::Show(bool show)
{
bool plainTransition = true;
if (show)
{
-#if wxOSX_USE_CARBON
- if ( plainTransition )
- ::ShowWindow( (WindowRef)m_macWindow );
- else
- ::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
-
+ ShowWithoutActivating();
::SelectWindow( (WindowRef)m_macWindow ) ;
-#endif
}
else
{
*y = (int)p.y;
}
+bool wxNonOwnedWindowCarbonImpl::IsActive()
+{
+ return ActiveNonFloatingWindow() == m_macWindow;
+}
+
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name )
{
[m_macWindow orderWindow:NSWindowBelow relativeTo:0];
}
+void wxNonOwnedWindowCocoaImpl::ShowWithoutActivating()
+{
+ [[m_macWindow contentView] setNeedsDisplay:YES];
+}
+
bool wxNonOwnedWindowCocoaImpl::Show(bool show)
{
if ( show )
{
wxNonOwnedWindow* wxpeer = GetWXPeer();
if (wxpeer && !(wxpeer->GetWindowStyle() & wxFRAME_TOOL_WINDOW))
- [m_macWindow makeKeyAndOrderFront:nil];
+ [m_macWindow makeKeyAndOrderFront:nil];
else
[m_macWindow orderFront:nil];
-
- [[m_macWindow contentView] setNeedsDisplay:YES];
+ ShowWithoutActivating();
}
else
[m_macWindow orderOut:nil];
*y = p.y;
}
+bool wxNonOwnedWindowCocoaImpl::IsActive()
+{
+ return [m_macWindow isKeyWindow];
+}
+
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& name )
{
return wxWindow::GetLabel();
}
+void wxTopLevelWindowMac::ShowWithoutActivating()
+{
+ return m_nowpeer->ShowWithoutActivating();
+}
+
bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
{
return m_nowpeer->ShowFullScreen(show, style);
{
return m_nowpeer->RequestUserAttention(flags);
}
+
+bool wxTopLevelWindowMac::IsActive()
+{
+ return m_nowpeer->IsActive();
+}
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/toplevel/toplevel.cpp
+// Purpose: Tests for wxTopLevelWindow
+// Author: Kevin Ollivier
+// Created: 2008-05-25
+// RCS-ID: $Id: toplevel.cpp 53741 2008-05-25 03:08:31Z VZ $
+// Copyright: (c) 2009 Kevin Ollivier <kevino@theolliviers.com>
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+ #include "wx/window.h"
+#endif // WX_PRECOMP
+
+#include "wx/evtloop.h"
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class TopLevelWindowTestCase : public CppUnit::TestCase
+{
+public:
+ TopLevelWindowTestCase() { }
+
+ virtual void setUp();
+ virtual void tearDown();
+
+private:
+ CPPUNIT_TEST_SUITE( TopLevelWindowTestCase );
+ CPPUNIT_TEST( DialogShowTest );
+ CPPUNIT_TEST( FrameShowTest );
+ CPPUNIT_TEST_SUITE_END();
+
+ void DialogShowTest();
+ void FrameShowTest();
+ void TopLevelWindowShowTest(wxTopLevelWindow* tlw);
+
+ DECLARE_NO_COPY_CLASS(TopLevelWindowTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( TopLevelWindowTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TopLevelWindowTestCase, "TopLevelWindowTestCase" );
+
+// ----------------------------------------------------------------------------
+// test initialization
+// ----------------------------------------------------------------------------
+
+void TopLevelWindowTestCase::setUp()
+{
+}
+
+void TopLevelWindowTestCase::tearDown()
+{
+}
+
+// ----------------------------------------------------------------------------
+// tests themselves
+// ----------------------------------------------------------------------------
+
+void TopLevelWindowTestCase::DialogShowTest()
+{
+ wxDialog* dialog = new wxDialog(NULL, -1, "Dialog Test");
+ TopLevelWindowShowTest(dialog);
+ dialog->Destroy();
+}
+
+void TopLevelWindowTestCase::FrameShowTest()
+{
+ wxFrame* frame = new wxFrame(NULL, -1, "Frame test");
+ TopLevelWindowShowTest(frame);
+ frame->Destroy();
+}
+
+void TopLevelWindowTestCase::TopLevelWindowShowTest(wxTopLevelWindow* tlw)
+{
+ CPPUNIT_ASSERT(!tlw->IsShown());
+
+ wxTextCtrl* textCtrl = new wxTextCtrl(tlw, -1, "test");
+ textCtrl->SetFocus();
+
+// only run this test on platforms where ShowWithoutActivating is implemented.
+#ifdef __WXMSW__ || defined(__WXMAC__)
+ tlw->ShowWithoutActivating();
+ CPPUNIT_ASSERT(tlw->IsShown());
+ CPPUNIT_ASSERT(!tlw->IsActive());
+
+ tlw->Hide();
+ CPPUNIT_ASSERT(!tlw->IsShown());
+ CPPUNIT_ASSERT(!tlw->IsActive());
+#endif
+
+ tlw->Show(true);
+ CPPUNIT_ASSERT(tlw->IsActive());
+ CPPUNIT_ASSERT(tlw->IsShown());
+
+ tlw->Hide();
+ CPPUNIT_ASSERT(!tlw->IsShown());
+ CPPUNIT_ASSERT(tlw->IsActive());
+}