mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
+ Modified makefile.vc to handle a completelly static compilation with VC++9.0 Express Edition
(the new compiler used for the following Win32 binary releases). + Modified some error handling code to use C++ exceptions. + Modified some collections (std::vector, std::map, etc.) from instances to pointers.
This commit is contained in:
parent
f9ac4089f5
commit
67a830183b
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2009-08-04 David A. Capello <davidcapello@gmail.com>
|
||||
|
||||
* Version 0.7 released.
|
||||
|
||||
* makefile.vc: Prepared to be compiled with VC++ 9.0 Express Edition.
|
||||
|
||||
2009-08-03 David A. Capello <davidcapello@gmail.com>
|
||||
|
||||
* Modified some error handling code from return-value to exceptions.
|
||||
|
||||
2009-08-02 David A. Capello <davidcapello@gmail.com>
|
||||
|
||||
* src/util/render.cpp (merge_zoomed_image): unified all
|
||||
|
3
fix.sh
3
fix.sh
@ -102,6 +102,9 @@ gen_makefile()
|
||||
echo "" >> $makefile
|
||||
fi
|
||||
|
||||
if [ X"$debug" == X"y" ] ; then echo -n "#" >> $makefile ; fi
|
||||
echo "RELEASE = 1" >> $makefile
|
||||
|
||||
if [ X"$debug" != X"y" ] ; then echo -n "#" >> $makefile ; fi
|
||||
echo "DEBUGMODE = 1" >> $makefile
|
||||
|
||||
|
@ -10,9 +10,11 @@
|
||||
######################################################################
|
||||
# Uncomment this if you want to debug or profile information
|
||||
|
||||
#RELEASE = 1
|
||||
#DEBUGMODE = 1
|
||||
#PROFILE = 1
|
||||
#MEMLEAK = 1
|
||||
#STATIC_ALLEG_LINK = 1
|
||||
|
||||
######################################################################
|
||||
# Default Unix directory to look for ASE data (to this path will be
|
||||
|
@ -138,6 +138,7 @@ COMMON_SOURCES = \
|
||||
src/jinete/jfontbmp.cpp \
|
||||
src/jinete/jhook.cpp \
|
||||
src/jinete/jimage.cpp \
|
||||
src/jinete/jinete.cpp \
|
||||
src/jinete/jintern.cpp \
|
||||
src/jinete/jlabel.cpp \
|
||||
src/jinete/jlist.cpp \
|
||||
|
38
makefile.vc
38
makefile.vc
@ -41,9 +41,25 @@ ifdef DEBUGMODE
|
||||
LFLAGS += -DEBUG
|
||||
LIBS += Alld.lib psapi.lib
|
||||
else
|
||||
CFLAGS += -O2 -MD -DNDEBUG
|
||||
LFLAGS += -RELEASE
|
||||
LIBS += Alleg.lib
|
||||
ifdef RELEASE
|
||||
CFLAGS += -O2 -DNDEBUG
|
||||
LFLAGS += -RELEASE
|
||||
|
||||
ifdef STATIC_ALLEG_LINK
|
||||
CFLAGS += -MT -DALLEGRO_STATICLINK
|
||||
LIBS += Alleg_s_crt.lib
|
||||
LIBS += dinput8.lib ddraw.lib dxguid.lib dsound.lib
|
||||
else
|
||||
CFLAGS += -MD
|
||||
LIBS += Alleg.lib
|
||||
endif
|
||||
else
|
||||
# Release with debug info
|
||||
CFLAGS += -Zi -O2 -MD -DNDEBUG
|
||||
LFLAGS += -DEBUG
|
||||
LIBS += Alleg.lib
|
||||
LIBS += psapi.lib
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MEMLEAK
|
||||
@ -73,27 +89,27 @@ distclean: clean
|
||||
|
||||
$(LIBART_LIB): $(LIBART_OBJS)
|
||||
-rm -f $@
|
||||
lib -NOLOGO /OUT:$@ $^
|
||||
lib -NOLOGO -OUT:$@ $^
|
||||
|
||||
$(LIBFREETYPE_LIB): $(LIBFREETYPE_OBJS)
|
||||
-rm -f $@
|
||||
lib -NOLOGO /OUT:$@ $^
|
||||
lib -NOLOGO -OUT:$@ $^
|
||||
|
||||
$(LIBGD_LIB): $(LIBGD_OBJS)
|
||||
-rm -f $@
|
||||
lib -NOLOGO /OUT:$@ $^
|
||||
lib -NOLOGO -OUT:$@ $^
|
||||
|
||||
$(LIBJPEG_LIB): $(LIBJPEG_OBJS)
|
||||
-rm -f $@
|
||||
lib -NOLOGO /OUT:$@ $^
|
||||
lib -NOLOGO -OUT:$@ $^
|
||||
|
||||
$(LIBPNG_LIB): $(LIBPNG_OBJS)
|
||||
-rm -f $@
|
||||
lib -NOLOGO /OUT:$@ $^
|
||||
lib -NOLOGO -OUT:$@ $^
|
||||
|
||||
$(ZLIB_LIB): $(ZLIB_OBJS)
|
||||
-rm -f $@
|
||||
lib -NOLOGO /OUT:$@ $^
|
||||
lib -NOLOGO -OUT:$@ $^
|
||||
|
||||
######################################################################
|
||||
# Rules to build objects and the application
|
||||
@ -174,3 +190,7 @@ $(OBJ_DIR)/icon.res: src/icon.rc
|
||||
|
||||
$(ASE): $(ASE_DEPS) $(OBJ_DIR)/icon.res
|
||||
link $(LFLAGS) $^ $(LIBS) -OUT:$@
|
||||
|
||||
# To embed the manifest file uncomment the following lines:
|
||||
# mt -nologo -manifest $@.manifest -outputresource:$@;#2
|
||||
# rm $@.manifest
|
||||
|
@ -195,20 +195,17 @@ $1/docs/*.pdf"
|
||||
if [ ! -f $distdir-win32.zip ] ; then
|
||||
|
||||
cd "$dir/.."
|
||||
make -f makefile.mgw CONFIGURED=1 clean
|
||||
make -f makefile.mgw CONFIGURED=1
|
||||
strip -s aseprite.exe
|
||||
make -f makefile.vc CONFIGURED=1 RELEASE=1 STATIC_ALLEG_LINK=1 clean
|
||||
make -f makefile.vc CONFIGURED=1 RELEASE=1 STATIC_ALLEG_LINK=1
|
||||
def_common_files .
|
||||
mkdir "$dir/$distdir-win32"
|
||||
cp -r --parents $txt_files $bin_files aseprite.exe "$dir/$distdir-win32"
|
||||
|
||||
cd "$dir"
|
||||
cp alleg42.dll "$dir/$distdir-win32"
|
||||
def_common_files $distdir-win32
|
||||
zip -9 $distdir-win32.zip $txt_files
|
||||
zip -9 $distdir-win32.zip $bin_files \
|
||||
$distdir-win32/aseprite.exe \
|
||||
$distdir-win32/alleg42.dll
|
||||
$distdir-win32/aseprite.exe
|
||||
rm -fr $distdir-win32
|
||||
|
||||
fi
|
||||
|
@ -176,7 +176,6 @@ static bool try_new_gfx_mode()
|
||||
/* oh no! more errors!, we can't restore the old graphics mode! */
|
||||
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
|
||||
user_printf(_("FATAL ERROR: Unable to restore the old graphics mode!\n"));
|
||||
app_exit();
|
||||
exit(1);
|
||||
}
|
||||
/* only print a message of the old error */
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "jinete/jinete.h"
|
||||
#include "jinete/jintern.h"
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "ase/ui_context.h"
|
||||
#include "commands/commands.h"
|
||||
#include "console/console.h"
|
||||
@ -110,7 +111,7 @@ static char *palette_filename = NULL;
|
||||
|
||||
static void tabsbar_select_callback(JWidget tabs, void *data, int button);
|
||||
|
||||
static int check_args(int argc, char *argv[]);
|
||||
static void check_args(int argc, char *argv[]);
|
||||
static void usage(int status);
|
||||
|
||||
static Option *option_new(int type, const char *data);
|
||||
@ -120,29 +121,22 @@ static void option_free(Option *option);
|
||||
* Initializes the application loading the modules, setting the
|
||||
* graphics mode, loading the configuration and resources, etc.
|
||||
*/
|
||||
bool app_init(int argc, char *argv[])
|
||||
Application::Application(int argc, char *argv[])
|
||||
{
|
||||
exe_name = argv[0];
|
||||
|
||||
/* initialize application hooks */
|
||||
{
|
||||
int c;
|
||||
for (c=0; c<APP_EVENTS; ++c)
|
||||
apphooks[c] = NULL;
|
||||
}
|
||||
for (int c=0; c<APP_EVENTS; ++c)
|
||||
apphooks[c] = NULL;
|
||||
|
||||
/* initialize language suppport */
|
||||
intl_init();
|
||||
|
||||
/* install the `core' of ASE application */
|
||||
if (!core_init()) {
|
||||
user_printf(_("ASE core initialization error.\n"));
|
||||
return FALSE;
|
||||
}
|
||||
core_init();
|
||||
|
||||
/* install the file-system access module */
|
||||
if (!file_system_init())
|
||||
return FALSE;
|
||||
file_system_init();
|
||||
|
||||
/* init configuration */
|
||||
ase_config_init();
|
||||
@ -151,22 +145,17 @@ bool app_init(int argc, char *argv[])
|
||||
intl_load_lang();
|
||||
|
||||
/* search options in the arguments */
|
||||
if (check_args(argc, argv) < 0)
|
||||
return FALSE;
|
||||
check_args(argc, argv);
|
||||
|
||||
/* GUI is the default mode */
|
||||
if (!(ase_mode & MODE_BATCH))
|
||||
ase_mode |= MODE_GUI;
|
||||
|
||||
/* install 'raster' stuff */
|
||||
if (!gfxobj_init())
|
||||
return FALSE;
|
||||
gfxobj_init();
|
||||
|
||||
/* install the modules */
|
||||
if (!modules_init(REQUIRE_INTERFACE))
|
||||
return FALSE;
|
||||
|
||||
_ji_font_init();
|
||||
modules_init(REQUIRE_INTERFACE);
|
||||
|
||||
/* custom default palette? */
|
||||
if (palette_filename) {
|
||||
@ -175,13 +164,9 @@ bool app_init(int argc, char *argv[])
|
||||
PRINTF("Loading custom palette file: %s\n", palette_filename);
|
||||
|
||||
pal = palette_load(palette_filename);
|
||||
if (pal == NULL) {
|
||||
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
|
||||
Console console;
|
||||
console.printf(_("Error loading default palette from `%s'\n"),
|
||||
palette_filename);
|
||||
return FALSE;
|
||||
}
|
||||
if (pal == NULL)
|
||||
throw ase_exception(std::string("Error loading default palette from: ")
|
||||
+ palette_filename);
|
||||
|
||||
set_default_palette(pal);
|
||||
palette_free(pal);
|
||||
@ -189,16 +174,13 @@ bool app_init(int argc, char *argv[])
|
||||
|
||||
/* set system palette to the default one */
|
||||
set_current_palette(NULL, TRUE);
|
||||
|
||||
/* ok */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the ASE application. In GUI mode it's the top-level window, in
|
||||
* console/scripting it just runs the specified scripts.
|
||||
*/
|
||||
void app_loop()
|
||||
void Application::run()
|
||||
{
|
||||
Option *option;
|
||||
JLink link;
|
||||
@ -363,17 +345,17 @@ void app_loop()
|
||||
/**
|
||||
* Finishes the ASE application.
|
||||
*/
|
||||
void app_exit()
|
||||
Application::~Application()
|
||||
{
|
||||
JLink link;
|
||||
int c;
|
||||
|
||||
/* remove ase handlers */
|
||||
// remove ase handlers
|
||||
PRINTF("Uninstalling ASE\n");
|
||||
|
||||
app_trigger_event(APP_EXIT);
|
||||
|
||||
/* destroy application hooks */
|
||||
// destroy application hooks
|
||||
for (c=0; c<APP_EVENTS; ++c) {
|
||||
if (apphooks[c] != NULL) {
|
||||
JI_LIST_FOR_EACH(apphooks[c], link) {
|
||||
@ -395,8 +377,6 @@ void app_exit()
|
||||
ase_config_exit();
|
||||
file_system_exit();
|
||||
core_exit();
|
||||
_ji_font_exit();
|
||||
|
||||
intl_exit();
|
||||
}
|
||||
|
||||
@ -589,7 +569,7 @@ static void tabsbar_select_callback(JWidget tabs, void *data, int button)
|
||||
/**
|
||||
* Looks the inpunt arguments in the command line.
|
||||
*/
|
||||
static int check_args(int argc, char *argv[])
|
||||
static void check_args(int argc, char *argv[])
|
||||
{
|
||||
Console console;
|
||||
int i, n, len;
|
||||
@ -673,8 +653,6 @@ static int check_args(int argc, char *argv[])
|
||||
else if (n == 0)
|
||||
jlist_append(options, option_new(OPEN_GFX_FILE, argv[i]));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "jinete/jbase.h"
|
||||
|
||||
/* enumeration of ASE events in the highest application level */
|
||||
// enumeration of ASE events in the highest application level
|
||||
enum {
|
||||
APP_EXIT,
|
||||
APP_PALETTE_CHANGE,
|
||||
@ -31,9 +31,14 @@ enum {
|
||||
class Layer;
|
||||
class Sprite;
|
||||
|
||||
bool app_init(int argc, char *argv[]);
|
||||
void app_loop();
|
||||
void app_exit();
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
Application(int argc, char *argv[]);
|
||||
~Application();
|
||||
|
||||
void run();
|
||||
};
|
||||
|
||||
void app_add_hook(int app_event, void (*proc)(void *data), void *data);
|
||||
void app_trigger_event(int app_event);
|
||||
|
@ -50,7 +50,7 @@ static char *log_filename = NULL;
|
||||
static FILE *log_fileptr = NULL;
|
||||
#endif
|
||||
|
||||
bool core_init()
|
||||
void core_init()
|
||||
{
|
||||
#ifdef NEED_LOG
|
||||
char buf[512];
|
||||
@ -69,8 +69,6 @@ bool core_init()
|
||||
log_filename = jstrdup(dirs->path);
|
||||
dirs_free(dirs);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void core_exit()
|
||||
|
@ -29,7 +29,7 @@ enum {
|
||||
|
||||
extern int ase_mode;
|
||||
|
||||
bool core_init();
|
||||
void core_init();
|
||||
void core_exit();
|
||||
|
||||
void verbose_printf(const char *format, ...);
|
||||
|
@ -35,7 +35,7 @@
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
|
||||
static WNDPROC base_wnd_proc = NULL;
|
||||
static std::vector<jstring> dropped_files;
|
||||
static std::vector<jstring>* dropped_files;
|
||||
static JMutex dropped_files_mutex;
|
||||
|
||||
static void subclass_hwnd();
|
||||
@ -44,6 +44,7 @@ static LRESULT ase_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
void install_drop_files()
|
||||
{
|
||||
dropped_files = new std::vector<jstring>();
|
||||
dropped_files_mutex = jmutex_new();
|
||||
|
||||
subclass_hwnd();
|
||||
@ -56,7 +57,7 @@ void uninstall_drop_files()
|
||||
jmutex_free(dropped_files_mutex);
|
||||
dropped_files_mutex = NULL;
|
||||
|
||||
dropped_files.clear();
|
||||
delete dropped_files;
|
||||
}
|
||||
|
||||
void check_for_dropped_files()
|
||||
@ -68,9 +69,9 @@ void check_for_dropped_files()
|
||||
return;
|
||||
|
||||
jmutex_lock(dropped_files_mutex);
|
||||
if (!dropped_files.empty()) {
|
||||
std::vector<jstring> files = dropped_files;
|
||||
dropped_files.clear();
|
||||
if (!dropped_files->empty()) {
|
||||
std::vector<jstring> files = *dropped_files;
|
||||
dropped_files->clear();
|
||||
|
||||
// open all files
|
||||
Command* cmd_open_file = command_get_by_name(CMD_OPEN_FILE);
|
||||
@ -117,7 +118,7 @@ static LRESULT ase_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
if (length > 0) {
|
||||
TCHAR* lpstr = new TCHAR[length+1];
|
||||
DragQueryFile(hdrop, index, lpstr, length+1);
|
||||
dropped_files.push_back(lpstr);
|
||||
dropped_files->push_back(lpstr);
|
||||
delete[] lpstr;
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +136,8 @@ typedef std::map<jstring, BITMAP*> ThumbnailMap;
|
||||
|
||||
// the root of the file-system
|
||||
static FileItem* rootitem = NULL;
|
||||
static FileItemMap fileitems_map;
|
||||
static ThumbnailMap thumbnail_map;
|
||||
static FileItemMap* fileitems_map;
|
||||
static ThumbnailMap* thumbnail_map;
|
||||
static unsigned int current_file_system_version = 0;
|
||||
|
||||
#ifdef USE_PIDLS
|
||||
@ -174,8 +174,11 @@ static unsigned int current_file_system_version = 0;
|
||||
/**
|
||||
* Initializes the file-system module to navigate the file-system.
|
||||
*/
|
||||
bool file_system_init()
|
||||
void file_system_init()
|
||||
{
|
||||
fileitems_map = new FileItemMap;
|
||||
thumbnail_map = new ThumbnailMap;
|
||||
|
||||
#ifdef USE_PIDLS
|
||||
/* get the IMalloc interface */
|
||||
SHGetMalloc(&shl_imalloc);
|
||||
@ -190,8 +193,6 @@ bool file_system_init()
|
||||
// get the root element of the file system (this will create
|
||||
// the 'rootitem' FileItem)
|
||||
get_root_fileitem();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,16 +201,16 @@ bool file_system_init()
|
||||
void file_system_exit()
|
||||
{
|
||||
for (FileItemMap::iterator
|
||||
it=fileitems_map.begin(); it!=fileitems_map.end(); ++it) {
|
||||
it=fileitems_map->begin(); it!=fileitems_map->end(); ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
fileitems_map.clear();
|
||||
fileitems_map->clear();
|
||||
|
||||
for (ThumbnailMap::iterator
|
||||
it=thumbnail_map.begin(); it!=thumbnail_map.end(); ++it) {
|
||||
it=thumbnail_map->begin(); it!=thumbnail_map->end(); ++it) {
|
||||
destroy_bitmap(it->second);
|
||||
}
|
||||
thumbnail_map.clear();
|
||||
thumbnail_map->clear();
|
||||
|
||||
#ifdef USE_PIDLS
|
||||
// relase desktop IShellFolder interface
|
||||
@ -219,6 +220,9 @@ void file_system_exit()
|
||||
shl_imalloc->Release();
|
||||
shl_imalloc = NULL;
|
||||
#endif
|
||||
|
||||
delete fileitems_map;
|
||||
delete thumbnail_map;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -534,8 +538,8 @@ BITMAP* fileitem_get_thumbnail(FileItem* fileitem)
|
||||
{
|
||||
assert(fileitem);
|
||||
|
||||
ThumbnailMap::iterator it = thumbnail_map.find(fileitem->filename);
|
||||
if (it != thumbnail_map.end())
|
||||
ThumbnailMap::iterator it = thumbnail_map->find(fileitem->filename);
|
||||
if (it != thumbnail_map->end())
|
||||
return it->second;
|
||||
else
|
||||
return NULL;
|
||||
@ -546,14 +550,14 @@ void fileitem_set_thumbnail(FileItem* fileitem, BITMAP* thumbnail)
|
||||
assert(fileitem);
|
||||
|
||||
// destroy the current thumbnail of the file (if exists)
|
||||
ThumbnailMap::iterator it = thumbnail_map.find(fileitem->filename);
|
||||
if (it != thumbnail_map.end()) {
|
||||
ThumbnailMap::iterator it = thumbnail_map->find(fileitem->filename);
|
||||
if (it != thumbnail_map->end()) {
|
||||
destroy_bitmap(it->second);
|
||||
thumbnail_map.erase(it);
|
||||
thumbnail_map->erase(it);
|
||||
}
|
||||
|
||||
// insert the new one in the map
|
||||
thumbnail_map.insert(std::make_pair(fileitem->filename, thumbnail));
|
||||
thumbnail_map->insert(std::make_pair(fileitem->filename, thumbnail));
|
||||
}
|
||||
|
||||
FileItem::FileItem(FileItem* parent)
|
||||
@ -899,8 +903,8 @@ static jstring get_key_for_pidl(LPITEMIDLIST pidl)
|
||||
|
||||
static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_not)
|
||||
{
|
||||
FileItemMap::iterator it = fileitems_map.find(get_key_for_pidl(fullpidl));
|
||||
if (it != fileitems_map.end())
|
||||
FileItemMap::iterator it = fileitems_map->find(get_key_for_pidl(fullpidl));
|
||||
if (it != fileitems_map->end())
|
||||
return it->second;
|
||||
|
||||
if (!create_if_not)
|
||||
@ -943,7 +947,7 @@ static void put_fileitem(FileItem* fileitem)
|
||||
assert(fileitem->keyname != NOTINITIALIZED);
|
||||
|
||||
// insert this file-item in the hash-table
|
||||
fileitems_map.insert(std::make_pair(fileitem->keyname, fileitem));
|
||||
fileitems_map->insert(std::make_pair(fileitem->keyname, fileitem));
|
||||
}
|
||||
|
||||
#else
|
||||
@ -957,8 +961,8 @@ static FileItem* get_fileitem_by_path(const jstring& path, bool create_if_not)
|
||||
if (path.empty())
|
||||
return rootitem;
|
||||
|
||||
FileItemMap::iterator it = fileitems_map.find(get_key_for_filename(path));
|
||||
if (it != fileitems_map.end())
|
||||
FileItemMap::iterator it = fileitems_map->find(get_key_for_filename(path));
|
||||
if (it != fileitems_map->end())
|
||||
return it->second;
|
||||
|
||||
if (!create_if_not)
|
||||
@ -1066,7 +1070,7 @@ static void put_fileitem(FileItem* fileitem)
|
||||
assert(fileitem->keyname != NOTINITIALIZED);
|
||||
|
||||
// insert this file-item in the hash-table
|
||||
fileitems_map.insert(std::make_pair(fileitem->keyname, fileitem));
|
||||
fileitems_map->insert(std::make_pair(fileitem->keyname, fileitem));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -29,7 +29,7 @@ class FileItem;
|
||||
|
||||
typedef std::vector<FileItem*> FileItemList;
|
||||
|
||||
bool file_system_init();
|
||||
void file_system_init();
|
||||
void file_system_exit();
|
||||
|
||||
void file_system_refresh();
|
||||
|
@ -58,27 +58,22 @@ static Module module[] =
|
||||
|
||||
static int modules = sizeof(module) / sizeof(Module);
|
||||
|
||||
bool modules_init(int requirements)
|
||||
void modules_init(int requirements)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c=0; c<modules; c++)
|
||||
for (int c=0; c<modules; c++)
|
||||
if (module[c].reqs & requirements) {
|
||||
PRINTF("Installing module: %s\n", module[c].name);
|
||||
|
||||
if ((*module[c].init)() < 0)
|
||||
return FALSE;
|
||||
throw ase_exception(std::string("Error initializing module: ") + module[c].name);
|
||||
|
||||
module[c].installed = TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void modules_exit()
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c=modules-1; c>=0; c--)
|
||||
for (int c=modules-1; c>=0; c--)
|
||||
if (module[c].installed) {
|
||||
PRINTF("Unstalling module: %s\n", module[c].name);
|
||||
(*module[c].exit)();
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#define REQUIRE_INTERFACE 1
|
||||
|
||||
bool modules_init(int requirements);
|
||||
void modules_init(int requirements);
|
||||
void modules_exit();
|
||||
|
||||
#endif /* CORE_MODULES_H */
|
||||
|
@ -257,9 +257,11 @@ char* jstrdup (const char* string);
|
||||
#define jrenew(struct_type, mem, n_structs) \
|
||||
((struct_type*)jrealloc((mem), (sizeof(struct_type) * (n_structs))))
|
||||
|
||||
#if defined MEMLEAK
|
||||
void jmemleak_init();
|
||||
void jmemleak_exit();
|
||||
#endif
|
||||
class Jinete
|
||||
{
|
||||
public:
|
||||
Jinete();
|
||||
~Jinete();
|
||||
};
|
||||
|
||||
#endif /* JINETE_BASE_H */
|
||||
|
81
src/jinete/jinete.cpp
Normal file
81
src/jinete/jinete.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2009 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "jinete/jbase.h"
|
||||
|
||||
#ifdef MEMLEAK
|
||||
void _jmemleak_init();
|
||||
void _jmemleak_exit();
|
||||
#endif
|
||||
|
||||
int _ji_widgets_init();
|
||||
void _ji_widgets_exit();
|
||||
|
||||
int _ji_system_init();
|
||||
void _ji_system_exit();
|
||||
|
||||
int _ji_font_init();
|
||||
void _ji_font_exit();
|
||||
|
||||
int _ji_theme_init();
|
||||
void _ji_theme_exit();
|
||||
|
||||
/**
|
||||
* Initializes the Jinete library.
|
||||
*/
|
||||
Jinete::Jinete()
|
||||
{
|
||||
#ifdef MEMLEAK
|
||||
_jmemleak_init();
|
||||
#endif
|
||||
|
||||
// initialize system
|
||||
_ji_system_init();
|
||||
_ji_font_init();
|
||||
_ji_widgets_init();
|
||||
_ji_theme_init();
|
||||
}
|
||||
|
||||
Jinete::~Jinete()
|
||||
{
|
||||
// shutdown system
|
||||
_ji_theme_exit();
|
||||
_ji_widgets_exit();
|
||||
_ji_font_exit();
|
||||
_ji_system_exit();
|
||||
|
||||
#ifdef MEMLEAK
|
||||
_jmemleak_exit();
|
||||
#endif
|
||||
}
|
||||
|
@ -39,19 +39,30 @@
|
||||
#include "jinete/jwidget.h"
|
||||
#include "jinete/jwindow.h"
|
||||
|
||||
static std::vector<JWidget> widgets;
|
||||
static std::vector<JWidget>* widgets;
|
||||
|
||||
int _ji_widgets_init()
|
||||
{
|
||||
widgets = new std::vector<JWidget>;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _ji_widgets_exit()
|
||||
{
|
||||
delete widgets;
|
||||
}
|
||||
|
||||
JWidget _ji_get_widget_by_id(JID widget_id)
|
||||
{
|
||||
assert((widget_id >= 0) && (widget_id < widgets.size()));
|
||||
assert((widget_id >= 0) && (widget_id < widgets->size()));
|
||||
|
||||
return widgets[widget_id];
|
||||
return (*widgets)[widget_id];
|
||||
}
|
||||
|
||||
JWidget* _ji_get_widget_array(int* n)
|
||||
{
|
||||
*n = widgets.size();
|
||||
return &widgets.front();
|
||||
*n = widgets->size();
|
||||
return &widgets->front();
|
||||
}
|
||||
|
||||
void _ji_add_widget(JWidget widget)
|
||||
@ -59,30 +70,30 @@ void _ji_add_widget(JWidget widget)
|
||||
JID widget_id;
|
||||
|
||||
// first widget
|
||||
if (widgets.empty()) {
|
||||
widgets.resize(2);
|
||||
if (widgets->empty()) {
|
||||
widgets->resize(2);
|
||||
|
||||
// id=0 no widget
|
||||
widgets[0] = NULL;
|
||||
(*widgets)[0] = NULL;
|
||||
|
||||
// id>0 all widgets
|
||||
widgets[1] = widget;
|
||||
widgets[1]->id = widget_id = 1;
|
||||
(*widgets)[1] = widget;
|
||||
(*widgets)[1]->id = widget_id = 1;
|
||||
}
|
||||
else {
|
||||
// find a free slot
|
||||
for (widget_id=1; widget_id<widgets.size(); widget_id++) {
|
||||
for (widget_id=1; widget_id<widgets->size(); widget_id++) {
|
||||
// is it free?
|
||||
if (widgets[widget_id] == NULL)
|
||||
if ((*widgets)[widget_id] == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
// we need space for other widget more?
|
||||
if (widget_id == widgets.size())
|
||||
widgets.resize(widgets.size()+1);
|
||||
if (widget_id == widgets->size())
|
||||
widgets->resize(widgets->size()+1);
|
||||
|
||||
widgets[widget_id] = widget;
|
||||
widgets[widget_id]->id = widget_id;
|
||||
(*widgets)[widget_id] = widget;
|
||||
(*widgets)[widget_id]->id = widget_id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,37 +101,37 @@ void _ji_remove_widget(JWidget widget)
|
||||
{
|
||||
assert_valid_widget(widget);
|
||||
|
||||
widgets[widget->id] = NULL;
|
||||
(*widgets)[widget->id] = NULL;
|
||||
}
|
||||
|
||||
bool _ji_is_valid_widget(JWidget widget)
|
||||
{
|
||||
return (widget &&
|
||||
widget->id >= 0 &&
|
||||
widget->id < widgets.size() &&
|
||||
widgets[widget->id] &&
|
||||
widgets[widget->id]->id == widget->id);
|
||||
widget->id < widgets->size() &&
|
||||
(*widgets)[widget->id] &&
|
||||
(*widgets)[widget->id]->id == widget->id);
|
||||
}
|
||||
|
||||
void _ji_set_font_of_all_widgets(struct FONT *f)
|
||||
{
|
||||
int c;
|
||||
|
||||
/* first of all, we have to set the font to all the widgets */
|
||||
for (c=0; c<widgets.size(); c++)
|
||||
if (_ji_is_valid_widget(widgets[c]))
|
||||
widgets[c]->font(f);
|
||||
// first of all, we have to set the font to all the widgets
|
||||
for (c=0; c<widgets->size(); c++)
|
||||
if (_ji_is_valid_widget((*widgets)[c]))
|
||||
(*widgets)[c]->font(f);
|
||||
|
||||
/* then we can reinitialize the theme of each widget */
|
||||
for (c=0; c<widgets.size(); c++)
|
||||
if (_ji_is_valid_widget(widgets[c]))
|
||||
jwidget_init_theme(widgets[c]);
|
||||
for (c=0; c<widgets->size(); c++)
|
||||
if (_ji_is_valid_widget((*widgets)[c]))
|
||||
jwidget_init_theme((*widgets)[c]);
|
||||
|
||||
/* remap the windows */
|
||||
for (c=0; c<widgets.size(); c++)
|
||||
if (_ji_is_valid_widget(widgets[c])) {
|
||||
if (widgets[c]->type == JI_WINDOW)
|
||||
jwindow_remap(widgets[c]);
|
||||
for (c=0; c<widgets->size(); c++)
|
||||
if (_ji_is_valid_widget((*widgets)[c])) {
|
||||
if ((*widgets)[c]->type == JI_WINDOW)
|
||||
jwindow_remap((*widgets)[c]);
|
||||
}
|
||||
|
||||
/* refresh the screen */
|
||||
|
@ -37,8 +37,8 @@
|
||||
struct FONT;
|
||||
struct BITMAP;
|
||||
|
||||
/**********************************************************************/
|
||||
/* jintern.c */
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jintern.c
|
||||
|
||||
JWidget _ji_get_widget_by_id(JID widget_id);
|
||||
JWidget *_ji_get_widget_array(int *nwidgets);
|
||||
@ -49,40 +49,25 @@ bool _ji_is_valid_widget(JWidget widget);
|
||||
|
||||
void _ji_set_font_of_all_widgets(struct FONT *f);
|
||||
|
||||
/**********************************************************************/
|
||||
/* jsystem.c */
|
||||
|
||||
int _ji_system_init();
|
||||
void _ji_system_exit();
|
||||
|
||||
/**********************************************************************/
|
||||
/* jfont.c */
|
||||
|
||||
int _ji_font_init();
|
||||
void _ji_font_exit();
|
||||
|
||||
/**********************************************************************/
|
||||
/* jwidget.c */
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jwidget.c
|
||||
|
||||
void _jwidget_add_hook(JWidget widget, JHook hook);
|
||||
void _jwidget_remove_hook(JWidget widget, JHook hook);
|
||||
|
||||
/**********************************************************************/
|
||||
/* jwindow.c */
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jwindow.c
|
||||
|
||||
bool _jwindow_is_moving();
|
||||
|
||||
/**********************************************************************/
|
||||
/* jmanager.c */
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jmanager.c
|
||||
|
||||
void _jmanager_open_window(JWidget manager, JWidget window);
|
||||
void _jmanager_close_window(JWidget manager, JWidget window, bool redraw_background);
|
||||
|
||||
/**********************************************************************/
|
||||
/* jtheme.c */
|
||||
|
||||
int _ji_theme_init();
|
||||
void _ji_theme_exit();
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jtheme.c
|
||||
|
||||
void _ji_theme_draw_sprite_color(struct BITMAP *bmp, struct BITMAP *sprite,
|
||||
int x, int y, int color);
|
||||
@ -90,8 +75,8 @@ void _ji_theme_draw_sprite_color(struct BITMAP *bmp, struct BITMAP *sprite,
|
||||
void _ji_theme_textbox_draw(struct BITMAP *bmp, JWidget textbox,
|
||||
int *w, int *h, int bg, int fg);
|
||||
|
||||
/**********************************************************************/
|
||||
/* jfontbmp.c */
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// jfontbmp.c
|
||||
|
||||
struct FONT *_ji_bitmap2font(struct BITMAP *bmp);
|
||||
|
||||
|
@ -157,10 +157,8 @@ JWidget jmanager_new()
|
||||
int c;
|
||||
|
||||
if (!default_manager) {
|
||||
/* initialize system */
|
||||
_ji_system_init();
|
||||
_ji_font_init();
|
||||
_ji_theme_init();
|
||||
if (!ji_screen)
|
||||
ji_set_screen(screen);
|
||||
|
||||
/* hook the window close message */
|
||||
want_close_stage = STAGE_NORMAL;
|
||||
@ -254,10 +252,6 @@ void jmanager_free(JWidget widget)
|
||||
default_manager = NULL;
|
||||
|
||||
/* shutdown system */
|
||||
_ji_theme_exit();
|
||||
_ji_font_exit();
|
||||
_ji_system_exit();
|
||||
|
||||
jlist_free(msg_queue);
|
||||
jlist_free(new_windows);
|
||||
jlist_free(proc_windows_list);
|
||||
|
@ -137,7 +137,7 @@ static bool memleak_status = false;
|
||||
static slot_t* headslot;
|
||||
static JMutex mutex;
|
||||
|
||||
void jmemleak_init()
|
||||
void _jmemleak_init()
|
||||
{
|
||||
assert(!memleak_status);
|
||||
|
||||
@ -147,7 +147,7 @@ void jmemleak_init()
|
||||
memleak_status = true;
|
||||
}
|
||||
|
||||
void jmemleak_exit()
|
||||
void _jmemleak_exit()
|
||||
{
|
||||
assert(memleak_status);
|
||||
memleak_status = false;
|
||||
|
@ -118,7 +118,8 @@ int _ji_system_init()
|
||||
if (install_int_ex(clock_inc, BPS_TO_TIMER(1000)) < 0)
|
||||
return -1;
|
||||
|
||||
jmouse_poll();
|
||||
if (screen)
|
||||
jmouse_poll();
|
||||
|
||||
moved = TRUE;
|
||||
m_cursor = JI_CURSOR_NULL;
|
||||
|
56
src/main.cpp
56
src/main.cpp
@ -20,8 +20,10 @@
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "ase_exception.h"
|
||||
#include "core/app.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Information for "ident".
|
||||
|
||||
const char ase_ident[] =
|
||||
@ -29,41 +31,41 @@ const char ase_ident[] =
|
||||
"$Website: " WEBSITE " $\n";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Basic classes for some RAII
|
||||
// Allegro libray initialization
|
||||
|
||||
class Allegro {
|
||||
public:
|
||||
Allegro() { allegro_init(); }
|
||||
~Allegro() { allegro_exit(); }
|
||||
Allegro() {
|
||||
allegro_init();
|
||||
set_uformat(U_ASCII);
|
||||
install_timer();
|
||||
}
|
||||
~Allegro() {
|
||||
remove_timer();
|
||||
allegro_exit();
|
||||
}
|
||||
};
|
||||
|
||||
#if defined MEMLEAK
|
||||
class MemLeaks {
|
||||
public:
|
||||
MemLeaks() { jmemleak_init(); }
|
||||
~MemLeaks() { jmemleak_exit(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Main Routine
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Here ASE starts.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Allegro allegro;
|
||||
#if defined MEMLEAK
|
||||
MemLeaks memleaks;
|
||||
#endif
|
||||
try {
|
||||
Allegro allegro;
|
||||
try {
|
||||
Jinete jinete;
|
||||
Application app(argc, argv);
|
||||
|
||||
set_uformat(U_ASCII);
|
||||
|
||||
// initialises the application
|
||||
if (!app_init(argc, argv))
|
||||
return 1;
|
||||
|
||||
app_loop();
|
||||
app_exit();
|
||||
app.run();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
allegro_message(e.what());
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
// do nothing
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -128,8 +128,8 @@ struct Monitor
|
||||
static JWidget manager = NULL;
|
||||
|
||||
static int monitor_timer = -1;
|
||||
static std::list<Monitor*> monitors;
|
||||
static std::vector<Shortcut*> shortcuts;
|
||||
static std::list<Monitor*>* monitors = NULL;
|
||||
static std::vector<Shortcut*>* shortcuts = NULL;
|
||||
|
||||
static bool ji_screen_created = FALSE;
|
||||
|
||||
@ -168,11 +168,8 @@ int init_module_gui()
|
||||
int c, w, h, bpp, autodetect;
|
||||
bool fullscreen;
|
||||
|
||||
/* install timer related stuff */
|
||||
if (install_timer() < 0) {
|
||||
user_printf(_("Error installing timer handler\n"));
|
||||
return -1;
|
||||
}
|
||||
monitors = new std::list<Monitor*>();
|
||||
shortcuts = new std::vector<Shortcut*>();
|
||||
|
||||
/* install the mouse */
|
||||
if (install_mouse() < 0) {
|
||||
@ -313,20 +310,24 @@ int init_module_gui()
|
||||
void exit_module_gui()
|
||||
{
|
||||
// destroy shortcuts
|
||||
assert(shortcuts != NULL);
|
||||
for (std::vector<Shortcut*>::iterator
|
||||
it = shortcuts.begin(); it != shortcuts.end(); ++it) {
|
||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||
Shortcut* shortcut = *it;
|
||||
delete shortcut;
|
||||
}
|
||||
shortcuts.clear();
|
||||
delete shortcuts;
|
||||
shortcuts = NULL;
|
||||
|
||||
// destroy monitors
|
||||
assert(monitors != NULL);
|
||||
for (std::list<Monitor*>::iterator
|
||||
it2 = monitors.begin(); it2 != monitors.end(); ++it2) {
|
||||
it2 = monitors->begin(); it2 != monitors->end(); ++it2) {
|
||||
Monitor* monitor = *it2;
|
||||
delete monitor;
|
||||
}
|
||||
monitors.clear();
|
||||
delete monitors;
|
||||
monitors = NULL;
|
||||
|
||||
if (double_buffering) {
|
||||
BITMAP *old_bmp = ji_screen;
|
||||
@ -344,7 +345,6 @@ void exit_module_gui()
|
||||
|
||||
remove_keyboard();
|
||||
remove_mouse();
|
||||
remove_timer();
|
||||
}
|
||||
|
||||
int guiscale()
|
||||
@ -783,7 +783,7 @@ JAccel add_keyboard_shortcut_to_execute_command(const char* shortcut_string, Com
|
||||
shortcut->command = command;
|
||||
shortcut->argument = argument ? argument: "";
|
||||
|
||||
shortcuts.push_back(shortcut);
|
||||
shortcuts->push_back(shortcut);
|
||||
}
|
||||
|
||||
shortcut->add_shortcut(shortcut_string);
|
||||
@ -798,7 +798,7 @@ JAccel add_keyboard_shortcut_to_change_tool(const char* shortcut_string, Tool* t
|
||||
shortcut = new Shortcut(Shortcut_ChangeTool);
|
||||
shortcut->tool = tool;
|
||||
|
||||
shortcuts.push_back(shortcut);
|
||||
shortcuts->push_back(shortcut);
|
||||
}
|
||||
|
||||
shortcut->add_shortcut(shortcut_string);
|
||||
@ -808,7 +808,7 @@ JAccel add_keyboard_shortcut_to_change_tool(const char* shortcut_string, Tool* t
|
||||
Command* get_command_from_key_message(JMessage msg)
|
||||
{
|
||||
for (std::vector<Shortcut*>::iterator
|
||||
it = shortcuts.begin(); it != shortcuts.end(); ++it) {
|
||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||
Shortcut* shortcut = *it;
|
||||
|
||||
if (shortcut->type == Shortcut_ExecuteCommand &&
|
||||
@ -873,7 +873,7 @@ static Shortcut* get_keyboard_shortcut_for_command(Command* command, const char*
|
||||
argument = "";
|
||||
|
||||
for (std::vector<Shortcut*>::iterator
|
||||
it = shortcuts.begin(); it != shortcuts.end(); ++it) {
|
||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||
Shortcut* shortcut = *it;
|
||||
|
||||
if (shortcut->type == Shortcut_ExecuteCommand &&
|
||||
@ -889,7 +889,7 @@ static Shortcut* get_keyboard_shortcut_for_command(Command* command, const char*
|
||||
static Shortcut* get_keyboard_shortcut_for_tool(Tool* tool)
|
||||
{
|
||||
for (std::vector<Shortcut*>::iterator
|
||||
it = shortcuts.begin(); it != shortcuts.end(); ++it) {
|
||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||
Shortcut* shortcut = *it;
|
||||
|
||||
if (shortcut->type == Shortcut_ChangeTool &&
|
||||
@ -911,7 +911,7 @@ Monitor* add_gui_monitor(void (*proc)(void *),
|
||||
{
|
||||
Monitor* monitor = new Monitor(proc, free, data);
|
||||
|
||||
monitors.push_back(monitor);
|
||||
monitors->push_back(monitor);
|
||||
|
||||
if (monitor_timer < 0)
|
||||
monitor_timer = jmanager_add_timer(manager, MONITOR_TIMER_MSECS);
|
||||
@ -927,17 +927,17 @@ Monitor* add_gui_monitor(void (*proc)(void *),
|
||||
void remove_gui_monitor(Monitor* monitor)
|
||||
{
|
||||
std::list<Monitor*>::iterator it =
|
||||
std::find(monitors.begin(), monitors.end(), monitor);
|
||||
std::find(monitors->begin(), monitors->end(), monitor);
|
||||
|
||||
assert(it != monitors.end());
|
||||
assert(it != monitors->end());
|
||||
|
||||
if (!monitor->lock)
|
||||
delete monitor;
|
||||
else
|
||||
monitor->deleted = true;
|
||||
|
||||
monitors.erase(it);
|
||||
if (monitors.empty())
|
||||
monitors->erase(it);
|
||||
if (monitors->empty())
|
||||
jmanager_stop_timer(monitor_timer);
|
||||
}
|
||||
|
||||
@ -958,7 +958,7 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
|
||||
case JM_TIMER:
|
||||
if (msg->timer.timer_id == monitor_timer) {
|
||||
for (std::list<Monitor*>::iterator
|
||||
it = monitors.begin(), next; it != monitors.end(); it = next) {
|
||||
it = monitors->begin(), next; it != monitors->end(); it = next) {
|
||||
Monitor* monitor = *it;
|
||||
next = it;
|
||||
++next;
|
||||
@ -976,14 +976,14 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
|
||||
}
|
||||
|
||||
// is monitors empty? we can stop the timer so
|
||||
if (monitors.empty())
|
||||
if (monitors->empty())
|
||||
jmanager_stop_timer(monitor_timer);
|
||||
}
|
||||
break;
|
||||
|
||||
case JM_KEYPRESSED:
|
||||
for (std::vector<Shortcut*>::iterator
|
||||
it = shortcuts.begin(); it != shortcuts.end(); ++it) {
|
||||
it = shortcuts->begin(); it != shortcuts->end(); ++it) {
|
||||
Shortcut* shortcut = *it;
|
||||
|
||||
if (shortcut->is_key_pressed(msg)) {
|
||||
|
@ -29,26 +29,24 @@
|
||||
#include "raster/gfxobj.h"
|
||||
|
||||
static JMutex objects_mutex;
|
||||
static gfxobj_id object_id = 0; // last object ID created
|
||||
static std::map<gfxobj_id, GfxObj*> objects_map; // graphics objects map
|
||||
static gfxobj_id object_id = 0; // last object ID created
|
||||
static std::map<gfxobj_id, GfxObj*>* objects_map; // graphics objects map
|
||||
|
||||
static void insert_gfxobj(GfxObj* gfxobj);
|
||||
static void erase_gfxobj(GfxObj* gfxobj);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool gfxobj_init()
|
||||
{
|
||||
objects_mutex = jmutex_new();
|
||||
if (!objects_mutex)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
void gfxobj_init()
|
||||
{
|
||||
objects_map = new std::map<gfxobj_id, GfxObj*>;
|
||||
objects_mutex = jmutex_new();
|
||||
}
|
||||
|
||||
void gfxobj_exit()
|
||||
{
|
||||
assert(objects_map.empty());
|
||||
assert(objects_map->empty());
|
||||
delete objects_map;
|
||||
jmutex_free(objects_mutex);
|
||||
}
|
||||
|
||||
@ -100,9 +98,9 @@ GfxObj* gfxobj_find(gfxobj_id id)
|
||||
jmutex_lock(objects_mutex);
|
||||
{
|
||||
std::map<gfxobj_id, GfxObj*>::iterator
|
||||
it = objects_map.find(id);
|
||||
it = objects_map->find(id);
|
||||
|
||||
if (it != objects_map.end())
|
||||
if (it != objects_map->end())
|
||||
ret = it->second;
|
||||
}
|
||||
jmutex_unlock(objects_mutex);
|
||||
@ -128,15 +126,15 @@ void _gfxobj_set_id(GfxObj* gfxobj, gfxobj_id id)
|
||||
|
||||
static void insert_gfxobj(GfxObj* gfxobj)
|
||||
{
|
||||
objects_map.insert(std::make_pair(gfxobj->id, gfxobj));
|
||||
objects_map->insert(std::make_pair(gfxobj->id, gfxobj));
|
||||
}
|
||||
|
||||
static void erase_gfxobj(GfxObj* gfxobj)
|
||||
{
|
||||
std::map<gfxobj_id, GfxObj*>::iterator
|
||||
it = objects_map.find(gfxobj->id);
|
||||
it = objects_map->find(gfxobj->id);
|
||||
|
||||
assert(it != objects_map.end());
|
||||
assert(it != objects_map->end());
|
||||
|
||||
objects_map.erase(it);
|
||||
objects_map->erase(it);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
void assign_id();
|
||||
};
|
||||
|
||||
bool gfxobj_init();
|
||||
void gfxobj_init();
|
||||
void gfxobj_exit();
|
||||
|
||||
GfxObj* gfxobj_find(gfxobj_id id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user