Commit 1628f2f2 authored by Cyril Deguet's avatar Cyril Deguet

* all: replaced the flex parser by the libxml one

* src/window_manager.cpp: improved the raise window algorithm
* src/tooltip.cpp: fixed a segfault after changing a theme
parent b6abc4fa
......@@ -67,16 +67,12 @@ SOURCES_skins2 = \
parser/builder.cpp \
parser/builder.hpp \
parser/builder_data.hpp \
parser/flex.c \
parser/interpreter.cpp \
parser/interpreter.hpp \
parser/parser_context.hpp \
parser/skin.c \
parser/skin.h \
parser/skin_parser.cpp \
parser/skin_parser.hpp \
parser/xmlparser.cpp \
parser/xmlparser.hpp \
parser/wrappers.cpp \
parser/wrappers.h \
\
src/anchor.cpp \
src/anchor.hpp \
......
......@@ -2,7 +2,7 @@
* builder.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: builder.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
* $Id: builder.cpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -47,7 +47,7 @@
#include "../utils/var_text.hpp"
Builder::Builder( intf_thread_t *pIntf, BuilderData &rData):
Builder::Builder( intf_thread_t *pIntf, const BuilderData &rData):
SkinObject( pIntf ), m_rData( rData ), m_pTheme( NULL )
{
}
......
......@@ -2,7 +2,7 @@
* builder.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: builder.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
* $Id: builder.hpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -47,7 +47,7 @@ class Theme;
class Builder: public SkinObject
{
public:
Builder( intf_thread_t *pIntf, BuilderData &rData );
Builder( intf_thread_t *pIntf, const BuilderData &rData );
virtual ~Builder() {}
/// Create a Theme object, ready to use.
......@@ -59,7 +59,7 @@ class Builder: public SkinObject
private:
/// Data from the XML
BuilderData &m_rData;
const BuilderData &m_rData;
/// Theme under construction
Theme *m_pTheme;
......
......@@ -2,7 +2,7 @@
* builder_data.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: builder_data.hpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
* $Id: builder_data.hpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -32,7 +32,6 @@ using namespace std;
#include <vlc/vlc.h>
#include <list>
#include <map>
#include <string>
/// Structure for mapping data from XML file
......
This diff is collapsed.
flexml -SH -a skin.act skin.dtd
sed -e 's/\([SE]Tag_.*\)(void)/\1(void *pContext)/' \
-e 's/int main().*//' skin.c > skin.c.new && mv -f skin.c.new skin.c
sed -e 's/\([SE]Tag_.*\)(void)/\1(void*)/' \
-e 's/extern int yylex(void)/extern int yylex(void*)/' \
-e 's/\/\* XML processor entry point. \*\//#define YY_DECL int yylex(void *pContext)/' skin.h > skin.h.new && mv -f skin.h.new skin.h
flex -oflex.c -B -L skin.l
sed -e 's/\([SE]Tag_[^()]*\)()/\1(pContext)/g' flex.c > flex.c.new && mv -f flex.c.new flex.c
<!-- vim: set filetype=xml : -->
<!DOCTYPE actions SYSTEM "flexml-act.dtd">
<actions>
<top>
<![CDATA[
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "parser/wrappers.h"
]]>
</top>
<start tag="Bitmap">
<![CDATA[
AddBitmap( pContext, {id}, {file}, {alphacolor} );
]]>
</start>
<start tag="Event">
<![CDATA[
AddEvent( pContext, {id}, {event}, {key} );
]]>
</start>
<start tag="Font">
<![CDATA[
AddFont( pContext, {id}, {font}, {size}, {color},
{italic}, {underline} );
]]>
</start>
<start tag="ThemeInfo">
<![CDATA[
AddThemeInfo( pContext, {name}, {author}, {email}, {webpage} );
]]>
</start>
<start tag="Window">
<![CDATA[
StartWindow( pContext, {id}, {x}, {y}, {visible}, {dragdrop},
{playondrop} );
]]>
</start>
<end tag="Window">
<![CDATA[
EndWindow( pContext );
]]>
</end>
<start tag="Layout">
<![CDATA[
StartLayout( pContext, {id}, {width}, {height}, {minwidth},
{maxwidth}, {minheight}, {maxheight} );
]]>
</start>
<end tag="Layout">
<![CDATA[
EndLayout( pContext );
]]>
</end>
<start tag="Group">
<![CDATA[
StartGroup( pContext, {x}, {y} );
]]>
</start>
<end tag="Group">
<![CDATA[
EndGroup( pContext );
]]>
</end>
<start tag="Anchor">
<![CDATA[
AddAnchor( pContext, {x}, {y}, {range}, {priority} );
]]>
</start>
<start tag="Image">
<![CDATA[
AddImage( pContext, {id}, {visible}, {x}, {y}, {lefttop},
{rightbottom}, {image}, {onclick}, {help} );
]]>
</start>
<start tag="Rectangle">
<![CDATA[
AddRectangle( pContext, {id}, {visible}, {x}, {y}, {w}, {h},
{color}, {onclick}, {help} );
]]>
</start>
<start tag="Button">
<![CDATA[
AddButton( pContext, {id}, {x}, {y}, {lefttop}, {rightbottom},
{up}, {down}, {over}, {action}, {tooltiptext}, {help} );
]]>
</start>
<start tag="CheckBox">
<![CDATA[
AddCheckBox( pContext, {id},
{x}, {y}, {lefttop}, {rightbottom},
{up1}, {down1}, {over1}, {up2}, {down2}, {over2},
{state}, {action1}, {action2}, {tooltiptext1},
{tooltiptext2}, {help} );
]]>
</start>
<start tag="Slider">
<![CDATA[
AddSlider( pContext, {id}, {visible}, {x}, {y},
{lefttop}, {rightbottom}, {up}, {down},
{over}, {points}, {thickness}, {value}, {tooltiptext},
{help} );
]]>
</start>
<start tag="RadialSlider">
<![CDATA[
AddRadialSlider( pContext, {id}, {visible}, {x}, {y},
{lefttop}, {rightbottom}, {sequence}, {nbimages},
{minangle}, {maxangle}, {value}, {tooltiptext},
{help} );
]]>
</start>
<start tag="Text">
<![CDATA[
AddText( pContext, {id}, {visible}, {x}, {y}, {text}, {font},
{align}, {width}, {display}, {scroll}, {scrollspace},
{help} );
]]>
</start>
<start tag="Playlist">
<![CDATA[
AddPlaylist( pContext, {id}, {visible}, {x}, {y}, {width},
{height}, {lefttop}, {rightbottom}, {font}, {var},
{fgcolor}, {playcolor}, {bgcolor1}, {bgcolor2},
{selcolor}, {help} );
]]>
</start>
<end tag="Playlist">
<![CDATA[
AddPlaylistEnd( pContext );
]]>
</end>
<start tag="Theme">
<![CDATA[
StartTheme( pContext, {version}, {magnet}, {alpha}, {movealpha}, {fadetime} );
]]>
</start>
<end tag="Theme">
<![CDATA[
EndTheme( pContext );
]]>
</end>
</actions>
/* XML application for skin.dtd.
* Includes actions from skin.act.
* Generated 2004/01/03 15:23:36.
*
* 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 5 "skin.act"
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "parser/wrappers.h"
void STag_Bitmap(void *pContext)
{
#line 12 "skin.act"
AddBitmap( pContext, A_Bitmap_id, A_Bitmap_file, A_Bitmap_alphacolor );
} /* STag_Bitmap */
void STag_Event(void *pContext)
{
#line 17 "skin.act"
AddEvent( pContext, A_Event_id, A_Event_event, A_Event_key );
} /* STag_Event */
void STag_Font(void *pContext)
{
#line 22 "skin.act"
AddFont( pContext, A_Font_id, A_Font_font, A_Font_size, A_Font_color,
A_Font_italic, A_Font_underline );
} /* STag_Font */
void STag_ThemeInfo(void *pContext)
{
#line 28 "skin.act"
AddThemeInfo( pContext, A_ThemeInfo_name, A_ThemeInfo_author, A_ThemeInfo_email, A_ThemeInfo_webpage );
} /* STag_ThemeInfo */
void STag_Window(void *pContext)
{
#line 33 "skin.act"
StartWindow( pContext, A_Window_id, A_Window_x, A_Window_y, A_Window_visible, A_Window_dragdrop,
A_Window_playondrop );
} /* STag_Window */
void ETag_Window(void *pContext)
{
#line 39 "skin.act"
EndWindow( pContext );
} /* ETag_Window */
void STag_Layout(void *pContext)
{
#line 44 "skin.act"
StartLayout( pContext, A_Layout_id, A_Layout_width, A_Layout_height, A_Layout_minwidth,
A_Layout_maxwidth, A_Layout_minheight, A_Layout_maxheight );
} /* STag_Layout */
void ETag_Layout(void *pContext)
{
#line 50 "skin.act"
EndLayout( pContext );
} /* ETag_Layout */
void STag_Group(void *pContext)
{
#line 56 "skin.act"
StartGroup( pContext, A_Group_x, A_Group_y );
} /* STag_Group */
void ETag_Group(void *pContext)
{
#line 61 "skin.act"
EndGroup( pContext );
} /* ETag_Group */
void STag_Anchor(void *pContext)
{
#line 66 "skin.act"
AddAnchor( pContext, A_Anchor_x, A_Anchor_y, A_Anchor_range, A_Anchor_priority );
} /* STag_Anchor */
void STag_Image(void *pContext)
{
#line 71 "skin.act"
AddImage( pContext, A_Image_id, A_Image_visible, A_Image_x, A_Image_y, A_Image_lefttop,
A_Image_rightbottom, A_Image_image, A_Image_onclick, A_Image_help );
} /* STag_Image */
void STag_Rectangle(void *pContext)
{
#line 77 "skin.act"
AddRectangle( pContext, A_Rectangle_id, A_Rectangle_visible, A_Rectangle_x, A_Rectangle_y, A_Rectangle_w, A_Rectangle_h,
A_Rectangle_color, A_Rectangle_onclick, A_Rectangle_help );
} /* STag_Rectangle */
void STag_Button(void *pContext)
{
#line 83 "skin.act"
AddButton( pContext, A_Button_id, A_Button_x, A_Button_y, A_Button_lefttop, A_Button_rightbottom,
A_Button_up, A_Button_down, A_Button_over, A_Button_action, A_Button_tooltiptext, A_Button_help );
} /* STag_Button */
void STag_CheckBox(void *pContext)
{
#line 89 "skin.act"
AddCheckBox( pContext, A_CheckBox_id,
A_CheckBox_x, A_CheckBox_y, A_CheckBox_lefttop, A_CheckBox_rightbottom,
A_CheckBox_up1, A_CheckBox_down1, A_CheckBox_over1, A_CheckBox_up2, A_CheckBox_down2, A_CheckBox_over2,
A_CheckBox_state, A_CheckBox_action1, A_CheckBox_action2, A_CheckBox_tooltiptext1,
A_CheckBox_tooltiptext2, A_CheckBox_help );
} /* STag_CheckBox */
void STag_Slider(void *pContext)
{
#line 98 "skin.act"
AddSlider( pContext, A_Slider_id, A_Slider_visible, A_Slider_x, A_Slider_y,
A_Slider_lefttop, A_Slider_rightbottom, A_Slider_up, A_Slider_down,
A_Slider_over, A_Slider_points, A_Slider_thickness, A_Slider_value, A_Slider_tooltiptext,
A_Slider_help );
} /* STag_Slider */
void STag_RadialSlider(void *pContext)
{
#line 106 "skin.act"
AddRadialSlider( pContext, A_RadialSlider_id, A_RadialSlider_visible, A_RadialSlider_x, A_RadialSlider_y,
A_RadialSlider_lefttop, A_RadialSlider_rightbottom, A_RadialSlider_sequence, A_RadialSlider_nbimages,
A_RadialSlider_minangle, A_RadialSlider_maxangle, A_RadialSlider_value, A_RadialSlider_tooltiptext,
A_RadialSlider_help );
} /* STag_RadialSlider */
void STag_Text(void *pContext)
{
#line 114 "skin.act"
AddText( pContext, A_Text_id, A_Text_visible, A_Text_x, A_Text_y, A_Text_text, A_Text_font,
A_Text_align, A_Text_width, A_Text_display, A_Text_scroll, A_Text_scrollspace,
A_Text_help );
} /* STag_Text */
void STag_Playlist(void *pContext)
{
#line 121 "skin.act"
AddPlaylist( pContext, A_Playlist_id, A_Playlist_visible, A_Playlist_x, A_Playlist_y, A_Playlist_width,
A_Playlist_height, A_Playlist_lefttop, A_Playlist_rightbottom, A_Playlist_font, A_Playlist_var,
A_Playlist_fgcolor, A_Playlist_playcolor, A_Playlist_bgcolor1, A_Playlist_bgcolor2,
A_Playlist_selcolor, A_Playlist_help );
} /* STag_Playlist */
void ETag_Playlist(void *pContext)
{
#line 129 "skin.act"
AddPlaylistEnd( pContext );
} /* ETag_Playlist */
void STag_Theme(void *pContext)
{
#line 134 "skin.act"
StartTheme( pContext, A_Theme_version, A_Theme_magnet, A_Theme_alpha, A_Theme_movealpha, A_Theme_fadetime );
} /* STag_Theme */
void ETag_Theme(void *pContext)
{
#line 139 "skin.act"
EndTheme( pContext );
} /* ETag_Theme */
/* Dummy main: filter XML from stdin. */
/* XML application entry points. */
void ETag_Bitmap(void *pContext) {}
void ETag_Event(void *pContext) {}
void ETag_Font(void *pContext) {}
void ETag_ThemeInfo(void *pContext) {}
void ETag_Anchor(void *pContext) {}
void ETag_Image(void *pContext) {}
void ETag_Rectangle(void *pContext) {}
void ETag_Button(void *pContext) {}
void ETag_CheckBox(void *pContext) {}
void ETag_Slider(void *pContext) {}
void ETag_RadialSlider(void *pContext) {}
void ETag_Text(void *pContext) {}
<!--
-->
<!ELEMENT Theme (ThemeInfo,(Bitmap|Font|Window|Event)*)>
<!ATTLIST Theme
version CDATA "1.0"
magnet CDATA "15"
alpha CDATA "255"
movealpha CDATA "255"
fadetime CDATA "400"
>
<!-- 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 #REQUIRED
font CDATA "arial"
size CDATA "12"
color CDATA "#000000"
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 (Layout)+>
<!ATTLIST Window
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
dragdrop CDATA "true"
playondrop CDATA "true"
>
<!ELEMENT Layout (Group)>
<!ATTLIST Layout
id CDATA "none"
width CDATA #REQUIRED
height CDATA #REQUIRED
minwidth CDATA "-1"
maxwidth CDATA "-1"
minheight CDATA "-1"
maxheight CDATA "-1"
>
<!ELEMENT Group (Group|Image|Button|Playlist|Slider|RadialSlider|Text|CheckBox|
Rectangle|Anchor)+>
<!ATTLIST Group
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 Image EMPTY>
<!ATTLIST Image
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
image CDATA #REQUIRED
onclick CDATA "none"
help CDATA "\0"
>
<!ELEMENT Rectangle EMPTY>
<!ATTLIST Rectangle
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 Button EMPTY>
<!ATTLIST Button
id CDATA "none"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up CDATA #REQUIRED
down CDATA "none"
over CDATA "none"
action CDATA "none"
tooltiptext CDATA "\0"
help CDATA "\0"
>
<!ELEMENT CheckBox EMPTY>
<!ATTLIST CheckBox
id CDATA "none"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up1 CDATA #REQUIRED
down1 CDATA "none"
over1 CDATA "none"
up2 CDATA #REQUIRED
down2 CDATA "none"
over2 CDATA "none"
state CDATA #REQUIRED
action1 CDATA "none"
action2 CDATA "none"
tooltiptext1 CDATA "\0"
tooltiptext2 CDATA "\0"
help CDATA "\0"
>
<!ELEMENT Slider EMPTY>
<!ATTLIST Slider
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up CDATA #REQUIRED
down CDATA "none"
over CDATA "none"
points CDATA #REQUIRED
thickness CDATA "10"
value CDATA "none"
tooltiptext CDATA "\0"
help CDATA "\0"
>
<!ELEMENT RadialSlider EMPTY>
<!ATTLIST RadialSlider
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
sequence CDATA #REQUIRED
nbimages CDATA #REQUIRED
minangle CDATA "\0"
maxangle CDATA "360"
value CDATA "none"
tooltiptext CDATA "\0"
help CDATA "\0"
>
<!ELEMENT Text EMPTY>
<!ATTLIST Text
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 Playlist Slider>
<!ATTLIST Playlist
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
width CDATA "\0"
height CDATA "\0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
font CDATA #REQUIRED
var CDATA "playlist"
fgcolor CDATA "#000000"
playcolor CDATA "#FF0000"
bgcolor1 CDATA "#FFFFFF"
bgcolor2 CDATA "#FFFFFF"
selcolor CDATA "#0000FF"
help CDATA "\0"
>
This diff is collapsed.
This diff is collapsed.
/*****************************************************************************
* skin_parser.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: skin_parser.cpp,v 1.1 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@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 "skin_parser.hpp"
#include <math.h>
// Current DTD version
#define SKINS_DTD_VERSION "2.0"
SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName ):
XMLParser( pIntf, rFileName ), m_xOffset( 0 ), m_yOffset( 0 )
{
}
void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
{
if( rName == "Anchor" )
{
const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset,
atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ),
atoi( attr["priority"] ), m_curWindowId );
m_data.m_listAnchor.push_back( anchor );
}
else if( rName == "Bitmap" )
{
const BuilderData::Bitmap bitmap( attr["id"], attr["file"],
ConvertColor( attr["alphacolor"] ) );
m_data.m_listBitmap.push_back( bitmap );
}
else if( rName == "Button" )
{
const BuilderData::Button button( attr["id"], atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
attr["rightbottom"], attr["up"], attr["down"], attr["over"],
attr["action"], attr["tooltiptext"], attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listButton.push_back( button );
}
else if( rName == "CheckBox" )
{
const BuilderData::Checkbox checkbox( attr["id"], atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
attr["rightbottom"], attr["up1"], attr["down1"], attr["over1"],
attr["up2"], attr["down2"], attr["over2"], attr["state"],
attr["action1"], attr["action2"], attr["tooltiptext1"],
attr["tooltiptext2"], attr["help"], m_curLayer, m_curWindowId,
m_curLayoutId );
m_curLayer++;
m_data.m_listCheckbox.push_back( checkbox );
}
else if( rName == "Font" )
{
const BuilderData::Font fontData( attr["id"], attr["font"],
atoi( attr["size"] ) );
m_data.m_listFont.push_back( fontData );
}
else if( rName == "Group" )
{
m_xOffset += atoi( attr["x"] );
m_yOffset += atoi( attr["y"] );
m_xOffsetList.push_back( atoi( attr["x"] ) );
m_yOffsetList.push_back( atoi( attr["y"] ) );
}
else if( rName == "Image" )
{
const BuilderData::Image imageData( attr["id"], atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["lefttop"],
attr["rightbottom"], ConvertBoolean( attr["visible"] ),
attr["image"], attr["onclick"], attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listImage.push_back( imageData );
}
else if( rName == "Layout" )
{
const BuilderData::Layout layout( attr["id"], atoi( attr["width"] ),
atoi( attr["height"] ), atoi( attr["minwidth"] ),
atoi( attr["maxwidth"] ), atoi( attr["minheight"] ),
atoi( attr["maxheight"] ), m_curWindowId );
m_data.m_listLayout.push_back( layout );
m_curLayoutId = attr["id"];
m_curLayer = 0;
}
else if( rName == "Playlist" )
{
const BuilderData::List listData( attr["id"], atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, atoi( attr["width"]),
atoi( attr["height"] ), attr["lefttop"], attr["rightbottom"],
attr["font"], attr["var"], ConvertColor( attr["fgcolor"] ),
ConvertColor( attr["playcolor"] ),
ConvertColor( attr["bgcolor1"] ),
ConvertColor( attr["bgcolor2"] ),
ConvertColor( attr["selcolor"] ), attr["help"],
m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
m_curListId = attr["id"];
m_data.m_listList.push_back( listData );
}
else if( rName == "RadialSlider" )
{
const BuilderData::RadialSlider radial( attr["id"], attr["visible"],
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], attr["rightbottom"], attr["sequence"],
atoi( attr["nbImages"] ), atof( attr["minAngle"] ) * M_PI / 180,
atof( attr["maxAngle"] ) * M_PI / 180, attr["value"],
attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId,
m_curLayoutId );
m_curLayer++;
m_data.m_listRadialSlider.push_back( radial );
}
else if( rName == "Slider" )
{
string newValue = attr["value"];
if( m_curListId != "" )
{
// Slider associated to a list
newValue = "playlist.slider";
}
const BuilderData::Slider slider( attr["id"], attr["visible"],
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
attr["lefttop"], attr["rightbottom"], attr["up"], attr["down"],
attr["over"], attr["points"], atoi( attr["thickness"] ),
newValue, attr["tooltiptext"], attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listSlider.push_back( slider );
}
else if( rName == "Text" )
{
const BuilderData::Text textData( attr["id"], atoi( attr["x"] ) +
m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["font"],
attr["text"], atoi( attr["width"] ), attr["help"], m_curLayer,
m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listText.push_back( textData );
}
else if( rName == "Theme" )
{
// Check the version
if( strcmp( attr["version"], SKINS_DTD_VERSION ) )
{
msg_Err( getIntf(), "Bad theme version : %s (you need version %s)",
attr["version"], SKINS_DTD_VERSION );
}
const BuilderData::Theme theme( atoi( attr["magnet"] ),
atoi( attr["alpha"] ), atoi( attr["movealpha"] ),
atoi( attr["fadetime"] ) );
m_data.m_listTheme.push_back( theme );
}
else if( rName == "ThemeInfo" )
{
msg_Warn( getIntf(), "skin: %s author: %s", attr["name"],
attr["author"] );
}
else if( rName == "Window" )
{
const BuilderData::Window window( attr["id"],
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
ConvertBoolean( attr["visible"] ),
ConvertBoolean( attr["dragdrop"] ),
ConvertBoolean( attr["playondrop"] ) );
m_data.m_listWindow.push_back( window );
m_curWindowId = attr["id"];
}
}
void SkinParser::handleEndElement( const string &rName )
{
if( rName == "Group" )
{
m_xOffset -= m_xOffsetList.back();
m_yOffset -= m_yOffsetList.back();
m_xOffsetList.pop_back();
m_yOffsetList.pop_back();
}
else if( rName == "Playlist" )
{
m_curListId = "";
}
}
bool SkinParser::ConvertBoolean( const char *value ) const
{
return strcmp( value, "true" ) == 0;
}
int SkinParser::ConvertColor( const char *transcolor ) const
{
unsigned long iRed, iGreen, iBlue;
iRed = iGreen = iBlue = 0;
sscanf( transcolor, "#%2lX%2lX%2lX", &iRed, &iGreen, &iBlue );
return ( iRed << 16 | iGreen << 8 | iBlue );
}
/*****************************************************************************
* parser_context.hpp
* skin_parser.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: parser_context.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* Copyright (C) 2004 VideoLAN
* $Id: skin_parser.hpp,v 1.1 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@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
......@@ -22,37 +21,42 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef PARSER_CONTEXT_HPP
#define PARSER_CONTEXT_HPP
#ifndef SKIN_PARSER_HPP
#define SKIN_PARSER_HPP
#include <vlc/intf.h>
#include "xmlparser.hpp"
#include "builder_data.hpp"
#include <list>
/// Context for the FLEX parser
class ParserContext
/// Parser for the skin DTD
class SkinParser: public XMLParser
{
public:
ParserContext( intf_thread_t *pIntf ):
m_pIntf( pIntf ), m_xOffset( 0 ), m_yOffset( 0 ) {}
SkinParser( intf_thread_t *pIntf, const string &rFileName );
virtual ~SkinParser() {}
intf_thread_t *m_pIntf;
const BuilderData &getData() const { return m_data; }
private:
/// Container for mapping data from the XML
BuilderData m_data;
/// Current IDs
string m_curWindowId;
string m_curLayoutId;
string m_curListId;
/// Current offset of the controls
int m_xOffset, m_yOffset;
list<int> m_xOffsetList, m_yOffsetList;
/// Layer of the current control in the layout
int m_curLayer;
/// Callbacks
virtual void handleBeginElement( const string &rName, AttrList_t &attr );
virtual void handleEndElement( const string &rName );
/// Helper functions
bool ConvertBoolean( const char *value ) const;
int ConvertColor( const char *transcolor ) const;
};
#endif
This diff is collapsed.
#if defined(__cplusplus)
extern "C" {
#endif
//---------------------------------------------------------------------------
// Divers
//---------------------------------------------------------------------------
void AddAnchor( void *pContext, char *x, char *y, char *len,
char *priority );
void AddBitmap( void *pContext, char *name, char *file,
char *transcolor );
void AddEvent( void *pContext, char *name, char *event, char *key );
void AddFont( void *pContext, char *name, char *font, char *size,
char *color, char *italic, char *underline );
void StartGroup( void *pContext, char *x, char *y );
void EndGroup( void *pContext );
//---------------------------------------------------------------------------
// Theme
//---------------------------------------------------------------------------
void AddThemeInfo( void *pContext, char *name, char *author,
char *email, char *webpage );
void StartTheme( void *pContext, char *version, char *magnet,
char *alpha, char *movealpha, char *fadetime );
void EndTheme( void *pContext );
//---------------------------------------------------------------------------
// Window
//---------------------------------------------------------------------------
void StartWindow( void *pContext, char *name, char *x, char *y,
char *visible, char *dragdrop, char *playOnDrop );
void EndWindow( void *pContext );
//---------------------------------------------------------------------------
// Layout
//---------------------------------------------------------------------------
void StartLayout( void *pContext, char *id, char *width, char *height,
char *minwidth, char *maxwidth, char *minheight,
char *maxheight );
void EndLayout( void *pContext );
//---------------------------------------------------------------------------
// Control
//---------------------------------------------------------------------------
void AddImage( void *pContext, char *id, char *visible, char *x,
char *y, char *lefttop, char *rightbottom, char *image,
char *event, char *help );
void AddRectangle( void *pContext, char *id, char *visible, char *x,
char *y, char *w, char *h, char *color, char *event,
char *help );
void AddButton( void *pContext, char *id,
char *x, char *y, char *lefttop, char *rightbottom,
char *up, char *down, char *over,
char *action, char *tooltiptext, char *help );
void AddCheckBox( void *pContext, char *id,
char *x, char *y, char *lefttop, char *rightbottom,
char *up1, char *down1, char *over1, char *up2,
char *down2, char *over2, char *state, char *action1,
char *action2, char *tooltiptext1, char *tooltiptext2,
char *help );
void AddSlider( void *pContext, char *id, char *visible, char *x, char *y,
char *lefttop, char *rightbottom,
char *up, char *down, char *over, char *points,
char *thickness, char *value, char *tooltiptext, char *help );
void AddRadialSlider( void *pContext, char *id, char *visible, char *x, char *y,
char *lefttop, char *rightbottom, char *sequence,
char *nbImages, char *minAngle, char *maxAngle,
char *value, char *tooltiptext, char *help );
void AddText( void *pContext, 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( void *pContext, char *id, char *visible, char *x,
char *y, char *width, char *height, char *lefttop,
char *rightbottom, char *font, char *var, char *fgcolor,
char *playcolor, char *bgcolor1, char *bgcolor2, char *selcolor,
char *help );
void AddPlaylistEnd( void *pContext );
//---------------------------------------------------------------------------
#if defined(__cplusplus)
}
#endif
......@@ -2,10 +2,9 @@
* xmlparser.cpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: xmlparser.cpp,v 1.2 2004/01/24 14:25:16 asmax Exp $
* $Id: xmlparser.cpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@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
......@@ -34,7 +33,12 @@ XMLParser::XMLParser( intf_thread_t *pIntf, const string &rFileName ):
rFileName.c_str() );
}
// Activate DTD validation
xmlTextReaderSetParserProp( m_pReader, XML_PARSER_DEFAULTATTRS, 1 );
xmlTextReaderSetParserProp( m_pReader, XML_PARSER_VALIDATE, 1 );
// Set the error handler
xmlTextReaderSetErrorHandler( m_pReader, handleError, this );
}
......@@ -47,13 +51,15 @@ XMLParser::~XMLParser()
}
int XMLParser::parse()
bool XMLParser::parse()
{
if( !m_pReader )
{
return -1;
}
m_errors = false;
int ret = xmlTextReaderRead( m_pReader );
while (ret == 1)
{
......@@ -104,23 +110,17 @@ int XMLParser::parse()
}
ret = xmlTextReaderRead( m_pReader );
}
return 0;
return (ret == 0 && !m_errors );
}
void XMLParser::handleBeginElement( const string &rName,
AttrList_t &attributes )
void XMLParser::handleError( void *pArg, const char *pMsg,
xmlParserSeverities severity,
xmlTextReaderLocatorPtr locator)
{
fprintf(stderr,"%s\n", rName.c_str());
AttrList_t::const_iterator it;
for (it = attributes.begin(); it != attributes.end(); it++)
{
fprintf(stderr," %s = %s\n", (*it).first, (*it).second);
}
XMLParser *pThis = (XMLParser*)pArg;
int line = xmlTextReaderLocatorLineNumber( locator );
msg_Err( pThis->getIntf(), "XML parser error (line %d) : %s", line, pMsg );
pThis->m_errors = true;
}
void XMLParser::handleEndElement( const string &rName )
{
fprintf(stderr,"--> %s\n", rName.c_str());
}
......@@ -2,10 +2,9 @@
* xmlparser.hpp
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: xmlparser.hpp,v 1.2 2004/01/24 14:25:16 asmax Exp $
* $Id: xmlparser.hpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@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
......@@ -38,9 +37,10 @@ class XMLParser: public SkinObject
XMLParser( intf_thread_t *pIntf, const string &rFileName );
virtual ~XMLParser();
int parse();
/// Parse the file. Returns true on success
bool parse();
private:
protected:
// Key comparison function for type "const char*"
struct ltstr
{
......@@ -52,11 +52,20 @@ class XMLParser: public SkinObject
/// Type for attribute lists
typedef map<const char*, const char*, ltstr> AttrList_t;
/// Callbacks
virtual void handleBeginElement( const string &rName, AttrList_t &attr ) {}
virtual void handleEndElement( const string &rName ) {}
private:
/// Reader context
xmlTextReaderPtr m_pReader;
/// Flag for validation errors
bool m_errors;
void handleBeginElement( const string &rName, AttrList_t &attributes );
void handleEndElement( const string &rName );
/// Callback for validation errors
static void handleError( void *pArg, const char *pMsg,
xmlParserSeverities severity,
xmlTextReaderLocatorPtr locator);
};
#endif
......@@ -2,7 +2,7 @@
* theme_loader.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: theme_loader.cpp,v 1.6 2004/01/24 14:25:16 asmax Exp $
* $Id: theme_loader.cpp,v 1.7 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -25,8 +25,7 @@
#include "theme_loader.hpp"
#include "theme.hpp"
#include "../parser/builder.hpp"
#include "../parser/parser_context.hpp"
#include "../parser/xmlparser.hpp"
#include "../parser/skin_parser.hpp"
#include "../src/os_factory.hpp"
#include "../src/window_manager.hpp"
......@@ -54,12 +53,6 @@ int tar_close ( TAR *t );
#define DEFAULT_XML_FILE "theme.xml"
extern "C"
{
extern FILE *yyin;
int yylex( void *pContext );
void yyrestart( FILE *input_file );
}
bool ThemeLoader::load( const string &fileName )
{
......@@ -166,20 +159,6 @@ void ThemeLoader::deleteTempFiles( const string &path )
bool ThemeLoader::parse( const string &xmlFile )
{
XMLParser parser( getIntf(), xmlFile );
parser.parse();
// Set the file to parse
FILE *file = fopen( xmlFile.c_str(), "r" );
if( file == NULL )
{
// Skin cannot be opened
msg_Err( getIntf(), "Cannot open the specified skin file: %s",
xmlFile.c_str() );
return false;
}
yyrestart( file );
// File loaded
msg_Dbg( getIntf(), "Using skin file: %s", xmlFile.c_str() );
......@@ -197,22 +176,19 @@ bool ThemeLoader::parse( const string &xmlFile )
}
// Start the parser
ParserContext context( getIntf() );
int lex = yylex( &context );
fclose( file );
if( lex )
SkinParser parser( getIntf(), xmlFile );
bool ret = parser.parse();
if( !ret )
{
msg_Err( getIntf(), "Failed to parse %s", xmlFile.c_str() );
// Set old working directory to current
chdir( cwd );
delete[] cwd;
msg_Warn( getIntf(), "yylex failed: %i", lex );
return false;
}
// Build and store the theme
Builder builder( getIntf(), context.m_data );
Builder builder( getIntf(), parser.getData() );
getIntf()->p_sys->p_theme = builder.build();
// Set old working directory to current.
......
......@@ -2,7 +2,7 @@
* tooltip.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: tooltip.cpp,v 1.2 2004/01/11 17:12:17 asmax Exp $
* $Id: tooltip.cpp,v 1.3 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -48,7 +48,7 @@ Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
Tooltip::~Tooltip()
{
// VarManager::instance( getIntf() )->getTooltipText().delObserver( this );
VarManager::instance( getIntf() )->getTooltipText().delObserver( this );
SKINS_DELETE( m_pTimer );
SKINS_DELETE( m_pOsTooltip );
if( m_pImage )
......
......@@ -2,7 +2,7 @@
* window_manager.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: window_manager.cpp,v 1.3 2004/01/18 00:50:24 asmax Exp $
* $Id: window_manager.cpp,v 1.4 2004/01/25 11:44:19 asmax Exp $
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -142,9 +142,13 @@ void WindowManager::raise( GenericWindow *pWindow )
// Raise all the windows
WinSet_t::const_iterator it;
for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
{
if( *it != pWindow )
{
(*it)->raise();
}
}
pWindow->raise();
}
......
......@@ -44,8 +44,8 @@
<!ATTLIST Window
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
dragdrop CDATA "true"
playondrop CDATA "true"
>
......@@ -63,15 +63,15 @@
<!ELEMENT Group (Group|Image|Button|Playlist|Slider|RadialSlider|Text|CheckBox|
Rectangle|Anchor)+>
<!ATTLIST Group
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
>
<!-- Anchors -->
<!ELEMENT Anchor EMPTY>
<!ATTLIST Anchor
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
priority CDATA #REQUIRED
range CDATA "10"
>
......@@ -81,8 +81,8 @@
<!ATTLIST Image
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
image CDATA #REQUIRED
......@@ -93,8 +93,8 @@
<!ATTLIST Rectangle
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
w CDATA "50"
h CDATA "50"
color CDATA "#C0C0C0"
......@@ -104,8 +104,8 @@
<!ELEMENT Button EMPTY>
<!ATTLIST Button
id CDATA "none"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up CDATA #REQUIRED
......@@ -118,8 +118,8 @@
<!ELEMENT CheckBox EMPTY>
<!ATTLIST CheckBox
id CDATA "none"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up1 CDATA #REQUIRED
......@@ -139,8 +139,8 @@
<!ATTLIST Slider
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
up CDATA #REQUIRED
......@@ -156,13 +156,13 @@
<!ATTLIST RadialSlider
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
x CDATA "0"
y CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
sequence CDATA #REQUIRED
nbimages CDATA #REQUIRED
minangle CDATA "\0"
minangle CDATA "0"
maxangle CDATA "360"
value CDATA "none"
tooltiptext CDATA "\0"
......@@ -172,12 +172,12 @@
<!ATTLIST Text
id CDATA "none"
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
text CDATA ""
x CDATA "0"
y CDATA "0"
text CDATA "\0"
font CDATA #REQUIRED
align CDATA "left"
width CDATA "\0"
width CDATA "0"
display CDATA "none"
scroll CDATA "true"
scrollspace CDATA "20"
......@@ -187,10 +187,10 @@
<!ATTLIST Playlist
id CDATA #REQUIRED
visible CDATA "true"
x CDATA "\0"
y CDATA "\0"
width CDATA "\0"
height CDATA "\0"
x CDATA "0"
y CDATA "0"
width CDATA "0"
height CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
font CDATA #REQUIRED
......
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