Commit fbe7f701 authored by Cyril Deguet's avatar Cyril Deguet

* reverted my previous commit: cannot work as expected

* src/theme.cpp: fixed a delete[] / free mismatch
parent e265882b
......@@ -2,7 +2,7 @@
* wrappers.cpp: Wrappers around C++ objects
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: wrappers.cpp,v 1.11 2003/06/22 00:00:28 asmax Exp $
* $Id: wrappers.cpp,v 1.12 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -117,7 +117,7 @@ void EndControlGroup()
void AddAnchor( char *x, char *y, char *len, char *priority )
{
int XOff, YOff;
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -137,7 +137,7 @@ void AddImage( char *id, char *visible, char *x, char *y, char *image,
char *event, char *help )
{
int XOff, YOff;
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -150,7 +150,7 @@ void AddRectangle( char *id, char *visible, char *x, char *y, char *w, char *h,
char *color, char *event, char *help )
{
int XOff, YOff;
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -168,7 +168,7 @@ void AddButton(
char *tooltiptext, char *help )
{
int XOff, YOff;
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -193,7 +193,7 @@ void AddCheckBox(
char *tooltiptext1, char *tooltiptext2, char *help )
{
int XOff, YOff;
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -231,7 +231,7 @@ void AddSlider( char *id, char *visible, char *x, char *y, char *type, char *up,
ConvertCoords( abs, p_abs );
ConvertCoords( ord, p_ord );
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
// Move control
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -286,7 +286,7 @@ void AddPlayList( char *id, char *visible, char *x, char *y, char *width,
ConvertCoords( abs, p_abs );
ConvertCoords( ord, p_ord );
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
// Move control
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......@@ -319,7 +319,7 @@ void AddText( char *id, char *visible, char *x, char *y, char *text, char *font,
char *help )
{
int XOff, YOff;
SkinWindow *vlcWin = SkinWindowList::Instance()->Back();
SkinWindow *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
......
......@@ -2,7 +2,7 @@
* event.cpp: Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: event.cpp,v 1.18 2003/06/22 00:00:28 asmax Exp $
* $Id: event.cpp,v 1.19 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -344,8 +344,8 @@ GenericControl * Event::FindControl( string id )
list<SkinWindow *>::const_iterator win;
unsigned int i;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
for( i = 0; i < (*win)->ControlList.size(); i++ )
{
......
......@@ -2,7 +2,7 @@
* event.h: Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: event.h,v 1.11 2003/06/22 00:00:28 asmax Exp $
* $Id: event.h,v 1.12 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -52,7 +52,8 @@ using namespace std;
// VLC messages
#define VLC_NOTHING (VLC_MESSAGE + 1)
#define VLC_HIDE (VLC_MESSAGE + 2)
#define VLC_SHOW (VLC_MESSAGE + 2)
#define VLC_HIDE (VLC_MESSAGE + 3)
#define VLC_QUIT (VLC_MESSAGE + 4)
#define VLC_OPEN (VLC_MESSAGE + 5)
......
......@@ -2,7 +2,7 @@
* theme.cpp: Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme.cpp,v 1.15 2003/06/22 00:00:28 asmax Exp $
* $Id: theme.cpp,v 1.16 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -63,8 +63,7 @@ Theme::~Theme()
{
// Delete the windows
list<SkinWindow *>::const_iterator win;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
delete (OSWindow *)(*win);
}
......@@ -88,8 +87,7 @@ void Theme::ShowTheme()
Event *evt2;
// Synchronize control to visible aspect
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// Synchronize windows visibility
if( (*win)->OnStartThemeVisible )
......@@ -110,14 +108,7 @@ void Theme::ShowTheme()
CheckAnchors();
// Show windows
for( list<SkinWindow *>::const_iterator win =
SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
{
if( (*win)->OnStartThemeVisible )
OSAPI_PostMessage( (*win), WINDOW_OPEN, 1, 0 );
}
p_intf->p_sys->b_all_win_closed = false;
OSAPI_PostMessage( NULL, VLC_SHOW, 0, 0 );
}
//---------------------------------------------------------------------------
void Theme::CreateSystemMenu()
......@@ -142,8 +133,7 @@ void Theme::LoadConfig()
int x, y, v, scan;
// Get config for each window
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// Get config
scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v );
......@@ -169,8 +159,7 @@ void Theme::SaveConfig()
int x, y;
// Save config of every window
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// Print config
(*win)->GetPos( x, y );
......@@ -209,9 +198,8 @@ void Theme::InitTheme()
//---------------------------------------------------------------------------
void Theme::InitWindows()
{
list<SkinWindow *>::const_iterator win;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( list<SkinWindow *>::const_iterator win = WindowList.begin();
win != WindowList.end(); win++ )
{
(*win)->Init();
}
......@@ -219,9 +207,8 @@ void Theme::InitWindows()
//---------------------------------------------------------------------------
void Theme::InitControls()
{
list<SkinWindow *>::const_iterator win;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( list<SkinWindow *>::const_iterator win = WindowList.begin();
win != WindowList.end(); win++ )
{
for( unsigned int i = 0; i < (*win)->ControlList.size(); i++ )
{
......@@ -232,9 +219,8 @@ void Theme::InitControls()
//---------------------------------------------------------------------------
SkinWindow * Theme::GetWindow( string name )
{
list<SkinWindow *>::const_iterator win;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( list<SkinWindow *>::const_iterator win = WindowList.begin();
win != WindowList.end(); win++ )
{
if( name == OSAPI_GetWindowTitle( *win ) )
{
......@@ -307,11 +293,8 @@ bool Theme::MoveSkinMagnet( SkinWindow *wnd, int left, int top )
// All windows can be moved
list<SkinWindow *>::const_iterator win;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
{
for( win = WindowList.begin(); win != WindowList.end(); win++ )
(*win)->Moved = false;
}
// Move Window
MoveSkin( wnd, NewLeft - Wx, NewTop - Wy );
......@@ -327,8 +310,7 @@ void Theme::HangToAnchors( SkinWindow *wnd, int &x, int &y, bool init )
list<Anchor *>::const_iterator win_anchor, wnd_anchor;
// Parse list of windows
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// If window is moved window
if( (*win) == wnd )
......@@ -410,8 +392,7 @@ void Theme::CheckAnchors()
list<SkinWindow *>::const_iterator win;
int x, y;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
(*win)->GetPos( x, y );
HangToAnchors( (*win), x, y, true );
......
......@@ -2,7 +2,7 @@
* theme.h: Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme.h,v 1.4 2003/06/22 00:00:28 asmax Exp $
* $Id: theme.h,v 1.5 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -80,6 +80,9 @@ class Theme
FontBank *FntBank;
OffSetBank *OffBank;
// List of the windows of the skin
list<SkinWindow *> WindowList;
// Magetism
void HangToAnchors( SkinWindow *wnd, int &x, int &y, bool init = false );
bool MoveSkinMagnet( SkinWindow *wnd, int left, int top );
......
......@@ -2,7 +2,7 @@
* vlcproc.cpp: VlcProc class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.37 2003/06/22 00:00:28 asmax Exp $
* $Id: vlcproc.cpp,v 1.38 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -71,8 +71,8 @@ bool VlcProc::EventProc( Event *evt )
case VLC_HIDE:
for( list<SkinWindow *>::const_iterator win =
SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
(*win)->OnStartThemeVisible = !(*win)->IsHidden();
}
......@@ -80,6 +80,17 @@ bool VlcProc::EventProc( Event *evt )
OSAPI_PostMessage( NULL, WINDOW_CLOSE, 1, 0 );
return true;
case VLC_SHOW:
for( list<SkinWindow *>::const_iterator win =
p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
if( (*win)->OnStartThemeVisible )
OSAPI_PostMessage( (*win), WINDOW_OPEN, 1, 0 );
}
p_intf->p_sys->b_all_win_closed = false;
return true;
case VLC_OPEN:
p_intf->p_sys->p_dialogs->ShowOpen( true );
InterfaceRefresh();
......@@ -168,8 +179,8 @@ bool VlcProc::EventProcEnd()
list<SkinWindow *>::const_iterator win;
// If a window has been closed, test if all are closed !
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
if( !(*win)->IsHidden() ) // Not all windows closed
{
......@@ -350,7 +361,7 @@ void VlcProc::LoadSkin()
delete Loader;
// Uninitialize new theme
delete (char *)p_intf->p_sys->p_new_theme_file;
delete[] p_intf->p_sys->p_new_theme_file;
p_intf->p_sys->p_new_theme_file = NULL;
}
}
......
......@@ -2,11 +2,10 @@
* window.cpp: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window.cpp,v 1.31 2003/06/22 00:00:28 asmax Exp $
* $Id: window.cpp,v 1.32 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
* Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -545,42 +544,5 @@ void SkinWindow::GetPos( int &x, int &y )
x = Left;
y = Top;
}
//---------------------------------------------------------------------------
// List of all the Skin Windows (singleton)
//---------------------------------------------------------------------------
SkinWindowList *SkinWindowList::_instance = NULL;
//---------------------------------------------------------------------------
SkinWindowList::SkinWindowList()
{
}
//---------------------------------------------------------------------------
SkinWindowList *SkinWindowList::Instance()
{
if( _instance == NULL )
{
_instance = new SkinWindowList;
}
return _instance;
}
//---------------------------------------------------------------------------
void SkinWindowList::Add( SkinWindow *win )
{
_list.push_back( win );
}
//---------------------------------------------------------------------------
SkinWindow *SkinWindowList::Back()
{
return _list.back();
}
//---------------------------------------------------------------------------
list<SkinWindow*>::const_iterator SkinWindowList::Begin()
{
return _list.begin();
}
//---------------------------------------------------------------------------
list<SkinWindow*>::const_iterator SkinWindowList::End()
{
return _list.end();
}
//---------------------------------------------------------------------------
......@@ -2,7 +2,7 @@
* window.h: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window.h,v 1.4 2003/06/22 00:00:28 asmax Exp $
* $Id: window.h,v 1.5 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -146,21 +146,5 @@ class SkinWindow
intf_thread_t *GetIntf() { return p_intf; }
};
//---------------------------------------------------------------------------
class SkinWindowList
{
private:
static SkinWindowList *_instance;
list<SkinWindow*> _list;
SkinWindowList();
public:
static SkinWindowList *Instance();
void Add( SkinWindow *win );
SkinWindow *Back();
list<SkinWindow*>::const_iterator Begin();
list<SkinWindow*>::const_iterator End();
};
//---------------------------------------------------------------------------
#endif
......@@ -2,7 +2,7 @@
* win32_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_run.cpp,v 1.19 2003/06/22 00:00:28 asmax Exp $
* $Id: win32_run.cpp,v 1.20 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -81,8 +81,8 @@ void OSRun( intf_thread_t *p_intf )
while( GetMessage( &msg, NULL, 0, 0 ) )
{
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
if( msg.hwnd == NULL ||
msg.hwnd == ((Win32Window*)(*win))->GetHandle() )
......@@ -90,7 +90,7 @@ void OSRun( intf_thread_t *p_intf )
break;
}
}
if( win == SkinWindowList::Instance()->End() )
if( win == p_intf->p_sys->p_theme->WindowList.end() )
{
// DispatchMessage( &msg );
// DefWindowProc( msg.hwnd, msg.message, msg.wParam, msg.lParam );
......@@ -163,8 +163,8 @@ void OSRun( intf_thread_t *p_intf )
**********************/
else if( msg.hwnd == NULL )
{
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
(*win)->ProcessEvent( ProcessEvent );
}
......
......@@ -2,7 +2,7 @@
* win32_theme.cpp: Win32 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_theme.cpp,v 1.8 2003/06/22 00:00:28 asmax Exp $
* $Id: win32_theme.cpp,v 1.9 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
......@@ -72,8 +72,8 @@ LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
// Find window matching with hwnd
list<SkinWindow *>::const_iterator win;
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
// If it is the correct window
if( hwnd == ( (Win32Window *)(*win) )->GetHandle() )
......@@ -301,8 +301,8 @@ void Win32Theme::AddWindow( string name, int x, int y, bool visible,
SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_intf );
SkinWindowList::Instance()->Add( (SkinWindow *)new OSWindow( p_intf,
hwnd, x, y, visible, fadetime, alpha, movealpha, dragdrop ) ) ;
WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, hwnd, x, y,
visible, fadetime, alpha, movealpha, dragdrop ) ) ;
}
//---------------------------------------------------------------------------
void Win32Theme::ChangeTray()
......
......@@ -2,7 +2,7 @@
* x11_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_run.cpp,v 1.22 2003/06/22 00:00:28 asmax Exp $
* $Id: x11_run.cpp,v 1.23 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -113,8 +113,8 @@ int ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event )
else if( wnd == p_intf->p_sys->mainWin )
{
// Broadcast event
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
(*win)->ProcessEvent( evt );
}
......@@ -122,8 +122,8 @@ int ProcessEvent( intf_thread_t *p_intf, VlcProc *proc, XEvent *event )
else
{
// Find window matching with gwnd
for( win = SkinWindowList::Instance()->Begin();
win != SkinWindowList::Instance()->End(); win++ )
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
// If it is the correct window
if( wnd == ( (X11Window *)(*win) )->GetHandle() )
......
......@@ -2,7 +2,7 @@
* x11_theme.cpp: X11 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: x11_theme.cpp,v 1.14 2003/06/22 00:00:28 asmax Exp $
* $Id: x11_theme.cpp,v 1.15 2003/06/22 12:46:49 asmax Exp $
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
......@@ -126,8 +126,8 @@ void X11Theme::AddWindow( string name, int x, int y, bool visible,
XStoreName( display, wnd, name.c_str() );
XUNLOCK;
SkinWindowList::Instance()->Add( (SkinWindow *)new OSWindow( p_intf, wnd,
x, y, visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
WindowList.push_back( (SkinWindow *)new OSWindow( p_intf, wnd, x, y,
visible, fadetime, alpha, movealpha, dragdrop, name ) ) ;
}
//---------------------------------------------------------------------------
void X11Theme::ChangeTray()
......
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