Initial ShowWithoutActivating implementations for Mac and Windows, and attempt to improve IsActive behavior on Mac. Also adding ShowWithoutActivating() and Show/Hide tests, but until the mainloop issues are resolved, not adding them to tests.bkl.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -52,6 +52,7 @@ public:
|
|||||||
|
|
||||||
virtual bool EnableCloseButton(bool enable = true);
|
virtual bool EnableCloseButton(bool enable = true);
|
||||||
|
|
||||||
|
virtual void ShowWithoutActivating();
|
||||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||||
virtual bool IsFullScreen() const { return m_fsIsShowing; };
|
virtual bool IsFullScreen() const { return m_fsIsShowing; };
|
||||||
|
|
||||||
|
@@ -64,6 +64,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Show(bool show = true);
|
virtual bool Show(bool show = true);
|
||||||
|
|
||||||
|
virtual void ShowWithoutActivating();
|
||||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
|
||||||
virtual bool IsFullScreen() const { return m_fsIsShowing; }
|
virtual bool IsFullScreen() const { return m_fsIsShowing; }
|
||||||
|
|
||||||
|
@@ -1041,11 +1041,14 @@ public :
|
|||||||
|
|
||||||
virtual bool ShowFullScreen(bool show, long style);
|
virtual bool ShowFullScreen(bool show, long style);
|
||||||
|
|
||||||
|
virtual void ShowWithoutActivating();
|
||||||
|
|
||||||
virtual void RequestUserAttention(int flags);
|
virtual void RequestUserAttention(int flags);
|
||||||
|
|
||||||
virtual void ScreenToWindow( int *x, int *y );
|
virtual void ScreenToWindow( int *x, int *y );
|
||||||
|
|
||||||
virtual void WindowToScreen( int *x, int *y );
|
virtual void WindowToScreen( int *x, int *y );
|
||||||
|
virtual bool IsActive();
|
||||||
|
|
||||||
|
|
||||||
bool MacGetUnifiedAppearance() const ;
|
bool MacGetUnifiedAppearance() const ;
|
||||||
|
@@ -234,12 +234,16 @@ public :
|
|||||||
|
|
||||||
virtual bool ShowFullScreen(bool show, long style);
|
virtual bool ShowFullScreen(bool show, long style);
|
||||||
|
|
||||||
|
virtual void ShowWithoutActivating();
|
||||||
|
|
||||||
virtual void RequestUserAttention(int flags);
|
virtual void RequestUserAttention(int flags);
|
||||||
|
|
||||||
virtual void ScreenToWindow( int *x, int *y );
|
virtual void ScreenToWindow( int *x, int *y );
|
||||||
|
|
||||||
virtual void WindowToScreen( int *x, int *y );
|
virtual void WindowToScreen( int *x, int *y );
|
||||||
|
|
||||||
|
virtual bool IsActive();
|
||||||
|
|
||||||
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
||||||
protected :
|
protected :
|
||||||
WX_wxNSWindow m_macWindow;
|
WX_wxNSWindow m_macWindow;
|
||||||
|
@@ -717,6 +717,8 @@ public :
|
|||||||
|
|
||||||
virtual bool IsFullScreen() const= 0;
|
virtual bool IsFullScreen() const= 0;
|
||||||
|
|
||||||
|
virtual void ShowWithoutActivating() { Show(true); }
|
||||||
|
|
||||||
virtual bool ShowFullScreen(bool show, long style)= 0;
|
virtual bool ShowFullScreen(bool show, long style)= 0;
|
||||||
|
|
||||||
virtual void RequestUserAttention(int flags) = 0;
|
virtual void RequestUserAttention(int flags) = 0;
|
||||||
@@ -725,6 +727,8 @@ public :
|
|||||||
|
|
||||||
virtual void WindowToScreen( int *x, int *y ) = 0;
|
virtual void WindowToScreen( int *x, int *y ) = 0;
|
||||||
|
|
||||||
|
virtual bool IsActive() = 0;
|
||||||
|
|
||||||
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
||||||
|
|
||||||
// static creation methods, must be implemented by all toolkits
|
// static creation methods, must be implemented by all toolkits
|
||||||
|
@@ -169,6 +169,9 @@ public :
|
|||||||
|
|
||||||
virtual void WindowToScreen( int *x, int *y );
|
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; }
|
wxNonOwnedWindow* GetWXPeer() { return m_wxPeer; }
|
||||||
protected :
|
protected :
|
||||||
WX_UIWindow m_macWindow;
|
WX_UIWindow m_macWindow;
|
||||||
|
@@ -63,6 +63,9 @@ public:
|
|||||||
virtual bool IsIconized() const;
|
virtual bool IsIconized() const;
|
||||||
virtual void Restore();
|
virtual void Restore();
|
||||||
|
|
||||||
|
virtual bool IsActive();
|
||||||
|
|
||||||
|
virtual void ShowWithoutActivating();
|
||||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) ;
|
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) ;
|
||||||
virtual bool IsFullScreen() const ;
|
virtual bool IsFullScreen() const ;
|
||||||
|
|
||||||
|
@@ -161,6 +161,12 @@ public:
|
|||||||
// maximize the window to cover entire screen
|
// maximize the window to cover entire screen
|
||||||
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
|
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
|
// return true if the frame is in fullscreen mode
|
||||||
virtual bool IsFullScreen() const = 0;
|
virtual bool IsFullScreen() const = 0;
|
||||||
|
|
||||||
|
@@ -609,6 +609,14 @@ void wxTopLevelWindowMSW::DoShowWindow(int nShowCmd)
|
|||||||
m_iconized = nShowCmd == SW_MINIMIZE;
|
m_iconized = nShowCmd == SW_MINIMIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTopLevelWindowMSW::ShowWithoutActivating()
|
||||||
|
{
|
||||||
|
if ( !wxWindowBase::Show(true) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DoShowWindow(SW_SHOWNA);
|
||||||
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowMSW::Show(bool show)
|
bool wxTopLevelWindowMSW::Show(bool show)
|
||||||
{
|
{
|
||||||
// don't use wxWindow version as we want to call DoShowWindow() ourselves
|
// don't use wxWindow version as we want to call DoShowWindow() ourselves
|
||||||
|
@@ -51,6 +51,21 @@ void wxNonOwnedWindowCarbonImpl::Lower()
|
|||||||
::SendBehind( m_macWindow , NULL ) ;
|
::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 wxNonOwnedWindowCarbonImpl::Show(bool show)
|
||||||
{
|
{
|
||||||
bool plainTransition = true;
|
bool plainTransition = true;
|
||||||
@@ -62,14 +77,8 @@ bool wxNonOwnedWindowCarbonImpl::Show(bool show)
|
|||||||
|
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
#if wxOSX_USE_CARBON
|
ShowWithoutActivating();
|
||||||
if ( plainTransition )
|
|
||||||
::ShowWindow( (WindowRef)m_macWindow );
|
|
||||||
else
|
|
||||||
::TransitionWindow( (WindowRef)m_macWindow, kWindowZoomTransitionEffect, kWindowShowTransitionAction, NULL );
|
|
||||||
|
|
||||||
::SelectWindow( (WindowRef)m_macWindow ) ;
|
::SelectWindow( (WindowRef)m_macWindow ) ;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1669,6 +1678,11 @@ void wxNonOwnedWindowCarbonImpl::WindowToScreen( int *x, int *y )
|
|||||||
*y = (int)p.y;
|
*y = (int)p.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxNonOwnedWindowCarbonImpl::IsActive()
|
||||||
|
{
|
||||||
|
return ActiveNonFloatingWindow() == m_macWindow;
|
||||||
|
}
|
||||||
|
|
||||||
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||||
long style, long extraStyle, const wxString& name )
|
long style, long extraStyle, const wxString& name )
|
||||||
{
|
{
|
||||||
|
@@ -471,6 +471,11 @@ void wxNonOwnedWindowCocoaImpl::Lower()
|
|||||||
[m_macWindow orderWindow:NSWindowBelow relativeTo:0];
|
[m_macWindow orderWindow:NSWindowBelow relativeTo:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNonOwnedWindowCocoaImpl::ShowWithoutActivating()
|
||||||
|
{
|
||||||
|
[[m_macWindow contentView] setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
|
|
||||||
bool wxNonOwnedWindowCocoaImpl::Show(bool show)
|
bool wxNonOwnedWindowCocoaImpl::Show(bool show)
|
||||||
{
|
{
|
||||||
if ( show )
|
if ( show )
|
||||||
@@ -480,8 +485,7 @@ bool wxNonOwnedWindowCocoaImpl::Show(bool show)
|
|||||||
[m_macWindow makeKeyAndOrderFront:nil];
|
[m_macWindow makeKeyAndOrderFront:nil];
|
||||||
else
|
else
|
||||||
[m_macWindow orderFront:nil];
|
[m_macWindow orderFront:nil];
|
||||||
|
ShowWithoutActivating();
|
||||||
[[m_macWindow contentView] setNeedsDisplay:YES];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
[m_macWindow orderOut:nil];
|
[m_macWindow orderOut:nil];
|
||||||
@@ -676,6 +680,11 @@ void wxNonOwnedWindowCocoaImpl::WindowToScreen( int *x, int *y )
|
|||||||
*y = p.y;
|
*y = p.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxNonOwnedWindowCocoaImpl::IsActive()
|
||||||
|
{
|
||||||
|
return [m_macWindow isKeyWindow];
|
||||||
|
}
|
||||||
|
|
||||||
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||||
long style, long extraStyle, const wxString& name )
|
long style, long extraStyle, const wxString& name )
|
||||||
{
|
{
|
||||||
|
@@ -157,6 +157,11 @@ wxString wxTopLevelWindowMac::GetTitle() const
|
|||||||
return wxWindow::GetLabel();
|
return wxWindow::GetLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTopLevelWindowMac::ShowWithoutActivating()
|
||||||
|
{
|
||||||
|
return m_nowpeer->ShowWithoutActivating();
|
||||||
|
}
|
||||||
|
|
||||||
bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
|
bool wxTopLevelWindowMac::ShowFullScreen(bool show, long style)
|
||||||
{
|
{
|
||||||
return m_nowpeer->ShowFullScreen(show, style);
|
return m_nowpeer->ShowFullScreen(show, style);
|
||||||
@@ -171,3 +176,8 @@ void wxTopLevelWindowMac::RequestUserAttention(int flags)
|
|||||||
{
|
{
|
||||||
return m_nowpeer->RequestUserAttention(flags);
|
return m_nowpeer->RequestUserAttention(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxTopLevelWindowMac::IsActive()
|
||||||
|
{
|
||||||
|
return m_nowpeer->IsActive();
|
||||||
|
}
|
||||||
|
113
tests/toplevel/toplevel.cpp
Normal file
113
tests/toplevel/toplevel.cpp
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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());
|
||||||
|
}
|
Reference in New Issue
Block a user