dolphin/Externals/wxWidgets3/include/wx/windowid.h
Soren Jorvang d14efe561b 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
2011-03-20 18:05:19 +00:00

191 lines
4.4 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: wx/windowid.h
// Purpose: wxWindowID class - a class for managing window ids
// Author: Brian Vanderburg II
// Created: 2007-09-21
// RCS-ID: $Id: windowid.h 51123 2008-01-09 04:08:33Z PC $
// Copyright: (c) 2007 Brian Vanderburg II
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOWID_H_
#define _WX_WINDOWID_H_
// NB: do not include defs.h as we are included from it
typedef int wxWindowID;
// ----------------------------------------------------------------------------
// wxWindowIDRef: reference counted id value
// ----------------------------------------------------------------------------
// A wxWindowIDRef object wraps an id value and marks it as (un)used as
// necessary. All ids returned from wxWindow::NewControlId() should be assigned
// to an instance of this class to ensure that the id is marked as being in
// use.
//
// This class is always defined but it is trivial if wxUSE_AUTOID_MANAGEMENT is
// off.
class WXDLLIMPEXP_CORE wxWindowIDRef
{
public:
// default ctor
wxWindowIDRef()
{
m_id = wxID_NONE;
}
// ctor taking id values
wxWindowIDRef(int id)
{
Init(id);
}
wxWindowIDRef(long id)
{
Init(id);
}
wxWindowIDRef(const wxWindowIDRef& id)
{
Init(id.m_id);
}
// dtor
~wxWindowIDRef()
{
Assign(wxID_NONE);
}
// assignment
wxWindowIDRef& operator=(int id)
{
Assign(id);
return *this;
}
wxWindowIDRef& operator=(long id)
{
Assign(id);
return *this;
}
wxWindowIDRef& operator=(const wxWindowIDRef& id)
{
if (&id != this)
Assign(id.m_id);
return *this;
}
// access to the stored id value
wxWindowID GetValue() const
{
return m_id;
}
operator wxWindowID() const
{
return m_id;
}
private:
#if wxUSE_AUTOID_MANAGEMENT
// common part of all ctors: call Assign() for our new id
void Init(wxWindowID id)
{
// m_id must be initialized before calling Assign()
m_id = wxID_NONE;
Assign(id);
}
// increase reference count of id, decrease the one of m_id
void Assign(wxWindowID id);
#else // !wxUSE_AUTOID_MANAGEMENT
// trivial stubs for the functions above
void Init(wxWindowID id)
{
m_id = id;
}
void Assign(wxWindowID id)
{
m_id = id;
}
#endif // wxUSE_AUTOID_MANAGEMENT/!wxUSE_AUTOID_MANAGEMENT
wxWindowID m_id;
};
// comparison operators
inline bool operator==(const wxWindowIDRef& lhs, const wxWindowIDRef& rhs)
{
return lhs.GetValue() == rhs.GetValue();
}
inline bool operator==(const wxWindowIDRef& lhs, int rhs)
{
return lhs.GetValue() == rhs;
}
inline bool operator==(const wxWindowIDRef& lhs, long rhs)
{
return lhs.GetValue() == rhs;
}
inline bool operator==(int lhs, const wxWindowIDRef& rhs)
{
return rhs == lhs;
}
inline bool operator==(long lhs, const wxWindowIDRef& rhs)
{
return rhs == lhs;
}
inline bool operator!=(const wxWindowIDRef& lhs, const wxWindowIDRef& rhs)
{
return !(lhs == rhs);
}
inline bool operator!=(const wxWindowIDRef& lhs, int rhs)
{
return !(lhs == rhs);
}
inline bool operator!=(const wxWindowIDRef& lhs, long rhs)
{
return !(lhs == rhs);
}
inline bool operator!=(int lhs, const wxWindowIDRef& rhs)
{
return !(lhs == rhs);
}
inline bool operator!=(long lhs, const wxWindowIDRef& rhs)
{
return !(lhs == rhs);
}
// ----------------------------------------------------------------------------
// wxIdManager
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxIdManager
{
public:
// This returns an id value and not an wxWindowIDRef. The returned value
// should be assigned a.s.a.p to a wxWindowIDRef. The IDs are marked as
// reserved so that another call to ReserveId before assigning the id to a
// wxWindowIDRef will not use the same ID
static wxWindowID ReserveId(int count = 1);
// This will release an unused reserved ID. This should only be called
// if the ID returned by ReserveId was NOT assigned to a wxWindowIDRef
// for some purpose, maybe an early return from a function
static void UnreserveId(wxWindowID id, int count = 1);
};
#endif // _WX_WINDOWID_H_