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