first pass of wxUniv merge - nothing works, most parts don't even compile
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
140
src/univ/theme.cpp
Normal file
140
src/univ/theme.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: univ/theme.cpp
|
||||
// Purpose: implementation of wxTheme
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 06.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ===========================================================================
|
||||
// declarations
|
||||
// ===========================================================================
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// headers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "theme.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/intl.h"
|
||||
#include "wx/log.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
wxThemeInfo *wxTheme::ms_allThemes = (wxThemeInfo *)NULL;
|
||||
wxTheme *wxTheme::ms_theme = (wxTheme *)NULL;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// "dynamic" theme creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxThemeInfo::wxThemeInfo(Constructor c,
|
||||
const wxChar *n,
|
||||
const wxChar *d)
|
||||
: name(n), desc(d), ctor(c)
|
||||
{
|
||||
// insert us (in the head of) the linked list
|
||||
next = wxTheme::ms_allThemes;
|
||||
wxTheme::ms_allThemes = this;
|
||||
}
|
||||
|
||||
/* static */ wxTheme *wxTheme::Create(const wxString& name)
|
||||
{
|
||||
// find the theme in the list by name
|
||||
wxThemeInfo *info = ms_allThemes;
|
||||
while ( info )
|
||||
{
|
||||
if ( name == info->name )
|
||||
{
|
||||
return info->ctor();
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
return (wxTheme *)NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// the default theme (called by wxApp::OnInitGui)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */ bool wxTheme::CreateDefault()
|
||||
{
|
||||
if ( ms_theme )
|
||||
{
|
||||
// we already have a theme
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxString nameDefTheme;
|
||||
|
||||
// use the environment variable first
|
||||
const wxChar *p = wxGetenv(_T("WXTHEME"));
|
||||
if ( p )
|
||||
{
|
||||
nameDefTheme = p;
|
||||
}
|
||||
else // use native theme by default
|
||||
{
|
||||
#if defined(__WXMSW__)
|
||||
nameDefTheme = _T("win32");
|
||||
#elif defined(__WXGTK__)
|
||||
nameDefTheme = _T("gtk");
|
||||
#endif
|
||||
}
|
||||
|
||||
ms_theme = Create(nameDefTheme);
|
||||
|
||||
// fallback to the first one in the list
|
||||
if ( !ms_theme && ms_allThemes )
|
||||
{
|
||||
ms_theme = ms_allThemes->ctor();
|
||||
}
|
||||
|
||||
// abort if still nothing
|
||||
if ( !ms_theme )
|
||||
{
|
||||
wxLogError(_("Failed to initialize GUI: no built-in themes found."));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* static */ wxTheme *wxTheme::Set(wxTheme *theme)
|
||||
{
|
||||
wxTheme *themeOld = ms_theme;
|
||||
ms_theme = theme;
|
||||
return themeOld;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// assorted trivial dtors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxTheme::~wxTheme()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user