1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
32 // Be sure things are destroyed in the right order (XXX check)
45 void Theme::loadConfig()
47 msg_Dbg( getIntf(), "Loading theme configuration");
49 // Get config from vlcrc file
50 char *save = config_GetPsz( getIntf(), "skins2-config" );
55 map<string, GenericWindowPtr>::const_iterator it;
59 // Get config for each window
60 for( it = m_windows.begin(); it != m_windows.end(); it++ )
62 GenericWindow *pWin = (*it).second.get();
64 scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v );
66 // If config has the correct number of arguments
79 void Theme::saveConfig()
81 msg_Dbg( getIntf(), "Saving theme configuration");
83 // Initialize char where config is stored
84 char *save = new char[400];
85 map<string, GenericWindowPtr>::const_iterator it;
89 // Save config of every window
90 for( it = m_windows.begin(); it != m_windows.end(); it++ )
92 GenericWindow *pWin = (*it).second.get();
96 sprintf( &save[i * 13], "(%4d,%4d,%1d)", x, y,
97 pWin->getVisibleVar().get() );
101 // Save config to file
102 config_PutPsz( getIntf(), "skins2-config", save );
103 config_SaveConfigFile( getIntf(), "skins2" );
111 #define FIND_OBJECT( mapData, mapName ) \
112 map<string, mapData>::const_iterator it; \
113 it = mapName.find( id ); \
114 if( it == mapName.end() ) \
118 return (*it).second.get();
120 GenericBitmap *Theme::getBitmapById( const string &id )
122 FIND_OBJECT( GenericBitmapPtr, m_bitmaps );
125 GenericFont *Theme::getFontById( const string &id )
127 FIND_OBJECT( GenericFontPtr, m_fonts );
130 GenericWindow *Theme::getWindowById( const string &id )
132 FIND_OBJECT( GenericWindowPtr, m_windows );
135 GenericLayout *Theme::getLayoutById( const string &id )
137 FIND_OBJECT( GenericLayoutPtr, m_layouts );
140 CtrlGeneric *Theme::getControlById( const string &id )
142 FIND_OBJECT( CtrlGenericPtr, m_controls );