Move jinete/jfile.cpp to xml_widgets.cpp.

This commit is contained in:
David Capello 2010-08-23 17:52:17 -03:00
parent a59cce0932
commit f87cf2a4bc
8 changed files with 49 additions and 76 deletions

View File

@ -90,7 +90,6 @@ Low priority stuff
- optimize the *_to_allegro image methods (I profiled ASE, and these
are the more slow routines in all the program);
- remove the jquickmenu.c
- move src/jinete/jfile.cpp to src/xml_widgets.cc (jfile is specific to ASE, not Jinete)
- fix Jinete examples:
+ 05fsel
+ 09lists

View File

@ -18,6 +18,7 @@ COMMON_SOURCES = \
src/resource_finder.cpp \
src/ui_context.cpp \
src/undoable.cpp \
src/xml_widgets.cpp \
src/commands/cmd_about.cpp \
src/commands/cmd_advanced_mode.cpp \
src/commands/cmd_background_from_layer.cpp \
@ -139,7 +140,6 @@ COMMON_SOURCES = \
src/jinete/jdraw.cpp \
src/jinete/jentry.cpp \
src/jinete/jexception.cpp \
src/jinete/jfile.cpp \
src/jinete/jfont.cpp \
src/jinete/jfontbmp.cpp \
src/jinete/jgrid.cpp \

View File

@ -40,6 +40,7 @@ add_executable(aseprite WIN32
resource_finder.cpp
ui_context.cpp
undoable.cpp
xml_widgets.cpp
commands/cmd_about.cpp
commands/cmd_advanced_mode.cpp
commands/cmd_background_from_layer.cpp
@ -161,7 +162,6 @@ add_executable(aseprite WIN32
jinete/jdraw.cpp
jinete/jentry.cpp
jinete/jexception.cpp
jinete/jfile.cpp
jinete/jfont.cpp
jinete/jfontbmp.cpp
jinete/jgrid.cpp

View File

@ -1,39 +0,0 @@
/* Jinete - a GUI library
* Copyright (C) 2003-2010 David Capello.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the author nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JINETE_JFILE_H_INCLUDED
#define JINETE_JFILE_H_INCLUDED
#include "jinete/jbase.h"
JWidget ji_load_widget(const char *filename, const char *name);
#endif

View File

@ -43,7 +43,6 @@
#include "jinete/jdraw.h"
#include "jinete/jentry.h"
#include "jinete/jexception.h"
#include "jinete/jfile.h"
#include "jinete/jfont.h"
#include "jinete/jgrid.h"
#include "jinete/jhook.h"

View File

@ -57,6 +57,7 @@
#include "widgets/editor.h"
#include "widgets/statebar.h"
#include "widgets/toolbar.h"
#include "xml_widgets.h"
#define REBUILD_RECENT_LIST 2
#define REFRESH_FULL_SCREEN 4
@ -674,7 +675,7 @@ void save_window_pos(JWidget window, const char *section)
set_config_rect(section, "WindowPos", window->getBounds());
}
JWidget load_widget(const char *filename, const char *name)
JWidget load_widget(const char* filename, const char* name)
{
JWidget widget;
char buf[512];
@ -698,7 +699,7 @@ JWidget load_widget(const char *filename, const char *name)
if (!found)
throw widget_file_not_found(filename);
widget = ji_load_widget(buf, name);
widget = load_widget_from_xmlfile(buf, name);
if (!widget)
throw widget_not_found(name);

View File

@ -1,32 +1,19 @@
/* Jinete - a GUI library
* Copyright (C) 2003-2010 David Capello.
* All rights reserved.
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2010 David Capello
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* 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.
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of the author nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* 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-1307 USA
*/
#include "config.h"
@ -39,7 +26,7 @@
#include "Vaca/Bind.h"
#include "jinete/jinete.h"
#include "modules/gui.h" // TODO jfile.cpp must be outside Jinete/Vaca stuff (it is specific to ASE)
#include "modules/gui.h"
#include "tinyxml.h"
@ -60,12 +47,12 @@ static bool bool_attr_is_true(TiXmlElement* elem, const char* attribute_name);
static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root);
static int convert_align_value_to_flags(const char *value);
JWidget ji_load_widget(const char *filename, const char *name)
Widget* load_widget_from_xmlfile(const char* xmlFilename, const char* widgetName)
{
JWidget widget = NULL;
Widget* widget = NULL;
TiXmlDocument doc;
if (!doc.LoadFile(filename))
if (!doc.LoadFile(xmlFilename))
throw jexception(&doc);
// search the requested widget
@ -77,7 +64,7 @@ JWidget ji_load_widget(const char *filename, const char *name)
while (xmlElement) {
const char* nodename = xmlElement->Attribute("name");
if (nodename && ustrcmp(nodename, name) == 0) {
if (nodename && ustrcmp(nodename, widgetName) == 0) {
widget = convert_xmlelement_to_widget(xmlElement, NULL);
break;
}

26
src/xml_widgets.h Normal file
View File

@ -0,0 +1,26 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2010 David Capello
*
* 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-1307 USA
*/
#ifndef XML_WIDGETS_H_INCLUDED
#define XML_WIDGETS_H_INCLUDED
class Widget;
Widget* load_widget_from_xmlfile(const char* xmlFilename, const char* widgetName);
#endif