Commit a64501fd authored by Olivier Teulière's avatar Olivier Teulière

Keep quiet, explanations will follow.

parent 71dfd6a5
......@@ -1669,8 +1669,19 @@ dnl MP4 module
dnl
AC_CHECK_HEADERS(zlib.h, [
LDFLAGS_mp4="${LDFLAGS_mp4} -lz"
LDFLAGS_skins="${LDFLAGS_skins} -lz"
] )
dnl
dnl skins module
dnl
AC_CHECK_HEADERS(libtar.h, [
LDFLAGS_skins="${LDFLAGS_skins} -ltar"
] )
dnl
dnl a52 AC3 decoder plugin
dnl
......@@ -2229,6 +2240,19 @@ then
PLUGINS="${PLUGINS} beos"
fi
dnl
dnl Skins module
dnl
AC_ARG_ENABLE(skins,
[ --enable-skins Win32 skins module (default enabled on Win32)])
if test "x${enable_skins}" != "xno"; then
if test "x${SYS}" = "xmingw32" -o "x${SYS}" = "xcygwin"; then
PLUGINS="${PLUGINS} skins"
CPPFLAGS_skins="${CPPFLAGS_skins} -Imodules/gui/skins -Imodules/gui/skins/src -Imodules/gui/skins/win32 -Imodules/gui/skins/controls"
LDFLAGS_skins="${LDFLAGS_skins} -lgdi32 -lcomdlg32 -lole32 -luuid -lcomctl32 -lmsimg32"
fi
fi
dnl
dnl Gtk+ module
dnl
......
......@@ -50,6 +50,7 @@ EXTRA_DIST = \
gui/ncurses/Modules.am \
gui/qnx/Modules.am \
gui/qt/Modules.am \
gui/skins/Modules.am \
gui/win32/Modules.am \
gui/wxwindows/Modules.am \
misc/Modules.am \
......
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
SOURCES_skins = \
modules/gui/skins/os_api.h \
modules/gui/skins/os_bitmap.h \
modules/gui/skins/os_dialog.h \
modules/gui/skins/os_event.h \
modules/gui/skins/os_font.h \
modules/gui/skins/os_graphics.h \
modules/gui/skins/os_theme.h \
modules/gui/skins/os_window.h \
\
modules/gui/skins/controls/controls.h \
modules/gui/skins/controls/button.cpp \
modules/gui/skins/controls/button.h \
modules/gui/skins/controls/checkbox.cpp \
modules/gui/skins/controls/checkbox.h \
modules/gui/skins/controls/generic.cpp \
modules/gui/skins/controls/generic.h \
modules/gui/skins/controls/image.cpp \
modules/gui/skins/controls/image.h \
modules/gui/skins/controls/playlist.cpp \
modules/gui/skins/controls/playlist.h \
modules/gui/skins/controls/rectangle.cpp \
modules/gui/skins/controls/rectangle.h \
modules/gui/skins/controls/slider.cpp \
modules/gui/skins/controls/slider.h \
modules/gui/skins/controls/text.cpp \
modules/gui/skins/controls/text.h \
\
modules/gui/skins/parser/flex.c \
modules/gui/skins/parser/skin.h \
modules/gui/skins/parser/skin.c \
modules/gui/skins/parser/wrappers.h \
modules/gui/skins/parser/wrappers.cpp \
\
modules/gui/skins/src/anchor.cpp \
modules/gui/skins/src/anchor.h \
modules/gui/skins/src/banks.cpp \
modules/gui/skins/src/banks.h \
modules/gui/skins/src/bezier.cpp \
modules/gui/skins/src/bezier.h \
modules/gui/skins/src/bitmap.cpp \
modules/gui/skins/src/bitmap.h \
modules/gui/skins/src/dialog.cpp \
modules/gui/skins/src/dialog.h \
modules/gui/skins/src/event.cpp \
modules/gui/skins/src/event.h \
modules/gui/skins/src/font.cpp \
modules/gui/skins/src/font.h \
modules/gui/skins/src/graphics.cpp \
modules/gui/skins/src/graphics.h \
modules/gui/skins/src/skin_main.cpp \
modules/gui/skins/src/skin-common.h \
modules/gui/skins/src/theme.cpp \
modules/gui/skins/src/theme.h \
modules/gui/skins/src/themeloader.cpp \
modules/gui/skins/src/themeloader.h \
modules/gui/skins/src/vlcproc.cpp \
modules/gui/skins/src/vlcproc.h \
modules/gui/skins/src/window.cpp \
modules/gui/skins/src/window.h \
\
modules/gui/skins/win32/win32_api.cpp \
modules/gui/skins/win32/win32_bitmap.cpp \
modules/gui/skins/win32/win32_bitmap.h \
modules/gui/skins/win32/win32_dialog.cpp \
modules/gui/skins/win32/win32_dialog.h \
modules/gui/skins/win32/win32_dragdrop.cpp \
modules/gui/skins/win32/win32_dragdrop.h \
modules/gui/skins/win32/win32_event.cpp \
modules/gui/skins/win32/win32_event.h \
modules/gui/skins/win32/win32_font.cpp \
modules/gui/skins/win32/win32_font.h \
modules/gui/skins/win32/win32_graphics.cpp \
modules/gui/skins/win32/win32_graphics.h \
modules/gui/skins/win32/win32_run.cpp \
modules/gui/skins/win32/win32_theme.cpp \
modules/gui/skins/win32/win32_theme.h \
modules/gui/skins/win32/win32_window.cpp \
modules/gui/skins/win32/win32_window.h \
$(NULL)
EXTRA_DIST += \
modules/gui/skins/parser/skin.dtd \
modules/gui/skins/parser/skin.act
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
/*****************************************************************************
* button.cpp: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: button.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
#include "banks.h"
#include "generic.h"
#include "button.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Control Button
//---------------------------------------------------------------------------
ControlButton::ControlButton( string id, bool visible, int x, int y, string Up,
string Down, string Disabled, string click, string tooltiptext, string help,
Window *Parent ) : GenericControl( id, visible, help, Parent )
{
Left = x;
Top = y;
State = 1; // 1 = up - 0 = down
Selected = false;
Enabled = true;
ClickActionName = click;
this->Up = Up;
this->Down = Down;
this->Disabled = Disabled;
ToolTipText = tooltiptext;
}
//---------------------------------------------------------------------------
ControlButton::~ControlButton()
{
}
//---------------------------------------------------------------------------
void ControlButton::Init()
{
// Init bitmaps
Img = new (Bitmap*)[3];
Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( Up );
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( Down );
if( Disabled == "none" )
Img[2] = p_intf->p_sys->p_theme->BmpBank->Get( Up );
else
Img[2] = p_intf->p_sys->p_theme->BmpBank->Get( Disabled );
// Get size of control
Img[0]->GetSize( Width, Height );
// Create script
ClickAction = new Action( p_intf, ClickActionName );
}
//---------------------------------------------------------------------------
bool ControlButton::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlButton::MoveRelative( int xOff, int yOff )
{
Left += xOff;
Top += yOff;
}
//---------------------------------------------------------------------------
void ControlButton::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn( x,y,w,h,Left,Top,Width,Height, xI, yI, wI, hI ) )
{
// Button is in down state
if( State == 0 && Enabled )
Img[1]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
// Button is in up state
if( State == 1 && Enabled )
Img[0]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
// Button is disabled
if( !Enabled )
Img[2]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
}
}
//---------------------------------------------------------------------------
bool ControlButton::MouseUp( int x, int y, int button )
{
if( !Enabled )
return false;
if( Img[1]->Hit( x - Left, y - Top ) && button == 1 && Selected )
{
State = 1;
Selected = false;
ClickAction->SendEvent();
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
if( button == 1 )
Selected = false;
return false;
}
//---------------------------------------------------------------------------
bool ControlButton::MouseDown( int x, int y, int button )
{
if( !Enabled )
return false;
if( Img[0]->Hit( x - Left, y - Top ) && button == 1 )
{
State = 0;
Selected = true;
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool ControlButton::MouseMove( int x, int y, int button )
{
if( !Enabled || !Selected || !button )
return false;
if( MouseOver( x, y ) )
{
if( State == 1 )
{
State = 0;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
else
{
if( State == 0 )
{
State = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
return true;
}
//---------------------------------------------------------------------------
bool ControlButton::MouseOver( int x, int y )
{
if( Img[1 - State]->Hit( x - Left, y - Top ) )
{
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------
bool ControlButton::ToolTipTest( int x, int y )
{
if( MouseOver( x, y ) && Enabled )
{
ParentWindow->ChangeToolTipText( ToolTipText );
return true;
}
return false;
}
//---------------------------------------------------------------------------
void ControlButton::Enable( Event *event, bool enabled )
{
if( !ClickAction->MatchEvent( event, ACTION_MATCH_ONE ) )
return;
if( enabled != Enabled )
{
Enabled = enabled;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* button.h: Button control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: button.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_BUTTON
#define VLC_SKIN_CONTROL_BUTTON
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Action;
class Graphics;
class Window;
//---------------------------------------------------------------------------
class ControlButton : public GenericControl
{
private:
// Image IDs
string Up;
string Down;
string Disabled;
// Control behaviour
bool Selected;
bool Enabled;
// List of actions to execute when clicking
Action *ClickAction;
string ClickActionName;
// ToolTip text
string ToolTipText;
public:
// Constructor
ControlButton( string id, bool visible, int x, int y, string Up,
string Down, string Disabled, string click,
string tooltiptext, string help, Window *Parent );
// Destructor
virtual ~ControlButton();
// Initializations
virtual void Init();
virtual bool ProcessEvent( Event *evt );
// Draw button
virtual void Draw( int x1, int y1, int x2, int y2, Graphics *dest );
// Mouse events
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool ToolTipTest( int x, int y );
// Translate control
virtual void MoveRelative( int xOff, int yOff );
// Enabling control
virtual void Enable( Event *event, bool enabled );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* checkbox.cpp: Checkbox control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: checkbox.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
#include "banks.h"
#include "generic.h"
#include "checkbox.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
#include "os_event.h"
#include "os_window.h"
//---------------------------------------------------------------------------
// Checkbox Button
//---------------------------------------------------------------------------
ControlCheckBox::ControlCheckBox( string id, bool visible, int x, int y,
string img1, string img2, string click1, string click2, string disabled1,
string disabled2, string action1, string action2, string tooltiptext1,
string tooltiptext2, string help,
Window *Parent ) : GenericControl( id, visible, help, Parent )
{
Left = x;
Top = y;
State = 1; // 1 = up - 0 = down
Selected = false;
Act = 1;
Enabled1 = true;
Enabled2 = true;
Img1 = img1;
Img2 = img2;
Click1 = click1;
Click2 = click2;
Disabled1 = disabled1;
Disabled2 = disabled2;
ClickActionName1 = action1;
ClickActionName2 = action2;
ToolTipText1 = tooltiptext1;
ToolTipText2 = tooltiptext2;
}
//---------------------------------------------------------------------------
ControlCheckBox::~ControlCheckBox()
{
}
//---------------------------------------------------------------------------
void ControlCheckBox::Init()
{
Img = new (Bitmap*)[6];
// Images for position 1
Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( Img1 );
if( Click1 == "none" )
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( Img2 );
else
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( Click1 );
// Images for position 2
Img[2] = p_intf->p_sys->p_theme->BmpBank->Get( Img2 );
if( Click2 == "none" )
Img[3] = p_intf->p_sys->p_theme->BmpBank->Get( Img1 );
else
Img[3] = p_intf->p_sys->p_theme->BmpBank->Get( Click2 );
// Disabled images
if( Disabled1 == "none" )
Img[4] = p_intf->p_sys->p_theme->BmpBank->Get( Img1 );
else
Img[4] = p_intf->p_sys->p_theme->BmpBank->Get( Disabled1 );
if( Disabled2 == "none" )
Img[5] = p_intf->p_sys->p_theme->BmpBank->Get( Img2 );
else
Img[5] = p_intf->p_sys->p_theme->BmpBank->Get( Disabled2 );
// Get Size of control
Img[0]->GetSize( Width, Height );
// Create script
ClickAction1 = new Action( p_intf, ClickActionName1 );
ClickAction2 = new Action( p_intf, ClickActionName2 );
}
//---------------------------------------------------------------------------
bool ControlCheckBox::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
case CTRL_SYNCHRO:
if( ClickAction1->MatchEvent( (Event*)evt->GetParam1(),
ACTION_MATCH_ONE ) )
{
Act = 2;
ParentWindow->Refresh( Left, Top, Width, Height );
}
else if( ClickAction2->MatchEvent( (Event*)evt->GetParam1(),
ACTION_MATCH_ONE ) )
{
Act = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
}
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlCheckBox::MoveRelative( int xOff, int yOff )
{
Left += xOff;
Top += yOff;
}
//---------------------------------------------------------------------------
void ControlCheckBox::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn( x,y,w,h,Left,Top,Width,Height, xI, yI, wI, hI ) )
{
if( Act == 1 )
{
if( State == 1 && Enabled1 )
Img[0]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else if( State == 0 && Enabled1 )
Img[1]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else
Img[4]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
}
else if( Act == 2 )
{
if( State == 1 && Enabled2 )
Img[2]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else if( State == 0 && Enabled2 )
Img[3]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
else
Img[5]->DrawBitmap( xI-Left,yI-Top,wI,hI,xI-x,yI-y,dest );
}
}
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseUp( int x, int y, int button )
{
// Test enabled
if( ( !Enabled1 && Act == 1 ) || ( !Enabled2 && Act == 2 ) )
return false;
if( button == 1 && Selected )
{
if( Act == 1 && Img[1]->Hit( x - Left, y - Top ) )
{
State = 1;
Selected = false;
Act = 2;
ParentWindow->Refresh( Left, Top, Width, Height );
ClickAction1->SendEvent();
return true;
}
else if( Act == 2 && Img[3]->Hit( x - Left, y - Top ) )
{
State = 1;
Selected = false;
Act = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
ClickAction2->SendEvent();
return true;
}
}
Selected = false;
return false;
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseDown( int x, int y, int button )
{
// Test enabled
if( ( !Enabled1 && Act == 1 ) || ( !Enabled2 && Act == 2 ) )
return false;
if( button == 1 )
{
if( Act == 1 && Img[0]->Hit( x - Left, y - Top ) )
{
State = 0;
Selected = true;
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
else if( Act == 2 && Img[2]->Hit( x - Left, y - Top ) )
{
State = 0;
Selected = true;
ParentWindow->Refresh( Left, Top, Width, Height );
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseMove( int x, int y, int button )
{
// Test enabled
if( !Selected || !button )
return false;
if( ( !Enabled1 && Act == 1 ) || ( !Enabled2 && Act == 2 ) )
return false;
if( Act == 1 )
{
if( State == 1 && Img[0]->Hit( x - Left, y - Top ) )
{
State = 0;
ParentWindow->Refresh( Left, Top, Width, Height );
}
else if( State == 0 && !Img[1]->Hit( x - Left, y - Top ) )
{
State = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
else if( Act == 2 )
{
if( State == 1 && Img[2]->Hit( x - Left, y - Top ) )
{
State = 0;
ParentWindow->Refresh( Left, Top, Width, Height );
}
else if( State == 0 && !Img[3]->Hit( x - Left, y - Top ) )
{
State = 1;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
return true;
}
//---------------------------------------------------------------------------
bool ControlCheckBox::MouseOver( int x, int y )
{
if( Act == 1 )
{
if( Img[1 - State]->Hit( x - Left, y - Top ) )
return true;
}
else if( Act == 2 )
{
if( Img[3 - State]->Hit( x - Left, y - Top ) )
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool ControlCheckBox::ToolTipTest( int x, int y )
{
if( Act == 1 && MouseOver( x, y ) && Enabled1 )
{
ParentWindow->ChangeToolTipText( ToolTipText1 );
return true;
}
else if( Act == 2 && MouseOver( x, y ) && Enabled2 )
{
ParentWindow->ChangeToolTipText( ToolTipText2 );
return true;
}
return false;
}
//---------------------------------------------------------------------------
void ControlCheckBox::Enable( Event *event, bool enabled )
{
if( enabled != !Enabled1 &&
ClickAction1->MatchEvent( event, ACTION_MATCH_ONE ) )
{
Enabled1 = enabled;
if( Act == 1 )
ParentWindow->Refresh( Left, Top, Width, Height );
}
else if( enabled != !Enabled2 &&
ClickAction2->MatchEvent( event, ACTION_MATCH_ONE ) )
{
Enabled2 = enabled;
if( Act == 2 )
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* checkbox.h: Checkbox control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: checkbox.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_CHECKBOX
#define VLC_SKIN_CONTROL_CHECKBOX
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Action;
class Graphics;
class Window;
//---------------------------------------------------------------------------
class ControlCheckBox : public GenericControl
{
private:
// Image IDs
string Img1;
string Img2;
string Click1;
string Click2;
string Disabled1;
string Disabled2;
// Behaviour
bool Enabled1;
bool Enabled2;
bool Selected;
// List of actions to execute when clicking
int Act;
Action *ClickAction1;
string ClickActionName1;
Action *ClickAction2;
string ClickActionName2;
// ToolTip text
string ToolTipText1;
string ToolTipText2;
public:
// Constructor
ControlCheckBox( string id, bool visible, int x, int y, string img1,
string img2, string click1, string click2, string disabled1,
string disabled2, string action1, string action2,
string tooltiptext1, string tooltiptext2, string help,
Window *Parent );
// Destructor
virtual ~ControlCheckBox();
// initialization
virtual void Init();
virtual bool ProcessEvent( Event *evt );
// Draw button
virtual void Draw( int x1, int y1, int x2, int y2, Graphics *dest );
// Mouse events
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool ToolTipTest( int x, int y );
// Translate control
virtual void MoveRelative( int xOff, int yOff );
// Enabling control
virtual void Enable( Event *event, bool enabled );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* controls.h:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: controls.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#include "generic.h"
#include "button.h"
#include "checkbox.h"
#include "image.h"
#include "slider.h"
#include "playlist.h"
#include "text.h"
/*****************************************************************************
* generic.cpp: Generic control, parent of the others
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "bitmap.h"
#include "os_bitmap.h"
#include "banks.h"
#include "graphics.h"
#include "os_graphics.h"
#include "event.h"
#include "generic.h"
#include "window.h"
#include "theme.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Generic Control
//---------------------------------------------------------------------------
GenericControl::GenericControl( string id, bool visible, string help,
Window *Parent )
{
ID = id;
Visible = visible;
Help = help;
ParentWindow = Parent;
Img = NULL;
p_intf = Parent->GetIntf();
}
//---------------------------------------------------------------------------
GenericControl::~GenericControl()
{
if( Img != NULL )
delete Img;
}
//---------------------------------------------------------------------------
bool GenericControl::GenericProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ID_VISIBLE:
if( (GenericControl *)evt->GetParam1() == this )
{
if( ( evt->GetParam2() == 0 && Visible ) ||
( evt->GetParam2() == 1 && !Visible ) ||
( evt->GetParam2() == 2 ) )
{
Visible = !Visible;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
return false;
case CTRL_ID_MOVE:
if( (GenericControl *)evt->GetParam1() == this )
{
int x = evt->GetParam2() & 0x7FFF;
int y = evt->GetParam2() >> 16 & 0x7FFF;
if( evt->GetParam2() & 0x8000 )
x = -x;
if( evt->GetParam2() >> 16 & 0x8000 )
y = -y;
MoveRelative( x, y );
ParentWindow->ReSize();
ParentWindow->RefreshAll();
}
return false;
default:
return ProcessEvent( evt );
}
}
//---------------------------------------------------------------------------
bool GenericControl::IsID( string id )
{
if( ID == "none" || ID != id )
{
return false;
}
else
{
return true;
}
}
//---------------------------------------------------------------------------
void GenericControl::Init()
{
}
//---------------------------------------------------------------------------
bool GenericControl::ProcessEvent( Event *evt )
{
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::MouseUp( int x, int y, int button )
{
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::MouseDown( int x, int y, int button )
{
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::MouseMove( int x, int y, int button )
{
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::MouseOver( int x, int y )
{
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::MouseDblClick( int x, int y, int button )
{
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::SendNewHelpText()
{
if( Help != "" )
{
p_intf->p_sys->p_theme->EvtBank->Get( "help" )
->PostTextMessage( Help );
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool GenericControl::ToolTipTest( int x, int y )
{
return false;
}
//---------------------------------------------------------------------------
void GenericControl::Enable( Event *event, bool enabled )
{
}
//---------------------------------------------------------------------------
bool GenericControl::GetIntersectRgn( int x1, int y1, int w1, int h1, int x2,
int y2, int w2, int h2, int &x, int &y, int &w, int &h )
{
if( x1 < x2 ) {x = x2;} else {x = x1;}
if( y1 < y2 ) {y = y2;} else {y = y1;}
if( x1+w1 < x2+w2 ) {w = x1+w1-x;} else {w = x2+w2-x;}
if( y1+h1 < y2+h2 ) {h = y1+h1-y;} else {h = y2+h2-y;}
return (w > 0 && h > 0);
}
//---------------------------------------------------------------------------
void GenericControl::Move( int left, int top )
{
MoveRelative( left - Left, top - Top );
}
//---------------------------------------------------------------------------
void GenericControl::MoveRelative( int xOff, int yOff )
{
Left += xOff;
Top += yOff;
}
//---------------------------------------------------------------------------
Region *GenericControl::CreateRegionFromBmp( Bitmap *bmp, int MoveX, int MoveY )
{
// Initialization
Region *Buffer;
int w, h;
int x = 0, y = 0, x_first = 0;
bmp->GetSize( w, h );
Buffer = (Region *)new OSRegion;
// Parse bitmap
for( y = 0; y < h; y++ )
{
for( x = 0; x < w; x++ )
{
if( bmp->GetBmpPixel( x, y ) == bmp->GetAlphaColor() )
{
if( x_first != x )
{
Buffer->AddRectangle( x_first + MoveX, y + MoveY,
x + MoveX, y + 1 + MoveY );
}
x_first = x + 1;
}
}
if( x_first != w )
{
Buffer->AddRectangle( x_first + MoveX, y + MoveY,
w + MoveX, y + 1 + MoveY );
}
x_first = 0;
}
// End of parsing
return Buffer;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* generic.h: Generic control, parent of the others
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_GENERIC
#define VLC_SKIN_CONTROL_GENERIC
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Window;
class Bitmap;
class Graphics;
class Region;
class Event;
//---------------------------------------------------------------------------
// Generic control class
//---------------------------------------------------------------------------
class GenericControl // This is the generic control class
{
protected:
Window * ParentWindow;
bool Visible;
string ID;
string Help;
intf_thread_t *p_intf;
private:
public:
// Constructor
GenericControl( string id, bool visible, string help, Window *Parent );
// Destructor
virtual ~GenericControl();
// initializations
virtual void Init();
bool GenericProcessEvent( Event *evt );
virtual bool ProcessEvent( Event *evt );
// Draw the control into the destination DC
virtual void Draw( int x, int y, int w, int h, Graphics *dest ) = 0;
// Simulate a mouse action on control at coordinates x/y
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool MouseDblClick( int x, int y, int button );
virtual bool ToolTipTest( int x, int y );
virtual bool SendNewHelpText();
// Move control
void Move( int left, int top );
virtual void MoveRelative( int xOff, int yOff );
// Get two rectangle regions and return intersection
bool GetIntersectRgn( int x1, int y1, int w1, int h1, int x2,
int y2, int w2, int h2, int &x, int &y, int &w, int &h );
// Create a region from a bitmap with transcolor as empty region
Region *CreateRegionFromBmp( Bitmap *bmp, int MoveX, int MoveY );
int Left; // Left offset of the control
int Top; // Top offset of the control
int Width; // Width of the control
int Height; // Height of the control
int State; // Used to special state of the control
// (for button, sets whether down or up)
Bitmap **Img; // Array of bitmap used to draw control
// Enabling control
virtual void Enable( Event *event, bool enabled );
// Found if ID matches
bool IsID( string id );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* image.cpp: Image control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: image.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
#include "banks.h"
#include "generic.h"
#include "image.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Control Image
//---------------------------------------------------------------------------
ControlImage::ControlImage( string id, bool visible, int x, int y, string img,
string event, string help, Window *Parent )
: GenericControl( id, visible, help, Parent )
{
Left = x;
Top = y;
MouseDownActionName = event;
Enabled = true;
Bg = img;
}
//---------------------------------------------------------------------------
ControlImage::~ControlImage()
{
}
//---------------------------------------------------------------------------
void ControlImage::Init()
{
Img = new (Bitmap*)[1];
Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( Bg );
Img[0]->GetSize( Width, Height );
// Create script
MouseDownAction = new Action( p_intf, MouseDownActionName );
}
//---------------------------------------------------------------------------
bool ControlImage::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlImage::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn(x, y, w, h, Left, Top, Width, Height, xI, yI, wI, hI ) )
Img[0]->DrawBitmap( xI-Left, yI-Top, wI, hI, xI-x, yI-y, dest );
}
//---------------------------------------------------------------------------
bool ControlImage::MouseDown( int x, int y, int button )
{
if( !Enabled || !Img[0]->Hit( x - Left, y - Top ) || button != 1 ||
!MouseDownAction->SendEvent() )
return false;
return true;
}
//---------------------------------------------------------------------------
bool ControlImage::MouseOver( int x, int y )
{
if( Img[0]->Hit( x - Left, y - Top ) )
return true;
else
return false;
}
//---------------------------------------------------------------------------
void ControlImage::Enable( Event *event, bool enabled )
{
if( !MouseDownAction->MatchEvent( event, ACTION_MATCH_ONE ) )
return;
if( enabled != !Enabled )
{
Enabled = enabled;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* image.h: Image control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: image.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_IMAGE
#define VLC_SKIN_CONTROL_IMAGE
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Action;
class Graphics;
class Window;
//---------------------------------------------------------------------------
class ControlImage : public GenericControl
{
private:
// Image ID
string Bg;
// Behaviour
bool Enabled;
// List of actions to execute when clicking
Action *MouseDownAction;
string MouseDownActionName;
public:
// Constructor
ControlImage( string id, bool visible, int x, int y, string img,
string event, string help, Window *Parent);
// Destructor
virtual ~ControlImage();
// initialization
virtual void Init();
virtual bool ProcessEvent( Event *evt );
//Draw image
virtual void Draw( int x, int y, int w, int h, Graphics *dest );
// Mouse events
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseOver( int x, int y );
// Enabling control
virtual void Enable( Event *event, bool enabled );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* playlist.cpp: Playlist control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: playlist.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
#include <math.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "bitmap.h"
#include "banks.h"
#include "bezier.h"
#include "graphics.h"
#include "os_graphics.h"
#include "font.h"
#include "os_font.h"
#include "generic.h"
#include "slider.h"
#include "playlist.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Control Playlist
//---------------------------------------------------------------------------
ControlPlayList::ControlPlayList( string id, bool visible, int width,
int infowidth, string font, string playfont, int selcolor, double *ptx,
double *pty, int nb, bool longfilename, string help, Window *Parent )
: GenericControl( id, visible, help, Parent )
{
Left = 0;
Top = 0;
Column = 1;
Line = 1;
Margin = 1;
Enabled = true;
FontName = font;
PlayFontName = playfont;
// Text zone
CaseWidth = width;
InfoWidth = infowidth;
NumWidth = 0;
FileWidth = 0;
CaseHeight = 1;
NumOfItems = 0;
SelectColor = selcolor;
TextCurve = new Bezier( ptx, pty, nb, BEZIER_PTS_Y );
LongFileName = longfilename;
// Scroll
StartIndex = 0;
}
//---------------------------------------------------------------------------
ControlPlayList::~ControlPlayList()
{
if( PlayList != NULL )
{
vlc_object_release( PlayList );
}
}
//---------------------------------------------------------------------------
void ControlPlayList::Init()
{
int i, j, h;
int *x, *y;
// Font & events
UpdateEvent = p_intf->p_sys->p_theme->EvtBank->Get( "playlist_refresh" );
TextFont = p_intf->p_sys->p_theme->FntBank->Get( FontName );
if( PlayFontName == "none" )
PlayFont = p_intf->p_sys->p_theme->FntBank->Get( FontName );
else
PlayFont = p_intf->p_sys->p_theme->FntBank->Get( PlayFontName );
TextFont->GetSize( "lp", h, CaseHeight );
// Get bitmap from list
Img = NULL;
// Get points for Text curve
h = TextCurve->GetNumOfDifferentPoints();
x = new int[h + 1];
y = new int[h + 1];
TextCurve->GetDifferentPoints( x, y, 0, 0 );
// Get top of first point
TextCurve->GetPoint( 0, i, TextTop );
// Set number of lines
Line = 0;
for( i = 0; i < h; i++ )
{
if( ( Line + 1 ) * CaseHeight < y[i] - TextTop )
Line++;
}
CaseLeft = new int[Line];
CaseRight = new int[Line];
CaseTextLeft = new int[Line];
for( i = 0; i < Line; i++ )
{
CaseLeft[i] = x[i * CaseHeight];
CaseTextLeft[i] = x[i * CaseHeight];
for( j = 1; j < CaseHeight; j++ )
{
if( x[i * CaseHeight + j] < CaseLeft[i] )
CaseLeft[i] = x[i * CaseHeight + j];
if( x[i * CaseHeight + j] > CaseTextLeft[i] )
CaseTextLeft[i] = x[i * CaseHeight + j];
}
CaseRight[i] = CaseTextLeft[i] + CaseWidth;
}
// Get size of text zone
TextHeight = Line * CaseHeight;
TextLeft = CaseLeft[0];
TextWidth = CaseRight[0];
for( i = 1; i < Line; i++ )
{
if( CaseLeft[i] < TextLeft )
TextLeft = CaseLeft[i];
if( CaseRight[i] > TextWidth )
TextWidth = CaseRight[i];
}
TextWidth -= TextLeft;
// Set Text Clipping Region
TextClipRgn = (Region *)new OSRegion;
for( i = 0; i < Line; i++ )
{
for( j = 0; j < CaseHeight; j++ )
{
h = i * CaseHeight + j;
TextClipRgn->AddRectangle( x[h] - TextLeft, h, CaseWidth, 1 );
}
}
// Curve is no more needed so delete it
delete TextCurve;
delete[] x;
delete[] y;
// Get size of control
Left = Slider->Left;
Top = Slider->Top;
Width = Slider->Left + Slider->Width;
Height = Slider->Top + Slider->Height;
if( TextLeft < Left )
Left = TextLeft;
if( TextTop < Top )
Top = TextTop;
if( TextLeft + TextWidth > Width )
Width = TextLeft + TextWidth;
if( TextTop + TextHeight > Height )
Height = TextTop + TextHeight;
Width -= Left;
Height -= Top;
// Getting playlist
PlayList = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( PlayList == NULL )
msg_Err( p_intf, "cannot find a playlist object" );
Slider->Init();
Slider->Enable( p_intf->p_sys->p_theme->EvtBank->Get( "none" ), true );
RefreshList();
}
//---------------------------------------------------------------------------
bool ControlPlayList::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
case CTRL_SYNCHRO:
if( UpdateEvent->IsEqual( (Event*)evt->GetParam1() ) )
{
RefreshList();
RefreshAll();
}
break;
case PLAYLIST_ID_DEL:
if( (GenericControl *)evt->GetParam1() == this )
{
for( int i = PlayList->i_size - 1; i >= 0; i-- )
{
if( Select[i] && i != PlayList->i_index )
playlist_Delete( PlayList, i );
}
RefreshAll();
}
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlPlayList::RefreshList()
{
if( NumOfItems != PlayList->i_size )
{
if( NumOfItems > 0 )
delete Select;
NumOfItems = PlayList->i_size;
if( PlayList->i_size > 0 )
{
Select = new bool[NumOfItems];
for( int i = 0; i < NumOfItems; i++ )
Select[i] = false;
int h;
sprintf( Num, " %i", NumOfItems + 1 );
TextFont->GetSize( Num, NumWidth, h);
FileWidth = CaseWidth - NumWidth - InfoWidth;
}
int Range = PlayList->i_size - Line * Column;
if( Range < 0 )
Range = 0;
Slider->ChangeSliderRange( Range );
StartIndex = Slider->GetCursorPosition();
}
}
//---------------------------------------------------------------------------
void ControlPlayList::RefreshAll()
{
ParentWindow->Refresh( TextLeft, TextTop, TextWidth, TextHeight );
}
//---------------------------------------------------------------------------
void ControlPlayList::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
// Slider Image
Slider->Draw( x, y, w, h, dest );
// TextZone
if( GetIntersectRgn( x, y, w, h, TextLeft, TextTop, TextWidth, TextHeight,
xI, yI, wI, hI) )
{
// Change clipping region
Region *destClipRgn = (Region *)new OSRegion( 0, 0, w, h );
TextClipRgn->Move( TextLeft - x, TextTop - y );
dest->SetClipRegion( TextClipRgn );
// Draw each line
DrawAllCase( dest, x, y, wI, hI );
// Reset clipping region to old region
dest->SetClipRegion( destClipRgn );
delete destClipRgn;
TextClipRgn->Move( x - TextLeft, y - TextTop );
}
}
//---------------------------------------------------------------------------
void ControlPlayList::DrawAllCase( Graphics *dest, int x, int y, int w, int h )
{
int i;
for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++ )
{
DrawCase( dest, i + StartIndex, x, y, w, h );
}
}
//---------------------------------------------------------------------------
void ControlPlayList::DrawCase( Graphics *dest, int i, int x, int y, int w,
int h )
{
// Test if case is in range
int j = i - StartIndex;
if( j < 0 || j >= Line * Column )
return;
// Draw background if selected
if( Select[i] )
{
dest->DrawRect(
CaseLeft[j] - x,
TextTop + j * CaseHeight - y,
CaseRight[j] - CaseLeft[j],
CaseHeight,
SelectColor
);
}
// Choose font
Font *F;
if( PlayList->i_index == i )
F = PlayFont;
else
F = TextFont;
// Print number
sprintf( Num, "%i", i + 1 );
F->Print( dest,
Num,
CaseTextLeft[j] - x, TextTop + j * CaseHeight - y,
NumWidth - Margin, CaseHeight, DT_RIGHT );
// Print name
F->Print( dest,
GetFileName( i ),
NumWidth + Margin + CaseTextLeft[j] - x,
TextTop + j * CaseHeight - y,
FileWidth - 2 * Margin, CaseHeight, DT_LEFT );
// Print info
F->Print( dest,
"no info",
NumWidth + FileWidth + Margin + CaseTextLeft[j] - x,
TextTop + j * CaseHeight - y,
InfoWidth - Margin, CaseHeight, DT_CENTER );
}
//---------------------------------------------------------------------------
char * ControlPlayList::GetFileName( int i )
{
if( LongFileName )
{
return PlayList->pp_items[i]->psz_name;
}
else
{
string f = PlayList->pp_items[i]->psz_name;
int pos = f.rfind( DIRECTORY_SEPARATOR, f.size() );
return PlayList->pp_items[i]->psz_name + pos + 1;
}
}
//---------------------------------------------------------------------------
void ControlPlayList::MoveRelative( int xOff, int yOff )
{
Slider->MoveRelative( xOff, yOff );
Left += xOff;
Top += yOff;
TextLeft += xOff;
TextTop += yOff;
for( int i = 1; i < Line; i++ )
{
CaseLeft[i] += xOff;
CaseTextLeft[i] += xOff;
CaseRight[i] += xOff;
}
}
//---------------------------------------------------------------------------
double ControlPlayList::Dist( int x1, int y1, int x2, int y2 )
{
return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}
//---------------------------------------------------------------------------
bool ControlPlayList::MouseDown( int x, int y, int button )
{
if( !Enabled )
return false;
// If hit into slider
if( Slider->MouseDown( x, y, button ) )
{
int New = Slider->GetCursorPosition();
if( New != StartIndex )
{
StartIndex = New;
ParentWindow->Refresh( TextLeft,TextTop,TextWidth,TextHeight );
}
return true;
}
if( !TextClipRgn->Hit( x - TextLeft, y - TextTop ) )
return false;
// If hit in a case
int i, j;
for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++)
{
if( x >= CaseLeft[i] && x <= CaseRight[i] && y >= TextTop +
i * CaseHeight && y < TextTop + (i + 1) * CaseHeight )
{
for( j = 0; j < NumOfItems; j++ )
{
if( j == i + StartIndex )
Select[j] = !Select[j];
}
RefreshAll();
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
bool ControlPlayList::MouseUp( int x, int y, int button )
{
if( !Enabled )
return false;
// If hit into slider
if( Slider->MouseUp( x, y, button ) )
return true;
return false;
}
//---------------------------------------------------------------------------
bool ControlPlayList::MouseMove( int x, int y, int button )
{
if( !Enabled || !button )
return false;
// If hit into slider
if( Slider->MouseMove( x, y, button ) )
{
int New = Slider->GetCursorPosition();
if( New != StartIndex )
{
StartIndex = New;
RefreshAll();
}
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool ControlPlayList::MouseOver( int x, int y )
{
if( TextClipRgn->Hit( x - Left, y - Top ) || Slider->MouseOver( x, y ) )
return true;
else
return false;
}
//---------------------------------------------------------------------------
bool ControlPlayList::MouseDblClick( int x, int y, int button )
{
if( !Enabled || button != 1 )
return false;
int i;
if( !TextClipRgn->Hit( x - TextLeft, y - TextTop ) )
return false;
for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++ )
{
if( x >= CaseLeft[i] && x <= CaseRight[i] && y >=
TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight )
{
playlist_Goto( PlayList, i + StartIndex );
OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)false );
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
bool ControlPlayList::ToolTipTest( int x, int y )
{
if( !Enabled )
return false;
int i, w, h;
for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++ )
{
if( x >= CaseLeft[i] && x <= CaseRight[i] && y >=
TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight )
{
TextFont->GetSize( PlayList->pp_items[i + StartIndex]->psz_name, w,
h );
if( w > FileWidth )
{
ParentWindow->ChangeToolTipText(
(string)PlayList->pp_items[i + StartIndex]->psz_name );
return true;
}
}
}
return false;
}
//---------------------------------------------------------------------------
void ControlPlayList::InitSliderCurve( double *ptx, double *pty, int nb,
string scroll_up, string scroll_down )
{
Slider = new ControlSlider( "none", true, "none", scroll_up, scroll_down,
ptx, pty, nb, "none", "", ParentWindow );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* playlist.h: Playlist control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: playlist.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_PLAYLIST
#define VLC_SKIN_CONTROL_PLAYLIST
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Event;
class Graphics;
class Window;
class Font;
class Bezier;
class Region;
//---------------------------------------------------------------------------
#define MAX_PLAYLIST_SIZE 7
//---------------------------------------------------------------------------
class ControlPlayList : public GenericControl
{
private:
Event *UpdateEvent;
Font *TextFont;
Font *PlayFont;
string FontName;
string PlayFontName;
bool Enabled;
playlist_t *PlayList;
// Scroll slider
ControlSlider *Slider;
int StartIndex;
// Playlist text zone
int Margin;
int Column;
int Line;
int CaseHeight;
int CaseWidth;
int NumWidth;
int FileWidth;
int InfoWidth;
char Num[MAX_PLAYLIST_SIZE];
int *CaseRight;
int *CaseLeft;
int *CaseTextLeft;
int TextLeft;
int TextTop;
int TextHeight;
int TextWidth;
Bezier *TextCurve;
Region *TextClipRgn;
int NumOfItems;
int SelectColor;
bool *Select;
bool LongFileName;
char * GetFileName( int i );
// Calculate distance between two points
double Dist( int x1, int y1, int x2, int y2 );
// Text functions
void DrawAllCase( Graphics *dest, int x, int y, int w, int h );
void DrawCase( Graphics *dest, int i, int x, int y, int w, int h );
void RefreshList();
void RefreshAll();
public:
// Constructor
ControlPlayList( string id, bool visible, int width, int infowidth,
string font, string playfont, int selcolor,
double *ptx, double *pty, int nb, bool longfilename,
string help, Window *Parent );
// Destructor
virtual ~ControlPlayList();
// initialization
virtual void Init();
virtual bool ProcessEvent( Event *evt );
void InitSliderCurve( double *ptx, double *pty, int nb,
string scroll_up, string scroll_down );
// Draw control
virtual void Draw( int x, int y, int w, int h, Graphics *dest );
// Mouse events
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool MouseDblClick( int x, int y, int button );
virtual bool ToolTipTest( int x, int y );
// Translate control
virtual void MoveRelative( int xOff, int yOff );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* image.cpp: Image control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: rectangle.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "graphics.h"
#include "bitmap.h"
#include "banks.h"
#include "generic.h"
#include "rectangle.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Control Image
//---------------------------------------------------------------------------
ControlRectangle::ControlRectangle( string id, bool visible, int x, int y,
int w, int h, int color, string event, string help, Window *Parent )
: GenericControl( id, visible, help, Parent )
{
Left = x;
Top = y;
Width = w;
Height = h;
MouseDownActionName = event;
Enabled = true;
Color = OSAPI_GetNonTransparentColor( color );
}
//---------------------------------------------------------------------------
ControlRectangle::~ControlRectangle()
{
}
//---------------------------------------------------------------------------
void ControlRectangle::Init()
{
// Create script
MouseDownAction = new Action( p_intf, MouseDownActionName );
}
//---------------------------------------------------------------------------
bool ControlRectangle::ProcessEvent( Event *evt )
{
switch( evt->GetMessage() )
{
case CTRL_ENABLED:
Enable( (Event*)evt->GetParam1(), (bool)evt->GetParam2() );
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlRectangle::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn(x, y, w, h, Left, Top, Width, Height, xI, yI, wI, hI ) )
{
dest->DrawRect( xI - x, yI - y, wI, hI, Color );
}
}
//---------------------------------------------------------------------------
bool ControlRectangle::MouseDown( int x, int y, int button )
{
if( !Enabled || !MouseOver( x, y ) || button != 1 ||
!MouseDownAction->SendEvent() )
return false;
return true;
}
//---------------------------------------------------------------------------
bool ControlRectangle::MouseOver( int x, int y )
{
if( x >= Left && x <= Left + Width && y >= Top && y <= Top + Height )
return true;
else
return false;
}
//---------------------------------------------------------------------------
void ControlRectangle::Enable( Event *event, bool enabled )
{
if( !MouseDownAction->MatchEvent( event, ACTION_MATCH_ONE ) )
return;
if( enabled != !Enabled )
{
Enabled = enabled;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* image.h: Image control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: rectangle.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_RECTANGLE
#define VLC_SKIN_CONTROL_RECTANGLE
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Action;
class Graphics;
class Window;
//---------------------------------------------------------------------------
class ControlRectangle : public GenericControl
{
private:
// Background color
int Color;
// Behaviour
bool Enabled;
// List of actions to execute when clicking
Action *MouseDownAction;
string MouseDownActionName;
public:
// Constructor
ControlRectangle( string id, bool visible, int x, int y, int w, int h,
int color, string event, string help, Window *Parent);
// Destructor
virtual ~ControlRectangle();
// initialization
virtual void Init();
virtual bool ProcessEvent( Event *evt );
//Draw image
virtual void Draw( int x, int y, int w, int h, Graphics *dest );
// Mouse events
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseOver( int x, int y );
// Enabling control
virtual void Enable( Event *event, bool enabled );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* slider.cpp: Slider control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: slider.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
#include <math.h>
#include <stdio.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "bitmap.h"
#include "bezier.h"
#include "banks.h"
#include "graphics.h"
#include "os_graphics.h"
#include "generic.h"
#include "slider.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Control Slider
//---------------------------------------------------------------------------
ControlSlider::ControlSlider( string id, bool visible, string type,
string cursorUp, string cursorDown, double *ptx, double *pty, int nb,
string tooltiptext, string help, Window *Parent )
: GenericControl( id, visible, help, Parent )
{
Type = type;
Left = 0;
Top = 0;
State = 1;
Value = 0;
Selected = false;
Enabled = false;
this->cursorUp = cursorUp;
this->cursorDown = cursorDown;
Curve = new Bezier( ptx, pty, nb );
UpdateEvent = NULL;
SliderRange = SLIDER_RANGE;
LastRefreshTime = OSAPI_GetTime();
// Tool tip text
BaseToolTipText = tooltiptext;
FullToolTipText = BaseToolTipText;
}
//---------------------------------------------------------------------------
ControlSlider::~ControlSlider()
{
delete[] CursorX;
delete[] CursorY;
DeleteObject( HitRgn );
}
//---------------------------------------------------------------------------
void ControlSlider::Init()
{
int i;
// Get bitmap from list
Img = new (Bitmap*)[2];
Img[0] = p_intf->p_sys->p_theme->BmpBank->Get( cursorUp );
Img[1] = p_intf->p_sys->p_theme->BmpBank->Get( cursorDown );
// Get images sizes
Img[0]->GetSize( CWidth, CHeight );
// Computing slider curve : get points
MaxValue = Curve->GetNumOfDifferentPoints();
CursorX = new int[MaxValue + 1];
CursorY = new int[MaxValue + 1];
Curve->GetDifferentPoints( CursorX, CursorY, -CWidth / 2, -CHeight / 2 );
// Search for size value
Left = CursorX[0];
Top = CursorY[0];
Width = CursorX[0];
Height = CursorY[0];
for( i = 1; i <= MaxValue; i++ )
{
if( CursorX[i] < Left )
Left = CursorX[i];
if( CursorY[i] < Top )
Top = CursorY[i];
if( CursorX[i] > Width )
Width = CursorX[i];
if( CursorY[i] > Height )
Height = CursorY[i];
}
Width += CWidth - Left;
Height += CHeight - Top;
// Curve is no more needed so delete it
delete Curve;
// Create Hit Region
HitRgn = (Region *)new OSRegion;
// Create slider hit region and move cursor inside control
for( i = 0; i <= MaxValue; i++ )
{
HitRgn->AddElipse( CursorX[i], CursorY[i], CWidth, CHeight );
CursorX[i] -= Left;
CursorY[i] -= Top;
}
// Select type of slider
if( Type == "time" )
{
Enabled = false;
UpdateEvent = p_intf->p_sys->p_theme->EvtBank->Get( "time" );
}
else if( Type == "volume" )
{
Enabled = true;
UpdateEvent = p_intf->p_sys->p_theme->EvtBank->Get( "volume_refresh" );
}
else
{
Enabled = false;
UpdateEvent = p_intf->p_sys->p_theme->EvtBank->Get( "none" );
}
}
//---------------------------------------------------------------------------
bool ControlSlider::ProcessEvent( Event *evt )
{
unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2();
switch( msg )
{
case CTRL_ENABLED:
Enable( (Event*)p1, (bool)p2 );
return true;
case CTRL_SET_SLIDER:
if( UpdateEvent->IsEqual( (Event*)p1 ) )
{
SetCursorPosition( (long)p2 );
}
return true;
}
return false;
}
//---------------------------------------------------------------------------
void ControlSlider::MoveRelative( int xOff, int yOff )
{
Left += xOff;
Top += yOff;
HitRgn->Move( xOff, yOff );
}
//---------------------------------------------------------------------------
void ControlSlider::SetCursorPosition( long Pos )
{
if( Pos < 0 )
Pos = 0;
if( Pos > SliderRange )
Pos = SliderRange;
if( !Selected )
{
if( SliderRange == 0 )
MoveCursor( 0 );
else
MoveCursor( Pos * MaxValue / SliderRange );
}
}
//---------------------------------------------------------------------------
long ControlSlider::GetCursorPosition()
{
return SliderRange * Value / MaxValue;
}
//---------------------------------------------------------------------------
void ControlSlider::MoveCursor( int newValue )
{
int X, Y, W, H;
int OldValue = Value;
Value = newValue;
if( OldValue != Value )
{
X = (CursorX[Value] > CursorX[OldValue])
? Left + CursorX[OldValue] : Left + CursorX[Value];
Y = (CursorY[Value] > CursorY[OldValue])
? Top + CursorY[OldValue] : Top + CursorY[Value];
W = (CursorX[Value] > CursorX[OldValue])
? CursorX[Value] - CursorX[OldValue] + CWidth
: CursorX[OldValue] - CursorX[Value] + CWidth;
H = (CursorY[Value] > CursorY[OldValue])
? CursorY[Value] - CursorY[OldValue] + CHeight
: CursorY[OldValue] - CursorY[Value] + CHeight;
if( 2 * CWidth * CHeight < W * H )
{
ParentWindow->Refresh( Left + CursorX[OldValue],
Top + CursorY[OldValue], CWidth, CHeight );
ParentWindow->Refresh( Left + CursorX[Value],
Top + CursorY[Value], CWidth, CHeight );
}
else
{
ParentWindow->Refresh( X, Y, W, H );
}
// Change tooltip
if( BaseToolTipText != "none" )
{
char *percent = new char[6];
sprintf( percent, "%i %%", Value * 100 / MaxValue );
FullToolTipText = BaseToolTipText + " - " + (string)percent;
delete[] percent;
}
}
}
//---------------------------------------------------------------------------
void ControlSlider::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
int xI, yI, wI, hI;
if( GetIntersectRgn( x, y, w, h, Left+CursorX[Value], Top+CursorY[Value],
CWidth, CHeight, xI, yI, wI, hI ) )
{
Img[1 - State]->DrawBitmap( xI - Left - CursorX[Value],
yI - Top - CursorY[Value], wI, hI, xI - x, yI - y, dest );
}
}
//---------------------------------------------------------------------------
bool ControlSlider::MouseUp( int x, int y, int button )
{
State = 1;
if( Enabled && Selected )
{
Selected = false;
ParentWindow->Refresh( Left + CursorX[Value],
Top + CursorY[Value], CWidth, CHeight );
UpdateEvent->SetParam2( GetCursorPosition() );
UpdateEvent->SendEvent();
}
return false;
}
//---------------------------------------------------------------------------
bool ControlSlider::MouseDown( int x, int y, int button )
{
if( !Enabled )
return false;
// If hit into cursor or indide active slider region
if( HitRgn->Hit( x, y ) && button == 1 )
{
State = 0;
Selected = true;
MoveCursor( FindNearestPoint( x, y ) );
UpdateEvent->SetParam2( GetCursorPosition() );
UpdateEvent->SendEvent();
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool ControlSlider::MouseMove( int x, int y, int button )
{
if( !Enabled || !Selected || !button )
return false;
MoveCursor( FindNearestPoint( x, y ) );
// Refresh value if time ellapsed since last refresh is more than 200 ms
int time = OSAPI_GetTime();
if( time > LastRefreshTime + 250 )
{
UpdateEvent->SetParam2( GetCursorPosition() );
UpdateEvent->SendEvent();
LastRefreshTime = time;
}
return true;
}
//---------------------------------------------------------------------------
bool ControlSlider::MouseOver( int x, int y )
{
if( HitRgn->Hit( x, y ) )
return true;
else
return false;
}
//---------------------------------------------------------------------------
bool ControlSlider::ToolTipTest( int x, int y )
{
if( MouseOver( x, y ) )
{
if( BaseToolTipText == "none" )
{
ParentWindow->ChangeToolTipText( BaseToolTipText );
}
else
{
ParentWindow->ChangeToolTipText( FullToolTipText );
}
return true;
}
return false;
}
//---------------------------------------------------------------------------
void ControlSlider::ChangeSliderRange( int NewRange )
{
if( NewRange == SliderRange )
return;
SliderRange = NewRange;
int Pos = GetCursorPosition();
SetCursorPosition( Pos );
}
//---------------------------------------------------------------------------
void ControlSlider::Enable( Event *event, bool enabled )
{
if( !UpdateEvent->IsEqual( event ) )
return;
if( enabled && !Enabled )
{
Enabled = true;
ParentWindow->Refresh( Left, Top, Width, Height );
}
else if( !enabled && Enabled )
{
Enabled = false;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
int ControlSlider::FindNearestPoint( int x, int y )
{
int i, wx, wy;
double D;
double minD = 50;
int RefValue = Value;
// Move point inside control
OSAPI_GetMousePos( x, y ); // This is used to avoid bug with
// negative values
ParentWindow->GetPos( wx, wy );
x += -wx - Left - CWidth / 2;
y += -wy - Top - CHeight / 2;
// Search nearest point
for( i = 0; i <= MaxValue; i++ )
{
D = sqrt( ( CursorX[i] - x ) * ( CursorX[i] - x ) +
( CursorY[i] - y ) * ( CursorY[i] - y ) );
if( D < minD )
{
minD = D;
RefValue = i;
}
}
return RefValue;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* slider.h: Slider control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: slider.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_SLIDER
#define VLC_SKIN_CONTROL_SLIDER
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Event;
class Graphics;
class Window;
class Bezier;
class Region;
//---------------------------------------------------------------------------
class ControlSlider : public GenericControl
{
private:
string Type;
string cursorUp;
string cursorDown;
Bezier *Curve;
bool Selected;
Event *UpdateEvent;
bool Enabled; // Is the button active
// Cursor properties
int CWidth; // Width of cursor
int CHeight; // Height of cursor
int * CursorX; // Array of x coordinates of slider points
int * CursorY; // Array of y coordinates of slider points
Region *HitRgn; // Active region for mouse events
int LastRefreshTime;
// Slider properties
int SliderRange; // Should stay to SLIDER_RANGE
int MaxValue; // Maximum value of the slider
int Value; // Value of slider
// ToolTip text
string BaseToolTipText;
string FullToolTipText;
int FindNearestPoint( int x, int y );
// Move cursor (wether SLIDER_MAX in skin_common.h)
void MoveCursor( int newValue );
public:
// Constructor
ControlSlider( string id, bool visible, string type, string cursorUp,
string cursorDown, double *ptx, double *pty, int nb,
string tooltiptext, string help, Window *Parent );
// Destructor
virtual ~ControlSlider();
// initialization
virtual void Init();
virtual bool ProcessEvent( Event *evt );
// Draw control
virtual void Draw( int x, int y, int w, int h, Graphics *dest );
// Mouse events
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool ToolTipTest( int x, int y );
// Slider calls
void SetCursorPosition( long Pos );
long GetCursorPosition();
// Enabling control
virtual void Enable( Event *event, bool enabled );
// Translate control
virtual void MoveRelative( int xOff, int yOff );
// Change SliderRange (do not use if not sure)
void ChangeSliderRange( int NewRange );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* text.cpp: Text control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: text.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "bitmap.h"
#include "banks.h"
#include "graphics.h"
#include "os_graphics.h"
#include "font.h"
#include "generic.h"
#include "text.h"
#include "event.h"
#include "theme.h"
#include "window.h"
#include "os_window.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Scrolling : one for each OS
//---------------------------------------------------------------------------
//-----------------------------------------------------------------------
// Win32 methods
//-----------------------------------------------------------------------
#if defined( WIN32 )
void CALLBACK ScrollingTextTimer( HWND hwnd, UINT uMsg, UINT_PTR idEvent,
DWORD dwTime )
{
if( (ControlText *)idEvent != NULL
&& !( (ControlText *)idEvent )->GetSelected() )
{
( (ControlText *)idEvent )->DoScroll();
}
}
//-----------------------------------------------------------------------
void ControlText::StartScrolling()
{
SetTimer( ( (Win32Window *)ParentWindow )->GetHandle(), (UINT_PTR)this,
100, (TIMERPROC)ScrollingTextTimer );
}
//-----------------------------------------------------------------------
void ControlText::StopScrolling()
{
KillTimer( ( (Win32Window *)ParentWindow )->GetHandle(),
(UINT_PTR)this );
}
//-----------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// CONTROL TEXT
//---------------------------------------------------------------------------
ControlText::ControlText( string id, bool visible, int x, int y, string text,
string font, int align, int width, string display, bool scroll,
int scrollspace, string help, Window *Parent )
: GenericControl( id, visible, help, Parent )
{
InitLeft = x;
Top = y;
InitWidth = width;
FontName = font;
Text = text;
Align = align;
Selected = false;
// Scrolling parameters
InitScroll = scroll;
Scroll = false;
ScrollSpace = scrollspace;
PauseScroll = false;
// Initialize display
if( display != "none" )
{
int begin = 0;
int pos = display.find( ';', 0 );
while( pos > 0 )
{
DisplayList.push_back( display.substr( begin, pos - begin ) );
begin = pos + 1;
pos = display.find( ';', begin );
}
DisplayList.push_back(
display.substr( begin, display.size() - begin ) );
Display = DisplayList.begin();
}
}
//---------------------------------------------------------------------------
ControlText::~ControlText()
{
if( TextClipRgn != NULL )
delete TextClipRgn;
TextWidth = 0;
SetScrolling();
}
//---------------------------------------------------------------------------
void ControlText::Init()
{
TextFont = p_intf->p_sys->p_theme->FntBank->Get( FontName );
// Init clipping region
TextClipRgn = NULL;
// Get size of control
SetSize();
SetScrolling();
}
//---------------------------------------------------------------------------
void ControlText::SetScrolling()
{
if( !Scroll && TextWidth > Width )
{
if( InitScroll )
{
Scroll = true;
StartScrolling();
}
}
else if( Scroll && TextWidth <= Width )
{
StopScrolling();
Scroll = false;
}
}
//---------------------------------------------------------------------------
void ControlText::SetSize()
{
// Get size parameters
int w, h;
TextFont->GetSize( Text, w, h );
TextWidth = w;
// Get width if not set
if( InitWidth <= 0 )
Width = w;
else
Width = InitWidth;
// Set height
Height = h;
// Set position wether alignment
if( Align == DT_CENTER )
{
Left = InitLeft - Width / 2;
TextLeft = InitLeft - TextWidth / 2;
}
else if( Align == DT_RIGHT )
{
Left = InitLeft - Width;
TextLeft = InitLeft - TextWidth;
}
else
{
Left = InitLeft;
TextLeft = InitLeft;
}
// Create clipping region
if( TextClipRgn != NULL )
delete TextClipRgn;
TextClipRgn = (Region *)new OSRegion( Left, Top, Width, Height );
}
//---------------------------------------------------------------------------
bool ControlText::ProcessEvent( Event *evt )
{
unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
long p2 = evt->GetParam2();
switch( msg )
{
case CTRL_SET_TEXT:
if( DisplayList.size() > 0 )
{
if( p_intf->p_sys->p_theme->EvtBank->Get( (*Display) )
->IsEqual( (Event*)p1 ) )
{
SetText( (char *)p2 );
}
}
break;
}
return false;
}
//---------------------------------------------------------------------------
void ControlText::Draw( int x, int y, int w, int h, Graphics *dest )
{
if( !Visible )
return;
// Test if control is in refresh zone
int xI, yI, wI, hI;
if( !GetIntersectRgn( x,y,w,h, Left,Top,Width,Height, xI,yI,wI,hI) )
return;
// Change clipping region
TextClipRgn->Move( -x, -y );
dest->SetClipRegion( TextClipRgn );
// Draw text
if( TextWidth <= Width || !Scroll )
{
TextFont->Print( dest, Text, Left - x, Top - y, Width, Height, Align );
}
else
{
if( TextLeft > Left + ScrollSpace )
{
TextFont->Print( dest, Text, TextLeft - x, Top - y,
TextWidth, Height, Align );
TextFont->Print( dest, Text, TextLeft - x - TextWidth - ScrollSpace,
Top - y, TextWidth, Height, Align );
}
else if( TextLeft + TextWidth + ScrollSpace < Left + Width )
{
TextFont->Print( dest, Text, TextLeft - x, Top - y,
TextWidth, Height, Align );
TextFont->Print( dest, Text, TextLeft - x + TextWidth + ScrollSpace,
Top - y, TextWidth, Height, Align );
}
else
{
TextFont->Print( dest, Text, TextLeft - x, Top - y,
TextWidth, Height, Align );
}
}
// Reset clipping region to old region
Region *destClipRgn = (Region *)new OSRegion( 0, 0, w, h );
dest->SetClipRegion( destClipRgn );
delete destClipRgn;
TextClipRgn->Move( x, y );
}
//---------------------------------------------------------------------------
void ControlText::SetText( const string newText )
{
if( Text != newText )
{
Selected = false;
Text = newText;
SetSize();
SetScrolling();
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
void ControlText::DoScroll()
{
if( !PauseScroll )
{
TextLeft -= 2;
if( TextLeft + TextWidth < Left )
TextLeft += TextWidth + ScrollSpace;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
//---------------------------------------------------------------------------
void ControlText::MoveRelative( int xOff, int yOff )
{
InitLeft += xOff;
Top += yOff;
SetSize();
}
//---------------------------------------------------------------------------
bool ControlText::MouseUp( int x, int y, int button )
{
Selected = false;
if( MouseOver( x, y ) && button == 1 )
{
if( DisplayList.size() > 1 || TextWidth > Width )
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool ControlText::MouseDown( int x, int y, int button )
{
if( MouseOver( x, y ) && button == 1 )
{
if( TextWidth > Width )
{
PauseScroll = !PauseScroll;
OSAPI_GetMousePos( MouseX, MouseY );
SelectedX = MouseX;
Selected = true;
return true;
}
else if( DisplayList.size() > 1 )
{
return true;
}
}
return false;
}
//---------------------------------------------------------------------------
bool ControlText::MouseMove( int x, int y, int button )
{
if( Selected && button == 1 )
{
OSAPI_GetMousePos( MouseX, MouseY );
if( MouseX != SelectedX )
{
TextLeft += MouseX - SelectedX;
SelectedX = MouseX;
while( TextLeft + TextWidth < Left )
TextLeft += TextWidth + ScrollSpace;
while( TextLeft > Left + ScrollSpace )
TextLeft -= TextWidth + ScrollSpace;
ParentWindow->Refresh( Left, Top, Width, Height );
}
}
return false;
}
//---------------------------------------------------------------------------
bool ControlText::MouseOver( int x, int y )
{
if( x >= Left && x < Left + Width && y >= Top && y < Top + Height )
return true;
else
return false;
}
//---------------------------------------------------------------------------
bool ControlText::MouseDblClick( int x, int y, int button )
{
Selected = false;
if( x >= Left && x < Left + Width && y >= Top && y < Top + Height
&& button == 1 && DisplayList.size() > 1 )
{
Display++;
if( Display == DisplayList.end() )
Display = DisplayList.begin();
return true;
}
else
{
return false;
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* text.h: Text control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: text.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_CONTROL_TEXT
#define VLC_SKIN_CONTROL_TEXT
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Event;
class BitmapBank;
class Graphics;
class Window;
class Region;
class Font;
//---------------------------------------------------------------------------
class ControlText : public GenericControl
{
private:
// Scrolling parameters
bool Scroll;
int TextWidth;
int TextLeft;
int ScrollSpace;
bool Selected;
int SelectedX;
int MouseX;
int MouseY;
bool PauseScroll;
// Initial parameters
bool InitScroll;
int InitLeft;
int InitWidth;
// General parameters
string Text;
int Align;
Font *TextFont;
string FontName;
list<string> DisplayList;
list<string>::const_iterator Display;
Region *TextClipRgn;
// Internal methods
void SetSize();
void SetScrolling();
void StartScrolling();
void StopScrolling();
public:
// Constructor
ControlText( string id, bool visible, int x, int y, string text,
string font, int align, int width, string display,
bool scroll, int scrollspace, string help, Window *Parent );
// initialization
virtual void Init();
virtual bool ProcessEvent( Event *evt );
// Destructor
~ControlText();
// Draw control
virtual void Draw( int x, int y, int w, int h, Graphics *dest );
// Mouse events
virtual bool MouseUp( int x, int y, int button );
virtual bool MouseDown( int x, int y, int button );
virtual bool MouseMove( int x, int y, int button );
virtual bool MouseOver( int x, int y );
virtual bool MouseDblClick( int x, int y, int button );
// Move control
virtual void MoveRelative( int xOff, int yOff );
// Set text
void SetText( const string newText );
// Keep on scrolling
void DoScroll();
// To avoid auto scrolling when manual scrolling
bool GetSelected() { return Selected; };
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* os_api.h: Wrapper for some os-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_api.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_API
#define VLC_SKIN_API
#if defined( WIN32 )
#define DIRECTORY_SEPARATOR '\\'
#endif
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Window;
//---------------------------------------------------------------------------
// Event API
//---------------------------------------------------------------------------
// This functions send a message to the interface message stack
// First argument is the destination window (NULL is broadcasting)
// Second argument is the name of the message (see event.h)
// Other parameters are the arguments of message
// Send message is supposed to treat the message directly and should not be
// used if possible
void OSAPI_SendMessage( Window *win, unsigned int message, unsigned int param1,
long param2 );
void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
long param2 );
//---------------------------------------------------------------------------
// Graphic API
//---------------------------------------------------------------------------
// This function get a color and return the correspounding color regarding
// color resolution. If it is black, it should return the nearest non black
// color
int OSAPI_GetNonTransparentColor( int c );
// This function get the size in pixel of the screen
void OSAPI_GetScreenSize( int &w, int &h );
//---------------------------------------------------------------------------
// General
//---------------------------------------------------------------------------
// This function get the position in pixel of the mouse cursor position
void OSAPI_GetMousePos( int &x, int &y );
// This function returns the Title of the specified window
string OSAPI_GetWindowTitle( Window *win );
// This functions removes a directory and all its contents
bool OSAPI_RmDir( string Path );
// This function returns a time in millisecond whose reference should be fixed
int OSAPI_GetTime();
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* os_bitmap.h: Wrapper for the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_bitmap.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_bitmap.h"
#define OSBitmap Win32Bitmap
#endif
/*****************************************************************************
* os_dialog.h: Wrapper for the common dialogs
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_dialog.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_dialog.h"
#define OSOpenFileDialog Win32OpenFileDialog
#define OSLogWindow Win32LogWindow
#endif
/*****************************************************************************
* os_event.h: Wrapper for the Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_event.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_event.h"
#define OSEvent Win32Event
#endif
/*****************************************************************************
* os_font.h: Wrapper for the OSFont class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_font.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_font.h"
#define OSFont Win32Font
#endif
/*****************************************************************************
* os_graphics.h: Wrapper for the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_graphics.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_graphics.h"
#define SRC_COPY SRCCOPY
#define SRC_AND SRCAND
#define OSGraphics Win32Graphics
#define OSRegion Win32Region
#endif
/*****************************************************************************
* os_theme.h: Wrapper for the OSTheme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_theme.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_theme.h"
#define OSTheme Win32Theme
#endif
/*****************************************************************************
* os_window.h: Wrapper for the OSWindow class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: os_window.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#if defined( WIN32 )
#include "win32_dragdrop.h"
#include "win32_window.h"
#define OSWindow Win32Window
#endif
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
*.l
This source diff could not be displayed because it is too large. You can view the blob instead.
<!-- vim: set filetype=xml : -->
<!--
*****************************************************************************
* skin.act: FleXML actions file
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin.act,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************
-->
<!DOCTYPE actions SYSTEM "flexml-act.dtd">
<actions>
<top>
<![CDATA[
#include "wrappers.h"
]]>
</top>
<start tag="Bitmap">
<![CDATA[
AddBitmap( {id}, {file}, {alphacolor} );
]]>
</start>
<start tag="Event">
<![CDATA[
AddEvent( {id}, {event}, {key} );
]]>
</start>
<start tag="Font">
<![CDATA[
AddFont( {id}, {font}, {size}, {color}, {weight}, {italic},
{underline} );
]]>
</start>
<start tag="ThemeInfo">
<![CDATA[
AddThemeInfo( {name}, {author}, {email}, {webpage} );
]]>
</start>
<start tag="Window">
<![CDATA[
StartWindow( {id}, {x}, {y}, {visible}, {fadetime}, {alpha},
{movealpha}, {dragdrop} );
]]>
</start>
<end tag="Window">
<![CDATA[
EndWindow();
]]>
</end>
<start tag="ControlGroup">
<![CDATA[
StartControlGroup( {x}, {y} );
]]>
</start>
<end tag="ControlGroup">
<![CDATA[
EndControlGroup();
]]>
</end>
<start tag="Anchor">
<![CDATA[
AddAnchor( {x}, {y}, {range}, {priority} );
]]>
</start>
<start tag="ImageControl">
<![CDATA[
AddImage( {id}, {visible}, {x}, {y}, {image}, {onclick}, {help} );
]]>
</start>
<start tag="RectangleControl">
<![CDATA[
AddRectangle( {id}, {visible}, {x}, {y}, {w}, {h}, {color},
{onclick}, {help} );
]]>
</start>
<start tag="ButtonControl">
<![CDATA[
AddButton( {id}, {visible}, {x}, {y}, {up}, {down}, {disabled},
{onclick}, {tooltiptext}, {help} );
]]>
</start>
<start tag="CheckBoxControl">
<![CDATA[
AddCheckBox( {id}, {visible}, {x}, {y}, {img1}, {img2}, {clickimg1},
{clickimg2}, {disabled1}, {disabled2}, {onclick1},
{onclick2}, {tooltiptext1}, {tooltiptext2}, {help} );
]]>
</start>
<start tag="SliderControl">
<![CDATA[
AddSlider( {id}, {visible}, {x}, {y}, {type}, {up}, {down}, {abs},
{ord}, {tooltiptext}, {help} );
]]>
</start>
<start tag="TextControl">
<![CDATA[
AddText( {id}, {visible}, {x}, {y}, {text}, {font}, {align},
{width}, {display}, {scroll}, {scrollspace},
{help} );
]]>
</start>
<start tag="PlayListControl">
<![CDATA[
AddPlayList( {id}, {visible}, {x}, {y}, {width}, {infowidth},
{font}, {playfont}, {selcolor}, {abs}, {ord},
{longfilename}, {help} );
]]>
</start>
<end tag="PlayListControl">
<![CDATA[
AddPlayListEnd();
]]>
</end>
<start tag="Theme">
<![CDATA[
StartTheme( {log}, {magnet} );
]]>
</start>
<end tag="Theme">
<![CDATA[
EndTheme();
]]>
</end>
</actions>
/* XML application for skin.dtd (Id: skin.dtd,v 1.8 2003/03/17 22:14:47 karibu Exp).
* Includes actions from skin.act.
* Generated 2003/03/18 03:18:31.
*
* This program was generated with the FleXML XML processor generator,
* (Id: flexml.pl,v 1.24 1999/12/13 16:18:30 krisrose Exp).
* Copyright 1999 Kristoffer Rose. All rights reserved.
*
* You can redistribute and/or modify this program provided the following
* two conditions hold:
*
* 1. The program is distributed WITHOUT ANY WARRANTY from the author of
* FleXML; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* 2. The program distribution conditions do not in any way affect the
* distribution conditions of the FleXML system used to generate this
* file or any version of FleXML derived from that system.
*
* Notice that these are explicit rights granted to you for files
* generated by the FleXML system. For your rights in connection with
* the FleXML system itself please consult the GNU General Public License.
*/
#include "skin.h"
#line 31 "skin.act"
#include "wrappers.h"
void STag_Bitmap(void)
{
#line 36 "skin.act"
AddBitmap( A_Bitmap_id, A_Bitmap_file, A_Bitmap_alphacolor );
} /* STag_Bitmap */
void STag_Event(void)
{
#line 41 "skin.act"
AddEvent( A_Event_id, A_Event_event, A_Event_key );
} /* STag_Event */
void STag_Font(void)
{
#line 46 "skin.act"
AddFont( A_Font_id, A_Font_font, A_Font_size, A_Font_color, A_Font_weight, A_Font_italic,
A_Font_underline );
} /* STag_Font */
void STag_ThemeInfo(void)
{
#line 52 "skin.act"
AddThemeInfo( A_ThemeInfo_name, A_ThemeInfo_author, A_ThemeInfo_email, A_ThemeInfo_webpage );
} /* STag_ThemeInfo */
void STag_Window(void)
{
#line 57 "skin.act"
StartWindow( A_Window_id, A_Window_x, A_Window_y, A_Window_visible, A_Window_fadetime, A_Window_alpha,
A_Window_movealpha, A_Window_dragdrop );
} /* STag_Window */
void ETag_Window(void)
{
#line 63 "skin.act"
EndWindow();
} /* ETag_Window */
void STag_ControlGroup(void)
{
#line 68 "skin.act"
StartControlGroup( A_ControlGroup_x, A_ControlGroup_y );
} /* STag_ControlGroup */
void ETag_ControlGroup(void)
{
#line 73 "skin.act"
EndControlGroup();
} /* ETag_ControlGroup */
void STag_Anchor(void)
{
#line 78 "skin.act"
AddAnchor( A_Anchor_x, A_Anchor_y, A_Anchor_range, A_Anchor_priority );
} /* STag_Anchor */
void STag_ImageControl(void)
{
#line 83 "skin.act"
AddImage( A_ImageControl_id, A_ImageControl_visible, A_ImageControl_x, A_ImageControl_y, A_ImageControl_image, A_ImageControl_onclick, A_ImageControl_help );
} /* STag_ImageControl */
void STag_RectangleControl(void)
{
#line 88 "skin.act"
AddRectangle( A_RectangleControl_id, A_RectangleControl_visible, A_RectangleControl_x, A_RectangleControl_y, A_RectangleControl_w, A_RectangleControl_h, A_RectangleControl_color,
A_RectangleControl_onclick, A_RectangleControl_help );
} /* STag_RectangleControl */
void STag_ButtonControl(void)
{
#line 94 "skin.act"
AddButton( A_ButtonControl_id, A_ButtonControl_visible, A_ButtonControl_x, A_ButtonControl_y, A_ButtonControl_up, A_ButtonControl_down, A_ButtonControl_disabled,
A_ButtonControl_onclick, A_ButtonControl_tooltiptext, A_ButtonControl_help );
} /* STag_ButtonControl */
void STag_CheckBoxControl(void)
{
#line 100 "skin.act"
AddCheckBox( A_CheckBoxControl_id, A_CheckBoxControl_visible, A_CheckBoxControl_x, A_CheckBoxControl_y, A_CheckBoxControl_img1, A_CheckBoxControl_img2, A_CheckBoxControl_clickimg1,
A_CheckBoxControl_clickimg2, A_CheckBoxControl_disabled1, A_CheckBoxControl_disabled2, A_CheckBoxControl_onclick1,
A_CheckBoxControl_onclick2, A_CheckBoxControl_tooltiptext1, A_CheckBoxControl_tooltiptext2, A_CheckBoxControl_help );
} /* STag_CheckBoxControl */
void STag_SliderControl(void)
{
#line 107 "skin.act"
AddSlider( A_SliderControl_id, A_SliderControl_visible, A_SliderControl_x, A_SliderControl_y, A_SliderControl_type, A_SliderControl_up, A_SliderControl_down, A_SliderControl_abs,
A_SliderControl_ord, A_SliderControl_tooltiptext, A_SliderControl_help );
} /* STag_SliderControl */
void STag_TextControl(void)
{
#line 113 "skin.act"
AddText( A_TextControl_id, A_TextControl_visible, A_TextControl_x, A_TextControl_y, A_TextControl_text, A_TextControl_font, A_TextControl_align,
A_TextControl_width, A_TextControl_display, A_TextControl_scroll, A_TextControl_scrollspace,
A_TextControl_help );
} /* STag_TextControl */
void STag_PlayListControl(void)
{
#line 120 "skin.act"
AddPlayList( A_PlayListControl_id, A_PlayListControl_visible, A_PlayListControl_x, A_PlayListControl_y, A_PlayListControl_width, A_PlayListControl_infowidth,
A_PlayListControl_font, A_PlayListControl_playfont, A_PlayListControl_selcolor, A_PlayListControl_abs, A_PlayListControl_ord,
A_PlayListControl_longfilename, A_PlayListControl_help );
} /* STag_PlayListControl */
void ETag_PlayListControl(void)
{
#line 127 "skin.act"
AddPlayListEnd();
} /* ETag_PlayListControl */
void STag_Theme(void)
{
#line 132 "skin.act"
StartTheme( A_Theme_log, A_Theme_magnet );
} /* STag_Theme */
void ETag_Theme(void)
{
#line 137 "skin.act"
EndTheme();
} /* ETag_Theme */
/* Dummy main: filter XML from stdin. */
//int main() { exit(yylex()); }
/* XML application entry points. */
void ETag_Bitmap(void) {}
void ETag_Event(void) {}
void ETag_Font(void) {}
void ETag_ThemeInfo(void) {}
void ETag_Anchor(void) {}
void ETag_ImageControl(void) {}
void ETag_RectangleControl(void) {}
void ETag_ButtonControl(void) {}
void ETag_CheckBoxControl(void) {}
void ETag_SliderControl(void) {}
void ETag_TextControl(void) {}
<!--
*****************************************************************************
* skin.dtd: DTD for the VLC skins
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin.dtd,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************
-->
<!ELEMENT Theme (ThemeInfo,(Bitmap|Font|Window|Event)*)>
<!ATTLIST Theme
magnet CDATA "9"
log CDATA "false"
>
<!-- main elements -->
<!ELEMENT Bitmap EMPTY>
<!ATTLIST Bitmap
id CDATA #REQUIRED
file CDATA #REQUIRED
alphacolor CDATA #REQUIRED
>
<!ELEMENT Event EMPTY>
<!ATTLIST Event
id CDATA #REQUIRED
event CDATA #REQUIRED
key CDATA "none"
>
<!ELEMENT Font EMPTY>
<!ATTLIST Font
id CDATA "default"
font CDATA "arial"
size CDATA "12"
color CDATA "#000000"
weight CDATA "400"
italic CDATA "false"
underline CDATA "false"
>
<!ELEMENT ThemeInfo EMPTY>
<!ATTLIST ThemeInfo
name CDATA #IMPLIED
author CDATA #IMPLIED
email CDATA #IMPLIED
webpage CDATA #IMPLIED
>
<!ELEMENT Window (ControlGroup)>
<!ATTLIST Window
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
fadetime CDATA "500"
alpha CDATA "255"
movealpha CDATA "255"
dragdrop CDATA "true"
>
<!ELEMENT ControlGroup (ControlGroup|ImageControl|ButtonControl|PlayListControl|
SliderControl|TextControl|CheckBoxControl|
RectangleControl|Anchor)+>
<!ATTLIST ControlGroup
x CDATA "\0"
y CDATA "\0"
>
<!-- Anchors -->
<!ELEMENT Anchor EMPTY>
<!ATTLIST Anchor
x CDATA "\0"
y CDATA "\0"
priority CDATA #REQUIRED
range CDATA "10"
>
<!-- Controls -->
<!ELEMENT ImageControl EMPTY>
<!ATTLIST ImageControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
image CDATA #REQUIRED
onclick CDATA "none"
help CDATA "\0"
>
<!ELEMENT RectangleControl EMPTY>
<!ATTLIST RectangleControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
w CDATA "50"
h CDATA "50"
color CDATA "#C0C0C0"
onclick CDATA "none"
help CDATA "\0"
>
<!ELEMENT ButtonControl EMPTY>
<!ATTLIST ButtonControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
up CDATA #REQUIRED
down CDATA #REQUIRED
disabled CDATA "none"
onclick CDATA "none"
tooltiptext CDATA "none"
help CDATA "\0"
>
<!ELEMENT CheckBoxControl EMPTY>
<!ATTLIST CheckBoxControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
img1 CDATA #REQUIRED
clickimg1 CDATA "none"
img2 CDATA #REQUIRED
clickimg2 CDATA "none"
disabled1 CDATA "none"
disabled2 CDATA "none"
onclick1 CDATA "none"
onclick2 CDATA "none"
tooltiptext1 CDATA "none"
tooltiptext2 CDATA "none"
help CDATA "\0"
>
<!ELEMENT SliderControl EMPTY>
<!ATTLIST SliderControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
type CDATA "time"
up CDATA #REQUIRED
down CDATA #REQUIRED
abs CDATA #REQUIRED
ord CDATA #REQUIRED
tooltiptext CDATA "none"
help CDATA "\0"
>
<!ELEMENT TextControl EMPTY>
<!ATTLIST TextControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
text CDATA ""
font CDATA #REQUIRED
align CDATA "left"
width CDATA "\0"
display CDATA "none"
scroll CDATA "true"
scrollspace CDATA "20"
help CDATA "\0"
>
<!ELEMENT PlayListControl SliderControl>
<!ATTLIST PlayListControl
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
width CDATA "200"
infowidth CDATA "50"
font CDATA #REQUIRED
playfont CDATA "none"
selcolor CDATA "#0000FF"
abs CDATA #REQUIRED
ord CDATA #REQUIRED
help CDATA "\0"
longfilename CDATA "false"
>
/* XML processor/application API for skin.dtd (Id: skin.dtd,v 1.8 2003/03/17 22:14:47 karibu Exp).
* Generated 2003/03/18 03:18:31.
*
* This program was generated with the FleXML XML processor generator,
* (Id: flexml.pl,v 1.24 1999/12/13 16:18:30 krisrose Exp).
* Copyright 1999 Kristoffer Rose. All rights reserved.
*
* You can redistribute and/or modify this program provided the following
* two conditions hold:
*
* 1. The program is distributed WITHOUT ANY WARRANTY from the author of
* FleXML; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* 2. The program distribution conditions do not in any way affect the
* distribution conditions of the FleXML system used to generate this
* file or any version of FleXML derived from that system.
*
* Notice that these are explicit rights granted to you for files
* generated by the FleXML system. For your rights in connection with
* the FleXML system itself please consult the GNU General Public License.
*/
#ifndef _FLEXML_skin_H
/* XML application entry points. */
extern void STag_Theme(void);
extern void ETag_Theme(void);
extern void STag_Bitmap(void);
extern void ETag_Bitmap(void);
extern void STag_Event(void);
extern void ETag_Event(void);
extern void STag_Font(void);
extern void ETag_Font(void);
extern void STag_ThemeInfo(void);
extern void ETag_ThemeInfo(void);
extern void STag_Window(void);
extern void ETag_Window(void);
extern void STag_ControlGroup(void);
extern void ETag_ControlGroup(void);
extern void STag_Anchor(void);
extern void ETag_Anchor(void);
extern void STag_ImageControl(void);
extern void ETag_ImageControl(void);
extern void STag_RectangleControl(void);
extern void ETag_RectangleControl(void);
extern void STag_ButtonControl(void);
extern void ETag_ButtonControl(void);
extern void STag_CheckBoxControl(void);
extern void ETag_CheckBoxControl(void);
extern void STag_SliderControl(void);
extern void ETag_SliderControl(void);
extern void STag_TextControl(void);
extern void ETag_TextControl(void);
extern void STag_PlayListControl(void);
extern void ETag_PlayListControl(void);
/* XML application data. */
typedef char* AT_TextControl_display;
#define AU_TextControl_display NULL
typedef char* AT_SliderControl_x;
#define AU_SliderControl_x NULL
typedef char* AT_ButtonControl_onclick;
#define AU_ButtonControl_onclick NULL
typedef char* AT_RectangleControl_color;
#define AU_RectangleControl_color NULL
typedef char* AT_SliderControl_y;
#define AU_SliderControl_y NULL
typedef char* AT_ButtonControl_id;
#define AU_ButtonControl_id NULL
typedef char* AT_Window_movealpha;
#define AU_Window_movealpha NULL
typedef char* AT_SliderControl_down;
#define AU_SliderControl_down NULL
typedef char* AT_ButtonControl_down;
#define AU_ButtonControl_down NULL
typedef char* AT_CheckBoxControl_disabled1;
#define AU_CheckBoxControl_disabled1 NULL
typedef char* AT_CheckBoxControl_disabled2;
#define AU_CheckBoxControl_disabled2 NULL
typedef char* AT_Font_underline;
#define AU_Font_underline NULL
typedef char* AT_ButtonControl_visible;
#define AU_ButtonControl_visible NULL
typedef char* AT_TextControl_scroll;
#define AU_TextControl_scroll NULL
typedef char* AT_SliderControl_id;
#define AU_SliderControl_id NULL
typedef char* AT_CheckBoxControl_x;
#define AU_CheckBoxControl_x NULL
typedef char* AT_Window_alpha;
#define AU_Window_alpha NULL
typedef char* AT_TextControl_x;
#define AU_TextControl_x NULL
typedef char* AT_CheckBoxControl_y;
#define AU_CheckBoxControl_y NULL
typedef char* AT_Window_id;
#define AU_Window_id NULL
typedef char* AT_TextControl_y;
#define AU_TextControl_y NULL
typedef char* AT_RectangleControl_onclick;
#define AU_RectangleControl_onclick NULL
typedef char* AT_Theme_magnet;
#define AU_Theme_magnet NULL
typedef char* AT_TextControl_font;
#define AU_TextControl_font NULL
typedef char* AT_PlayListControl_selcolor;
#define AU_PlayListControl_selcolor NULL
typedef char* AT_Anchor_x;
#define AU_Anchor_x NULL
typedef char* AT_Anchor_y;
#define AU_Anchor_y NULL
typedef char* AT_ButtonControl_up;
#define AU_ButtonControl_up NULL
typedef char* AT_RectangleControl_visible;
#define AU_RectangleControl_visible NULL
typedef char* AT_SliderControl_type;
#define AU_SliderControl_type NULL
typedef char* AT_CheckBoxControl_id;
#define AU_CheckBoxControl_id NULL
typedef char* AT_Anchor_priority;
#define AU_Anchor_priority NULL
typedef char* AT_PlayListControl_visible;
#define AU_PlayListControl_visible NULL
typedef char* AT_Bitmap_alphacolor;
#define AU_Bitmap_alphacolor NULL
typedef char* AT_ImageControl_onclick;
#define AU_ImageControl_onclick NULL
typedef char* AT_PlayListControl_x;
#define AU_PlayListControl_x NULL
typedef char* AT_PlayListControl_y;
#define AU_PlayListControl_y NULL
typedef char* AT_ImageControl_image;
#define AU_ImageControl_image NULL
typedef char* AT_ThemeInfo_name;
#define AU_ThemeInfo_name NULL
typedef char* AT_TextControl_width;
#define AU_TextControl_width NULL
typedef char* AT_PlayListControl_id;
#define AU_PlayListControl_id NULL
typedef char* AT_Bitmap_id;
#define AU_Bitmap_id NULL
typedef char* AT_Font_italic;
#define AU_Font_italic NULL
typedef char* AT_PlayListControl_ord;
#define AU_PlayListControl_ord NULL
typedef char* AT_ButtonControl_disabled;
#define AU_ButtonControl_disabled NULL
typedef char* AT_SliderControl_up;
#define AU_SliderControl_up NULL
typedef char* AT_ImageControl_x;
#define AU_ImageControl_x NULL
typedef char* AT_ControlGroup_x;
#define AU_ControlGroup_x NULL
typedef char* AT_PlayListControl_infowidth;
#define AU_PlayListControl_infowidth NULL
typedef char* AT_ImageControl_y;
#define AU_ImageControl_y NULL
typedef char* AT_ControlGroup_y;
#define AU_ControlGroup_y NULL
typedef char* AT_PlayListControl_longfilename;
#define AU_PlayListControl_longfilename NULL
typedef char* AT_PlayListControl_abs;
#define AU_PlayListControl_abs NULL
typedef char* AT_ImageControl_visible;
#define AU_ImageControl_visible NULL
typedef char* AT_Theme_log;
#define AU_Theme_log NULL
typedef char* AT_PlayListControl_width;
#define AU_PlayListControl_width NULL
typedef char* AT_SliderControl_help;
#define AU_SliderControl_help NULL
typedef char* AT_ButtonControl_help;
#define AU_ButtonControl_help NULL
typedef char* AT_TextControl_scrollspace;
#define AU_TextControl_scrollspace NULL
typedef char* AT_Font_font;
#define AU_Font_font NULL
typedef char* AT_SliderControl_visible;
#define AU_SliderControl_visible NULL
typedef char* AT_PlayListControl_playfont;
#define AU_PlayListControl_playfont NULL
typedef char* AT_TextControl_text;
#define AU_TextControl_text NULL
typedef char* AT_SliderControl_ord;
#define AU_SliderControl_ord NULL
typedef char* AT_Window_visible;
#define AU_Window_visible NULL
typedef char* AT_TextControl_align;
#define AU_TextControl_align NULL
typedef char* AT_TextControl_id;
#define AU_TextControl_id NULL
typedef char* AT_Window_x;
#define AU_Window_x NULL
typedef char* AT_SliderControl_abs;
#define AU_SliderControl_abs NULL
typedef char* AT_Window_y;
#define AU_Window_y NULL
typedef char* AT_RectangleControl_help;
#define AU_RectangleControl_help NULL
typedef char* AT_CheckBoxControl_img1;
#define AU_CheckBoxControl_img1 NULL
typedef char* AT_CheckBoxControl_img2;
#define AU_CheckBoxControl_img2 NULL
typedef char* AT_ButtonControl_x;
#define AU_ButtonControl_x NULL
typedef char* AT_ButtonControl_y;
#define AU_ButtonControl_y NULL
typedef char* AT_Window_dragdrop;
#define AU_Window_dragdrop NULL
typedef char* AT_ImageControl_help;
#define AU_ImageControl_help NULL
typedef char* AT_PlayListControl_help;
#define AU_PlayListControl_help NULL
typedef char* AT_Font_weight;
#define AU_Font_weight NULL
typedef char* AT_ThemeInfo_author;
#define AU_ThemeInfo_author NULL
typedef char* AT_CheckBoxControl_help;
#define AU_CheckBoxControl_help NULL
typedef char* AT_TextControl_visible;
#define AU_TextControl_visible NULL
typedef char* AT_ButtonControl_tooltiptext;
#define AU_ButtonControl_tooltiptext NULL
typedef char* AT_Event_event;
#define AU_Event_event NULL
typedef char* AT_RectangleControl_h;
#define AU_RectangleControl_h NULL
typedef char* AT_ThemeInfo_webpage;
#define AU_ThemeInfo_webpage NULL
typedef char* AT_CheckBoxControl_tooltiptext1;
#define AU_CheckBoxControl_tooltiptext1 NULL
typedef char* AT_CheckBoxControl_tooltiptext2;
#define AU_CheckBoxControl_tooltiptext2 NULL
typedef char* AT_ImageControl_id;
#define AU_ImageControl_id NULL
typedef char* AT_CheckBoxControl_onclick1;
#define AU_CheckBoxControl_onclick1 NULL
typedef char* AT_Font_size;
#define AU_Font_size NULL
typedef char* AT_Bitmap_file;
#define AU_Bitmap_file NULL
typedef char* AT_CheckBoxControl_onclick2;
#define AU_CheckBoxControl_onclick2 NULL
typedef char* AT_Window_fadetime;
#define AU_Window_fadetime NULL
typedef char* AT_Event_id;
#define AU_Event_id NULL
typedef char* AT_Font_id;
#define AU_Font_id NULL
typedef char* AT_CheckBoxControl_visible;
#define AU_CheckBoxControl_visible NULL
typedef char* AT_Event_key;
#define AU_Event_key NULL
typedef char* AT_ThemeInfo_email;
#define AU_ThemeInfo_email NULL
typedef char* AT_Font_color;
#define AU_Font_color NULL
typedef char* AT_RectangleControl_w;
#define AU_RectangleControl_w NULL
typedef char* AT_SliderControl_tooltiptext;
#define AU_SliderControl_tooltiptext NULL
typedef char* AT_RectangleControl_x;
#define AU_RectangleControl_x NULL
typedef char* AT_RectangleControl_y;
#define AU_RectangleControl_y NULL
typedef char* AT_CheckBoxControl_clickimg1;
#define AU_CheckBoxControl_clickimg1 NULL
typedef char* AT_CheckBoxControl_clickimg2;
#define AU_CheckBoxControl_clickimg2 NULL
typedef char* AT_Anchor_range;
#define AU_Anchor_range NULL
typedef char* AT_PlayListControl_font;
#define AU_PlayListControl_font NULL
typedef char* AT_TextControl_help;
#define AU_TextControl_help NULL
typedef char* AT_RectangleControl_id;
#define AU_RectangleControl_id NULL
/* FleXML-provided data. */
extern char* pcdata;
extern AT_TextControl_display A_TextControl_display;
extern AT_SliderControl_x A_SliderControl_x;
extern AT_ButtonControl_onclick A_ButtonControl_onclick;
extern AT_RectangleControl_color A_RectangleControl_color;
extern AT_SliderControl_y A_SliderControl_y;
extern AT_ButtonControl_id A_ButtonControl_id;
extern AT_Window_movealpha A_Window_movealpha;
extern AT_SliderControl_down A_SliderControl_down;
extern AT_ButtonControl_down A_ButtonControl_down;
extern AT_CheckBoxControl_disabled1 A_CheckBoxControl_disabled1;
extern AT_CheckBoxControl_disabled2 A_CheckBoxControl_disabled2;
extern AT_Font_underline A_Font_underline;
extern AT_ButtonControl_visible A_ButtonControl_visible;
extern AT_TextControl_scroll A_TextControl_scroll;
extern AT_SliderControl_id A_SliderControl_id;
extern AT_CheckBoxControl_x A_CheckBoxControl_x;
extern AT_Window_alpha A_Window_alpha;
extern AT_TextControl_x A_TextControl_x;
extern AT_CheckBoxControl_y A_CheckBoxControl_y;
extern AT_Window_id A_Window_id;
extern AT_TextControl_y A_TextControl_y;
extern AT_RectangleControl_onclick A_RectangleControl_onclick;
extern AT_Theme_magnet A_Theme_magnet;
extern AT_TextControl_font A_TextControl_font;
extern AT_PlayListControl_selcolor A_PlayListControl_selcolor;
extern AT_Anchor_x A_Anchor_x;
extern AT_Anchor_y A_Anchor_y;
extern AT_ButtonControl_up A_ButtonControl_up;
extern AT_RectangleControl_visible A_RectangleControl_visible;
extern AT_SliderControl_type A_SliderControl_type;
extern AT_CheckBoxControl_id A_CheckBoxControl_id;
extern AT_Anchor_priority A_Anchor_priority;
extern AT_PlayListControl_visible A_PlayListControl_visible;
extern AT_Bitmap_alphacolor A_Bitmap_alphacolor;
extern AT_ImageControl_onclick A_ImageControl_onclick;
extern AT_PlayListControl_x A_PlayListControl_x;
extern AT_PlayListControl_y A_PlayListControl_y;
extern AT_ImageControl_image A_ImageControl_image;
extern AT_ThemeInfo_name A_ThemeInfo_name;
extern AT_TextControl_width A_TextControl_width;
extern AT_PlayListControl_id A_PlayListControl_id;
extern AT_Bitmap_id A_Bitmap_id;
extern AT_Font_italic A_Font_italic;
extern AT_PlayListControl_ord A_PlayListControl_ord;
extern AT_ButtonControl_disabled A_ButtonControl_disabled;
extern AT_SliderControl_up A_SliderControl_up;
extern AT_ImageControl_x A_ImageControl_x;
extern AT_ControlGroup_x A_ControlGroup_x;
extern AT_PlayListControl_infowidth A_PlayListControl_infowidth;
extern AT_ImageControl_y A_ImageControl_y;
extern AT_ControlGroup_y A_ControlGroup_y;
extern AT_PlayListControl_longfilename A_PlayListControl_longfilename;
extern AT_PlayListControl_abs A_PlayListControl_abs;
extern AT_ImageControl_visible A_ImageControl_visible;
extern AT_Theme_log A_Theme_log;
extern AT_PlayListControl_width A_PlayListControl_width;
extern AT_SliderControl_help A_SliderControl_help;
extern AT_ButtonControl_help A_ButtonControl_help;
extern AT_TextControl_scrollspace A_TextControl_scrollspace;
extern AT_Font_font A_Font_font;
extern AT_SliderControl_visible A_SliderControl_visible;
extern AT_PlayListControl_playfont A_PlayListControl_playfont;
extern AT_TextControl_text A_TextControl_text;
extern AT_SliderControl_ord A_SliderControl_ord;
extern AT_Window_visible A_Window_visible;
extern AT_TextControl_align A_TextControl_align;
extern AT_TextControl_id A_TextControl_id;
extern AT_Window_x A_Window_x;
extern AT_SliderControl_abs A_SliderControl_abs;
extern AT_Window_y A_Window_y;
extern AT_RectangleControl_help A_RectangleControl_help;
extern AT_CheckBoxControl_img1 A_CheckBoxControl_img1;
extern AT_CheckBoxControl_img2 A_CheckBoxControl_img2;
extern AT_ButtonControl_x A_ButtonControl_x;
extern AT_ButtonControl_y A_ButtonControl_y;
extern AT_Window_dragdrop A_Window_dragdrop;
extern AT_ImageControl_help A_ImageControl_help;
extern AT_PlayListControl_help A_PlayListControl_help;
extern AT_Font_weight A_Font_weight;
extern AT_ThemeInfo_author A_ThemeInfo_author;
extern AT_CheckBoxControl_help A_CheckBoxControl_help;
extern AT_TextControl_visible A_TextControl_visible;
extern AT_ButtonControl_tooltiptext A_ButtonControl_tooltiptext;
extern AT_Event_event A_Event_event;
extern AT_RectangleControl_h A_RectangleControl_h;
extern AT_ThemeInfo_webpage A_ThemeInfo_webpage;
extern AT_CheckBoxControl_tooltiptext1 A_CheckBoxControl_tooltiptext1;
extern AT_CheckBoxControl_tooltiptext2 A_CheckBoxControl_tooltiptext2;
extern AT_ImageControl_id A_ImageControl_id;
extern AT_CheckBoxControl_onclick1 A_CheckBoxControl_onclick1;
extern AT_Font_size A_Font_size;
extern AT_Bitmap_file A_Bitmap_file;
extern AT_CheckBoxControl_onclick2 A_CheckBoxControl_onclick2;
extern AT_Window_fadetime A_Window_fadetime;
extern AT_Event_id A_Event_id;
extern AT_Font_id A_Font_id;
extern AT_CheckBoxControl_visible A_CheckBoxControl_visible;
extern AT_Event_key A_Event_key;
extern AT_ThemeInfo_email A_ThemeInfo_email;
extern AT_Font_color A_Font_color;
extern AT_RectangleControl_w A_RectangleControl_w;
extern AT_SliderControl_tooltiptext A_SliderControl_tooltiptext;
extern AT_RectangleControl_x A_RectangleControl_x;
extern AT_RectangleControl_y A_RectangleControl_y;
extern AT_CheckBoxControl_clickimg1 A_CheckBoxControl_clickimg1;
extern AT_CheckBoxControl_clickimg2 A_CheckBoxControl_clickimg2;
extern AT_Anchor_range A_Anchor_range;
extern AT_PlayListControl_font A_PlayListControl_font;
extern AT_TextControl_help A_TextControl_help;
extern AT_RectangleControl_id A_RectangleControl_id;
/* XML application utilities. */
extern int element_context(int);
/* XML processor entry point. */
extern int yylex(void);
#endif
/*****************************************************************************
* wrappers.cpp: Wrappers around C++ objects
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: wrappers.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
#include <stdlib.h>
#include <string>
using namespace std;
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
extern intf_thread_t *g_pIntf;
//--- SKIN ------------------------------------------------------------------
#include "anchor.h"
#include "banks.h"
#include "controls.h"
#include "window.h"
#include "theme.h"
#include "skin_common.h"
#include "wrappers.h"
//---------------------------------------------------------------------------
// Local prototypes
//---------------------------------------------------------------------------
static bool ConvertBoolean( const char *value );
static int ConvertColor( const char *transcolor );
static int CheckCoords( const char *coord );
static void ConvertCoords( char *coord, double *p_coord );
static int ConvertAlign( char *align );
//---------------------------------------------------------------------------
// Wrappers
//---------------------------------------------------------------------------
void AddBitmap( char *name, char *file, char *transcolor )
{
g_pIntf->p_sys->p_theme->BmpBank->Add( name, file,
ConvertColor( transcolor ) );
}
//---------------------------------------------------------------------------
void AddEvent( char *name, char *event, char *key )
{
g_pIntf->p_sys->p_theme->EvtBank->Add( name, event, key );
}
//---------------------------------------------------------------------------
void AddFont( char *name, char *font, char *size, char *color,
char *weight, char *italic, char *underline )
{
g_pIntf->p_sys->p_theme->FntBank->Add(
name, font, atoi( size ), ConvertColor( color ), atoi( weight ),
ConvertBoolean( italic ), ConvertBoolean( underline ) );
}
//---------------------------------------------------------------------------
void AddThemeInfo( char *name, char *author, char *email, char *webpage )
{
g_pIntf->p_sys->p_theme->ChangeClientWindowName(
"VLC Media Player - " + (string)name );
}
//---------------------------------------------------------------------------
void StartWindow( char *name, char *x, char *y, char *visible, char *fadetime,
char *alpha, char *movealpha, char *dragdrop )
{
g_pIntf->p_sys->p_theme->AddWindow( name, atoi( x ), atoi( y ),
ConvertBoolean( visible ), atoi( fadetime ), atoi( alpha ),
atoi( movealpha ), ConvertBoolean( dragdrop ) );
}
//---------------------------------------------------------------------------
void EndWindow()
{
}
//---------------------------------------------------------------------------
void StartTheme( char *log, char *magnet )
{
g_pIntf->p_sys->p_theme->StartTheme( ConvertBoolean( log ),
atoi( magnet ) );
}
//---------------------------------------------------------------------------
void EndTheme()
{
}
//---------------------------------------------------------------------------
void StartControlGroup( char *x, char *y )
{
g_pIntf->p_sys->p_theme->OffBank->PushOffSet( atoi( x ), atoi( y ) );
}
//---------------------------------------------------------------------------
void EndControlGroup()
{
g_pIntf->p_sys->p_theme->OffBank->PopOffSet();
}
//---------------------------------------------------------------------------
void AddAnchor( char *x, char *y, char *len, char *priority )
{
int XOff, YOff;
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->AnchorList.push_back( new Anchor( g_pIntf, atoi( x ) + XOff,
atoi( y ) + YOff, atoi( len ),
atoi( priority ), vlcWin ) );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// CONTROLS
//---------------------------------------------------------------------------
void AddImage( char *id, char *visible, char *x, char *y, char *image,
char *event, char *help )
{
int XOff, YOff;
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->ControlList.push_back( new ControlImage( id,
ConvertBoolean( visible ), atoi( x ) + XOff,
atoi( y ) + YOff, image, event, help, vlcWin ) );
}
//---------------------------------------------------------------------------
void AddRectangle( char *id, char *visible, char *x, char *y, char *w, char *h,
char *color, char *event, char *help )
{
int XOff, YOff;
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->ControlList.push_back( new ControlRectangle( id,
ConvertBoolean( visible ), atoi( x ) + XOff, atoi( y ) + YOff,
atoi( w ), atoi( h ), ConvertColor( color ), event, help, vlcWin ) );
}
//---------------------------------------------------------------------------
void AddButton( char *id, char *visible, char *x, char *y, char *up, char *down,
char *disabled, char *click, char *tooltiptext, char *help )
{
int XOff, YOff;
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->ControlList.push_back( new ControlButton( id,
ConvertBoolean( visible ), atoi( x ) + XOff, atoi( y ) + YOff,
up, down, disabled, click, tooltiptext, help, vlcWin ) );
}
//---------------------------------------------------------------------------
void AddCheckBox( char *id, char *visible, char *x, char *y, char *img1,
char *img2, char *click1, char *click2, char *disabled1, char *disabled2,
char *action1, char *action2, char *tooltiptext1, char *tooltiptext2,
char *help )
{
int XOff, YOff;
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->ControlList.push_back( new ControlCheckBox( id,
ConvertBoolean( visible ), atoi( x ) + XOff,
atoi( y ) + YOff, img1, img2, click1, click2, disabled1, disabled2,
action1, action2, tooltiptext1, tooltiptext2, help, vlcWin ) );
}
//---------------------------------------------------------------------------
void AddSlider( char *id, char *visible, char *x, char *y, char *type, char *up,
char *down, char *abs, char *ord, char *tooltiptext, char *help )
{
int XOff, YOff, i;
int res1 = CheckCoords( abs );
int res2 = CheckCoords( ord );
if( res1 < 2 || res2 < 2 )
{
msg_Warn( g_pIntf, "Cannot add slider: not enough points" );
return;
}
if( res1 != res2 )
{
msg_Warn( g_pIntf, "Cannot add slider: invalid list of points" );
return;
}
// now, res1 == res2
double *p_abs, *p_ord;
p_abs = new double[res1];
p_ord = new double[res1];
ConvertCoords( abs, p_abs );
ConvertCoords( ord, p_ord );
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
// Move control
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
for( i = 0; i < res1; i++ )
{
p_abs[i] += XOff + atoi(x);
p_ord[i] += YOff + atoi(y);
}
// Create Control
if( g_pIntf->p_sys->p_theme->ConstructPlaylist )
{
GenericControl *playlist = vlcWin->ControlList.back();
( (ControlPlayList *)playlist )->InitSliderCurve( p_abs, p_ord, res1,
up, down );
}
else
{
vlcWin->ControlList.push_back( new ControlSlider( id,
ConvertBoolean( visible ), type, up, down, p_abs, p_ord, res1,
tooltiptext, help, vlcWin ) );
}
delete[] p_abs;
delete[] p_ord;
}
//---------------------------------------------------------------------------
void AddPlayList( char *id, char *visible, char *x, char *y, char *width,
char *infowidth, char *font, char *playfont, char *selcolor, char *abs,
char *ord, char *longfilename, char *help )
{
g_pIntf->p_sys->p_theme->ConstructPlaylist = true;
int XOff, YOff, i;
int res1 = CheckCoords( abs );
int res2 = CheckCoords( ord );
if( res1 < 2 || res2 < 2 )
{
msg_Warn( g_pIntf, "Cannot add slider: not enough points" );
return;
}
if( res1 != res2 )
{
msg_Warn( g_pIntf, "Cannot add slider: invalid list of points" );
return;
}
// now, res1 == res2
double *p_abs, *p_ord;
p_abs = new double[res1];
p_ord = new double[res1];
ConvertCoords( abs, p_abs );
ConvertCoords( ord, p_ord );
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
// Move control
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
for( i = 0; i < res1; i++ )
{
p_abs[i] += XOff + atoi(x);
p_ord[i] += YOff + atoi(y);
}
// Move control
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->ControlList.push_back( new ControlPlayList( id,
ConvertBoolean( visible ), atoi( width ), atoi( infowidth ), font,
playfont, ConvertColor( selcolor ), p_abs, p_ord, res1,
ConvertBoolean( longfilename ), help, vlcWin ) );
delete[] p_abs;
delete[] p_ord;
}
//---------------------------------------------------------------------------
void AddPlayListEnd()
{
g_pIntf->p_sys->p_theme->ConstructPlaylist = false;
}
//---------------------------------------------------------------------------
void AddText( char *id, char *visible, char *x, char *y, char *text, char *font,
char *align, char *width, char *display, char *scroll, char *scrollspace,
char *help )
{
int XOff, YOff;
Window *vlcWin = g_pIntf->p_sys->p_theme->WindowList.back();
g_pIntf->p_sys->p_theme->OffBank->GetOffSet( XOff, YOff );
vlcWin->ControlList.push_back( new ControlText( id,
ConvertBoolean( visible ), atoi( x ) + XOff,
atoi( y ) + YOff, text, font, ConvertAlign( align ), atoi( width ),
display, ConvertBoolean( scroll ), atoi( scrollspace ), help,
vlcWin ) );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Useful functions
//---------------------------------------------------------------------------
static bool ConvertBoolean( const char *value )
{
return strcmp( value, "true" ) == 0;
}
//---------------------------------------------------------------------------
static int ConvertColor( const char *transcolor )
{
int iRed, iGreen, iBlue;
iRed = iGreen = iBlue = 0;
sscanf( transcolor, "#%2X%2X%2X", &iRed, &iGreen, &iBlue );
return ( 65536 * iBlue + 256 * iGreen + iRed );
}
//---------------------------------------------------------------------------
// Check that abs and ord contain the same number of comas
static int CheckCoords( const char *coord )
{
int i_coord = 1;
while( coord && *coord )
{
if( *coord == ',' )
i_coord++;
coord++;
}
return i_coord;
}
//---------------------------------------------------------------------------
static void ConvertCoords( char *coord, double *p_coord )
{
int i = 0;
char *ptr = coord;
while( coord && *coord )
{
if( *coord == ',' )
{
*coord = '\0';
p_coord[i] = atof( ptr );
i++;
ptr = coord + 1;
}
coord++;
}
p_coord[i] = atof( ptr );
}
//---------------------------------------------------------------------------
static int ConvertAlign( char *align )
{
if( strcmp( align, "left" ) == 0 )
return DT_LEFT;
else if( strcmp( align, "right" ) == 0 )
return DT_RIGHT;
else if( strcmp( align, "center" ) == 0 )
return DT_CENTER;
else
return DT_LEFT;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* wrappers.h: Wrappers around C++ objects
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: wrappers.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//---------------------------------------------------------------------------
#if defined(__cplusplus)
extern "C" {
#endif
//---------------------------------------------------------------------------
// Divers
//---------------------------------------------------------------------------
void AddAnchor( char *x, char *y, char *len, char *priority );
void AddBitmap( char *name, char *file, char *transcolor );
void AddEvent( char *name, char *event, char *key );
void AddFont( char *name, char *font, char *size,
char *color, char *weight, char *italic, char *underline );
void StartControlGroup( char *x, char *y );
void EndControlGroup();
//---------------------------------------------------------------------------
// Theme
//---------------------------------------------------------------------------
void AddThemeInfo( char *name, char *author, char *email,
char *webpage );
void StartTheme( char *log, char *magnet );
void EndTheme();
//---------------------------------------------------------------------------
// Window
//---------------------------------------------------------------------------
void StartWindow( char *name, char *x, char *y, char *visible,
char *fadetime, char *alpha, char *movealpha,
char *dragdrop );
void EndWindow();
//---------------------------------------------------------------------------
// Control
//---------------------------------------------------------------------------
void AddImage( char *id, char *visible, char *x, char *y, char *image,
char *event, char *help );
void AddRectangle( char *id, char *visible, char *x, char *y, char *w,
char *h, char *color, char *event, char *help );
void AddButton( char *id, char *visible, char *x, char *y, char *up,
char *down, char *disabled, char *click,
char *tooltiptext, char *help );
void AddCheckBox( char *id, char *visible, char *x, char *y, char *img1,
char *img2, char *click1, char *click2, char *disabled1,
char *disabled2, char *action1, char *action2,
char *tooltiptext1, char *tooltiptext2, char *help );
void AddSlider( char *id, char *visible, char *x, char *y, char *type,
char *up, char *down, char *abs, char *ord,
char *tooltiptext, char *help );
void AddText( char *id, char *visible, char *x, char *y, char *text,
char *font, char *align, char *width, char *display,
char *scroll, char *scrollspace, char *help );
void AddPlayList( char *id, char *visible, char *x, char *y, char *width,
char *infowidth, char *font, char *playfont,
char *selcolor, char *abs, char *ord,
char *longfilename, char *help );
void AddPlayListEnd();
//---------------------------------------------------------------------------
#if defined(__cplusplus)
}
#endif
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
/*****************************************************************************
* anchor.cpp: Anchor class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: anchor.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
#include <math.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "anchor.h"
#include "window.h"
//---------------------------------------------------------------------------
// Anchors
//---------------------------------------------------------------------------
Anchor::Anchor( intf_thread_t *_p_intf, int x, int y, int len, int priority,
Window *parent )
{
p_intf = _p_intf;
Parent = parent;
Left = x;
Top = y;
Priority = priority;
Len = len;
}
//---------------------------------------------------------------------------
bool Anchor::IsInList( Anchor *anc )
{
// Declare iterator
list<Anchor *>::const_iterator elt;
// Iterate through list
for( elt = HangList.begin(); elt != HangList.end(); elt++)
{
if( (*elt) == anc )
return true;
}
return false;
}
//---------------------------------------------------------------------------
void Anchor::Add( Anchor *anc )
{
HangList.push_back( anc );
}
//---------------------------------------------------------------------------
void Anchor::Remove( Anchor *anc )
{
HangList.remove( anc );
}
//---------------------------------------------------------------------------
bool Anchor::Hang( Anchor *anc, int mx, int my )
{
// Get position of anchor
int x, y, px, py;
Parent->GetPos( px, py );
anc->GetPos( x, y );
x += mx - px;
y += my - py;
// Len of 0 is equal to unactivate anchor
if( Len > 0 && sqrt( (Left-x)*(Left-x) + (Top-y)*(Top-y) ) <= Len )
{
return true;
}
return false;
}
//---------------------------------------------------------------------------
void Anchor::GetPos( int &x, int &y )
{
x = Left;
y = Top;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* anchor.h: Anchor class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: anchor.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_ANCHOR
#define VLC_SKIN_ANCHOR
//--- GENERAL ---------------------------------------------------------------
#include <list>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Window;
//---------------------------------------------------------------------------
class Anchor
{
private:
// Position parameters
int Left;
int Top;
// Ray of action
int Len;
// Priority
int Priority;
// Parent window
Window *Parent;
// Interface thread
intf_thread_t *p_intf;
public:
// Constructor
Anchor( intf_thread_t *_p_intf, int x, int y, int len, int priority,
Window *parent );
// Hang to anchor if in neighbourhood
bool Hang( Anchor *anc, int mx, int my );
void Add( Anchor *anc );
void Remove( Anchor *anc );
bool IsInList( Anchor *anc );
// List of windows actually magnetized
list<Anchor *> HangList;
// Get position of anchor
void GetPos( int &x, int &y );
// Getters
int GetPriority() { return Priority; }
Window *GetParent() { return Parent; }
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* banks.cpp: Bitmap bank, Event, bank, Font bank and OffSet bank
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: banks.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
#include "os_bitmap.h"
#include "event.h"
#include "os_event.h"
#include "font.h"
#include "os_font.h"
#include "banks.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Bitmap Bank
//---------------------------------------------------------------------------
BitmapBank::BitmapBank( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
// Create default bitmap
Add( DEFAULT_BITMAP_NAME, "", 0 );
}
//---------------------------------------------------------------------------
BitmapBank::~BitmapBank()
{
for( map<string,Bitmap *>::iterator iter = Bank.begin();
iter != Bank.end(); iter++ )
{
delete (OSBitmap *)iter->second;
}
}
//---------------------------------------------------------------------------
bool BitmapBank::Add( string Id, string FileName, int AColor )
{
if( Bank[Id] != NULL )
{
msg_Warn( p_intf, "Bitmap name already exists: %s", Id.c_str() );
return false;
}
Bank[Id] = (Bitmap *)new OSBitmap( p_intf, FileName, AColor );
return true;
}
//---------------------------------------------------------------------------
Bitmap * BitmapBank::Get( string Id )
{
// If the specified bitmap doesn't exist, use the default one
if( Bank[Id] == NULL )
{
msg_Warn( p_intf, "Unknown bitmap name '%s', using default one",
Id.c_str() );
return Bank[DEFAULT_BITMAP_NAME];
}
return Bank[Id];
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Font Bank
//---------------------------------------------------------------------------
FontBank::FontBank( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
// Create default font
Add( DEFAULT_FONT_NAME, "arial", 12, 0, 400, false, false );
}
//---------------------------------------------------------------------------
FontBank::~FontBank()
{
for( map<string,Font *>::iterator iter = Bank.begin();
iter != Bank.end(); iter++ )
{
delete (OSFont *)iter->second;
}
}
//---------------------------------------------------------------------------
bool FontBank::Add( string name, string fontname, int size,
int color, int weight, bool italic, bool underline )
{
if( Bank[name] != NULL )
{
msg_Warn( p_intf, "Font name already exists: %s", name.c_str() );
return false;
}
Bank[name] = (Font *)new OSFont( p_intf, fontname, size, color,
weight, italic, underline );
return true;
}
//---------------------------------------------------------------------------
Font * FontBank::Get( string Id )
{
// If the specified font doesn't exist, use the default one
if( Bank[Id] == NULL )
{
msg_Warn( p_intf, "Unknown font name '%s', using default one",
Id.c_str() );
return Bank[DEFAULT_FONT_NAME];
}
return Bank[Id];
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Event Bank
//---------------------------------------------------------------------------
EventBank::EventBank( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
// Create default event
Add( DEFAULT_EVENT_NAME, "VLC_NOTHING", "none" );
Add( "none", "VLC_NOTHING", "none" );
Add( "time", "VLC_STREAMPOS", "none" );
Add( "left_time", "VLC_ENDSTREAMPOS", "none" );
Add( "total_time", "VLC_TOTALSTREAMPOS", "none" );
Add( "file_name", "VLC_STREAMNAME", "none" );
Add( "help", "VLC_HELP_TEXT", "none" );
Add( "tray", "VLC_CHANGE_TRAY", "CTRL+T" );
Add( "taskbar", "VLC_CHANGE_TASKBAR", "CTRL+B" );
Add( "playlist_refresh", "CTRL_PLAYLIST", "none" );
Add( "play", "VLC_PLAY", "X" );
Add( "pause", "VLC_PAUSE", "C" );
Add( "stop", "VLC_STOP", "V" );
Add( "next", "VLC_NEXT", "B" );
Add( "prev", "VLC_PREV", "Z" );
Add( "fullscreen", "VLC_FULLSCREEN", "F" );
// Volume control
Add( "mute", "VLC_VOLUME_CHANGE(MUTE)", "none" );
Add( "volume_up", "VLC_VOLUME_CHANGE(UP)", "none" );
Add( "volume_down", "VLC_VOLUME_CHANGE(DOWN)", "none" );
Add( "volume_refresh", "VLC_VOLUME_CHANGE(SET)", "none" );
// Log events
Add( "show_log", "VLC_LOG_SHOW(TRUE)", "none" );
Add( "hide_log", "VLC_LOG_SHOW(FALSE)", "none" );
Add( "clear_log", "VLC_LOG_CLEAR", "none" );
Add( "quit", "VLC_HIDE(VLC_QUIT)", "CTRL+C" );
Add( "open", "VLC_OPEN", "CTRL+O" );
Add( "add_file", "VLC_PLAYLIST_ADD_FILE", "CTRL+A" );
Add( "load_skin", "VLC_LOAD_SKIN", "CTRL+S" );
}
//---------------------------------------------------------------------------
EventBank::~EventBank()
{
for( map<string,Event *>::iterator iter = Bank.begin();
iter != Bank.end(); iter++ )
{
delete (OSEvent *)iter->second;
}
}
//---------------------------------------------------------------------------
bool EventBank::Add( string Name, string EventDesc, string shortcut )
{
if( Bank[Name] != NULL )
{
msg_Warn( p_intf, "Event name already exists: %s", Name.c_str() );
return false;
}
Bank[Name] = (Event *)new OSEvent( p_intf, EventDesc, shortcut );
return true;
}
//---------------------------------------------------------------------------
void EventBank::TestShortcut( int key, int mod )
{
for( map<string,Event *>::iterator iter = Bank.begin();
iter != Bank.end(); iter++ )
{
// If key and modifier match to event shortcut, send event
if( iter->second->MatchShortcut( key, mod ) )
iter->second->SendEvent();
}
}
//---------------------------------------------------------------------------
Event * EventBank::Get( string Id )
{
// If the specified font doesn't exist, use the default one
if( Bank[Id] == NULL )
{
msg_Warn( p_intf, "Unknown event name '%s', using default one",
Id.c_str() );
return Bank[DEFAULT_EVENT_NAME];
}
return Bank[Id];
}
//---------------------------------------------------------------------------
void EventBank::Init()
{
for( map<string,Event *>::iterator iter = Bank.begin();
iter != Bank.end(); iter++ )
{
iter->second->CreateEvent();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Offset Bank
//---------------------------------------------------------------------------
OffSetBank::OffSetBank( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
XOff = 0;
YOff = 0;
}
//---------------------------------------------------------------------------
OffSetBank::~OffSetBank()
{
if( !XList.empty() )
msg_Warn( p_intf, "At least one offset remains" );
}
//---------------------------------------------------------------------------
void OffSetBank::PushOffSet( int X, int Y )
{
XList.push_front( X );
YList.push_front( Y );
XOff += X;
YOff += Y;
}
//---------------------------------------------------------------------------
void OffSetBank::PopOffSet()
{
if( XList.empty() )
{
msg_Warn( p_intf, "No offset to pop" );
return;
}
XOff -= XList.front();
YOff -= YList.front();
XList.pop_front();
YList.pop_front();
}
//---------------------------------------------------------------------------
void OffSetBank::GetOffSet( int &X, int &Y )
{
X = XOff;
Y = YOff;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* banks.h: Bitmap bank, Event bank, Font bank and OffSet bank
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: banks.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_BANKS
#define VLC_SKIN_BANKS
//---------------------------------------------------------------------------
//--- GENERAL ---------------------------------------------------------------
#include <map>
#include <list>
#include <string>
using namespace std;
//---------------------------------------------------------------------------
#define DEFAULT_BITMAP_NAME "DEFAULT_BITMAP"
#define DEFAULT_FONT_NAME "DEFAULT_FONT"
#define DEFAULT_EVENT_NAME "DEFAULT_EVENT"
//---------------------------------------------------------------------------
struct intf_thread_t;
class Bitmap;
class Font;
class Event;
//---------------------------------------------------------------------------
class BitmapBank
{
private:
map<string,Bitmap *> Bank;
intf_thread_t *p_intf;
public:
BitmapBank( intf_thread_t *_p_intf );
~BitmapBank();
bool Add( string Id, string FileName, int AColor ); // Add a bitmap
Bitmap * Get( string Id ); // Return the bitmap with matching ID
};
//---------------------------------------------------------------------------
class FontBank
{
private:
map<string,Font *> Bank;
intf_thread_t *p_intf;
public:
FontBank( intf_thread_t *_p_intf );
~FontBank();
bool Add( string name, string fontname, int size,
int color, int weight, bool italic, bool underline );
Font * Get( string Id ); // Return the font with matching ID
};
//---------------------------------------------------------------------------
class EventBank
{
private:
map<string,Event *> Bank;
intf_thread_t *p_intf;
public:
EventBank( intf_thread_t *_p_intf );
~EventBank();
bool Add( string Name, string EventDesc, string shortcut );
void TestShortcut( int key, int mod );
Event * Get( string Id ); // Return the event with matching ID
void Init();
};
//---------------------------------------------------------------------------
class OffSetBank
{
private:
int XOff;
int YOff;
list<int> XList;
list<int> YList;
intf_thread_t *p_intf;
public:
OffSetBank( intf_thread_t *_p_intf );
~OffSetBank();
void PushOffSet( int X, int Y );
void PopOffSet();
void GetOffSet( int &X, int &Y );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* bezier.cpp: Functions to handle Bezier curves
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bezier.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- SKIN ------------------------------------------------------------------
#include "bezier.h"
//---------------------------------------------------------------------------
// Inline methods : supposed to accelerate the code
//---------------------------------------------------------------------------
inline double Bezier::melange( int i, int n, double t )
{
return Power( t, i ) * Power( 1 - t, (n - i) ) * ft[n] / ft[i] / ft[n - i];
}
//---------------------------------------------------------------------------
inline double Bezier::bezier_pty( double t )
{
double res = 0;
for( int i = 0; i <= maxpt; i++ )
{
res += pty[i] * melange( i, maxpt, t );
}
return res;
}
//---------------------------------------------------------------------------
inline double Bezier::bezier_ptx( double t )
{
double res = 0;
for( int i = 0; i <= maxpt; i++ )
{
res += ptx[i] * melange( i, maxpt, t );
}
return res;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// BEZIER
// The bezier class generate bezier curves
//---------------------------------------------------------------------------
Bezier::Bezier( double *x, double *y, int n, int flag )
{
int i;
// x and y pointer are arrays of the coordinates of the points
// n is the number of points
// Allocation of ressources for arrays of points
ptx = new double[n];
pty = new double[n];
// ft is factoriels
// Here we create an array an precalculate them
ft = new double[n];
ft[0] = 1;
for( i = 0; i < n; i++ )
{
ptx[i] = x[i]; // assign values of coordinates
pty[i] = y[i];
if( i > 0 )
ft[i] = i * ft[i - 1];
}
maxpt = n - 1;
// FLAG values :
// - BEZIER_PTS_ALL : when x and y are differents
// - BEZIER_PTS_Y : when only y is different
// - BEZIER_PTS_X : when only x is different
// Initialization
Flag = flag;
Max = 0; // Init number of pixels
double Range = MAX_BEZIER_POINT; // max number of pixel
int last_i = 0;
int cx, cy, oldx, oldy;
Left = new int[MAX_BEZIER_POINT + 1];
Top = new int[MAX_BEZIER_POINT + 1];
// Calculate first point
double per = 0;
double j;
GetPoint( per, oldx, oldy );
Left[0] = oldx;
Top[0] = oldy;
// Search for number of different points
for( j = 1; j <= Range; j++ )
{
per = j / Range;
GetPoint( per, cx, cy );
if( ( Flag == BEZIER_PTS_ALL && ( cy != oldy || cx != oldx ) ) ||
( Flag == BEZIER_PTS_Y && cy != oldy ) ||
( Flag == BEZIER_PTS_X && cx != oldx ) )
{
Max++;
Left[Max] = cx;
Top[Max] = cy;
oldx = cx;
oldy = cy;
// Accelerator
if( i - last_i > 2 )
{
i += i - last_i - 1;
}
last_i = i;
}
}
}
//---------------------------------------------------------------------------
Bezier::~Bezier()
{
delete[] Left;
delete[] Top;
delete[] ptx;
delete[] pty;
delete[] ft;
}
//---------------------------------------------------------------------------
void Bezier::GetPoint( double i, int &x, int &y )
{
// Get the coordinates of the point at i precent of
// the curve (i must be between 0 and 1)
x = (int)(float)bezier_ptx( i );
y = (int)(float)bezier_pty( i );
}
//---------------------------------------------------------------------------
int Bezier::GetNumOfDifferentPoints()
{
return Max;
}
//---------------------------------------------------------------------------
void Bezier::GetDifferentPoints( int *x, int *y, int OffX, int OffY )
{
for( int i = 0; i <= Max; i++ )
{
x[i] = Left[i] + OffX;
y[i] = Top[i] + OffY;
}
}
//---------------------------------------------------------------------------
double Bezier::Power( double x, int n )
{
if( n > 0 )
return x * Power( x, n - 1);
else
return 1;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* bezier.h: Functios to handle Bezier curves
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bezier.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_BEZIER
#define VLC_SKIN_BEZIER
//---------------------------------------------------------------------------
#define MAX_BEZIER_POINT 1023
#define BEZIER_PTS_ALL 0
#define BEZIER_PTS_Y 1
#define BEZIER_PTS_X 2
//---------------------------------------------------------------------------
class Bezier
{
private:
int maxpt;
double *ptx;
double *pty;
double *ft;
double melange( int i, int n, double t );
double bezier_pty( double t );
double bezier_ptx( double t );
// Different points
int Flag;
int Max;
int *Left;
int *Top;
// x^n
double Power( double x, int n );
public:
// Constructor
Bezier( double *x, double *y, int n, int flag = BEZIER_PTS_ALL );
// Destructor
~Bezier();
void GetPoint( double i, int &x, int &y );
void GetDifferentPoints( int *x, int *y, int OffX = 0, int OffY = 0 );
int GetNumOfDifferentPoints();
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* bitmap.cpp: Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bitmap.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "bitmap.h"
//---------------------------------------------------------------------------
// Bitmap
//---------------------------------------------------------------------------
Bitmap::Bitmap( intf_thread_t *_p_intf, string FileName, int AColor )
{
p_intf = _p_intf;
}
//---------------------------------------------------------------------------
Bitmap::Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
int w, int h, int AColor )
{
p_intf = _p_intf;
}
//---------------------------------------------------------------------------
Bitmap::Bitmap( intf_thread_t *_p_intf, Bitmap *c )
{
p_intf = _p_intf;
}
//---------------------------------------------------------------------------
Bitmap::~Bitmap()
{
}
//---------------------------------------------------------------------------
void Bitmap::GetSize( int &w, int &h )
{
w = Width;
h = Height;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* bitmap.h: Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: bitmap.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_BITMAP
#define VLC_SKIN_BITMAP
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Graphics;
//---------------------------------------------------------------------------
class Bitmap
{
protected:
int Width;
int Height;
unsigned int AlphaColor;
intf_thread_t *p_intf;
public:
void GetSize( int &w, int &h );
int GetAlphaColor() { return AlphaColor; }
// Constructors
Bitmap( intf_thread_t *_p_intf, string FileName, int AColor );
Bitmap( intf_thread_t *_p_intf, Graphics *from, int x, int y,
int w, int h, int AColor );
Bitmap( intf_thread_t *_p_intf, Bitmap *c );
// Destructor
virtual ~Bitmap();
virtual void DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest ) = 0;
virtual bool Hit( int x, int y ) = 0;
virtual int GetBmpPixel( int x, int y ) = 0;
virtual void SetBmpPixel( int x, int y, int color ) = 0;
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* dialog.cpp: Classes for some dialog boxes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: dialog.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "dialog.h"
//---------------------------------------------------------------------------
// Open file dialog box
//---------------------------------------------------------------------------
OpenFileDialog::OpenFileDialog( string title, bool multiselect )
{
MultiSelect = multiselect;
Title = title;
Filter = new char[200];
FilterLength = 0;
}
//---------------------------------------------------------------------------
OpenFileDialog::~OpenFileDialog()
{
delete[] Filter;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Log Window
//---------------------------------------------------------------------------
LogWindow::LogWindow( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
Visible = false;
}
//---------------------------------------------------------------------------
LogWindow::~LogWindow()
{
}
//---------------------------------------------------------------------------
void LogWindow::Update( msg_subscription_t *Sub )
{
//if( !Visible )
// return;
int i_start, i_stop;
int i_max_lines;
vlc_mutex_lock( Sub->p_lock );
i_stop = *Sub->pi_stop;
vlc_mutex_unlock( Sub->p_lock );
if( Sub->i_start != i_stop )
{
for( i_start = Sub->i_start;
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
// Append all messages to log window
switch( Sub->p_msg[i_start].i_type )
{
case VLC_MSG_ERR:
ChangeColor( RGB( 255, 0, 0 ), true );
break;
case VLC_MSG_WARN:
ChangeColor( RGB( 255, 128, 0 ), true );
break;
default:
ChangeColor( RGB( 128, 128, 128 ) );
break;
}
// Add message
if( i_max_lines )
{
AddLine( (string)Sub->p_msg[i_start].psz_msg );
}
}
vlc_mutex_lock( Sub->p_lock );
Sub->i_start = i_start;
vlc_mutex_unlock( Sub->p_lock );
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* dialog.h: Classes for some dialog boxes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: dialog.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_DIALOG
#define VLC_SKIN_DIALOG
//--- GENERAL ---------------------------------------------------------------
#include <string>
#include <list>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
struct msg_subscription_t;
//---------------------------------------------------------------------------
class OpenFileDialog
{
private:
protected:
char *Filter;
int FilterLength;
string Title;
bool MultiSelect;
public:
// Constructors
OpenFileDialog( string title, bool multiselect );
// Destructors
virtual ~OpenFileDialog();
// List of files
list<string> FileList;
// Specific methods
virtual void AddFilter( string name, string type ) = 0;
virtual bool Open() = 0;
};
//---------------------------------------------------------------------------
class LogWindow
{
protected:
bool Visible;
intf_thread_t *p_intf;
public:
// Constructors
LogWindow( intf_thread_t *_p_intf );
// Destructors
virtual ~LogWindow();
virtual void Clear() = 0;
virtual void AddLine( string line ) = 0;
virtual void ChangeColor( int color, bool bold = false ) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
// Getters
bool IsVisible() { return Visible; };
void Update( msg_subscription_t *Sub );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* event.cpp: Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: event.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "skin_common.h"
#include "banks.h"
#include "generic.h"
#include "window.h"
#include "theme.h"
#include "event.h"
#include "os_event.h"
//---------------------------------------------------------------------------
// VLC Event
//---------------------------------------------------------------------------
Event::Event( intf_thread_t *_p_intf, string Desc, string shortcut )
{
p_intf = _p_intf;
EventDesc = Desc;
Message = VLC_NOTHING;
Param1 = 0;
Param2 = 0;
Shortcut = shortcut;
}
//---------------------------------------------------------------------------
Event::Event( intf_thread_t *_p_intf, unsigned int msg, unsigned int par1,
long par2 )
{
p_intf = _p_intf;
Message = msg;
Param1 = par1;
Param2 = par2;
Shortcut = "none";
}
//---------------------------------------------------------------------------
Event::~Event()
{
}
//---------------------------------------------------------------------------
void Event::DestructParameters()
{
switch( Message )
{
case CTRL_SYNCHRO:
if( Param2 == (int)true )
delete (Event *)Param1;
break;
case CTRL_SET_TEXT:
delete (char *)Param2;
break;
}
}
//---------------------------------------------------------------------------
bool Event::IsEqual( Event *evt )
{
return( evt->GetMessage() == Message && evt->GetParam1() == Param1 &&
evt->GetParam2() == Param2 );
}
//---------------------------------------------------------------------------
void Event::PostSynchroMessage( bool autodelete )
{
OSAPI_PostMessage( NULL, CTRL_SYNCHRO, (unsigned int)this,
(long)autodelete );
}
//---------------------------------------------------------------------------
void Event::PostTextMessage( string text )
{
char *txt = new char[text.size()];
strcpy( txt, text.c_str() );
OSAPI_PostMessage( NULL, CTRL_SET_TEXT, (unsigned int)this, (long)txt );
}
//---------------------------------------------------------------------------
unsigned int Event::GetMessageType( string Desc )
{
if( Desc == "VLC_NOTHING" )
return VLC_NOTHING;
// VLC messages
else if( Desc == "VLC_QUIT" )
return VLC_QUIT;
else if( Desc == "VLC_HIDE" )
return VLC_HIDE;
else if( Desc == "VLC_OPEN" )
return VLC_OPEN;
else if( Desc == "VLC_LOAD_SKIN" )
return VLC_LOAD_SKIN;
else if( Desc == "VLC_CHANGE_TRAY" )
return VLC_CHANGE_TRAY;
else if( Desc == "VLC_CHANGE_TASKBAR" )
return VLC_CHANGE_TASKBAR;
// Stream control
else if( Desc == "VLC_PLAY" )
return VLC_PLAY;
else if( Desc == "VLC_STOP" )
return VLC_STOP;
else if( Desc == "VLC_PAUSE" )
return VLC_PAUSE;
else if( Desc == "VLC_NEXT" )
return VLC_NEXT;
else if( Desc == "VLC_PREV" )
return VLC_PREV;
else if( Desc == "VLC_STREAMPOS" )
return VLC_STREAMPOS;
else if( Desc == "VLC_ENDSTREAMPOS" )
return VLC_ENDSTREAMPOS;
else if( Desc == "VLC_TOTALSTREAMPOS" )
return VLC_TOTALSTREAMPOS;
else if( Desc == "VLC_STREAMNAME" )
return VLC_STREAMNAME;
else if( Desc == "VLC_HELP_TEXT" )
return VLC_HELP_TEXT;
// Volume control
else if( Desc == "VLC_VOLUME_CHANGE" )
return VLC_VOLUME_CHANGE;
else if( Desc == "VLC_VOLUME_MUTE" )
return VLC_VOLUME_MUTE;
else if( Desc == "VLC_VOLUME_UP" )
return VLC_VOLUME_UP;
else if( Desc == "VLC_VOLUME_DOWN" )
return VLC_VOLUME_DOWN;
else if( Desc == "VLC_VOLUME_SET" )
return VLC_VOLUME_SET;
// Logs
else if( Desc == "VLC_LOG_SHOW" )
return VLC_LOG_SHOW;
else if( Desc == "VLC_LOG_CLEAR" )
return VLC_LOG_CLEAR;
// Playlist events
else if( Desc == "VLC_PLAYLIST_ADD_FILE" )
return VLC_PLAYLIST_ADD_FILE;
// Video output events
else if( Desc == "VLC_FULLSCREEN" )
return VLC_FULLSCREEN;
// Window event
else if( Desc == "WINDOW_MOVE" )
return WINDOW_MOVE;
else if( Desc == "WINDOW_OPEN" )
return WINDOW_OPEN;
else if( Desc == "WINDOW_CLOSE" )
return WINDOW_CLOSE;
else if( Desc == "WINDOW_SHOW" )
return WINDOW_SHOW;
else if( Desc == "WINDOW_HIDE" )
return WINDOW_HIDE;
else if( Desc == "WINDOW_FADE" )
return WINDOW_FADE;
// Control event
else if( Desc == "CTRL_ENABLED" )
return CTRL_ENABLED;
else if( Desc == "CTRL_VISIBLE" )
return CTRL_VISIBLE;
else if( Desc == "CTRL_SYNCHRO" )
return CTRL_SYNCHRO;
else if( Desc == "CTRL_SET_TEXT" )
return CTRL_SET_TEXT;
else if( Desc == "CTRL_SET_SLIDER" )
return CTRL_SET_SLIDER;
// Control event by ID
else if( Desc == "CTRL_ID_VISIBLE" )
return CTRL_ID_VISIBLE;
else if( Desc == "CTRL_ID_ENABLED" )
return CTRL_ID_ENABLED;
else if( Desc == "CTRL_ID_MOVE" )
return CTRL_ID_MOVE;
// Control definition
else if( Desc == "CTRL_SLIDER" )
return CTRL_SLIDER;
else if( Desc == "CTRL_TIME" )
return CTRL_TIME;
else if( Desc == "CTRL_PLAYLIST" )
return CTRL_PLAYLIST;
// Playlist
else if( Desc == "PLAYLIST_ID_DEL" )
return PLAYLIST_ID_DEL;
// Not found
else
{
msg_Warn( p_intf, "Theme: Unknown event (%s)", EventDesc.c_str() );
return VLC_NOTHING;
}
}
//---------------------------------------------------------------------------
void Event::CreateEvent()
{
// Initiatization
int x, y;
char *msg = new char[MAX_EVENT_SIZE];
char *para1 = new char[MAX_PARAM_SIZE];
char *para2 = new char[MAX_PARAM_SIZE];
char *para3 = new char[MAX_PARAM_SIZE];
// Scan the event
int scan = sscanf( EventDesc.c_str(),
"%[^(](%[^,)],%[^,)],%[^,)])", msg, para1, para2, para3 );
// Check parameters
if( scan < 1 )
msg = "VLC_NOTHING";
if( scan < 2 )
para1 = "";
if( scan < 3 )
para2 = "";
if( scan < 4 )
para3 = "";
// Find Message type
Message = GetMessageType( msg );
// Find Parameters
switch( Message )
{
case VLC_HIDE:
Param1 = GetMessageType( para1 );
break;
case VLC_VOLUME_CHANGE:
if( strcmp( para1, "MUTE" ) == 0 )
Param1 = VLC_VOLUME_MUTE;
else if( strcmp( para1, "UP" ) == 0 )
Param1 = VLC_VOLUME_UP;
else if( strcmp( para1, "DOWN" ) == 0 )
Param1 = VLC_VOLUME_DOWN;
else if( strcmp( para1, "SET" ) == 0 )
{
Param1 = VLC_VOLUME_SET;
Param2 = atoi( para2 ) * AOUT_VOLUME_MAX / 100;
}
break;
case VLC_LOG_SHOW:
Param2 = GetBool( para1 );
break;
case CTRL_ID_VISIBLE:
Param1 = (unsigned int)FindControl( para1 );
Param2 = GetBool( para2 );
break;
case CTRL_ID_ENABLED:
Param1 = (unsigned int)FindControl( para1 );
Param2 = GetBool( para2 );
break;
case CTRL_ID_MOVE:
Param1 = (unsigned int)FindControl( para1 );
x = atoi( para2 );
y = atoi( para3 );
if( x < 0 )
x = -x + 0x8000;
if( y < 0 )
y = -y + 0x8000;
Param2 = ( y << 16 ) | x;
break;
case WINDOW_OPEN:
Param2 = GetBool( para2 );
break;
case WINDOW_CLOSE:
Param2 = GetBool( para2 );
break;
case PLAYLIST_ID_DEL:
Param1 = (unsigned int)FindControl( para1 );
break;
default:
break;
}
// Get OS specific parameters
CreateOSEvent( para1, para2, para3 );
// Free memory
delete[] msg;
delete[] para1;
delete[] para2;
delete[] para3;
// Create shortcut
CreateShortcut();
}
//---------------------------------------------------------------------------
GenericControl * Event::FindControl( string id )
{
list<Window *>::const_iterator win;
unsigned int i;
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++ )
{
if( (*win)->ControlList[i]->IsID( id ) )
return (*win)->ControlList[i];
}
}
return NULL;
}
//---------------------------------------------------------------------------
int Event::GetBool( string expr )
{
if( expr == "FALSE" )
{
return 0;
}
else if( expr == "TRUE" )
{
return 1;
}
else if( expr == "CHANGE" )
{
return 2;
}
return 2;
}
//---------------------------------------------------------------------------
void Event::CreateShortcut()
{
if( Shortcut == "none" )
return;
// Initiatization
char *mod = new char[4];
char *key = new char[4];
// Scan the event
int scan = sscanf( Shortcut.c_str(), "%[^+]+%s", mod, key );
// Check parameters
if( scan == 2 )
{
Key = (int)key[0];
if( (string)mod == "ALT" )
KeyModifier = 1;
else if( (string)mod == "CTRL" )
KeyModifier = 2;
else
KeyModifier = 0;
}
else if( scan == 1 )
{
Key = (int)mod[0];
KeyModifier = 0;
}
delete[] mod;
delete[] key;
}
//---------------------------------------------------------------------------
bool Event::MatchShortcut( int key, int mod )
{
// Modifier
// None = 0
// ALT = 1
// CONTROL = 2
if( Shortcut != "none" && key == Key && mod == KeyModifier )
return true;
else
return false;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Action
//---------------------------------------------------------------------------
Action::Action( intf_thread_t *_p_intf, string code )
{
p_intf = _p_intf;
// Initiatization
int scan;
char *evt = new char[MAX_EVENT_SIZE];
char *next = new char[MAX_PARAM_SIZE];
// Create events separated with a semicolon
while( code != "none" )
{
scan = sscanf( code.c_str(), "%[^;];%s", evt, next );
EventList.push_back( p_intf->p_sys->p_theme->EvtBank->Get( evt ) );
// Check if script is finished
if( scan < 2 )
code = "none";
else
code = next;
}
// Free memory
delete[] evt;
delete[] next;
}
//---------------------------------------------------------------------------
Action::~Action()
{
}
//---------------------------------------------------------------------------
bool Action::SendEvent()
{
bool res = false;
for( list<Event *>::const_iterator evt = EventList.begin();
evt != EventList.end(); evt++ )
{
res |= (*evt)->SendEvent();
}
return res;
}
//---------------------------------------------------------------------------
bool Action::MatchEvent( Event *evt, int flag )
{
list<Event *>::const_iterator event;
switch( flag )
{
case ACTION_MATCH_ALL:
for( event = EventList.begin(); event != EventList.end(); event++ )
if( !(*event)->IsEqual( evt ) )
return false;
break;
case ACTION_MATCH_ONE:
for( event = EventList.begin(); event != EventList.end(); event++ )
if( (*event)->IsEqual( evt ) )
return true;
return false;
break;
case ACTION_MATCH_FIRST:
if( !(*EventList.begin())->IsEqual( evt ) )
return false;
break;
}
return true;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* event.h: Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: event.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_EVENT
#define VLC_SKIN_EVENT
//--- GENERAL ---------------------------------------------------------------
#include <string>
#include <list>
using namespace std;
//---------------------------------------------------------------------------
// VLC specific messages
//---------------------------------------------------------------------------
#define MAX_EVENT_SIZE 20
#define MAX_PARAM_SIZE 20
#define VLC_MESSAGE (WM_APP)
#define VLC_WINDOW (WM_APP + 1000)
#define VLC_CONTROL (WM_APP + 2000)
// VLC messages
#define VLC_NOTHING (VLC_MESSAGE + 1)
#define VLC_SHOW (VLC_MESSAGE + 2)
#define VLC_HIDE (VLC_MESSAGE + 3)
#define VLC_QUIT (VLC_MESSAGE + 4)
#define VLC_OPEN (VLC_MESSAGE + 5)
#define VLC_LOAD_SKIN (VLC_MESSAGE + 6)
#define VLC_DROP (VLC_MESSAGE + 7)
#define VLC_LOG_SHOW (VLC_MESSAGE + 20)
#define VLC_LOG_CLEAR (VLC_MESSAGE + 22)
#define VLC_INTF_REFRESH (VLC_MESSAGE + 30)
#define VLC_CHANGE_TRAY (VLC_MESSAGE + 31)
#define VLC_CHANGE_TASKBAR (VLC_MESSAGE + 32)
#define VLC_FULLSCREEN (VLC_MESSAGE + 40)
// Stream control
#define VLC_PLAY (VLC_MESSAGE + 101)
#define VLC_STOP (VLC_MESSAGE + 102)
#define VLC_PAUSE (VLC_MESSAGE + 103)
#define VLC_NEXT (VLC_MESSAGE + 104)
#define VLC_PREV (VLC_MESSAGE + 105)
#define VLC_STREAMPOS (VLC_MESSAGE + 106)
#define VLC_ENDSTREAMPOS (VLC_MESSAGE + 107)
#define VLC_TOTALSTREAMPOS (VLC_MESSAGE + 108)
#define VLC_STREAMNAME (VLC_MESSAGE + 109)
#define VLC_HELP_TEXT (VLC_MESSAGE + 110)
// Volume control
#define VLC_VOLUME_CHANGE (VLC_MESSAGE + 201)
#define VLC_VOLUME_MUTE (VLC_MESSAGE + 202)
#define VLC_VOLUME_UP (VLC_MESSAGE + 203)
#define VLC_VOLUME_DOWN (VLC_MESSAGE + 204)
#define VLC_VOLUME_SET (VLC_MESSAGE + 205)
// Playlist events
#define VLC_PLAYLIST_ADD_FILE (VLC_MESSAGE + 301)
#define VLC_TEST_ALL_CLOSED (VLC_MESSAGE + 600)
// Window event
#define WINDOW_MOVE (VLC_WINDOW + 1)
#define WINDOW_OPEN (VLC_WINDOW + 2)
#define WINDOW_CLOSE (VLC_WINDOW + 3)
#define WINDOW_SHOW (VLC_WINDOW + 4)
#define WINDOW_HIDE (VLC_WINDOW + 5)
#define WINDOW_FADE (VLC_WINDOW + 6)
// Control event
#define CTRL_ENABLED (VLC_CONTROL + 1)
#define CTRL_VISIBLE (VLC_CONTROL + 2)
#define CTRL_SYNCHRO (VLC_CONTROL + 3)
#define CTRL_SET_SLIDER (VLC_CONTROL + 10)
#define CTRL_SET_TEXT (VLC_CONTROL + 11)
// Control event by ID
#define CTRL_ID_VISIBLE (VLC_CONTROL + 100)
#define CTRL_ID_ENABLED (VLC_CONTROL + 101)
#define CTRL_ID_MOVE (VLC_CONTROL + 102)
// Control definition
#define CTRL_SLIDER (VLC_CONTROL + 301)
#define CTRL_TIME (VLC_CONTROL + 302)
#define CTRL_PLAYLIST (VLC_CONTROL + 303)
// Playlist
#define PLAYLIST_ID_DEL (VLC_CONTROL + 400)
//---------------------------------------------------------------------------
struct intf_thread_t;
class GenericControl;
class Window;
class Event;
//---------------------------------------------------------------------------
// EVENT CLASS
//---------------------------------------------------------------------------
class Event
{
protected:
string EventDesc;
unsigned int Message;
unsigned int Param1;
long Param2;
unsigned int GetMessageType( string desc );
string Shortcut;
int KeyModifier;
int Key;
intf_thread_t * p_intf;
// Transform expr to special boolean :
// 0 = false
// 1 = true
// 2 = change boolean
int GetBool( string expr );
public:
// Constructor
Event( intf_thread_t *_p_intf, string Desc, string shortcut );
Event( intf_thread_t *_p_intf, unsigned int msg, unsigned int par1,
long par2 );
// Destructor
virtual ~Event();
void DestructParameters();
// General operations on events
GenericControl * FindControl( string id );
void CreateEvent();
virtual void CreateOSEvent( string para1, string para2,
string para3 ) = 0;
virtual bool IsEqual( Event *evt );
// Event sending
virtual bool SendEvent() = 0;
void PostTextMessage( string text );
void PostSynchroMessage( bool autodelete = false );
// Shortcuts methods
bool MatchShortcut( int key, int mod );
void CreateShortcut();
// Getters
unsigned int GetMessage() { return Message; }
unsigned int GetParam1() { return Param1; }
long GetParam2() { return Param2; }
// Setters
void SetParam1( unsigned int p1 ) { Param1 = p1; }
void SetParam2( unsigned int p2 ) { Param2 = p2; }
};
//---------------------------------------------------------------------------
#define ACTION_MATCH_ALL 0
#define ACTION_MATCH_FIRST 1
#define ACTION_MATCH_ONE 2
//---------------------------------------------------------------------------
class Action
{
private:
list<Event *> EventList;
int GetBool( string expr );
intf_thread_t * p_intf;
public:
// Constructor
Action::Action( intf_thread_t *_p_intf, string code );
// Destructor
Action::~Action();
// Send event
bool SendEvent();
bool MatchEvent( Event *evt, int flag = ACTION_MATCH_ALL );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* font.cpp: Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: font.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "font.h"
//---------------------------------------------------------------------------
// Font object
//---------------------------------------------------------------------------
Font::Font( intf_thread_t *_p_intf, string fontname, int size, int color,
int weight, bool italic, bool underline )
{
p_intf = _p_intf;
FontName = fontname;
Size = size;
Color = OSAPI_GetNonTransparentColor( color );
Italic = italic;
Underline = underline;
Weight = weight;
if( Weight > 1000 )
Weight = 1000;
if( Weight < 1 )
Weight = 1;
}
//---------------------------------------------------------------------------
Font::~Font()
{
}
//---------------------------------------------------------------------------
/*****************************************************************************
* font.h: Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: font.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_FONT
#define VLC_SKIN_FONT
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Graphics;
//---------------------------------------------------------------------------
class Font
{
private:
// Assign font to Device Context
virtual void AssignFont( Graphics *dest ) = 0;
// Helper function
virtual void GenericPrint( Graphics *dest, string text, int x, int y,
int w, int h, int align, int color ) = 0;
protected:
int Weight;
string FontName;
bool Italic;
bool Underline;
int Size;
int Color;
intf_thread_t *p_intf;
public:
// Constructor
Font( intf_thread_t *_p_intf, string fontname, int size, int color,
int weight, bool italic, bool underline );
// Destructor
virtual ~Font();
// Get size of text
virtual void GetSize( string text, int &w, int &h ) = 0;
// Draw text with boundaries
virtual void Print( Graphics *dest, string text, int x, int y, int w,
int h, int align ) = 0;
virtual void PrintColor( Graphics *dest, string text, int x, int y,
int w, int h, int align, int color ) = 0;
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* graphics.cpp: Graphics class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: graphics.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- SKIN ------------------------------------------------------------------
#include "graphics.h"
//---------------------------------------------------------------------------
Graphics::Graphics( int w, int h )
{
Width = w;
Height = h;
}
//---------------------------------------------------------------------------
Graphics::~Graphics()
{
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// REGION
//---------------------------------------------------------------------------
Region::Region()
{
}
//---------------------------------------------------------------------------
Region::Region( int x, int y, int w, int h )
{
}
//---------------------------------------------------------------------------
Region::~Region()
{
}
//---------------------------------------------------------------------------
/*****************************************************************************
* graphics.h: Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: graphics.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_GRAPHICS
#define VLC_SKIN_GRAPHICS
//---------------------------------------------------------------------------
class Region;
//---------------------------------------------------------------------------
class Graphics
{
private:
int Width;
int Height;
public:
// Constructor
Graphics( int w, int h );
// Destructor
virtual ~Graphics();
// Drawing methods
virtual void CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
int sx, int sy, int Flag ) = 0;
//virtual void CopyTo( Graphics *Dest, int dx, int dy, int dw, int dh,
// int sx, int sy, int Flag ) = 0;
virtual void DrawRect( int x, int y, int w, int h, int color ) = 0;
// Clipping methods
virtual void SetClipRegion( Region *rgn ) = 0;
};
//---------------------------------------------------------------------------
class Region
{
private:
public:
// Constructor
Region();
Region( int x, int y, int w, int h );
// Destructor
virtual ~Region();
// Modify region
virtual void Move( int x, int y ) = 0;
virtual void AddPoint( int x, int y ) = 0;
virtual void AddRectangle( int x, int y, int w, int h ) = 0;
virtual void AddElipse( int x, int y, int w, int h ) = 0;
virtual bool Hit( int x, int y ) = 0;
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* skin_common.h: Private Skin interface description
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin_common.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef SKIN_COMMON_H
#define SKIN_COMMON_H
#define SLIDER_RANGE 1048576 // 1024*1024
#define DEFAULT_SKIN_FILE "skins/default.vlt"
class Theme;
/*****************************************************************************
* intf_sys_t: description and status of skin interface
*****************************************************************************/
struct intf_sys_t
{
/* Pointer to the theme main class */
Theme *p_theme;
char *p_new_theme_file;
/* The input thread */
input_thread_t * p_input;
/* The playlist thread */
playlist_t * p_playlist;
// Check if thread is closing
int i_close_status;
bool b_all_win_closed;
/* message bank subscription */
msg_subscription_t* p_sub;
// Interface status
int i_index; // Set wich file is being played
int i_size; // Size of playlist;
};
#endif
/*****************************************************************************
* skin-main.cpp: skins plugin for VLC
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: skin_main.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/aout.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "event.h"
#include "dialog.h"
#include "os_dialog.h"
#include "banks.h"
#include "window.h"
#include "theme.h"
#include "os_theme.h"
#include "themeloader.h"
#include "vlcproc.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Interface thread
// It is a global variable because we have C code for the parser, and we
// need to access C++ objects from there
//---------------------------------------------------------------------------
intf_thread_t *g_pIntf;
//---------------------------------------------------------------------------
// Exported interface functions.
//---------------------------------------------------------------------------
extern "C" __declspec( dllexport )
int __VLC_SYMBOL( vlc_entry ) ( module_t *p_module );
//---------------------------------------------------------------------------
// Local prototypes.
//---------------------------------------------------------------------------
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
int SkinManage( intf_thread_t *p_intf );
void OSRun( intf_thread_t *p_intf );
//---------------------------------------------------------------------------
// Open: initialize interface
//---------------------------------------------------------------------------
static int Open ( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
g_pIntf = p_intf;
// Allocate instance and initialize some members
p_intf->p_sys = (intf_sys_t *) malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return( 1 );
};
p_intf->pf_run = Run;
// Suscribe to messages bank
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
// Set no new theme when opening file
p_intf->p_sys->p_new_theme_file = NULL;
// Initialize Win32 thread
p_intf->p_sys->i_index = -1;
p_intf->p_sys->i_size = 0;
p_intf->p_sys->i_close_status = VLC_NOTHING;
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf );
return( 0 );
}
//---------------------------------------------------------------------------
// Close: destroy interface
//---------------------------------------------------------------------------
static void Close ( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
if( p_intf->p_sys->p_input )
{
vlc_object_release( p_intf->p_sys->p_input );
}
if( p_intf->p_sys->p_playlist )
{
vlc_object_release( p_intf->p_sys->p_playlist );
}
// Delete theme, it's important to do it correctly
delete (OSTheme *)p_intf->p_sys->p_theme;
// Unsuscribe to messages bank
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
// Destroy structure
free( p_intf->p_sys );
}
//---------------------------------------------------------------------------
// Run: main loop
//---------------------------------------------------------------------------
static void Run( intf_thread_t *p_intf )
{
int a = OSAPI_GetTime();
// Load a theme
char *skin_last = config_GetPsz( p_intf, "skin_last" );
ThemeLoader *Loader = new ThemeLoader( p_intf );
if( skin_last == NULL || ! Loader->Load( skin_last ) )
{
// Too bad, it failed. Let's try with the default theme
if( ! Loader->Load( DEFAULT_SKIN_FILE ) )
{
// Last chance: the user can select a new theme file
// Initialize file structure
OpenFileDialog *OpenFile;
OpenFile = (OpenFileDialog *)new OSOpenFileDialog( _("Open skin"),
false );
OpenFile->AddFilter( _("Skin files"), "*.vlt" );
OpenFile->AddFilter( _("Skin files"), "*.xml" );
OpenFile->AddFilter( _("All files"), "*.*" );
// Open dialog box
if( OpenFile->Open() )
{
// try to load selected file
if( ! Loader->Load( OpenFile->FileList.front() ) )
{
// He, he, what the hell is he doing ?
delete OpenFile;
delete Loader;
return;
}
}
else
{
delete OpenFile;
delete Loader;
return;
}
delete OpenFile;
}
}
// Show the theme
p_intf->p_sys->p_theme->InitTheme();
p_intf->p_sys->p_theme->ShowTheme();
delete Loader;
msg_Err( p_intf, "Load theme time : %i ms", OSAPI_GetTime() - a );
// Refresh the whole interface
OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)true );
// Run interface message loop
OSRun( p_intf );
}
//---------------------------------------------------------------------------
// Module descriptor
//---------------------------------------------------------------------------
#define DEFAULT_SKIN N_("Last skin actually used")
#define DEFAULT_SKIN_LONG N_("Last skin actually used")
#define SKIN_CONFIG N_("Config of last used skin")
#define SKIN_CONFIG_LONG N_("Config of last used skin")
#define SKIN_TRAY N_("Show application in system tray")
#define SKIN_TRAY_LONG N_("Show application in system tray")
#define SKIN_TASKBAR N_("Show application in taskbar")
#define SKIN_TASKBAR_LONG N_("Show application in taskbar")
vlc_module_begin();
add_string( "skin_last", "", NULL, DEFAULT_SKIN, DEFAULT_SKIN_LONG,
VLC_TRUE );
add_string( "skin_config", "", NULL, SKIN_CONFIG, SKIN_CONFIG_LONG,
VLC_TRUE );
add_bool( "show_in_tray", VLC_FALSE, NULL, SKIN_TRAY, SKIN_TRAY_LONG,
VLC_FALSE );
add_bool( "show_in_taskbar", VLC_TRUE, NULL, SKIN_TASKBAR,
SKIN_TASKBAR_LONG, VLC_FALSE );
set_description( _("Skinnable Interface Module") );
set_capability( "interface", 30 );
set_callbacks( E_(Open), E_(Close) );
add_shortcut( "skin" );
vlc_module_end();
//---------------------------------------------------------------------------
// Refresh procedure
//---------------------------------------------------------------------------
int SkinManage( intf_thread_t *p_intf )
{
vlc_mutex_lock( &p_intf->change_lock );
// Update the input
if( p_intf->p_sys->p_input == NULL )
{
p_intf->p_sys->p_input = (input_thread_t *)
vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
}
else if( p_intf->p_sys->p_input->b_dead )
{
vlc_object_release( p_intf->p_sys->p_input );
p_intf->p_sys->p_input = NULL;
}
OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (long)false );
// Update the log window
//p_intf->p_sys->p_theme->UpdateLog( p_intf->p_sys->p_sub );
//-------------------------------------------------------------------------
if( p_intf->p_sys->p_input != NULL && !p_intf->p_sys->p_input->b_die )
{
input_thread_t * p_input = p_intf->p_sys->p_input;
vlc_mutex_lock( &p_input->stream.stream_lock );
// Refresh sound volume
audio_volume_t volume;
// Get sound volume from VLC
aout_VolumeGet( p_intf, &volume);
// Update sliders
OSAPI_PostMessage( NULL, CTRL_SET_SLIDER,
(unsigned int)
p_intf->p_sys->p_theme->EvtBank->Get( "volume_refresh" ),
(long)( volume * SLIDER_RANGE / AOUT_VOLUME_MAX ) );
// Refresh slider
//if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
//{
#define p_area p_input->stream.p_selected_area
// Set value of sliders
long Value = SLIDER_RANGE *
p_input->stream.p_selected_area->i_tell /
p_input->stream.p_selected_area->i_size;
// Update sliders
OSAPI_PostMessage( NULL, CTRL_SET_SLIDER, (unsigned int)
p_intf->p_sys->p_theme->EvtBank->Get( "time" ), (long)Value );
// Text char * for updating text controls
char *text = new char[OFFSETTOTIME_MAX_SIZE];
// Create end time text
input_OffsetToTime( p_intf->p_sys->p_input, &text[1],
p_area->i_size - p_area->i_tell );
text[0] = '-';
p_intf->p_sys->p_theme->EvtBank->Get( "left_time" )
->PostTextMessage( text );
// Create time text and update
input_OffsetToTime( p_intf->p_sys->p_input, text, p_area->i_tell );
p_intf->p_sys->p_theme->EvtBank->Get( "time" )
->PostTextMessage( text );
// Create total time text
input_OffsetToTime( p_intf->p_sys->p_input, text, p_area->i_size );
p_intf->p_sys->p_theme->EvtBank->Get( "total_time" )
->PostTextMessage( text );
// Free memory
delete[] text;
#undef p_area
//}
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
//-------------------------------------------------------------------------
vlc_mutex_unlock( &p_intf->change_lock );
return( TRUE );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* theme.cpp: Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "window.h"
#include "os_window.h"
#include "dialog.h"
#include "os_dialog.h"
#include "banks.h"
#include "anchor.h"
#include "event.h"
#include "os_event.h"
#include "generic.h"
#include "theme.h"
#include "vlcproc.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// THEME
//---------------------------------------------------------------------------
Theme::Theme( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
BmpBank = new BitmapBank( p_intf );
FntBank = new FontBank( p_intf );
EvtBank = new EventBank( p_intf );
OffBank = new OffSetBank( p_intf );
Log = NULL;
ConstructPlaylist = false;
ShowInTray = false;
ShowInTaskbar = false;
}
//---------------------------------------------------------------------------
Theme::~Theme()
{
// Delete the windows
list<Window *>::const_iterator win;
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
delete (OSWindow *)(*win);
}
delete (OSLogWindow *)Log;
delete OffBank;
delete EvtBank;
delete BmpBank;
delete FntBank;
}
//---------------------------------------------------------------------------
void Theme::ShowTheme()
{
// Get parameters form vlcrc config file
if( ShowInTray != (bool)config_GetInt( p_intf, "show_in_tray" ) )
ChangeTray();
if( ShowInTaskbar != (bool)config_GetInt( p_intf, "show_in_taskbar" ) )
ChangeTaskbar();
list<Window *>::const_iterator win;
Event *evt;
// Synchronize control to visible aspect
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// Synchronize windows visibility
if( (*win)->OnStartThemeVisible )
evt = (Event *)new OSEvent( p_intf, (*win), WINDOW_OPEN, 0, 1 );
else
evt = (Event *)new OSEvent( p_intf, (*win), WINDOW_CLOSE, 0, 1 );
evt->PostSynchroMessage( true );
}
// Initialize magnetism
CheckAnchors();
// Show windows
OSAPI_PostMessage( NULL, VLC_SHOW, 0, 0 );
}
//---------------------------------------------------------------------------
void Theme::CreateSystemMenu()
{
AddSystemMenu( "Open file...", EvtBank->Get( "open" ) );
AddSystemMenu( "Change skin...", EvtBank->Get( "load_skin" ) );
AddSystemMenu( "Preferences...", NULL );
AddSystemMenu( "SEPARATOR", 0 );
AddSystemMenu( "Exit", EvtBank->Get( "quit" ) );
}
//---------------------------------------------------------------------------
void Theme::LoadConfig()
{
// Get config from vlcrc file
char *save = config_GetPsz( p_intf, "skin_config" );
if( save == NULL )
return;
// Initialization
list<Window *>::const_iterator win;
int i = 0;
int x, y, v, scan;
// Get config for each window
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// Get config
scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v );
// If config has the correct number of arguments
if( scan > 2 )
{
(*win)->Move( x, y );
(*win)->OnStartThemeVisible = (bool)v;
}
// Next window
i++;
}
}
//---------------------------------------------------------------------------
void Theme::SaveConfig()
{
// Initialize char where config is stored
char *save = new char[400];
list<Window *>::const_iterator win;
int i = 0;
int x, y;
// Save config of every window
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// Print config
(*win)->GetPos( x, y );
sprintf( &save[i * 13], "(%4d,%4d,%1d)", x, y,
(*win)->OnStartThemeVisible );
i++;
}
// Save config to file
config_PutPsz( p_intf, "skin_config", save );
config_PutInt( p_intf, "show_in_tray", (int)ShowInTray );
config_PutInt( p_intf, "show_in_taskbar", (int)ShowInTaskbar );
config_SaveConfigFile( p_intf, "skin" );
// Free memory
delete[] save;
}
//---------------------------------------------------------------------------
void Theme::StartTheme( bool log, int magnet )
{
Magnet = magnet;
if( log )
{
Log = (LogWindow *)new OSLogWindow( p_intf );
}
}
//---------------------------------------------------------------------------
void Theme::InitTheme()
{
// Initialize the events
EvtBank->Init();
// Initialize the controls
InitControls();
// Initialize the windows
InitWindows();
}
//---------------------------------------------------------------------------
void Theme::InitWindows()
{
for( list<Window *>::const_iterator win = WindowList.begin();
win != WindowList.end(); win++ )
{
(*win)->Init();
}
}
//---------------------------------------------------------------------------
void Theme::InitControls()
{
for( list<Window *>::const_iterator win = WindowList.begin();
win != WindowList.end(); win++ )
{
for( unsigned int i = 0; i < (*win)->ControlList.size(); i++ )
{
(*win)->ControlList[i]->Init();
}
}
}
//---------------------------------------------------------------------------
Window * Theme::GetWindow( string name )
{
for( list<Window *>::const_iterator win = WindowList.begin();
win != WindowList.end(); win++ )
{
if( name == OSAPI_GetWindowTitle( *win ) )
{
return (*win);
}
}
return NULL;
}
//---------------------------------------------------------------------------
void Theme::MoveSkin( Window *wnd, int left, int top )
{
int x, y, oldx, oldy;
Window *win;
list<Anchor *>::const_iterator anc;
list<Anchor *>::const_iterator hang;
wnd->GetPos( oldx, oldy );
// Move child windows recursively
for( anc = wnd->AnchorList.begin(); anc != wnd->AnchorList.end(); anc++ )
{
for( hang = (*anc)->HangList.begin(); hang != (*anc)->HangList.end();
hang++ )
{
win = (*hang)->GetParent();
win->GetPos( x, y );
MoveSkin( win, left, top );
}
}
// Move window only if has not been moved yet
if( !wnd->Moved )
{
wnd->Moved = true;
wnd->Move( oldx + left, oldy + top );
}
}
//---------------------------------------------------------------------------
bool Theme::MoveSkinMagnet( Window *wnd, int left, int top )
{
// If magnetism not activate
if( !Magnet )
{
wnd->Move( left, top );
return false;
}
// Screen bounds initialization
int NewLeft = left;
int NewTop = top;
int Sx, Sy, Wx, Wy;
OSAPI_GetScreenSize( Sx, Sy );
int width, height;
wnd->GetSize( width, height );
wnd->GetPos( Wx, Wy );
// Magnetism with screen bounds
if( left < Magnet && left > -Magnet)
NewLeft = 0;
else if( left + width > Sx - Magnet && left + width < Sx + Magnet )
NewLeft = Sx - width;
if( top < Magnet && top > -Magnet )
NewTop = 0;
else if( top + height > Sy - Magnet && top + height < Sy + Magnet )
NewTop = Sy - height;
// Deal with anchors
HangToAnchors( wnd, NewLeft, NewTop );
// All windows can be moved
list<Window *>::const_iterator win;
for( win = WindowList.begin(); win != WindowList.end(); win++ )
(*win)->Moved = false;
// Move Window
MoveSkin( wnd, NewLeft - Wx, NewTop - Wy );
return true;
}
//---------------------------------------------------------------------------
void Theme::HangToAnchors( Window *wnd, int &x, int &y, bool init )
{
// Magnetism initialization
int win_x, win_y, win_anchor_x, win_anchor_y, wnd_anchor_x, wnd_anchor_y;
list<Window *>::const_iterator win;
list<Anchor *>::const_iterator win_anchor, wnd_anchor;
// Parse list of windows
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
// If window is moved window
if( (*win) == wnd )
continue; // Check next window
// If window is hidden
if( !init )
{
if( (*win)->IsHidden() )
continue; // Check next window
}
else
{
if( !(*win)->OnStartThemeVisible )
continue; // Check next window
}
// Parse anchor lists
for( wnd_anchor = wnd->AnchorList.begin();
wnd_anchor != wnd->AnchorList.end(); wnd_anchor++ )
{
for( win_anchor = (*win)->AnchorList.begin();
win_anchor != (*win)->AnchorList.end(); win_anchor++ )
{
if( (*wnd_anchor)->GetPriority() <
(*win_anchor)->GetPriority() )
{
// Parent anchor is win and child is wnd !!!
if( !(*win_anchor)->Hang( (*wnd_anchor), x, y ) )
{
// If child is in parent list and parent doesn't hang ch
if( (*win_anchor)->IsInList( (*wnd_anchor) ) )
(*win_anchor)->Remove( (*wnd_anchor) );
}
else
{
// If parent hang child and child is not still in list
if( !(*win_anchor)->IsInList( (*wnd_anchor) ) )
(*win_anchor)->Add( (*wnd_anchor) );
// Move window to stick anchor
(*wnd_anchor)->GetPos( wnd_anchor_x, wnd_anchor_y );
(*win_anchor)->GetPos( win_anchor_x, win_anchor_y );
(*win)->GetPos( win_x, win_y );
x = win_x + win_anchor_x - wnd_anchor_x;
y = win_y + win_anchor_y - wnd_anchor_y;
break;
}
}
else if( (*win_anchor)->Hang( (*wnd_anchor), x, y ) )
{
// Move window to stick anchor
(*wnd_anchor)->GetPos( wnd_anchor_x, wnd_anchor_y );
(*win_anchor)->GetPos( win_anchor_x, win_anchor_y );
(*win)->GetPos( win_x, win_y );
x = win_x + win_anchor_x - wnd_anchor_x;
y = win_y + win_anchor_y - wnd_anchor_y;
break;
}
}
}
}
}
//---------------------------------------------------------------------------
void Theme::CheckAnchors()
{
list<Window *>::const_iterator win;
int x, y;
for( win = WindowList.begin(); win != WindowList.end(); win++ )
{
(*win)->GetPos( x, y );
HangToAnchors( (*win), x, y, true );
}
}
//---------------------------------------------------------------------------
void Theme::UpdateLog( msg_subscription_t *Sub )
{
if( Log != NULL )
Log->Update( Sub );
}
//---------------------------------------------------------------------------
void Theme::ShowLog( int show )
{
if( Log == NULL )
return;
if( show == 1 )
{
Log->Show();
}
else if( show == 0 )
{
Log->Hide();
}
else if( show == 2 )
{
if( Log->IsVisible() )
Log->Hide();
else
Log->Show();
}
}
//---------------------------------------------------------------------------
void Theme::ClearLog()
{
if( Log!= NULL )
Log->Clear();
}
//---------------------------------------------------------------------------
/*****************************************************************************
* theme.h: Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_THEME
#define VLC_SKIN_THEME
//--- GENERAL ---------------------------------------------------------------
#include <list>
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Window;
class EventBank;
class BitmapBank;
class FontBank;
class Event;
class OffSetBank;
class LogWindow;
//---------------------------------------------------------------------------
class Theme
{
private:
protected:
LogWindow *Log;
int Magnet;
intf_thread_t *p_intf;
bool ShowInTray;
bool ShowInTaskbar;
public:
// Constructors
Theme( intf_thread_t *_p_intf );
void StartTheme( bool log, int magnet );
// Destructor
virtual ~Theme();
virtual void OnLoadTheme() = 0;
// Initialization
void InitTheme();
void InitWindows();
void InitControls();
void ShowTheme();
virtual void AddWindow( string name, int x, int y, bool visible,
int fadetime, int alpha, int movealpha, bool dragdrop ) = 0;
virtual void ChangeClientWindowName( string name ) = 0;
Window * GetWindow( string name );
// Banks
BitmapBank *BmpBank;
EventBank *EvtBank;
FontBank *FntBank;
OffSetBank *OffBank;
// List of the windows of the skin
list<Window *> WindowList;
// Magetism
void HangToAnchors( Window *wnd, int &x, int &y, bool init = false );
bool MoveSkinMagnet( Window *wnd, int left, int top );
void MoveSkin( Window *wnd, int left, int top );
void CheckAnchors();
// Log window
LogWindow *GetLogWindow() { return Log; };
void UpdateLog( msg_subscription_t *Sub );
void ShowLog( int show );
void ClearLog();
bool ConstructPlaylist;
// Config file treatment
void LoadConfig();
void SaveConfig();
// Taskbar && system tray
void CreateSystemMenu();
virtual void AddSystemMenu( string name, Event *event ) = 0;
virtual void ChangeTray() = 0;
virtual void ChangeTaskbar() = 0;
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* themeloader.cpp: ThemeLoader class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: themeloader.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
#include <string>
#include <fcntl.h>
#if defined( HAVE_LIBTAR_H ) && defined( HAVE_ZLIB_H )
# include <zlib.h>
# include <libtar.h>
#endif
//--- VLC -------------------------------------------------------------------
#include <vlc/vlc.h>
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "theme.h"
#include "os_theme.h"
#include "themeloader.h"
#include "skin_common.h"
#define DEFAULT_XML_FILE "theme.xml"
//---------------------------------------------------------------------------
extern "C"
{
extern FILE *yyin;
int yylex();
}
//---------------------------------------------------------------------------
ThemeLoader::ThemeLoader( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
}
//---------------------------------------------------------------------------
ThemeLoader::~ThemeLoader()
{
}
//---------------------------------------------------------------------------
int gzopen_frontend( char *pathname, int oflags, int mode )
{
#if defined( HAVE_LIBTAR_H ) && defined( HAVE_ZLIB_H )
char *gzflags;
gzFile gzf;
int fd;
switch( oflags & O_ACCMODE )
{
case O_WRONLY:
gzflags = "wb";
break;
case O_RDONLY:
gzflags = "rb";
break;
case O_RDWR:
default:
errno = EINVAL;
return -1;
}
fd = open( pathname, oflags, mode );
if( fd == -1 )
return -1;
// if( ( oflags & O_CREAT ) && fchmod( fd, mode ) )
// return -1;
gzf = gzdopen( fd, gzflags );
if( !gzf )
{
errno = ENOMEM;
return -1;
}
return (int)gzf;
#else
return 0;
#endif
}
//---------------------------------------------------------------------------
#if defined( HAVE_LIBTAR_H ) && defined( HAVE_ZLIB_H )
bool ThemeLoader::ExtractTarGz( const string tarfile, const string rootdir )
{
TAR *t;
tartype_t gztype = { (openfunc_t) gzopen_frontend, (closefunc_t) gzclose,
(readfunc_t) gzread, (writefunc_t) gzwrite };
if( tar_open( &t, (char *)tarfile.c_str(), &gztype, O_RDONLY, 0,
TAR_GNU ) == -1 )
{
return false;
}
if( tar_extract_all( t, (char *)rootdir.c_str() ) != 0 )
{
return false;
}
if( tar_close( t ) != 0 )
{
return false;
}
return true;
}
//---------------------------------------------------------------------------
bool ThemeLoader::Extract( const string FileName )
{
char *tmpdir = tempnam( NULL, "vlt" );
string TempPath = tmpdir;
free( tmpdir );
if( ! ExtractTarGz( FileName, TempPath ) )
return false;
if( ! Parse( TempPath + DIRECTORY_SEPARATOR + string( DEFAULT_XML_FILE ) ) )
{
DeleteTempFiles( TempPath );
return false;
}
DeleteTempFiles( TempPath );
return true;
}
//---------------------------------------------------------------------------
void ThemeLoader::DeleteTempFiles( const string Path )
{
OSAPI_RmDir( Path );
}
#endif
//---------------------------------------------------------------------------
void ThemeLoader::CleanTheme()
{
delete (OSTheme *)p_intf->p_sys->p_theme;
p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf );
}
//---------------------------------------------------------------------------
bool ThemeLoader::Parse( const string XmlFile )
{
// Things to do before loading theme
p_intf->p_sys->p_theme->OnLoadTheme();
// Set the file to parse
yyin = fopen( XmlFile.c_str(), "r" );
if( yyin == NULL )
{
// Skin cannot be opened
msg_Warn( p_intf, "Cannot open the specified skin file: %s",
XmlFile.c_str() );
return false;
}
// File loaded
msg_Dbg( p_intf, "Using skin file: %s", XmlFile.c_str() );
// Save current working directory
char *cwd = new char[MAX_PATH];
getcwd( cwd, MAX_PATH );
// Directory separator is different in each OS !
int p = XmlFile.rfind( DIRECTORY_SEPARATOR, XmlFile.size() );
// Change current working directory to xml file
string path = "";
if( p > 0 )
path = XmlFile.substr( 0, p );
chdir( path.c_str() );
p_intf->p_sys->b_all_win_closed = false;
// Start the parser
int lex = yylex();
fclose( yyin );
if( lex )
{
// Set old working directory to current
chdir( cwd );
delete[] cwd;
msg_Warn( p_intf, "yylex failed: %i", lex );
CleanTheme();
return false;
}
// Set old working directory to current
chdir( cwd );
delete[] cwd;
return true;
}
//---------------------------------------------------------------------------
bool ThemeLoader::Load( const string FileName )
{
// First, we try to un-targz the file, and if it fails we hope it's a XML
// file...
#if defined( HAVE_LIBTAR_H ) && defined( HAVE_ZLIB_H )
if( ! Extract( FileName ) && ! Parse( FileName ) )
return false;
#else
if( ! Parse( FileName ) )
return false;
#endif
// Check if the skin to load is in the config file, to load its config
char *skin_last = config_GetPsz( p_intf, "skin_last" );
if( skin_last != NULL && FileName == (string)skin_last )
{
p_intf->p_sys->p_theme->LoadConfig();
}
else
{
config_PutPsz( p_intf, "skin_last", FileName.c_str() );
config_SaveConfigFile( p_intf, "skin" );
}
return true;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* themeloader.h: ThemeLoader class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: themeloader.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_THEMELOADER
#define VLC_SKIN_THEMELOADER
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
int gzopen_frontend( char *pathname, int oFlags, int mode );
//---------------------------------------------------------------------------
class ThemeLoader
{
private:
intf_thread_t *p_intf;
#ifdef HAVE_LIBTAR_LIBZ
bool ExtractTarGz( const string tarfile, const string rootdir );
bool Extract( const string FileName );
void DeleteTempFiles( const string Path );
#endif
void CleanTheme();
bool Parse( const string XmlFile );
public:
ThemeLoader( intf_thread_t *_p_intf );
~ThemeLoader();
bool Load( const string FileName );
};
#endif
/*****************************************************************************
* vlcproc.cpp: VlcProc class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/aout.h>
#include <vlc/vout.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "dialog.h"
#include "os_dialog.h"
#include "event.h"
#include "banks.h"
#include "theme.h"
#include "os_theme.h"
#include "themeloader.h"
#include "window.h"
#include "vlcproc.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// VlcProc
//---------------------------------------------------------------------------
VlcProc::VlcProc( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
}
//---------------------------------------------------------------------------
bool VlcProc::EventProc( Event *evt )
{
switch( evt->GetMessage() )
{
case VLC_STREAMPOS:
MoveStream( evt->GetParam2() );
return true;
case VLC_VOLUME_CHANGE:
ChangeVolume( evt->GetParam1(), evt->GetParam2() );
return true;
case VLC_FULLSCREEN:
FullScreen();
return true;
case VLC_HIDE:
for( list<Window *>::const_iterator win =
p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
(*win)->OnStartThemeVisible = !(*win)->IsHidden();
}
p_intf->p_sys->i_close_status = (int)evt->GetParam1();
OSAPI_PostMessage( NULL, WINDOW_CLOSE, 0, 0 );
return true;
case VLC_SHOW:
for( list<Window *>::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, 0, 0 );
}
p_intf->p_sys->b_all_win_closed = false;
return true;
case VLC_OPEN:
OpenFile( true );
return true;
case VLC_LOAD_SKIN:
LoadSkin();
return true;
case VLC_DROP:
DropFile( evt->GetParam1() );
return true;
case VLC_PLAY:
PlayStream();
return true;
case VLC_PAUSE:
PauseStream();
return true;
case VLC_STOP:
StopStream();
return true;
case VLC_NEXT:
NextStream();
return true;
case VLC_PREV:
PrevStream();
return true;
case VLC_PLAYLIST_ADD_FILE:
OpenFile( false );
return true;
case VLC_LOG_SHOW:
p_intf->p_sys->p_theme->ShowLog( evt->GetParam2() );
return true;
case VLC_LOG_CLEAR:
p_intf->p_sys->p_theme->ClearLog();
return true;
case VLC_INTF_REFRESH:
InterfaceRefresh( (bool)evt->GetParam2() );
return true;
case VLC_TEST_ALL_CLOSED:
return EventProcEnd();
case VLC_QUIT:
return false;
case VLC_CHANGE_TRAY:
p_intf->p_sys->p_theme->ChangeTray();
return true;
case VLC_CHANGE_TASKBAR:
p_intf->p_sys->p_theme->ChangeTaskbar();
return true;
default:
return true;
}
}
//---------------------------------------------------------------------------
bool VlcProc::EventProcEnd()
{
if( p_intf->p_sys->b_all_win_closed )
return true;
list<Window *>::const_iterator win;
// If a window has been closed, test if all are closed !
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
{
return true;
}
}
// All window are closed
switch( p_intf->p_sys->i_close_status )
{
case VLC_QUIT:
// Save config before exiting
p_intf->p_sys->p_theme->SaveConfig();
break;
}
// Send specified event
OSAPI_PostMessage( NULL, p_intf->p_sys->i_close_status, 0, 0 );
// Reset values
p_intf->p_sys->i_close_status = VLC_NOTHING;
p_intf->p_sys->b_all_win_closed = true;
// Return true
return true;
}
//---------------------------------------------------------------------------
bool VlcProc::IsClosing()
{
if( p_intf->b_die && p_intf->p_sys->i_close_status != VLC_QUIT )
{
p_intf->p_sys->i_close_status = VLC_QUIT;
OSAPI_PostMessage( NULL, VLC_HIDE, VLC_QUIT, 0 );
}
return true;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Private methods
//---------------------------------------------------------------------------
void VlcProc::InterfaceRefresh( bool All )
{
// Shortcut pointers
intf_sys_t *Sys = p_intf->p_sys;
Theme *Thema = Sys->p_theme;
playlist_t *PlayList = Sys->p_playlist;
// Refresh
if( PlayList != NULL && Sys->p_input != NULL &&
Sys->p_input->stream.b_seekable )
{
// Refresh stream control controls ! :)
switch( PlayList->i_status )
{
case PLAYLIST_STOPPED:
EnabledEvent( "time", false );
EnabledEvent( "stop", false );
EnabledEvent( "play", true );
EnabledEvent( "pause", false );
break;
case PLAYLIST_RUNNING:
EnabledEvent( "time", true );
EnabledEvent( "stop", true );
EnabledEvent( "play", false );
EnabledEvent( "pause", true );
break;
case PLAYLIST_PAUSED:
EnabledEvent( "time", true );
EnabledEvent( "stop", true );
EnabledEvent( "play", true );
EnabledEvent( "pause", false );
break;
}
// Refresh next and prev buttons
if( PlayList->i_index == 0 || PlayList->i_size == 1 )
EnabledEvent( "prev", false );
else
EnabledEvent( "prev", true );
if( PlayList->i_index == PlayList->i_size - 1 || PlayList->i_size == 1 )
EnabledEvent( "next", false );
else
EnabledEvent( "next", true );
// Update file name text
if( PlayList->i_index != Sys->i_index )
{
Thema->EvtBank->Get( "file_name" )->PostTextMessage(
PlayList->pp_items[PlayList->i_index]->psz_name );
}
// Update playlists
if( PlayList->i_index != Sys->i_index ||
PlayList->i_size != Sys->i_size )
{
Thema->EvtBank->Get( "playlist_refresh" )->PostSynchroMessage();
Sys->i_size = PlayList->i_size;
Sys->i_index = PlayList->i_index;
}
}
else
{
EnabledEvent( "time", false );
EnabledEvent( "stop", false );
EnabledEvent( "play", false );
EnabledEvent( "pause", false );
EnabledEvent( "prev", false );
EnabledEvent( "next", false );
// Update playlists
if( Sys->i_size > 0 )
{
Thema->EvtBank->Get( "playlist_refresh" )->PostSynchroMessage();
Sys->i_size = 0;
}
}
}
//---------------------------------------------------------------------------
void VlcProc::EnabledEvent( string type, bool state )
{
OSAPI_PostMessage( NULL, CTRL_ENABLED, (unsigned int)
p_intf->p_sys->p_theme->EvtBank->Get( type ), (int)state );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Common VLC procedures
//---------------------------------------------------------------------------
void VlcProc::LoadSkin()
{
if( p_intf->p_sys->p_new_theme_file == NULL )
{
// Initialize file structure
OpenFileDialog *OpenFile;
OpenFile = (OpenFileDialog *)new OSOpenFileDialog(
_("Change skin - Open new file"), false );
OpenFile->AddFilter( _("Skin files"), "*.vlt" );
OpenFile->AddFilter( _("Skin files"), "*.xml" );
OpenFile->AddFilter( _("All files"), "*.*" );
// Open dialog box
if( OpenFile->Open() )
{
p_intf->p_sys->p_new_theme_file =
new char[OpenFile->FileList.front().length()];
strcpy( p_intf->p_sys->p_new_theme_file,
OpenFile->FileList.front().c_str() );
// Tell vlc to change skin after hiding interface
OSAPI_PostMessage( NULL, VLC_HIDE, VLC_LOAD_SKIN, 0 );
}
// Free memory
delete OpenFile;
}
else
{
// Place a new theme in the global structure, because it will
// be filled by the parser
// We save the old one to restore it in case of problem
Theme *oldTheme = p_intf->p_sys->p_theme;
p_intf->p_sys->p_theme = (Theme *)new OSTheme( p_intf );
// Run the XML parser
ThemeLoader *Loader = new ThemeLoader( p_intf );
if( Loader->Load( p_intf->p_sys->p_new_theme_file ) )
{
// Everything went well
msg_Dbg( p_intf, "New theme successfully loaded" );
delete (OSTheme *)oldTheme;
// Show the theme
p_intf->p_sys->p_theme->InitTheme();
p_intf->p_sys->p_theme->ShowTheme();
}
else
{
msg_Warn( p_intf, "A problem occurred when loading the new theme,"
" restoring the previous one" );
delete (OSTheme *)p_intf->p_sys->p_theme;
p_intf->p_sys->p_theme = oldTheme;
// Show the theme
p_intf->p_sys->p_theme->ShowTheme();
}
delete Loader;
// Uninitialize new theme
delete (char *)p_intf->p_sys->p_new_theme_file;
p_intf->p_sys->p_new_theme_file = NULL;
}
}
//---------------------------------------------------------------------------
void VlcProc::OpenFile( bool play )
{
// Initialize file structure
OpenFileDialog *OpenFile;
if( play )
{
OpenFile = (OpenFileDialog *)new OSOpenFileDialog( _("Open file"),
false );
}
else
{
OpenFile = (OpenFileDialog *)new OSOpenFileDialog( _("Add file"),
true );
}
OpenFile->AddFilter( _("All files"), "*.*" );
// Check if palylist is available
playlist_t *p_playlist = p_intf->p_sys->p_playlist;
if( p_playlist == NULL )
return;
// Open dialog box and launch file
if( OpenFile->Open() )
{
list<string>::const_iterator file;
for( file = OpenFile->FileList.begin();
file != OpenFile->FileList.end(); file++ )
{
playlist_Add( p_playlist, (*file).c_str(), PLAYLIST_APPEND,
PLAYLIST_END );
}
// Refreshing
if( play )
{
// Play
p_intf->p_sys->p_theme->EvtBank->Get( "play" )->SendEvent();
}
// Refresh interface !
p_intf->p_sys->p_theme->EvtBank->Get( "playlist_refresh" )
->PostSynchroMessage();
InterfaceRefresh();
}
// Free memory
delete OpenFile;
}
//---------------------------------------------------------------------------
void VlcProc::DropFile( unsigned int param )
{
// Get pointer to file
char *FileName = (char *)param;
// Add the new file to the playlist
if( p_intf->p_sys->p_playlist != NULL )
{
if( config_GetInt( p_intf, "enqueue" ) )
{
playlist_Add( p_intf->p_sys->p_playlist, FileName,
PLAYLIST_APPEND, PLAYLIST_END );
}
else
{
playlist_Add( p_intf->p_sys->p_playlist, FileName,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
}
// VLC_DROP must be called with a pointer to a char else it will
// ******** SEGFAULT ********
// The delete is here because the processus in asynchronous
delete[] FileName;
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Stream Control
//---------------------------------------------------------------------------
void VlcProc::PauseStream()
{
if( p_intf->p_sys->p_input == NULL )
return;
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
void VlcProc::PlayStream()
{
if( p_intf->p_sys->p_playlist == NULL )
return;
if( !p_intf->p_sys->p_playlist->i_size )
return;
playlist_Play( p_intf->p_sys->p_playlist );
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
void VlcProc::StopStream()
{
if( p_intf->p_sys->p_playlist == NULL )
return;
playlist_Stop( p_intf->p_sys->p_playlist );
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
void VlcProc::NextStream()
{
if( p_intf->p_sys->p_playlist == NULL )
return;
playlist_Next( p_intf->p_sys->p_playlist );
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
void VlcProc::PrevStream()
{
if( p_intf->p_sys->p_playlist == NULL )
return;
playlist_Prev( p_intf->p_sys->p_playlist );
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
void VlcProc::MoveStream( long Pos )
{
if( p_intf->p_sys->p_input == NULL )
return;
off_t i_seek = (off_t)(Pos *
p_intf->p_sys->p_input->stream.p_selected_area->i_size
/ SLIDER_RANGE);
input_Seek( p_intf->p_sys->p_input, i_seek, INPUT_SEEK_SET );
// Refresh interface
InterfaceRefresh();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Fullscreen
//---------------------------------------------------------------------------
void VlcProc::FullScreen()
{
vout_thread_t *p_vout;
if( p_intf->p_sys->p_input == NULL )
return;
p_vout = (vout_thread_t *)vlc_object_find( p_intf->p_sys->p_input,
VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout == NULL )
return;
p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE;
vlc_object_release( p_vout );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Volume Control
//---------------------------------------------------------------------------
void VlcProc::ChangeVolume( unsigned int msg, long param )
{
audio_volume_t volume;
switch( msg )
{
case VLC_VOLUME_MUTE:
aout_VolumeMute( p_intf, NULL );
break;
case VLC_VOLUME_UP:
aout_VolumeUp( p_intf, 1, NULL );
break;
case VLC_VOLUME_DOWN:
aout_VolumeDown( p_intf, 1, NULL );
break;
case VLC_VOLUME_SET:
aout_VolumeSet( p_intf, param * AOUT_VOLUME_MAX / SLIDER_RANGE );
break;
}
aout_VolumeGet( p_intf, &volume );
PostMessage( NULL, CTRL_SET_SLIDER,
(unsigned int)
p_intf->p_sys->p_theme->EvtBank->Get( "volume_refresh" ),
(int)( volume * SLIDER_RANGE / AOUT_VOLUME_MAX ) );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* vlcproc.h: VlcProc class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: vlcproc.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_PROC
#define VLC_SKIN_PROC
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
//---------------------------------------------------------------------------
class VlcProc
{
private:
intf_thread_t *p_intf;
// Vlc methods
void LoadSkin();
void OpenFile( bool play );
void DropFile( unsigned int param );
void PauseStream();
void PlayStream();
void StopStream();
void NextStream();
void PrevStream();
void MoveStream( long Pos );
void FullScreen();
void ChangeVolume( unsigned int msg, long param );
void InterfaceRefresh( bool All = false );
void EnabledEvent( string type, bool state );
public:
// Constuctor
VlcProc( intf_thread_t *_p_intf );
// Destructor
~VlcProc();
// Event procedures
bool EventProc( Event *evt );
bool EventProcEnd();
bool IsClosing();
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* window.cpp: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "anchor.h"
#include "generic.h"
#include "window.h"
#include "event.h"
#include "os_api.h"
#include "graphics.h"
#include "os_graphics.h"
#include "banks.h"
#include "theme.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Skinable Window
//---------------------------------------------------------------------------
Window::Window( intf_thread_t *_p_intf, int x, int y, bool visible,
int transition, int normalalpha, int movealpha, bool dragdrop )
{
p_intf = _p_intf;
// Set position parameters
Left = x;
Top = y;
Width = 0;
Height = 0;
WindowMoving = false;
Moved = false;
// Set transparency
Transition = transition;
if( Transition < 1 )
Transition = 1;
NormalAlpha = normalalpha;
MoveAlpha = movealpha;
Alpha = normalalpha;
StartAlpha = 0;
EndAlpha = 0;
StartTime = 0;
EndTime = 0;
Lock = 0;
// Visible parameters
Image = NULL;
Hidden = true;
Changing = false;
OnStartThemeVisible = visible;
// Drag & drop
DragDrop = dragdrop;
// ToolTip
ToolTipText = "none";
}
//---------------------------------------------------------------------------
Window::~Window()
{
// Destroy the controls
for( unsigned int i = 0; i < ControlList.size(); i++ )
delete ControlList[i];
}
//---------------------------------------------------------------------------
void Window::Open()
{
if( !Hidden )
return;
Changing = true;
if( Transition )
{
SetTransparency( 0 );
OSAPI_PostMessage( this, WINDOW_SHOW, 0, 0 );
Fade( NormalAlpha, Transition );
}
else
{
OSAPI_PostMessage( this, WINDOW_SHOW, 0, 0 );
}
}
//---------------------------------------------------------------------------
void Window::Close()
{
Changing = true;
if( Transition )
Fade( 0, Transition, WINDOW_HIDE );
else
OSAPI_PostMessage( this, WINDOW_FADE, WINDOW_HIDE, 1242 );
}
//---------------------------------------------------------------------------
void Window::Show()
{
Changing = false;
Hidden = false;
OSShow( true );
}
//---------------------------------------------------------------------------
void Window::Hide()
{
if( Hidden )
return;
Changing = false;
Hidden = true;
OSShow( false );
OSAPI_PostMessage( NULL, VLC_TEST_ALL_CLOSED, 0, 0 );
}
//---------------------------------------------------------------------------
void Window::Fade( int To, int Time, unsigned int evt )
{
StartAlpha = Alpha;
EndAlpha = To;
StartTime = OSAPI_GetTime();
EndTime = StartTime + Time;
Lock++;
OSAPI_PostMessage( this, WINDOW_FADE, evt, Lock );
}
//---------------------------------------------------------------------------
bool Window::ProcessEvent( Event *evt )
{
unsigned int i;
unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2();
// Send event to control if necessary
if( msg > VLC_CONTROL )
{
for( i = 0; i < ControlList.size(); i++ )
ControlList[i]->GenericProcessEvent( evt );
return true;
}
// Message processing
switch( msg )
{
case WINDOW_FADE:
if( Lock == p2 && ChangeAlpha( OSAPI_GetTime() ) )
{
OSAPI_PostMessage( this, WINDOW_FADE, p1, p2 );
}
else
{
OSAPI_PostMessage( this, p1, 0, 0 );
}
return true;
case WINDOW_MOVE:
WindowManualMoveInit();
WindowMoving = true;
if( MoveAlpha )
Fade( MoveAlpha, 100 );
return true;
case WINDOW_OPEN:
Open();
return true;
case WINDOW_CLOSE:
Close();
return true;
case WINDOW_SHOW:
Show();
return true;
case WINDOW_HIDE:
Hide();
return true;
default:
// OS specific messages processing
return ProcessOSEvent( evt );
}
}
//---------------------------------------------------------------------------
bool Window::ChangeAlpha( int time )
{
if( time >= EndTime )
{
if( Lock )
{
SetTransparency( EndAlpha );
Lock = 0;
}
return false;
}
int NewAlpha = StartAlpha + (EndAlpha - StartAlpha) * (time - StartTime)
/ (EndTime - StartTime);
if( NewAlpha != Alpha )
SetTransparency( NewAlpha );
if( NewAlpha == EndAlpha )
{
Lock = 0;
return false;
}
return true;
}
//---------------------------------------------------------------------------
void Window::RefreshImage( int x, int y, int w, int h )
{
unsigned int i;
// Create Bitmap Buffer
Graphics *Buffer = (Graphics *)new OSGraphics( w, h, this );
// Draw every control
for( i = 0; i < ControlList.size(); i++ )
ControlList[i]->Draw( x, y, w, h, Buffer );
// Copy buffer in Image
Image->CopyFrom( x, y, w, h, Buffer, 0, 0, SRC_COPY );
// Free memory
delete Buffer;
}
//---------------------------------------------------------------------------
void Window::Refresh( int x, int y, int w, int h )
{
if( Image == NULL )
return;
// Refresh buffer image
RefreshImage( x, y, w, h );
if( Hidden )
return;
// And copy buffer to window
RefreshFromImage( x, y, w, h );
}
//---------------------------------------------------------------------------
void Window::RefreshAll()
{
Refresh( 0, 0, Width, Height );
}
//---------------------------------------------------------------------------
void Window::MouseDown( int x, int y, int button )
{
// Checking event in controls
for( int i = ControlList.size() - 1; i >= 0 ; i-- )
{
if( ControlList[i]->MouseDown( x, y, button ) )
{
return;
}
}
}
//---------------------------------------------------------------------------
void Window::MouseMove( int x, int y, int button )
{
int i;
// Move window if selected !
if( WindowMoving )
{
WindowManualMove();
}
// Checking event in controls
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
ControlList[i]->MouseMove( x, y, button );
}
// Checking help text
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
if( ControlList[i]->MouseOver( x, y ) )
{
if( ControlList[i]->SendNewHelpText() )
{
break;
}
}
}
// If help text not found, change it to ""
if( i == -1 )
{
p_intf->p_sys->p_theme->EvtBank->Get( "help" )
->PostTextMessage( " " );
}
// Checking for change in Tool Tip
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
if( ControlList[i]->ToolTipTest( x, y ) )
break;
}
// If no change, delete tooltip text
if( i == -1 )
ChangeToolTipText( "none" );
}
//---------------------------------------------------------------------------
void Window::MouseUp( int x, int y, int button )
{
int i;
// Move window if selected !
if( WindowMoving )
{
if( MoveAlpha )
Fade( NormalAlpha, 100 );
// Check for magnetism
p_intf->p_sys->p_theme->CheckAnchors();
WindowMoving = false;
}
// Checking event in controls
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
if( ControlList[i]->MouseUp( x, y, button ) )
return;
}
}
//---------------------------------------------------------------------------
void Window::MouseDblClick( int x, int y, int button )
{
int i;
// Checking event in controls
for( i = ControlList.size() - 1; i >= 0 ; i-- )
{
if( ControlList[i]->MouseDblClick( x, y, button ) )
return;
}
}
//---------------------------------------------------------------------------
void Window::Init()
{
// Get size of window
ReSize();
// Refresh Image buffer
RefreshImage( 0, 0, Width, Height );
}
//---------------------------------------------------------------------------
void Window::ReSize()
{
// Initialization
unsigned int i;
int w = 0;
int h = 0;
int MinX = 10000000;
int MinY = 10000000;
// Search size of window and negative values to move all
for( i = 0; i < ControlList.size(); i++ )
{
#define min(a,b) ((a)<(b))?(a):(b)
#define max(a,b) ((a)>(b))?(a):(b)
w = max( w, ControlList[i]->Left + ControlList[i]->Width );
h = max( h, ControlList[i]->Top + ControlList[i]->Height );
MinX = min( MinX, ControlList[i]->Left );
MinY = min( MinY, ControlList[i]->Top );
#undef max
#undef min
}
// Correct values
w = w - MinX;
h = h - MinY;
if( w <= 0 )
w = 1;
if( h <= 0 )
h = 1;
// Move window and controls !
if( MinX != 0 || MinY != 0 )
{
Move( Left + MinX, Top + MinY );
for( i = 0; i < ControlList.size(); i++ )
ControlList[i]->MoveRelative( -MinX, -MinY );
}
// Create buffer image for repainting if size has changed
if( w != Width || h != Height )
{
// Change image buffer
if( Image != NULL )
delete (OSGraphics *)Image;
Image = (Graphics *)new OSGraphics( w, h, this );
Size( w, h );
}
}
//---------------------------------------------------------------------------
void Window::GetSize( int &w, int &h )
{
w = Width;
h = Height;
}
//---------------------------------------------------------------------------
void Window::GetPos( int &x, int &y )
{
x = Left;
y = Top;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* window.h: Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN
#define VLC_SKIN_WIN
//--- GENERAL ---------------------------------------------------------------
#include <list>
#include <string>
#include <vector>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Graphics;
class GenericControl;
class Anchor;
class Event;
//---------------------------------------------------------------------------
class Window
{
protected:
// Interface thread
intf_thread_t *p_intf;
// Position parmaters
int Left;
int Top;
int Width;
int Height;
// General parameters
Graphics *Image;
int Transition;
int MoveAlpha;
int NormalAlpha;
int Alpha;
bool WindowMoving;
bool Hidden;
bool Changing;
// Fading transition;
int StartAlpha;
int EndAlpha;
int StartTime;
int EndTime;
int Lock;
// Tooltip
string ToolTipText;
// Drag & drop
bool DragDrop;
public:
// Controls
vector<GenericControl *> ControlList;
// Constructors
Window( intf_thread_t *_p_intf, int x, int y, bool visible,
int transition, int normalalpha, int movealpha, bool dragdrop );
// Destructors
virtual ~Window();
// Event processing
bool ProcessEvent( Event *evt );
virtual bool ProcessOSEvent( Event *evt ) = 0;
// Mouse events
void MouseUp( int x, int y, int nutton );
void MouseDown( int x, int y, int button );
void MouseMove( int x, int y, int button );
void MouseDblClick( int x, int y, int button );
// Window graphic aspect
bool OnStartThemeVisible;
void Show();
void Hide();
void Open();
void Close();
void RefreshAll();
void Refresh( int x, int y, int w, int h );
void RefreshImage( int x, int y, int w, int h );
virtual void RefreshFromImage( int x, int y, int w, int h ) = 0;
void Fade( int To, int Time = 1000, unsigned int evt = 0 );
bool IsHidden() { return Hidden; };
virtual void OSShow( bool show ) = 0;
virtual void SetTransparency( int Value = -1 ) = 0;
virtual void WindowManualMove() = 0;
virtual void WindowManualMoveInit() = 0;
// Window methods
void Init();
void ReSize();
void GetSize( int &w, int &h );
void GetPos( int &x, int &y );
virtual void Move( int left, int top ) = 0;
virtual void Size( int width, int height ) = 0;
// Fading transition
bool ChangeAlpha( int time );
void Init( int start, int end, int time );
// Texts
virtual void ChangeToolTipText( string text ) = 0;
// Magnetic Anchors
list<Anchor *> AnchorList;
bool Moved;
// Get the interface thread
intf_thread_t *GetIntf() { return p_intf; }
};
//---------------------------------------------------------------------------
#endif
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
/*****************************************************************************
* win32_api.cpp: Various win32-specific functions
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_api.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- SKIN ------------------------------------------------------------------
#include "window.h"
#include "os_window.h"
#include "os_api.h"
#include "event.h" // for MAX_PARAM_SIZE
//---------------------------------------------------------------------------
// Event API
//---------------------------------------------------------------------------
void OSAPI_SendMessage( Window *win, unsigned int message, unsigned int param1,
long param2 )
{
if( win == NULL )
SendMessage( NULL, message, param1, param2 );
else
SendMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
param2 );
}
//---------------------------------------------------------------------------
void OSAPI_PostMessage( Window *win, unsigned int message, unsigned int param1,
long param2 )
{
if( win == NULL )
PostMessage( NULL, message, param1, param2 );
else
PostMessage( ( (Win32Window *)win )->GetHandle(), message, param1,
param2 );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Graphic API
//---------------------------------------------------------------------------
int OSAPI_GetNonTransparentColor( int c )
{
// Get desktop device context
HDC DeskDC = GetWindowDC( GetDesktopWindow() );
// If color is black or color is same as black wether pixel color depth
if( c == 0 || SetPixel( DeskDC, 0, 0, c ) == 0 )
{
if( GetDeviceCaps( DeskDC, BITSPIXEL ) < 24 )
c = RGB(8, 0, 0);
else
c = RGB(1, 0, 0);
}
ReleaseDC( GetDesktopWindow(), DeskDC );
return c;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// General
//---------------------------------------------------------------------------
int OSAPI_GetTime()
{
return GetTickCount();
}
//---------------------------------------------------------------------------
void OSAPI_GetScreenSize( int &w, int &h )
{
w = GetSystemMetrics(SM_CXSCREEN);
h = GetSystemMetrics(SM_CYSCREEN);
}
//---------------------------------------------------------------------------
void OSAPI_GetMousePos( int &x, int &y )
{
LPPOINT MousePos = new POINT;
GetCursorPos( MousePos );
x = MousePos->x;
y = MousePos->y;
delete MousePos;
}
//---------------------------------------------------------------------------
string OSAPI_GetWindowTitle( Window *win )
{
char *buffer = new char[MAX_PARAM_SIZE];
GetWindowText( ((Win32Window *)win)->GetHandle(), buffer, MAX_PARAM_SIZE );
string Title = buffer;
delete buffer;
return Title;
}
//---------------------------------------------------------------------------
bool OSAPI_RmDir( string path )
{
WIN32_FIND_DATA find;
string File;
string FindFiles = path + "\\*.*";
HANDLE handle = FindFirstFile( (char *)FindFiles.c_str(), &find );
while( handle != INVALID_HANDLE_VALUE )
{
// If file is neither "." nor ".."
if( strcmp( find.cFileName, "." ) && strcmp( find.cFileName, ".." ) )
{
// Set file name
File = path + "\\" + (string)find.cFileName;
// If file is a directory, delete it recursively
if( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
{
OSAPI_RmDir( File );
}
// Else, it is a file so simply delete it
else
{
DeleteFile( (char *)File.c_str() );
}
}
// If no more file in directory, exit while
if( !FindNextFile( handle, &find ) )
break;
}
// Now directory is empty so can be removed
FindClose( handle );
RemoveDirectory( (char *)path.c_str() );
return true;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_bitmap.cpp: Win32 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_bitmap.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#define WINVER 0x0500
#include <windows.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "graphics.h"
#include "win32_graphics.h"
#include "bitmap.h"
#include "win32_bitmap.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// Win32Bitmap
//---------------------------------------------------------------------------
Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, string FileName, int AColor )
: Bitmap( p_intf, FileName, AColor )
{
HBITMAP HBitmap;
HBITMAP HBuf;
BITMAP Bmp;
HDC bufDC;
AlphaColor = AColor;
// Create image from file if it exists
HBitmap = (HBITMAP) LoadImage( NULL, FileName.c_str(), IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE );
if( HBitmap == NULL )
{
if( FileName != "" )
msg_Warn( p_intf, "Couldn't load bitmap: %s", FileName.c_str() );
HBitmap = CreateBitmap( 0, 0, 1, 32, NULL );
}
// Create device context
bmpDC = CreateCompatibleDC( NULL );
SelectObject( bmpDC, HBitmap );
// Get size of image
GetObject( HBitmap, sizeof( Bmp ), &Bmp );
Width = Bmp.bmWidth;
Height = Bmp.bmHeight;
// If alpha color is not 0, then change 0 colors to non black color to avoid
// window transparency
if( (int)AlphaColor != OSAPI_GetNonTransparentColor( 0 ) )
{
bufDC = CreateCompatibleDC( bmpDC );
HBuf = CreateCompatibleBitmap( bmpDC, Width, Height );
SelectObject( bufDC, HBuf );
LPRECT r = new RECT;
HBRUSH Brush = CreateSolidBrush( OSAPI_GetNonTransparentColor( 0 ) );
r->left = 0;
r->top = 0;
r->right = Width;
r->bottom = Height;
FillRect( bufDC, r, Brush );
DeleteObject( Brush );
delete r;
TransparentBlt( bufDC, 0, 0, Width, Height, bmpDC, 0, 0, Width, Height, 0 );
BitBlt( bmpDC, 0, 0, Width, Height, bufDC, 0, 0, SRCCOPY );
DeleteDC( bufDC );
DeleteObject( HBuf );
}
// Delete objects
DeleteObject( HBitmap );
}
//---------------------------------------------------------------------------
Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, Graphics *from, int x, int y,
int w, int h, int AColor ) : Bitmap( p_intf, from, x, y, w, h, AColor )
{
Width = w;
Height = h;
AlphaColor = AColor;
HBITMAP HBmp;
HDC fromDC = ( (Win32Graphics *)from )->GetImageHandle();
// Create image
bmpDC = CreateCompatibleDC( fromDC );
HBmp = CreateCompatibleBitmap( fromDC, Width, Height );
SelectObject( bmpDC, HBmp );
DeleteObject( HBmp );
BitBlt( bmpDC, 0, 0, Width, Height, fromDC, x, y, SRCCOPY );
}
//---------------------------------------------------------------------------
Win32Bitmap::Win32Bitmap( intf_thread_t *p_intf, Bitmap *c )
: Bitmap( p_intf, c )
{
HBITMAP HBuf;
// Copy attibutes
c->GetSize( Width, Height );
AlphaColor = c->GetAlphaColor();
// Copy bmpDC
bmpDC = CreateCompatibleDC( NULL );
HBuf = CreateCompatibleBitmap( bmpDC, Width, Height );
SelectObject( bmpDC, HBuf );
BitBlt( bmpDC, 0, 0, Width, Height, ( (Win32Bitmap *)c )->GetBmpDC(),
0, 0, SRCCOPY );
DeleteObject( HBuf );
}
//---------------------------------------------------------------------------
Win32Bitmap::~Win32Bitmap()
{
DeleteDC( bmpDC );
}
//---------------------------------------------------------------------------
void Win32Bitmap::DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest )
{
HDC destDC = ( (Win32Graphics *)dest )->GetImageHandle();
// New method, not available in win95
TransparentBlt( destDC, xRef, yRef, w, h, bmpDC, x, y, w, h, AlphaColor );
}
//---------------------------------------------------------------------------
bool Win32Bitmap::Hit( int x, int y)
{
unsigned int c = GetPixel( bmpDC, x, y );
if( c == AlphaColor || c == CLR_INVALID )
return false;
else
return true;
}
//---------------------------------------------------------------------------
int Win32Bitmap::GetBmpPixel( int x, int y )
{
return GetPixel( bmpDC, x, y );
}
//---------------------------------------------------------------------------
void Win32Bitmap::SetBmpPixel( int x, int y, int color )
{
SetPixelV( bmpDC, x, y, color );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_bitmap.h: Win32 implementation of the Bitmap class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_bitmap.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_WIN32_BITMAP
#define VLC_WIN32_BITMAP
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Bitmap;
class Graphics;
//---------------------------------------------------------------------------
class Win32Bitmap : public Bitmap
{
private:
HDC bmpDC;
public:
// Constructors
Win32Bitmap( intf_thread_t *p_intf, string FileName, int AColor );
Win32Bitmap( intf_thread_t *p_intf, Graphics *from, int x, int y,
int w, int h, int AColor );
Win32Bitmap( intf_thread_t *p_intf, Bitmap *c );
// Destructor
virtual ~Win32Bitmap();
virtual void DrawBitmap( int x, int y, int w, int h, int xRef, int yRef,
Graphics *dest );
virtual bool Hit( int x, int y );
virtual int GetBmpPixel( int x, int y );
virtual void SetBmpPixel( int x, int y, int color );
HDC GetBmpDC() { return bmpDC; }
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_dialog.cpp: Win32 implementation of some dialog boxes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_dialog.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- WIN32 -----------------------------------------------------------------
#define _WIN32_IE 0x0400 // Yes, i think it's a fucking kludge !
#include <windows.h>
#include <commdlg.h>
#include <commctrl.h>
#include <richedit.h>
//--- SKIN ------------------------------------------------------------------
#include "banks.h"
#include "dialog.h"
#include "os_dialog.h"
#include "skin_common.h"
#include "theme.h"
#include "os_theme.h"
#include "event.h"
#include "os_api.h"
//---------------------------------------------------------------------------
// Open file dialog box
//---------------------------------------------------------------------------
Win32OpenFileDialog::Win32OpenFileDialog( string title, bool multiselect ) :
OpenFileDialog( title, multiselect )
{
}
//---------------------------------------------------------------------------
Win32OpenFileDialog::~Win32OpenFileDialog()
{
}
//---------------------------------------------------------------------------
void Win32OpenFileDialog::AddFilter( string name, string type )
{
unsigned int i;
for( i = 0; i < name.length(); i++ )
Filter[FilterLength++] = name[i];
Filter[FilterLength++] = ' ';
Filter[FilterLength++] = '(';
for( i = 0; i < type.length(); i++ )
Filter[FilterLength++] = type[i];
Filter[FilterLength++] = ')';
Filter[FilterLength++] = '\0';
for( i = 0; i < type.length(); i++ )
Filter[FilterLength++] = type[i];
Filter[FilterLength++] = '\0';
// Ending null character if this filter is the last
Filter[FilterLength] = '\0';
}
//---------------------------------------------------------------------------
bool Win32OpenFileDialog::Open()
{
// Initailize dialog box
OPENFILENAME OpenFile;
memset( &OpenFile, 0, sizeof( OpenFile ) );
OpenFile.lStructSize = sizeof( OPENFILENAME );
OpenFile.hwndOwner = NULL;
OpenFile.lpstrFile = new char[MAX_PATH];
OpenFile.lpstrFile[0] = '\0';
OpenFile.nMaxFile = MAX_PATH;
if( MultiSelect )
{
OpenFile.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER;
}
else
{
OpenFile.Flags = OFN_EXPLORER;
}
OpenFile.lpstrTitle = Title.c_str();
OpenFile.lpstrFilter = Filter;
// Show dialog box
if( !GetOpenFileName( &OpenFile ) )
return false;
// Find files in string result
char * File = OpenFile.lpstrFile;
int i = OpenFile.nFileOffset;
int last = OpenFile.nFileOffset;
string path;
string tmpFile;
// If only one file has been selected
if( File[OpenFile.nFileOffset - 1] != '\0' )
{
FileList.push_back( (string)File );
}
// If multiple files have been selected
else
{
// Add \ if not present at end of path
if( File[OpenFile.nFileOffset - 2] != '\\' )
{
path = (string)File + '\\';
}
else
{
path = (string)File;
}
// Search filenames
while( true )
{
if( File[i] == '\0' )
{
if( i == last )
break;
else
{
// Add file
FileList.push_back( path + (string)&File[last] );
last = i + 1;
}
}
i++;
}
}
// Free memory
delete[] OpenFile.lpstrFile;
return true;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// CALLBACKs
//---------------------------------------------------------------------------
LRESULT CALLBACK LogWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
GWLP_USERDATA );
//msg_Err( p_intf, "Message to hwnd %i (%i)", (int)hwnd, (int)uMsg );
switch( uMsg )
{
case WM_PAINT:
PAINTSTRUCT Infos;
BeginPaint( hwnd , &Infos );
EndPaint( hwnd , &Infos );
return 0;
case WM_SIZE:
if( ( (Win32Theme *)p_intf->p_sys->p_theme )
->GetLogHandle() == hwnd )
{
SetWindowPos( ( (Win32LogWindow *)
p_intf->p_sys->p_theme->GetLogWindow() )->GetRichCtrl(),
0, 0, 0, LOWORD( lParam ), HIWORD( lParam ),
SWP_NOREDRAW|SWP_NOZORDER|SWP_NOMOVE );
}
return 0;
case WM_CLOSE:
OSAPI_PostMessage( NULL, VLC_LOG_SHOW, 0, (int)false );
p_intf->p_sys->p_theme->EvtBank->Get( "hide_log" )
->PostSynchroMessage();
return 0;
}
return DefWindowProc( hwnd, uMsg, wParam, lParam );
}
//---------------------------------------------------------------------------
DWORD CALLBACK LogWindowStream( DWORD_PTR dwCookie, LPBYTE pbBuff,
LONG cb, LONG *pcb )
{
int i;
char *text = (char *)( (string *)dwCookie )->c_str();
if( strlen( text ) < (unsigned int)cb )
{
*pcb = strlen( text );
for( i = 0; i < *pcb; i++ )
pbBuff[i] = text[i];
}
else
{
*pcb = cb;
for( i = 0; i < *pcb; i++ )
pbBuff[i] = text[i];
}
delete (string *)dwCookie;
return 0;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Win32 Log Window class
//---------------------------------------------------------------------------
Win32LogWindow::Win32LogWindow( intf_thread_t *_p_intf ) : LogWindow( _p_intf )
{
hWindow = NULL;
hRichCtrl = NULL;
// Define window class
WNDCLASS WindowClass;
WindowClass.style = CS_VREDRAW|CS_HREDRAW;
WindowClass.lpfnWndProc = (WNDPROC)LogWindowProc;
WindowClass.lpszClassName = "LogWindow";
WindowClass.lpszMenuName = NULL;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.hbrBackground = HBRUSH (COLOR_WINDOW);
WindowClass.hCursor = LoadCursor( NULL , IDC_ARROW );
WindowClass.hIcon = LoadIcon( GetModuleHandle( NULL ), "VLC_ICON" );
WindowClass.hInstance = GetModuleHandle( NULL );
// Register window class
RegisterClass( &WindowClass );
// Load library
LoadLibrary("riched20.dll");
// Init common controls
InitCommonControlsEx( NULL );
// Create log window
hWindow = CreateWindowEx( 0, "LogWindow", "Log Window",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 300, 0, 0,
GetModuleHandle( NULL ), NULL );
// Store with it a pointer to the interface thread
SetWindowLongPtr( hWindow, GWLP_USERDATA, (LONG_PTR)p_intf );
// Create rich text control
hRichCtrl = CreateWindowEx( 0, RICHEDIT_CLASS, NULL,
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|ES_READONLY|WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWindow, 0, GetModuleHandle( NULL ), 0);
// Change text format
SendMessage( hRichCtrl, EM_SETBKGNDCOLOR, 0, RGB(0,0,0) );
ChangeColor( RGB( 128, 128, 128 ) );
RtfHeader = "{\\rtf1 ";
Clear();
}
//---------------------------------------------------------------------------
Win32LogWindow::~Win32LogWindow()
{
DestroyWindow( hRichCtrl );
DestroyWindow( hWindow );
}
//---------------------------------------------------------------------------
void Win32LogWindow::Clear()
{
EDITSTREAM *Stream;
Stream = new EDITSTREAM;
string *buffer = new string( RtfHeader );
Stream->dwCookie = (DWORD)buffer;
Stream->dwError = 0;
Stream->pfnCallback = (EDITSTREAMCALLBACK)LogWindowStream;
SendMessage( hRichCtrl, EM_STREAMIN, SF_RTF, (LPARAM)Stream );
}
//---------------------------------------------------------------------------
void Win32LogWindow::AddLine( string line )
{
// Initialize stream
EDITSTREAM *Stream;
string *buffer = new string( RtfHeader + line + "\\par }" );
Stream = new EDITSTREAM;
Stream->dwCookie = (DWORD)buffer;
Stream->dwError = 0;
Stream->pfnCallback = (EDITSTREAMCALLBACK)LogWindowStream;
SendMessage( hRichCtrl, EM_STREAMIN, SF_RTF|SFF_SELECTION, (LPARAM)Stream );
SendMessage( hRichCtrl, WM_VSCROLL, SB_BOTTOM, 0 );
}
//---------------------------------------------------------------------------
void Win32LogWindow::ChangeColor( int color, bool bold )
{
CHARFORMAT format;
memset(&format, 0, sizeof(CHARFORMAT));
format.cbSize = sizeof(CHARFORMAT);
format.dwMask = bold ? CFM_COLOR|CFM_BOLD : CFM_COLOR;
format.dwEffects = bold ? CFE_BOLD : 0;
format.crTextColor = color;
SendMessage( hRichCtrl, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format );
}
//---------------------------------------------------------------------------
void Win32LogWindow::Show()
{
ShowWindow( hWindow, SW_SHOW );
Visible = true;
}
//---------------------------------------------------------------------------
void Win32LogWindow::Hide()
{
ShowWindow( hWindow, SW_HIDE );
Visible = false;
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_dialog.h: Win32 implementation of some dialog boxes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_dialog.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_DIALOG
#define VLC_SKIN_WIN32_DIALOG
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
class Win32OpenFileDialog : OpenFileDialog
{
private:
protected:
public:
// Constructors
Win32OpenFileDialog( string title, bool multiselect );
// Destructors
virtual ~Win32OpenFileDialog();
virtual void AddFilter( string name, string type );
virtual bool Open();
};
//---------------------------------------------------------------------------
class Win32LogWindow : LogWindow
{
private:
HWND hWindow;
HWND hRichCtrl;
string RtfHeader;
public:
// Constructors
Win32LogWindow( intf_thread_t *_p_intf );
// Destructors
virtual ~Win32LogWindow();
virtual void Clear();
virtual void AddLine( string line );
virtual void ChangeColor( int color, bool bold = false );
virtual void Show();
virtual void Hide();
// Specific methods
HWND GetRichCtrl() { return hRichCtrl; };
HWND GetWindow() { return hWindow; };
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_dragdrop.cpp: Win32 implementation of the drag & drop
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_dragdrop.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
#include <list>
using namespace std;
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- SKIN ------------------------------------------------------------------
#include "event.h"
#include "win32_dragdrop.h"
//---------------------------------------------------------------------------
Win32DropObject::Win32DropObject() : IDropTarget()
{
References = 1;
}
//---------------------------------------------------------------------------
Win32DropObject::~Win32DropObject()
{
}
//---------------------------------------------------------------------------
void Win32DropObject::HandleDrop( HDROP HDrop )
{
// Get number of files that are dropped into vlc
int NbFiles = DragQueryFile( (HDROP)HDrop, 0xFFFFFFFF, NULL, 0 );
// For each dropped files
for( int i = 0; i < NbFiles; i++ )
{
// Get the name of the file
int NameLength = DragQueryFile( (HDROP)HDrop, i, NULL, 0 ) + 1;
char *FileName = new char[NameLength];
DragQueryFile( (HDROP)HDrop, i, FileName, NameLength );
// The pointer must not be deleted here because it will be deleted
// in the VLC specific messages processing function
PostMessage( NULL, VLC_DROP, (WPARAM)FileName, 0 );
}
DragFinish( (HDROP)HDrop );
}
//---------------------------------------------------------------------------
STDMETHODIMP Win32DropObject::QueryInterface( REFIID iid, void FAR* FAR* ppv )
{
// Tell other objects about our capabilities
if( iid == IID_IUnknown || iid == IID_IDropTarget )
{
*ppv = this;
AddRef();
return S_OK;
}
*ppv = NULL;
return ResultFromScode( E_NOINTERFACE );
}
//---------------------------------------------------------------------------
STDMETHODIMP_(ULONG) Win32DropObject::AddRef()
{
return ++References;
}
//---------------------------------------------------------------------------
STDMETHODIMP_(ULONG) Win32DropObject::Release()
{
if( --References == 0 )
{
delete this;
return 0;
}
return References;
}
//---------------------------------------------------------------------------
STDMETHODIMP Win32DropObject::DragEnter( LPDATAOBJECT pDataObj,
DWORD grfKeyState, POINTL pt, DWORD *pdwEffect )
{
FORMATETC fmtetc;
fmtetc.cfFormat = CF_HDROP;
fmtetc.ptd = NULL;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.lindex = -1;
fmtetc.tymed = TYMED_HGLOBAL;
// Check that the drag source provides CF_HDROP,
// which is the only format we accept
if( pDataObj->QueryGetData( &fmtetc ) == S_OK )
*pdwEffect = DROPEFFECT_COPY;
else
*pdwEffect = DROPEFFECT_NONE;
return S_OK;
}
//---------------------------------------------------------------------------
STDMETHODIMP Win32DropObject::DragOver( DWORD grfKeyState, POINTL pt,
DWORD *pdwEffect )
{
// For visual feedback
// TODO
return S_OK;
}
//---------------------------------------------------------------------------
STDMETHODIMP Win32DropObject::DragLeave()
{
// Remove visual feedback
// TODO
return S_OK;
}
//---------------------------------------------------------------------------
STDMETHODIMP Win32DropObject::Drop( LPDATAOBJECT pDataObj, DWORD grfKeyState,
POINTL pt, DWORD *pdwEffect )
{
// User has dropped on us -- get the CF_HDROP data from drag source
FORMATETC fmtetc;
fmtetc.cfFormat = CF_HDROP;
fmtetc.ptd = NULL;
fmtetc.dwAspect = DVASPECT_CONTENT;
fmtetc.lindex = -1;
fmtetc.tymed = TYMED_HGLOBAL;
STGMEDIUM medium;
HRESULT hr = pDataObj->GetData( &fmtetc, &medium );
if( !FAILED(hr) )
{
// Grab a pointer to the data
HGLOBAL HFiles = medium.hGlobal;
HDROP HDrop = (HDROP)GlobalLock( HFiles );
// Notify the Form of the drop
HandleDrop( HDrop );
// Release the pointer to the memory
GlobalUnlock( HFiles );
// ReleaseStgMedium( &medium );
}
else
{
*pdwEffect = DROPEFFECT_NONE;
return hr;
}
return S_OK;
}
/*****************************************************************************
* win32_dragdrop.h: Win32 implementation of the drag & drop
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_dragdrop.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_DRAGDROP
#define VLC_SKIN_WIN32_DRAGDROP
//--- WIN32 -----------------------------------------------------------------
#include <shellapi.h>
#include <ole2.h>
//---------------------------------------------------------------------------
class Win32DropObject : public IDropTarget
{
public:
Win32DropObject();
virtual ~Win32DropObject();
protected:
// IUnknown methods
STDMETHOD(QueryInterface)( REFIID riid, void FAR* FAR* ppvObj );
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();
// IDropTarget methods
STDMETHOD(DragEnter)( LPDATAOBJECT pDataObj, DWORD grfKeyState,
POINTL pt, DWORD *pdwEffect );
STDMETHOD(DragOver)( DWORD grfKeyState, POINTL pt, DWORD *pdwEffect );
STDMETHOD(DragLeave)();
STDMETHOD(Drop)( LPDATAOBJECT pDataObj, DWORD grfKeyState,
POINTL pt, DWORD *pdwEffect );
private:
unsigned long References;
// Helper function
void HandleDrop( HDROP HDrop );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_event.cpp: Win32 implementation of the Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_event.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "event.h"
#include "os_event.h"
#include "window.h"
#include "os_window.h"
#include "theme.h"
#include "os_theme.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
// VLC Event
//---------------------------------------------------------------------------
Win32Event::Win32Event( intf_thread_t *p_intf, string Desc, string shortcut )
: Event( p_intf, Desc, shortcut )
{
hWnd = NULL;
}
//---------------------------------------------------------------------------
Win32Event::Win32Event( intf_thread_t *p_intf, HWND hwnd, unsigned int msg,
unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
{
hWnd = hwnd;
}
//---------------------------------------------------------------------------
Win32Event::Win32Event( intf_thread_t *p_intf, Window *win, unsigned int msg,
unsigned int par1, long par2 ) : Event( p_intf, msg, par1, par2 )
{
hWnd = ( (Win32Window *)win )->GetHandle();
}
//---------------------------------------------------------------------------
Win32Event::~Win32Event()
{
}
//---------------------------------------------------------------------------
bool Win32Event::SendEvent()
{
if( Message != VLC_NOTHING )
{
PostMessage( hWnd, Message, Param1, Param2 );
PostSynchroMessage();
return true;
}
return true;
}
//---------------------------------------------------------------------------
bool Win32Event::IsEqual( Event *evt )
{
Win32Event *WinEvt = (Win32Event *)evt;
return( WinEvt->GetWindow() == hWnd && WinEvt->GetMessage() == Message &&
WinEvt->GetParam1() == Param1 && WinEvt->GetParam2() == Param2 );
}
//---------------------------------------------------------------------------
void Win32Event::CreateOSEvent( string para1, string para2, string para3 )
{
// Find Parameters
switch( Message )
{
case WINDOW_MOVE:
hWnd = GetWindowFromName( para1 );
break;
}
}
//---------------------------------------------------------------------------
HWND Win32Event::GetWindowFromName( string name )
{
Win32Window *win = (Win32Window *)
p_intf->p_sys->p_theme->GetWindow( name );
if( win == NULL )
return NULL;
else
return win->GetHandle();
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_event.h: Win32 implementation of the Event class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_event.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_EVENT
#define VLC_SKIN_WIN32_EVENT
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Window;
//---------------------------------------------------------------------------
class Win32Event : Event
{
private:
HWND GetWindowFromName( string name );
HWND hWnd;
public:
// Constructor
Win32Event( intf_thread_t *p_intf, string Desc, string shortcut );
Win32Event( intf_thread_t *p_intf, HWND hwnd, unsigned int msg,
unsigned int par1, long par2 );
Win32Event( intf_thread_t *p_intf, Window *win, unsigned int msg,
unsigned int par1, long par2 );
// Destructor
virtual ~Win32Event();
// Event sending
virtual bool SendEvent();
// General operations on events
virtual void CreateOSEvent( string para1, string para2, string para3 );
virtual bool IsEqual( Event *evt );
// Getters
HWND GetWindow() { return hWnd; }
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_font.cpp: Win32 implementation of the Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_font.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "graphics.h"
#include "win32_graphics.h"
#include "font.h"
#include "win32_font.h"
//---------------------------------------------------------------------------
// Font object
//---------------------------------------------------------------------------
Win32Font::Win32Font( intf_thread_t *_p_intf, string fontname, int size,
int color, int weight, bool italic, bool underline )
: Font( _p_intf, fontname, size, color, weight, italic, underline )
{
}
//---------------------------------------------------------------------------
Win32Font::~Win32Font()
{
}
//---------------------------------------------------------------------------
void Win32Font::AssignWin32Font( HDC DC )
{
// Create font
HGDIOBJ fontObj = CreateFont(
-MulDiv( Size, GetDeviceCaps( DC, LOGPIXELSX ), 72 ),
0,
0, // angle of escapement
0, // base-line orientation angle
Weight, // font weight
Italic, // italic attribute flag
Underline, // underline attribute flag
0, // strikeout attribute flag
ANSI_CHARSET, // character set identifier
OUT_TT_PRECIS, // output precision
0, // clipping precision
ANTIALIASED_QUALITY, // output quality
0, // pitch and family
FontName.c_str() // pointer to typeface name string
);
// Assign font to DC
SelectObject( DC, fontObj );
// Free memory
DeleteObject( fontObj );
}
//---------------------------------------------------------------------------
void Win32Font::AssignFont( Graphics *dest )
{
HDC DC = ( (Win32Graphics *)dest )->GetImageHandle();
AssignWin32Font( DC );
}
//---------------------------------------------------------------------------
void Win32Font::GetSize( string text, int &w, int &h )
{
// Get device context of screen
HDC DeskDC = GetWindowDC( GetDesktopWindow() );
// Get size
LPRECT rect = new RECT;;
rect->left = 0;
rect->top = 0;
AssignWin32Font( DeskDC );
DrawText( DeskDC, text.c_str(), text.length(), rect, DT_CALCRECT);
w = rect->right - rect->left;
h = rect->bottom - rect->top;
// Release screen device context
ReleaseDC( GetDesktopWindow(), DeskDC );
}
//---------------------------------------------------------------------------
void Win32Font::GenericPrint( Graphics *dest, string text, int x, int y,
int w, int h, int align, int color )
{
HDC DC = ( (Win32Graphics *)dest )->GetImageHandle();
// Set boundaries
LPRECT r = new RECT;
r->left = x;
r->top = y;
r->right = x + w;
r->bottom = y + h;
// Get desktop Device Context
SetBkMode( DC, TRANSPARENT );
// Modify desktop attributes
AssignFont( dest );
// Change text color
SetTextColor( DC, color );
// Draw text on screen
DrawText( DC, text.c_str(), text.length(), r, align );
// Set text color to black to avoid graphic bugs
SetTextColor( DC, 0 );
// Free memory
delete r;
}
//---------------------------------------------------------------------------
void Win32Font::Print( Graphics *dest, string text, int x, int y, int w,
int h, int align )
{
GenericPrint( dest, text, x, y, w, h, align, Color );
}
//---------------------------------------------------------------------------
void Win32Font::PrintColor( Graphics *dest, string text, int x, int y, int w,
int h, int align, int color )
{
GenericPrint( dest, text, x, y, w, h, align, color );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_font.h: Win32 implementation of the Font class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_font.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_FONT
#define VLC_SKIN_WIN32_FONT
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//---------------------------------------------------------------------------
struct intf_thread_t;
class Graphics;
//---------------------------------------------------------------------------
class Win32Font : Font
{
private:
// Assign font to Device Context
virtual void AssignFont( Graphics *dest );
void AssignWin32Font( HDC DC );
// Helper function
virtual void GenericPrint( Graphics *dest, string text, int x, int y,
int w, int h, int align, int color );
public:
// Constructor
Win32Font( intf_thread_t *_p_intf, string fontname, int size, int color,
int weight, bool italic, bool underline );
// Destructor
virtual ~Win32Font();
// Get size of text
virtual void GetSize( string text, int &w, int &h );
// Draw text with boundaries
virtual void Print( Graphics *dest, string text, int x, int y, int w,
int h, int align );
virtual void PrintColor( Graphics *dest, string text, int x, int y,
int w, int h, int align, int color );
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_graphics.cpp: Win32 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_graphics.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- SKIN ------------------------------------------------------------------
#include "graphics.h"
#include "window.h"
#include "os_window.h"
#include "win32_graphics.h"
//---------------------------------------------------------------------------
// WIN32 GRAPHICS
//---------------------------------------------------------------------------
Win32Graphics::Win32Graphics( int w, int h, Window *from ) : Graphics( w, h )
{
HBITMAP HImage ;
Image = CreateCompatibleDC( NULL );
if( from != NULL )
{
HDC DC = GetWindowDC( ( (Win32Window *)from )->GetHandle() );
HImage = CreateCompatibleBitmap( DC, w, h );
ReleaseDC( ( (Win32Window *)from )->GetHandle(), DC );
}
else
{
HImage = CreateCompatibleBitmap( Image, w, h );
}
SelectObject( Image, HImage );
DeleteObject( HImage );
}
//---------------------------------------------------------------------------
Win32Graphics::~Win32Graphics()
{
DeleteDC( Image );
}
//---------------------------------------------------------------------------
void Win32Graphics::CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
int sx, int sy, int Flag )
{
BitBlt( Image, dx, dy, dw, dh, ( (Win32Graphics *)Src )->GetImageHandle(),
sx, sy, Flag );
}
//---------------------------------------------------------------------------
/*void Win32Graphics::CopyTo( Graphics *Dest, int dx, int dy, int dw, int dh,
int sx, int sy, int Flag )
{
BitBlt( ( (Win32Graphics *)Dest )->GetImageHandle(), dx, dy, dw, dh, Image,
sx, sy, Flag );
}*/
//---------------------------------------------------------------------------
void Win32Graphics::DrawRect( int x, int y, int w, int h, int color )
{
LPRECT r = new RECT;
HBRUSH Brush = CreateSolidBrush( color );
r->left = x;
r->top = y;
r->right = x + w;
r->bottom = y + h;
FillRect( Image, r, Brush );
DeleteObject( Brush );
delete r;
}
//---------------------------------------------------------------------------
void Win32Graphics::SetClipRegion( Region *rgn )
{
SelectClipRgn( Image, ( (Win32Region *)rgn )->GetHandle() );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// WIN32 REGION
//---------------------------------------------------------------------------
Win32Region::Win32Region()
{
Rgn = CreateRectRgn( 0, 0, 0, 0 );
}
//---------------------------------------------------------------------------
Win32Region::Win32Region( int x, int y, int w, int h )
{
Rgn = CreateRectRgn( x, y, x + w, y + h );
}
//---------------------------------------------------------------------------
Win32Region::~Win32Region()
{
DeleteObject( Rgn );
}
//---------------------------------------------------------------------------
void Win32Region::AddPoint( int x, int y )
{
AddRectangle( x, y, x + 1, y + 1 );
}
//---------------------------------------------------------------------------
void Win32Region::AddRectangle( int x, int y, int w, int h )
{
HRGN Buffer;
Buffer = CreateRectRgn( x, y, x + w, y + h );
CombineRgn( Rgn, Buffer, Rgn, 0x2 );
DeleteObject( Buffer );
}
//---------------------------------------------------------------------------
void Win32Region::AddElipse( int x, int y, int w, int h )
{
HRGN Buffer;
Buffer = CreateEllipticRgn( x, y, x + w, y + h );
CombineRgn( Rgn, Buffer, Rgn, 0x2 );
DeleteObject( Buffer );
}
//---------------------------------------------------------------------------
void Win32Region::Move( int x, int y )
{
OffsetRgn( Rgn, x, y );
}
//---------------------------------------------------------------------------
bool Win32Region::Hit( int x, int y )
{
return PtInRegion( Rgn, x, y );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_graphics.h: Win32 implementation of the Graphics and Region classes
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_graphics.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_GRAPHICS
#define VLC_SKIN_WIN32_GRAPHICS
//---------------------------------------------------------------------------
class Region;
class Window;
//---------------------------------------------------------------------------
class Win32Graphics : public Graphics
{
private:
int Width;
int Height;
HDC Image;
public:
// Constructor
Win32Graphics( int w, int h, Window *from = NULL );
// Destructor
virtual ~Win32Graphics();
// Drawing methods
virtual void CopyFrom( int dx, int dy, int dw, int dh, Graphics *Src,
int sx, int sy, int Flag );
//virtual void CopyTo( Graphics *Dest, int dx, int dy, int dw, int dh,
// int sx, int sy, int Flag );
virtual void DrawRect( int x, int y, int w, int h, int color );
// Clipping methods
virtual void SetClipRegion( Region *rgn );
// Specific win32 methods
HDC GetImageHandle() { return Image; };
};
//---------------------------------------------------------------------------
class Win32Region : public Region
{
private:
HRGN Rgn;
public:
// Constructor
Win32Region();
Win32Region( int x, int y, int w, int h );
// Destructor
~Win32Region();
// Modify region
virtual void AddPoint( int x, int y );
virtual void AddRectangle( int x, int y, int w, int h );
virtual void AddElipse( int x, int y, int w, int h );
virtual void Move( int x, int y );
virtual bool Hit( int x, int y );
// Specific win32 methods
HRGN GetHandle() { return Rgn; };
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_run.cpp:
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_run.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "event.h"
#include "os_event.h"
#include "banks.h"
#include "window.h"
#include "os_window.h"
#include "theme.h"
#include "os_theme.h"
#include "skin_common.h"
#include "vlcproc.h"
//---------------------------------------------------------------------------
// Specific method
//---------------------------------------------------------------------------
bool IsVLCEvent( unsigned int msg );
int SkinManage( intf_thread_t *p_intf );
//---------------------------------------------------------------------------
// REFRESH TIMER CALLBACK
//---------------------------------------------------------------------------
void CALLBACK RefreshTimer( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
GWLP_USERDATA );
SkinManage( p_intf );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Win32 interface
//---------------------------------------------------------------------------
void OSRun( intf_thread_t *p_intf )
{
VlcProc *Proc = new VlcProc( p_intf );
MSG msg;
list<Window *>::const_iterator win;
Event *ProcessEvent;
int KeyModifier = 0;
// Create refresh timer
SetTimer( ((OSTheme *)p_intf->p_sys->p_theme)->GetParentWindow(), 42, 200,
(TIMERPROC)RefreshTimer );
// Compute windows message list
while( GetMessage( &msg, NULL, 0, 0 ) )
{
// Translate keys
TranslateMessage( &msg );
// Create event
ProcessEvent = (Event *)new OSEvent( p_intf, msg.hwnd, msg.message,
msg.wParam, msg.lParam );
/*****************************
* Process keyboard shortcuts *
*****************************/
if( msg.message == WM_KEYUP )
{
// If key is CTRL
if( msg.wParam == 17 )
KeyModifier = 0;
else if( KeyModifier == 0 )
p_intf->p_sys->p_theme->EvtBank->TestShortcut(
msg.wParam, KeyModifier );
}
else if( msg.message == WM_KEYDOWN )
{
// If key is control
if( msg.wParam == 17 )
KeyModifier = 2;
else if( KeyModifier > 0 )
p_intf->p_sys->p_theme->EvtBank->TestShortcut(
msg.wParam, KeyModifier );
}
else if( msg.message == WM_SYSKEYDOWN )
{
// If key is ALT
if( msg.wParam == 18 )
KeyModifier = 1;
}
else if( msg.message == WM_SYSKEYUP )
{
// If key is a system key
KeyModifier = 0;
}
/************************
* Process timer message *
************************/
else if( msg.message == WM_TIMER )
{
DispatchMessage( &msg );
}
/***********************
* VLC specific message *
***********************/
else if( IsVLCEvent( msg.message ) )
{
if( !Proc->EventProc( ProcessEvent ) )
break; // Exit VLC !
}
/**********************
* Broadcsated message *
**********************/
else if( msg.hwnd == NULL )
{
for( win = p_intf->p_sys->p_theme->WindowList.begin();
win != p_intf->p_sys->p_theme->WindowList.end(); win++ )
{
(*win)->ProcessEvent( ProcessEvent );
}
}
/***********************
* Process window event *
***********************/
else
{
DispatchMessage( &msg );
}
// Delete event
ProcessEvent->DestructParameters();
delete (OSEvent *)ProcessEvent;
// Check if vlc is closing
Proc->IsClosing();
}
}
//---------------------------------------------------------------------------
bool IsVLCEvent( unsigned int msg )
{
return( msg > VLC_MESSAGE && msg < VLC_WINDOW );
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_theme.cpp: Win32 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_theme.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "banks.h"
#include "window.h"
#include "os_window.h"
#include "event.h"
#include "os_event.h"
#include "theme.h"
#include "os_theme.h"
#include "dialog.h"
#include "os_dialog.h"
#include "vlcproc.h"
#include "skin_common.h"
//---------------------------------------------------------------------------
void SkinManage( intf_thread_t *p_intf );
//---------------------------------------------------------------------------
// Win32 interface
//---------------------------------------------------------------------------
LRESULT CALLBACK Win32Proc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// Get pointer to thread info
intf_thread_t *p_intf = (intf_thread_t *)GetWindowLongPtr( hwnd,
GWLP_USERDATA );
// If doesn't exist, treat windows message normally
if( p_intf == NULL )
return DefWindowProc( hwnd, uMsg, wParam, lParam );
// Create event to dispatch in windows
Event *evt = (Event *)new OSEvent( p_intf, hwnd, uMsg, wParam, lParam );
// Find window matching with hwnd
list<Window *>::const_iterator 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() )
{
// Send event and check if processed
if( (*win)->ProcessEvent( evt ) )
{
delete (OSEvent *)evt;
return 0;
}
else
{
break;
}
}
}
delete (OSEvent *)evt;
// If Window is parent window
if( hwnd == ( (Win32Theme *)p_intf->p_sys->p_theme )->GetParentWindow() )
{
if( uMsg == WM_SYSCOMMAND )
{
if( (Event *)wParam != NULL )
( (Event *)wParam )->SendEvent();
return 0;
}
else if( uMsg == WM_RBUTTONDOWN && wParam == 42 &&
lParam == WM_RBUTTONDOWN )
{
int x, y;
OSAPI_GetMousePos( x, y );
TrackPopupMenu(
( (Win32Theme *)p_intf->p_sys->p_theme )->GetSysMenu(),
0, x, y, 0, hwnd, NULL );
}
}
// If closing parent window
if( uMsg == WM_CLOSE )
{
OSAPI_PostMessage( NULL, VLC_HIDE, VLC_QUIT, 0 );
return 0;
}
// If hwnd does not match any window or message not processed
return DefWindowProc( hwnd, uMsg, wParam, lParam );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// THEME
//---------------------------------------------------------------------------
Win32Theme::Win32Theme( intf_thread_t *_p_intf ) : Theme( _p_intf )
{
// Get instance handle
hinst = GetModuleHandle( NULL );
// Create window class
WNDCLASS SkinWindow;
SkinWindow.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS;
SkinWindow.lpfnWndProc = (WNDPROC) Win32Proc;
SkinWindow.lpszClassName = "SkinWindow";
SkinWindow.lpszMenuName = NULL;
SkinWindow.cbClsExtra = 0;
SkinWindow.cbWndExtra = 0;
SkinWindow.hbrBackground = HBRUSH (COLOR_WINDOW);
SkinWindow.hCursor = LoadCursor( NULL , IDC_ARROW );
SkinWindow.hIcon = LoadIcon( hinst, "VLC_ICON" );
SkinWindow.hInstance = hinst;
if( !RegisterClass( &SkinWindow ) )
{
WNDCLASS wndclass;
// Check why it failed. If it's because the class already exists
// then fine, otherwise return with an error.
if( !GetClassInfo( hinst, "SkinWindow", &wndclass ) )
{
msg_Err( p_intf, "Cannot register window class" );
return;
}
}
//Initialize value
ParentWindow = NULL;
}
//---------------------------------------------------------------------------
Win32Theme::~Win32Theme()
{
// Unregister the window class if needed
WNDCLASS wndclass;
if( GetClassInfo( hinst, "SkinWindow", &wndclass ) )
{
UnregisterClass( "SkinWindow", hinst );
}
if( GetClassInfo( hinst, "LogWindow", &wndclass ) )
{
UnregisterClass( "LogWindow", hinst );
}
if( GetClassInfo( hinst, "ParentWindow", &wndclass ) )
{
UnregisterClass( "ParentWindow", hinst );
}
// Delete tray icon if exists
if( ShowInTray )
{
Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
}
// Destroy parent window
if( ParentWindow )
{
DestroyWindow( ParentWindow );
}
}
//---------------------------------------------------------------------------
void Win32Theme::OnLoadTheme()
{
// Create window class
WNDCLASS ParentClass;
ParentClass.style = CS_VREDRAW|CS_HREDRAW|CS_DBLCLKS;
ParentClass.lpfnWndProc = (WNDPROC) Win32Proc;
ParentClass.lpszClassName = "ParentWindow";
ParentClass.lpszMenuName = NULL;
ParentClass.cbClsExtra = 0;
ParentClass.cbWndExtra = 0;
ParentClass.hbrBackground = HBRUSH (COLOR_WINDOW);
ParentClass.hCursor = LoadCursor( NULL , IDC_ARROW );
ParentClass.hIcon = LoadIcon( hinst, "VLC_ICON" );
ParentClass.hInstance = hinst;
// register class and check it
if( !RegisterClass( &ParentClass ) )
{
WNDCLASS wndclass;
// Check why it failed. If it's because the class already exists
// then fine, otherwise return with an error.
if( !GetClassInfo( hinst, "ParentWindow", &wndclass ) )
{
msg_Err( p_intf, "Cannot register window class" );
return;
}
}
// Create Window
ParentWindow = CreateWindowEx( WS_EX_LAYERED|WS_EX_TOOLWINDOW,
"ParentWindow", "VLC Media Player",
WS_SYSMENU,
0, 0, 0, 0, 0, 0, hinst, NULL );
// Store with it a pointer to the interface thread
SetWindowLongPtr( ParentWindow, GWLP_USERDATA, (LONG_PTR)p_intf );
ShowWindow( ParentWindow, SW_SHOW );
// System tray icon
TrayIcon.cbSize = sizeof( PNOTIFYICONDATA );
TrayIcon.hWnd = ParentWindow;
TrayIcon.uID = 42;
TrayIcon.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;
TrayIcon.uCallbackMessage = WM_RBUTTONDOWN;
TrayIcon.hIcon = LoadIcon( hinst, "VLC_ICON" );
strcpy( TrayIcon.szTip, "VLC Media Player" );
// Remove default entries from system menu popup
SysMenu = GetSystemMenu( ParentWindow, false );
RemoveMenu( SysMenu, SC_RESTORE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_MOVE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_SIZE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_MINIMIZE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_MAXIMIZE, MF_BYCOMMAND );
RemoveMenu( SysMenu, SC_CLOSE, MF_BYCOMMAND );
RemoveMenu( SysMenu, 0, MF_BYPOSITION );
// The create menu
CreateSystemMenu();
}
//---------------------------------------------------------------------------
void Win32Theme::AddSystemMenu( string name, Event *event )
{
if( name == "SEPARATOR" )
{
AppendMenu( SysMenu, MF_SEPARATOR, 0, NULL );
}
else
{
AppendMenu( SysMenu, MF_STRING, (unsigned int)event,
(char *)name.c_str() );
}
}
//---------------------------------------------------------------------------
void Win32Theme::ChangeClientWindowName( string name )
{
SetWindowText( ParentWindow, name.c_str() );
}
//---------------------------------------------------------------------------
void Win32Theme::AddWindow( string name, int x, int y, bool visible,
int fadetime, int alpha, int movealpha, bool dragdrop )
{
HWND hwnd;
hwnd = CreateWindowEx( WS_EX_LAYERED|WS_EX_TOOLWINDOW,
"SkinWindow", name.c_str(), WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, ParentWindow, 0, hinst, NULL );
if( !hwnd )
{
msg_Err( p_intf, "CreateWindow failed" );
return;
}
SetWindowLongPtr( hwnd, GWLP_USERDATA, (LONG_PTR)p_intf );
WindowList.push_back( (Window *)new OSWindow( p_intf, hwnd, x, y, visible,
fadetime, alpha, movealpha, dragdrop ) ) ;
}
//---------------------------------------------------------------------------
HWND Win32Theme::GetLogHandle()
{
if( Log != NULL )
return ( (Win32LogWindow *)Log )->GetWindow();
else
return NULL;
}
//---------------------------------------------------------------------------
void Win32Theme::ChangeTray()
{
if( ShowInTray )
{
Shell_NotifyIcon( NIM_DELETE, &TrayIcon );
ShowInTray = false;
}
else
{
Shell_NotifyIcon( NIM_ADD, &TrayIcon );
ShowInTray = true;
}
}
//---------------------------------------------------------------------------
void Win32Theme::ChangeTaskbar()
{
if( ShowInTaskbar )
{
ShowWindow( ParentWindow, SW_HIDE );
SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
WS_EX_LAYERED|WS_EX_TOOLWINDOW );
ShowWindow( ParentWindow, SW_SHOW );
ShowInTaskbar = false;
}
else
{
ShowWindow( ParentWindow, SW_HIDE );
SetWindowLongPtr( ParentWindow, GWL_EXSTYLE,
WS_EX_LAYERED|WS_EX_APPWINDOW );
ShowWindow( ParentWindow, SW_SHOW );
ShowInTaskbar = true;
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_theme.h: Win32 implementation of the Theme class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_theme.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_THEME
#define VLC_SKIN_WIN32_THEME
//--- GENERAL ---------------------------------------------------------------
#include <string>
using namespace std;
//--- WIN32 -----------------------------------------------------------------
#include <shellapi.h>
//---------------------------------------------------------------------------
struct intf_thread_t;
class Window;
class EventBank;
class BitmapBank;
class FontBank;
class LogWindow;
//---------------------------------------------------------------------------
class Win32Theme : public Theme
{
protected:
// Handles
HINSTANCE hinst;
HWND ParentWindow;
// System tray icon
NOTIFYICONDATA TrayIcon;
HMENU SysMenu;
public:
// Constructor
Win32Theme( intf_thread_t *_p_intf );
virtual void OnLoadTheme();
// Destructor
virtual ~Win32Theme();
// Specific windows methods
HINSTANCE getInstance() { return hinst; }
HWND GetLogHandle();
HWND GetParentWindow() { return ParentWindow; }
// !!!
virtual void AddWindow( string name, int x, int y, bool visible,
int fadetime, int alpha, int movealpha, bool dragdrop );
virtual void ChangeClientWindowName( string name );
// Taskbar && system tray
virtual void AddSystemMenu( string name, Event *event );
virtual void ChangeTray();
virtual void ChangeTaskbar();
HMENU GetSysMenu() { return SysMenu; }
};
//---------------------------------------------------------------------------
#endif
/*****************************************************************************
* win32_window.cpp: Win32 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_window.cpp,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
//--- GENERAL ---------------------------------------------------------------
//#include <math.h>
//--- VLC -------------------------------------------------------------------
#include <vlc/intf.h>
//--- WIN32 -----------------------------------------------------------------
#include <windows.h>
//--- SKIN ------------------------------------------------------------------
#include "os_api.h"
#include "anchor.h"
#include "generic.h"
#include "window.h"
#include "os_window.h"
#include "event.h"
#include "os_event.h"
#include "graphics.h"
#include "os_graphics.h"
#include "skin_common.h"
#include "theme.h"
//---------------------------------------------------------------------------
// Fading API
//---------------------------------------------------------------------------
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
typedef BOOL (WINAPI *SLWA)(HWND, COLORREF, BYTE, DWORD);
HMODULE hModule = LoadLibrary( "user32.dll" );
SLWA SetLayeredWindowAttributes =
(SLWA)GetProcAddress( hModule, "SetLayeredWindowAttributes" );
//---------------------------------------------------------------------------
// Skinable Window
//---------------------------------------------------------------------------
Win32Window::Win32Window( intf_thread_t *p_intf, HWND hwnd, int x, int y,
bool visible, int transition, int normalalpha, int movealpha,
bool dragdrop )
: Window( p_intf, x, y, visible, transition, normalalpha, movealpha,
dragdrop )
{
// Set handles
hWnd = hwnd;
// Set position parameters
CursorPos = new POINT;
WindowPos = new POINT;
// Create Tool Tip Window
ToolTipWindow = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, 0, GetModuleHandle( NULL ), 0);
// Create Tool Tip infos
ToolTipInfo.cbSize = sizeof(TOOLINFO);
ToolTipInfo.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
ToolTipInfo.hwnd = hWnd;
ToolTipInfo.hinst = GetModuleHandle( NULL );
ToolTipInfo.uId = (unsigned int)hWnd;
ToolTipInfo.lpszText = NULL;
ToolTipInfo.rect.left = ToolTipInfo.rect.top = 0;
ToolTipInfo.rect.right = ToolTipInfo.rect.bottom = 0;
SendMessage( ToolTipWindow, TTM_ADDTOOL, 0,
(LPARAM)(LPTOOLINFO) &ToolTipInfo );
// Drag & drop
if( DragDrop )
{
// Initialize the OLE library
OleInitialize( NULL );
DropTarget = (LPDROPTARGET) new Win32DropObject();
// register the listview as a drop target
RegisterDragDrop( hWnd, DropTarget );
}
}
//---------------------------------------------------------------------------
Win32Window::~Win32Window()
{
delete CursorPos;
delete WindowPos;
if( hWnd != NULL )
{
DestroyWindow( hWnd );
}
if( ToolTipWindow != NULL )
{
DestroyWindow( ToolTipWindow );
}
if( DragDrop )
{
// Remove the listview from the list of drop targets
RevokeDragDrop( hWnd );
DropTarget->Release();
// Uninitialize the OLE library
OleUninitialize();
}
}
//---------------------------------------------------------------------------
void Win32Window::OSShow( bool show )
{
if( show )
{
ShowWindow( hWnd, SW_SHOW );
}
else
{
ShowWindow( hWnd, SW_HIDE );
}
}
//---------------------------------------------------------------------------
bool Win32Window::ProcessOSEvent( Event *evt )
{
HDC DC;
unsigned int msg = evt->GetMessage();
unsigned int p1 = evt->GetParam1();
int p2 = evt->GetParam2();
switch( msg )
{
case WM_PAINT:
PAINTSTRUCT Infos;
DC = BeginPaint( hWnd , &Infos );
EndPaint( hWnd , &Infos );
RefreshFromImage( 0, 0, Width, Height );
return true;
case WM_MOUSEMOVE:
if( p1 == MK_LBUTTON )
MouseMove( LOWORD( p2 ), HIWORD( p2 ), 1 );
else if( p1 == MK_RBUTTON )
MouseMove( LOWORD( p2 ), HIWORD( p2 ), 2 );
else
MouseMove( LOWORD( p2 ), HIWORD( p2 ), 0 );
return true;
case WM_LBUTTONDOWN:
SetCapture( hWnd );
MouseDown( LOWORD( p2 ), HIWORD( p2 ), 1 );
return true;
case WM_LBUTTONUP:
ReleaseCapture();
MouseUp( LOWORD( p2 ), HIWORD( p2 ), 1 );
return true;
case WM_RBUTTONDOWN:
MouseDown( LOWORD( p2 ), HIWORD( p2 ), 2 );
return true;
case WM_RBUTTONUP:
MouseUp( LOWORD( p2 ), HIWORD( p2 ), 2 );
return true;
case WM_LBUTTONDBLCLK:
MouseDblClick( LOWORD( p2 ), HIWORD( p2 ), 1 );
return true;
default:
return false;
}
}
//---------------------------------------------------------------------------
void Win32Window::SetTransparency( int Value )
{
if( Value > -1 )
Alpha = Value;
SetLayeredWindowAttributes( hWnd, 0, Alpha, LWA_ALPHA | LWA_COLORKEY );
UpdateWindow( hWnd );
}
//---------------------------------------------------------------------------
void Win32Window::RefreshFromImage( int x, int y, int w, int h )
{
// Initialize painting
HDC DC = GetWindowDC( hWnd );
// Draw image on window
BitBlt( DC, x, y, w, h, ( (Win32Graphics *)Image )->GetImageHandle(),
x, y, SRCCOPY );
// Release window device context
ReleaseDC( hWnd, DC );
}
//---------------------------------------------------------------------------
void Win32Window::WindowManualMove()
{
// Get mouse cursor position
LPPOINT NewPos = new POINT;
GetCursorPos( NewPos );
// Move window and chek for magnetism
p_intf->p_sys->p_theme->MoveSkinMagnet( this,
WindowPos->x + NewPos->x - CursorPos->x,
WindowPos->y + NewPos->y - CursorPos->y );
// Free memory
delete[] NewPos;
}
//---------------------------------------------------------------------------
void Win32Window::WindowManualMoveInit()
{
GetCursorPos( CursorPos );
WindowPos->x = Left;
WindowPos->y = Top;
}
//---------------------------------------------------------------------------
void Win32Window::Move( int left, int top )
{
Left = left;
Top = top;
//SetWindowPos( hWnd, HWND_TOP, Left, Top, Width, Height,
// SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER );
MoveWindow( hWnd, Left, Top, Width, Height, false );
}
//---------------------------------------------------------------------------
void Win32Window::Size( int width, int height )
{
Width = width;
Height = height;
SetWindowPos( hWnd, HWND_TOP, Left, Top, Width, Height,
SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER );
}
//---------------------------------------------------------------------------
void Win32Window::ChangeToolTipText( string text )
{
if( text == "none" )
{
if( ToolTipText != "none" )
{
ToolTipText = "none";
ToolTipInfo.lpszText = NULL;
SendMessage( ToolTipWindow, TTM_ACTIVATE, 0 , 0 );
}
}
else
{
if( text != ToolTipText )
{
ToolTipText = text;
ToolTipInfo.lpszText = (char *)ToolTipText.c_str();
SendMessage( ToolTipWindow, TTM_ACTIVATE, 1 , 0 );
SendMessage( ToolTipWindow, TTM_UPDATETIPTEXT, 0,
(LPARAM)(LPTOOLINFO)&ToolTipInfo );
}
}
}
//---------------------------------------------------------------------------
/*****************************************************************************
* win32_window.h: Win32 implementation of the Window class
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: win32_window.h,v 1.1 2003/03/18 02:21:47 ipkiss Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
* USA.
*****************************************************************************/
#ifndef VLC_SKIN_WIN32_WIN
#define VLC_SKIN_WIN32_WIN
//--- WIN32 -----------------------------------------------------------------
#include <commctrl.h>
//---------------------------------------------------------------------------
class Graphics;
class Event;
//---------------------------------------------------------------------------
class Win32Window : public Window
{
private:
// General parameters
HWND hWnd;
LPPOINT CursorPos;
LPPOINT WindowPos;
// Tooltip texts
HWND ToolTipWindow;
TOOLINFO ToolTipInfo;
// Drag & drop
LPDROPTARGET DropTarget;
public:
// Cosntructors
Win32Window( intf_thread_t *_p_intf, HWND hwnd, int x, int y,
bool visible, int transition, int normalalpha, int movealpha,
bool dragdrop );
// Destructors
virtual ~Win32Window();
// Event processing
virtual bool ProcessOSEvent( Event *evt );
// Window graphic aspect
virtual void OSShow( bool show );
virtual void RefreshFromImage( int x, int y, int w, int h );
virtual void SetTransparency( int Value = -1 );
virtual void WindowManualMove();
virtual void WindowManualMoveInit();
// Window methods
virtual void Move( int left, int top );
virtual void Size( int width, int height );
// Specific win32 methods
HWND GetHandle() {return hWnd; };
// Tooltip texts
virtual void ChangeToolTipText( string text );
};
//---------------------------------------------------------------------------
#endif
#! /bin/sh
## toolbox for the VLC media player
## $Id: toolbox,v 1.17 2003/03/18 01:54:40 sam Exp $
## $Id: toolbox,v 1.18 2003/03/18 02:21:47 ipkiss Exp $
##
## Authors: Samuel Hocevar <sam@zoy.org>
......@@ -26,6 +26,7 @@ recognized flags are:
--update-includes [BUILTINS] generate various include files
--update-glade generate and fix Glade code
--update-glade2 generate and fix Glade 2 code
--update-flexml generate and fix flexml and flex code
EOF
exit 1
}
......@@ -62,6 +63,9 @@ case "$1" in
--update-includes)
action=includes
;;
--update-flexml)
action=flexml
;;
--update-glade|--fix-glade)
action=glade
;;
......@@ -471,3 +475,17 @@ then
exit 0
fi
##
## Fix flexml-generated files
##
if test "${action}" = "flexml"
then
cd modules/gui/skins/parser
flexml -SH -a skin.act skin.dtd
# comment the dummy main function
file=skin.c
sed 's@int main@//int main@' < $file > $file.$$.bak
mv -f $file.$$.bak $file
flex -oflex.c -BLs skin.l
fi
......
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