mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 17:19:44 -06:00
Import r67258 of the wxWidgets trunk, which I expect will before
long become wxWidgets 2.9.2, which in turn is expected to be the last 2.9 release before the 3.0 stable release. Since the full wxWidgets distribution is rather large, I have imported only the parts that we use, on a subdirectory basis: art include/wx/*.* include/wx/aui include/wx/cocoa include/wx/generic include/wx/gtk include/wx/meta include/wx/msw include/wx/osx include/wx/persist include/wx/private include/wx/protocol include/wx/unix src/aui src/common src/generic src/gtk src/msw src/osx src/unix git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7380 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
67
Externals/wxWidgets3/include/wx/persist/bookctrl.h
vendored
Normal file
67
Externals/wxWidgets3/include/wx/persist/bookctrl.h
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/bookctrl.h
|
||||
// Purpose: persistence support for wxBookCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-01-19
|
||||
// RCS-ID: $Id: bookctrl.h 58529 2009-01-30 21:38:29Z VZ $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PERSIST_BOOKCTRL_H_
|
||||
#define _WX_PERSIST_BOOKCTRL_H_
|
||||
|
||||
#include "wx/persist/window.h"
|
||||
|
||||
#include "wx/bookctrl.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string constants used by wxPersistentBookCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxPERSIST_BOOK_KIND "Book"
|
||||
|
||||
#define wxPERSIST_BOOK_SELECTION "Selection"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPersistentBookCtrl: supports saving/restoring book control selection
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxPersistentBookCtrl : public wxPersistentWindow<wxBookCtrlBase>
|
||||
{
|
||||
public:
|
||||
wxPersistentBookCtrl(wxBookCtrlBase *book)
|
||||
: wxPersistentWindow<wxBookCtrlBase>(book)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Save() const
|
||||
{
|
||||
SaveValue(wxPERSIST_BOOK_SELECTION, Get()->GetSelection());
|
||||
}
|
||||
|
||||
virtual bool Restore()
|
||||
{
|
||||
long sel;
|
||||
if ( RestoreValue(wxPERSIST_BOOK_SELECTION, &sel) )
|
||||
{
|
||||
wxBookCtrlBase * const book = Get();
|
||||
if ( sel >= 0 && (unsigned)sel < book->GetPageCount() )
|
||||
{
|
||||
book->SetSelection(sel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual wxString GetKind() const { return wxPERSIST_BOOK_KIND; }
|
||||
};
|
||||
|
||||
inline wxPersistentObject *wxCreatePersistentObject(wxBookCtrlBase *book)
|
||||
{
|
||||
return new wxPersistentBookCtrl(book);
|
||||
}
|
||||
|
||||
#endif // _WX_PERSIST_BOOKCTRL_H_
|
129
Externals/wxWidgets3/include/wx/persist/toplevel.h
vendored
Normal file
129
Externals/wxWidgets3/include/wx/persist/toplevel.h
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/toplevel.h
|
||||
// Purpose: persistence support for wxTLW
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-01-19
|
||||
// RCS-ID: $Id: toplevel.h 58529 2009-01-30 21:38:29Z VZ $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PERSIST_TOPLEVEL_H_
|
||||
#define _WX_PERSIST_TOPLEVEL_H_
|
||||
|
||||
#include "wx/persist/window.h"
|
||||
|
||||
#include "wx/toplevel.h"
|
||||
#include "wx/display.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string constants used by wxPersistentTLW
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// we use just "Window" to keep configuration files and such short, there
|
||||
// should be no confusion with wxWindow itself as we don't have persistent
|
||||
// windows, just persistent controls which have their own specific kind strings
|
||||
#define wxPERSIST_TLW_KIND "Window"
|
||||
|
||||
// names for various persistent options
|
||||
#define wxPERSIST_TLW_X "x"
|
||||
#define wxPERSIST_TLW_Y "y"
|
||||
#define wxPERSIST_TLW_W "w"
|
||||
#define wxPERSIST_TLW_H "h"
|
||||
|
||||
#define wxPERSIST_TLW_MAXIMIZED "Maximized"
|
||||
#define wxPERSIST_TLW_ICONIZED "Iconized"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPersistentTLW: supports saving/restoring window position and size as well
|
||||
// as maximized/iconized/restore state
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxPersistentTLW : public wxPersistentWindow<wxTopLevelWindow>
|
||||
{
|
||||
public:
|
||||
wxPersistentTLW(wxTopLevelWindow *tlw)
|
||||
: wxPersistentWindow<wxTopLevelWindow>(tlw)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Save() const
|
||||
{
|
||||
const wxTopLevelWindow * const tlw = Get();
|
||||
|
||||
const wxPoint pos = tlw->GetScreenPosition();
|
||||
SaveValue(wxPERSIST_TLW_X, pos.x);
|
||||
SaveValue(wxPERSIST_TLW_Y, pos.y);
|
||||
|
||||
// notice that we use GetSize() here and not GetClientSize() because
|
||||
// the latter doesn't return correct results for the minimized windows
|
||||
// (at least not under Windows)
|
||||
//
|
||||
// of course, it shouldn't matter anyhow usually, the client size
|
||||
// should be preserved as well unless the size of the decorations
|
||||
// changed between the runs
|
||||
const wxSize size = tlw->GetSize();
|
||||
SaveValue(wxPERSIST_TLW_W, size.x);
|
||||
SaveValue(wxPERSIST_TLW_H, size.y);
|
||||
|
||||
SaveValue(wxPERSIST_TLW_MAXIMIZED, tlw->IsMaximized());
|
||||
SaveValue(wxPERSIST_TLW_ICONIZED, tlw->IsIconized());
|
||||
}
|
||||
|
||||
virtual bool Restore()
|
||||
{
|
||||
wxTopLevelWindow * const tlw = Get();
|
||||
|
||||
long x wxDUMMY_INITIALIZE(-1),
|
||||
y wxDUMMY_INITIALIZE(-1),
|
||||
w wxDUMMY_INITIALIZE(-1),
|
||||
h wxDUMMY_INITIALIZE(-1);
|
||||
const bool hasPos = RestoreValue(wxPERSIST_TLW_X, &x) &&
|
||||
RestoreValue(wxPERSIST_TLW_Y, &y);
|
||||
const bool hasSize = RestoreValue(wxPERSIST_TLW_W, &w) &&
|
||||
RestoreValue(wxPERSIST_TLW_H, &h);
|
||||
|
||||
if ( hasPos )
|
||||
{
|
||||
// to avoid making the window completely invisible if it had been
|
||||
// shown on a monitor which was disconnected since the last run
|
||||
// (this is pretty common for notebook with external displays)
|
||||
//
|
||||
// NB: we should allow window position to be (slightly) off screen,
|
||||
// it's not uncommon to position the window so that its upper
|
||||
// left corner has slightly negative coordinate
|
||||
if ( wxDisplay::GetFromPoint(wxPoint(x, y)) != wxNOT_FOUND ||
|
||||
(hasSize && wxDisplay::GetFromPoint(
|
||||
wxPoint(x + w, y + h)) != wxNOT_FOUND) )
|
||||
{
|
||||
tlw->Move(x, y, wxSIZE_ALLOW_MINUS_ONE);
|
||||
}
|
||||
//else: should we try to adjust position/size somehow?
|
||||
}
|
||||
|
||||
if ( hasSize )
|
||||
tlw->SetSize(w, h);
|
||||
|
||||
// note that the window can be both maximized and iconized
|
||||
bool maximized;
|
||||
if ( RestoreValue(wxPERSIST_TLW_MAXIMIZED, &maximized) && maximized )
|
||||
tlw->Maximize();
|
||||
|
||||
bool iconized;
|
||||
if ( RestoreValue(wxPERSIST_TLW_ICONIZED, &iconized) && iconized )
|
||||
tlw->Iconize();
|
||||
|
||||
// the most important property of the window that we restore is its
|
||||
// size, so disregard the value of hasPos here
|
||||
return hasSize;
|
||||
}
|
||||
|
||||
virtual wxString GetKind() const { return wxPERSIST_TLW_KIND; }
|
||||
};
|
||||
|
||||
inline wxPersistentObject *wxCreatePersistentObject(wxTopLevelWindow *tlw)
|
||||
{
|
||||
return new wxPersistentTLW(tlw);
|
||||
}
|
||||
|
||||
#endif // _WX_PERSIST_TOPLEVEL_H_
|
97
Externals/wxWidgets3/include/wx/persist/treebook.h
vendored
Normal file
97
Externals/wxWidgets3/include/wx/persist/treebook.h
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/treebook.h
|
||||
// Purpose: persistence support for wxBookCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-01-19
|
||||
// RCS-ID: $Id: treebook.h 58529 2009-01-30 21:38:29Z VZ $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PERSIST_TREEBOOK_H_
|
||||
#define _WX_PERSIST_TREEBOOK_H_
|
||||
|
||||
#include "wx/persist/bookctrl.h"
|
||||
|
||||
#include "wx/arrstr.h"
|
||||
#include "wx/treebook.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// string constants used by wxPersistentTreeBookCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define wxPERSIST_TREEBOOK_KIND "TreeBook"
|
||||
|
||||
// this key contains the indices of all expanded nodes in the tree book
|
||||
// separated by wxPERSIST_TREEBOOK_EXPANDED_SEP
|
||||
#define wxPERSIST_TREEBOOK_EXPANDED_BRANCHES "Expanded"
|
||||
#define wxPERSIST_TREEBOOK_EXPANDED_SEP ','
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPersistentTreeBookCtrl: supports saving/restoring open tree branches
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxPersistentTreeBookCtrl : public wxPersistentBookCtrl
|
||||
{
|
||||
public:
|
||||
wxPersistentTreeBookCtrl(wxTreebook *book)
|
||||
: wxPersistentBookCtrl(book)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Save() const
|
||||
{
|
||||
const wxTreebook * const book = GetTreeBook();
|
||||
|
||||
wxString expanded;
|
||||
const size_t count = book->GetPageCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
if ( book->IsNodeExpanded(n) )
|
||||
{
|
||||
if ( !expanded.empty() )
|
||||
expanded += wxPERSIST_TREEBOOK_EXPANDED_SEP;
|
||||
|
||||
expanded += wxString::Format("%u", static_cast<unsigned>(n));
|
||||
}
|
||||
}
|
||||
|
||||
SaveValue(wxPERSIST_TREEBOOK_EXPANDED_BRANCHES, expanded);
|
||||
|
||||
wxPersistentBookCtrl::Save();
|
||||
}
|
||||
|
||||
virtual bool Restore()
|
||||
{
|
||||
wxTreebook * const book = GetTreeBook();
|
||||
|
||||
wxString expanded;
|
||||
if ( RestoreValue(wxPERSIST_TREEBOOK_EXPANDED_BRANCHES, &expanded) )
|
||||
{
|
||||
const wxArrayString
|
||||
indices(wxSplit(expanded, wxPERSIST_TREEBOOK_EXPANDED_SEP));
|
||||
|
||||
const size_t pageCount = book->GetPageCount();
|
||||
const size_t count = indices.size();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
unsigned long idx;
|
||||
if ( indices[n].ToULong(&idx) && idx < pageCount )
|
||||
book->ExpandNode(idx);
|
||||
}
|
||||
}
|
||||
|
||||
return wxPersistentBookCtrl::Restore();
|
||||
}
|
||||
|
||||
virtual wxString GetKind() const { return wxPERSIST_TREEBOOK_KIND; }
|
||||
|
||||
wxTreebook *GetTreeBook() const { return static_cast<wxTreebook *>(Get()); }
|
||||
};
|
||||
|
||||
inline wxPersistentObject *wxCreatePersistentObject(wxTreebook *book)
|
||||
{
|
||||
return new wxPersistentTreeBookCtrl(book);
|
||||
}
|
||||
|
||||
#endif // _WX_PERSIST_TREEBOOK_H_
|
80
Externals/wxWidgets3/include/wx/persist/window.h
vendored
Normal file
80
Externals/wxWidgets3/include/wx/persist/window.h
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/window.h
|
||||
// Purpose: wxPersistentWindow declaration
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2009-01-23
|
||||
// RCS-ID: $Id: window.h 59262 2009-03-02 12:10:40Z VZ $
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PERSIST_WINDOW_H_
|
||||
#define _WX_PERSIST_WINDOW_H_
|
||||
|
||||
#include "wx/persist.h"
|
||||
|
||||
#include "wx/window.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPersistentWindow: base class for persistent windows, uses the window name
|
||||
// as persistent name by default and automatically reacts
|
||||
// to the window destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// type-independent part of wxPersistentWindow
|
||||
class wxPersistentWindowBase :
|
||||
wxBIND_OR_CONNECT_HACK_BASE_CLASS
|
||||
public wxPersistentObject
|
||||
{
|
||||
public:
|
||||
wxPersistentWindowBase(wxWindow *win)
|
||||
: wxPersistentObject(win)
|
||||
{
|
||||
wxBIND_OR_CONNECT_HACK(win, wxEVT_DESTROY, wxWindowDestroyEventHandler,
|
||||
wxPersistentWindowBase::HandleDestroy, this);
|
||||
}
|
||||
|
||||
virtual wxString GetName() const
|
||||
{
|
||||
const wxString name = GetWindow()->GetName();
|
||||
wxASSERT_MSG( !name.empty(), "persistent windows should be named!" );
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
protected:
|
||||
wxWindow *GetWindow() const { return static_cast<wxWindow *>(GetObject()); }
|
||||
|
||||
private:
|
||||
void HandleDestroy(wxWindowDestroyEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
|
||||
// only react to the destruction of this object itself, not of any of
|
||||
// its children
|
||||
if ( event.GetEventObject() == GetObject() )
|
||||
{
|
||||
// this will delete this object itself
|
||||
wxPersistenceManager::Get().SaveAndUnregister(GetWindow());
|
||||
}
|
||||
}
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxPersistentWindowBase);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class wxPersistentWindow : public wxPersistentWindowBase
|
||||
{
|
||||
public:
|
||||
typedef T WindowType;
|
||||
|
||||
wxPersistentWindow(WindowType *win)
|
||||
: wxPersistentWindowBase(win)
|
||||
{
|
||||
}
|
||||
|
||||
WindowType *Get() const { return static_cast<WindowType *>(GetWindow()); }
|
||||
};
|
||||
|
||||
#endif // _WX_PERSIST_WINDOW_H_
|
||||
|
Reference in New Issue
Block a user