Merge wxQT branch into the trunk.
This merges in the latest sources from GSoC 2014 wxQt project with just a few minor corrections, mostly undoing wrong changes to common files in that branch (results of a previous bad merge?) and getting rid of whitespace-only changes. Also remove debug logging from wxGrid. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77455 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
200
src/qt/toplevel.cpp
Normal file
200
src/qt/toplevel.cpp
Normal file
@@ -0,0 +1,200 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/qt/toplevel.cpp
|
||||
// Author: Peter Most, Javier Torres
|
||||
// Copyright: (c) Peter Most, Javier Torres
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/toplevel.h"
|
||||
#include "wx/qt/private/converter.h"
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
wxTopLevelWindowQt::wxTopLevelWindowQt()
|
||||
{
|
||||
}
|
||||
|
||||
wxTopLevelWindowQt::wxTopLevelWindowQt(wxWindow *parent,
|
||||
wxWindowID winId,
|
||||
const wxString &title,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
long style,
|
||||
const wxString &name )
|
||||
{
|
||||
Create( parent, winId, title, pos, size, style, name );
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowQt::Create( wxWindow *parent, wxWindowID winId,
|
||||
const wxString &title, const wxPoint &pos, const wxSize &sizeOrig,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
wxSize size(sizeOrig);
|
||||
if ( !size.IsFullySpecified() )
|
||||
size.SetDefaults( GetDefaultSize() );
|
||||
|
||||
wxTopLevelWindows.Append( this );
|
||||
|
||||
if (!CreateBase( parent, winId, pos, size, style, wxDefaultValidator, name ))
|
||||
{
|
||||
wxFAIL_MSG( wxT("wxTopLevelWindowNative creation failed") );
|
||||
return false;
|
||||
}
|
||||
|
||||
SetTitle( title );
|
||||
SetWindowStyleFlag( style );
|
||||
|
||||
if (pos != wxDefaultPosition)
|
||||
m_qtWindow->move( pos.x, pos.y );
|
||||
|
||||
m_qtWindow->resize( wxQtConvertSize( size ) );
|
||||
|
||||
// Prevent automatic deletion of Qt main window on close
|
||||
// (this should be the default, but left just fo enforce it)
|
||||
GetHandle()->setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
|
||||
// not calling to wxWindow::Create, so do the rest of initialization:
|
||||
if (parent) parent->AddChild( this );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowQt::Maximize(bool WXUNUSED(maximize))
|
||||
{
|
||||
}
|
||||
|
||||
void wxTopLevelWindowQt::Restore()
|
||||
{
|
||||
}
|
||||
|
||||
void wxTopLevelWindowQt::Iconize(bool WXUNUSED(iconize) )
|
||||
{
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowQt::IsMaximized() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowQt::IsIconized() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool wxTopLevelWindowQt::ShowFullScreen(bool WXUNUSED(show), long WXUNUSED(style))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxTopLevelWindowQt::IsFullScreen() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowQt::SetTitle(const wxString& title)
|
||||
{
|
||||
GetHandle()->setWindowTitle( wxQtConvertString( title ));
|
||||
}
|
||||
|
||||
wxString wxTopLevelWindowQt::GetTitle() const
|
||||
{
|
||||
return ( wxQtConvertString( GetHandle()->windowTitle() ));
|
||||
}
|
||||
|
||||
void wxTopLevelWindowQt::SetIcons( const wxIconBundle& icons )
|
||||
{
|
||||
wxTopLevelWindowBase::SetIcons( icons );
|
||||
|
||||
QIcon qtIcons;
|
||||
for ( size_t i = 0; i < icons.GetIconCount(); i++ )
|
||||
{
|
||||
qtIcons.addPixmap( *icons.GetIconByIndex( i ).GetHandle() );
|
||||
}
|
||||
GetHandle()->setWindowIcon( qtIcons );
|
||||
}
|
||||
|
||||
void wxTopLevelWindowQt::SetWindowStyleFlag( long style )
|
||||
{
|
||||
wxWindow::SetWindowStyleFlag( style );
|
||||
|
||||
Qt::WindowFlags qtFlags = GetHandle()->windowFlags();
|
||||
|
||||
if ( HasFlag( wxSTAY_ON_TOP ) != qtFlags.testFlag( Qt::WindowStaysOnTopHint ) )
|
||||
qtFlags ^= Qt::WindowStaysOnTopHint;
|
||||
|
||||
if ( HasFlag( wxCAPTION ) )
|
||||
{
|
||||
// Only show buttons if window has caption
|
||||
if ( HasFlag( wxSYSTEM_MENU ) )
|
||||
{
|
||||
qtFlags |= Qt::WindowSystemMenuHint;
|
||||
if ( HasFlag( wxMINIMIZE_BOX ) )
|
||||
qtFlags |= Qt::WindowMinimizeButtonHint;
|
||||
else
|
||||
qtFlags &= ~Qt::WindowMinimizeButtonHint;
|
||||
|
||||
if ( HasFlag( wxMAXIMIZE_BOX ) )
|
||||
qtFlags |= Qt::WindowMaximizeButtonHint;
|
||||
else
|
||||
qtFlags &= ~Qt::WindowMaximizeButtonHint;
|
||||
|
||||
if ( HasFlag( wxCLOSE_BOX ) )
|
||||
qtFlags |= Qt::WindowCloseButtonHint;
|
||||
else
|
||||
qtFlags &= ~Qt::WindowCloseButtonHint;
|
||||
}
|
||||
else
|
||||
{
|
||||
qtFlags &= ~Qt::WindowSystemMenuHint;
|
||||
qtFlags &= ~Qt::WindowMinMaxButtonsHint;
|
||||
qtFlags &= ~Qt::WindowCloseButtonHint;
|
||||
}
|
||||
}
|
||||
|
||||
GetHandle()->setWindowFlags( qtFlags );
|
||||
|
||||
wxCHECK_RET( !( HasFlag( wxMAXIMIZE ) && HasFlag( wxMAXIMIZE ) ), "Window cannot be both maximized and minimized" );
|
||||
if ( HasFlag( wxMAXIMIZE ) )
|
||||
GetHandle()->setWindowState( Qt::WindowMaximized );
|
||||
else if ( HasFlag( wxMINIMIZE ) )
|
||||
GetHandle()->setWindowState( Qt::WindowMinimized );
|
||||
|
||||
if ( HasFlag( wxRESIZE_BORDER ) )
|
||||
GetHandle()->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
else
|
||||
GetHandle()->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
|
||||
if ( HasFlag( wxCENTRE ) )
|
||||
{
|
||||
Centre();
|
||||
}
|
||||
}
|
||||
|
||||
long wxTopLevelWindowQt::GetWindowStyleFlag() const
|
||||
{
|
||||
// Update maximized/minimized state
|
||||
long winStyle = wxWindow::GetWindowStyleFlag();
|
||||
|
||||
if (GetHandle())
|
||||
{
|
||||
switch ( GetHandle()->windowState() )
|
||||
{
|
||||
case Qt::WindowMaximized:
|
||||
winStyle &= ~wxMINIMIZE;
|
||||
winStyle |= wxMAXIMIZE;
|
||||
break;
|
||||
case Qt::WindowMinimized:
|
||||
winStyle &= ~wxMAXIMIZE;
|
||||
winStyle |= wxMINIMIZE;
|
||||
break;
|
||||
default:
|
||||
winStyle &= ~wxMINIMIZE;
|
||||
winStyle &= ~wxMAXIMIZE;
|
||||
}
|
||||
}
|
||||
|
||||
return winStyle;
|
||||
}
|
Reference in New Issue
Block a user