Commit 4e3c8943 authored by Olivier Teulière's avatar Olivier Teulière

* skins2: Added friend classes where appropriate, to reduce the scope of

   some methods.
parent c0c09ac8
......@@ -104,7 +104,7 @@ Theme *Builder::build()
#define GET_BMP( pBmp, id ) \
if( id != "none" ) \
{ \
pBmp = m_pTheme->m_bitmaps[id].get(); \
pBmp = m_pTheme->getBitmapById(id); \
if( pBmp == NULL ) \
{ \
msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
......@@ -184,7 +184,7 @@ void Builder::addWindow( const BuilderData::Window &rData )
void Builder::addLayout( const BuilderData::Layout &rData )
{
TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
TopWindow *pWin = m_pTheme->getWindowById(rData.m_windowId);
if( pWin == NULL )
{
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
......@@ -210,7 +210,7 @@ void Builder::addLayout( const BuilderData::Layout &rData )
void Builder::addAnchor( const BuilderData::Anchor &rData )
{
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -245,7 +245,7 @@ void Builder::addButton( const BuilderData::Button &rData )
GenericBitmap *pBmpOver = pBmpUp;
GET_BMP( pBmpOver, rData.m_overId );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -302,7 +302,7 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
GenericBitmap *pBmpOver2 = pBmpUp2;
GET_BMP( pBmpOver2, rData.m_over2Id );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -361,14 +361,14 @@ void Builder::addImage( const BuilderData::Image &rData )
GenericBitmap *pBmp = NULL;
GET_BMP( pBmp, rData.m_bmpId );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
return;
}
TopWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get();
TopWindow *pWindow = m_pTheme->getWindowById(rData.m_windowId);
if( pWindow == NULL )
{
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
......@@ -414,7 +414,7 @@ void Builder::addImage( const BuilderData::Image &rData )
void Builder::addText( const BuilderData::Text &rData )
{
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -459,7 +459,7 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
GenericBitmap *pSeq = NULL;
GET_BMP( pSeq, rData.m_sequence );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -511,7 +511,7 @@ void Builder::addSlider( const BuilderData::Slider &rData )
GenericBitmap *pBmpOver = pBmpUp;
GET_BMP( pBmpOver, rData.m_overId );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -566,7 +566,7 @@ void Builder::addSlider( const BuilderData::Slider &rData )
void Builder::addList( const BuilderData::List &rData )
{
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -613,7 +613,7 @@ void Builder::addList( const BuilderData::List &rData )
void Builder::addVideo( const BuilderData::Video &rData )
{
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL )
{
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
......@@ -711,7 +711,7 @@ const Position Builder::makePosition( const string &rLeftTop,
GenericFont *Builder::getFont( const string &fontId )
{
GenericFont *pFont = m_pTheme->m_fonts[fontId].get();
GenericFont *pFont = m_pTheme->getFontById(fontId);
if( !pFont && fontId == "defaultfont" )
{
#ifdef WIN32_SKINS
......
......@@ -37,11 +37,14 @@ class EvtMouse;
class EvtKey;
class EvtRefresh;
class EvtScroll;
class WindowManager;
/// Generic window class
class GenericWindow: public SkinObject, public Observer<VarBool>
{
private:
friend class WindowManager;
public:
GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
bool dragDrop, bool playOnDrop,
......@@ -58,21 +61,37 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
virtual void processEvent( EvtRefresh &rEvtRefresh );
// Show the window
/// Resize the window
virtual void resize( int width, int height );
/// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height ) {}
/// Get the coordinates of the window
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
virtual int getWidth() const { return m_width; }
virtual int getHeight() const { return m_height; }
/// Give access to the visibility variable
VarBool &getVisibleVar() { return m_varVisible; }
protected:
/// Get the OS window
OSWindow *getOSWindow() const { return m_pOsWindow; }
/// These methods do not need to be public since they are accessed
/// only by the window manager or by inheritant classes.
//@{
/// Show the window
virtual void show();
// Hide the window
/// Hide the window
virtual void hide();
// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height ) {}
/// Move the window
virtual void move( int left, int top );
/// Resize the window
virtual void resize( int width, int height );
/// Bring the window on top
virtual void raise() const;
......@@ -81,26 +100,14 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
/// Toggle the window on top
virtual void toggleOnTop( bool onTop ) const;
//@}
/// Get the coordinates of the window
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
virtual int getWidth() const { return m_width; }
virtual int getHeight() const { return m_height; }
/// Give access to the visibility variable
VarBool &getVisibleVar() { return m_varVisible; }
protected:
/// Actually show the window
virtual void innerShow();
/// Actually hide the window
virtual void innerHide();
/// Get the OS window
OSWindow *getOSWindow() const { return m_pOsWindow; }
private:
/// Window position and size
int m_left, m_top, m_width, m_height;
......
......@@ -53,20 +53,25 @@ void Theme::loadConfig()
// Initialization
map<string, TopWindowPtr>::const_iterator it;
int i = 0;
int x, y, v, scan;
int x, y, visible, scan;
// Get config for each window
for( it = m_windows.begin(); it != m_windows.end(); it++ )
{
TopWindow *pWin = (*it).second.get();
// Get config
scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v );
scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &visible );
// If config has the correct number of arguments
if( scan > 2 )
{
pWin->move( x, y );
if( v ) pWin->show();
m_windowManager.startMove( *pWin );
m_windowManager.move( *pWin, x, y );
m_windowManager.stopMove();
if( visible )
{
m_windowManager.show( *pWin );
}
}
// Next window
......
......@@ -37,10 +37,15 @@
#include <list>
#include <map>
class Builder;
class Interpreter;
/// Class storing the data of the current theme
class Theme: public SkinObject
{
private:
friend class Builder;
friend class Interpreter;
public:
Theme( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_windowManager( getIntf() ) {}
......@@ -57,9 +62,7 @@ class Theme: public SkinObject
WindowManager &getWindowManager() { return m_windowManager; }
// XXX: It would be nicer to put everything private, and have the
// builder and interpreter classes as friends of this one
// private:
private:
/// Store the bitmaps by ID
map<string, GenericBitmapPtr> m_bitmaps;
/// Store the fonts by ID
......@@ -77,7 +80,6 @@ class Theme: public SkinObject
/// Store the variables
list<VariablePtr> m_vars;
private:
WindowManager m_windowManager;
};
......
......@@ -39,10 +39,12 @@ class WindowManager;
/// Class to handle top-level windows
class TopWindow: public GenericWindow
{
private:
friend class WindowManager;
public:
TopWindow( intf_thread_t *pIntf, int xPos, int yPos,
WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop );
WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop );
virtual ~TopWindow();
/// Methods to process OS events.
......@@ -59,9 +61,6 @@ class TopWindow: public GenericWindow
// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height );
/// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout );
/// Get the active layout
virtual const GenericLayout& getActiveLayout() const;
......@@ -82,6 +81,9 @@ class TopWindow: public GenericWindow
virtual void innerShow();
private:
/// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout );
/// Window manager
WindowManager &m_rWindowManager;
/// Current active layout of the window
......
......@@ -37,6 +37,19 @@ class VoutWindow: public GenericWindow
bool dragDrop, bool playOnDrop, GenericWindow &rParent );
virtual ~VoutWindow();
/// These methods are redefined here to make them public
//@{
/// Show the window
virtual void show() { GenericWindow::show(); }
/// Hide the window
virtual void hide() { GenericWindow::hide(); }
/// Move the window
virtual void move( int left, int top )
{ GenericWindow::move( left, top ); }
//@}
/// Resize the window
virtual void resize( int width, int height );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment