Project converted to C++.

This commit is contained in:
David Capello 2008-09-30 21:01:54 +00:00
parent 60683e6623
commit a587132ffe
312 changed files with 1790 additions and 2002 deletions

View File

@ -1,48 +0,0 @@
# Copyright (C) 2001-2008 by David A. Capello -*-Makefile-*-
ifndef CONFIGURED
include makefile.cfg
endif
.PHONY = cfgtest
ifndef CONFIGURED
cfgtest:
@echo You must configure ASE: edit \"makefile.cfg\" or run \"fix.sh\" script
endif
######################################################################
# Flags for DJGPP
CFLAGS =
LFLAGS = -lalleg
######################################################################
# GCC stuff
CC = gcc
OBJ = .o
LIB = .a
EXE = .exe
SUBMAKEFILE = makefile.dj
OBJ_DIR = obj/djgpp
include makefile.lst
include makefile.gcc
######################################################################
# General rules
.PHONY = default all clean distclean
default: all
all: $(ASE)
clean:
-rm -f $(ALL_OBJS) $(THIRD_PARTY_LIBS)
distclean: clean
-rm -f $(ASE)
-include makefile.dep

View File

@ -124,8 +124,8 @@ ASE_DEPS = $(ASE_OBJS) $(THIRD_PARTY_LIBS)
######################################################################
# Rules to build the object files
$(OBJ_DIR)/%$(OBJ): %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJ_DIR)/%$(OBJ): %.cpp
$(CPP) $(CFLAGS) -o $@ -c $<
$(OBJ_DIR)/%$(OBJ): %.s
$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $<
@ -153,26 +153,26 @@ $(OBJ_DIR)/zlib.%$(OBJ): %.c
ifndef WITHICON
$(ASE): $(ASE_DEPS)
$(CC) -o $@ $(ASE_OBJS) $(LFLAGS) $(LFLAGS_LAST)
$(CPP) -o $@ $(ASE_OBJS) $(LFLAGS) $(LFLAGS_LAST)
else
$(OBJ_DIR)/%.res: src/%.rc
$(WINDRES) -O coff -o $@ -i $<
$(ASE): $(ASE_DEPS) $(OBJ_DIR)/icon.res
$(CC) -o $@ $(ASE_OBJS) $(OBJ_DIR)/icon.res $(LFLAGS) $(LFLAGS_LAST)
$(CPP) -o $@ $(ASE_OBJS) $(OBJ_DIR)/icon.res $(LFLAGS) $(LFLAGS_LAST)
endif
######################################################################
# Rules to make tests
src/test/%$(EXE): src/test/%.c $(COMMON_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LFLAGS_LAST)
src/test/%$(EXE): src/test/%.cpp $(COMMON_OBJS)
$(CPP) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LFLAGS_LAST)
src/test/raster/%$(EXE): src/test/raster/%.c $(COMMON_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LFLAGS_LAST)
src/test/raster/%$(EXE): src/test/raster/%.cpp $(COMMON_OBJS)
$(CPP) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LFLAGS_LAST)
src/test/jinete/%$(EXE): src/test/jinete/%.c $(COMMON_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LFLAGS_LAST)
src/test/jinete/%$(EXE): src/test/jinete/%.cpp $(COMMON_OBJS)
$(CPP) $(CFLAGS) -o $@ $^ $(LFLAGS) $(LFLAGS_LAST)
test: $(TESTS)

View File

@ -26,11 +26,12 @@ endif
# GCC stuff
CC = gcc
CPP = g++
OBJ = .o
LIB = .a
EXE =
SUBMAKEFILE = makefile.lnx
LIB_EXT = .a
OBJ_DIR = obj/unix
SUBMAKEFILE = makefile.lnx
include makefile.lst
include makefile.gcc

View File

@ -33,11 +33,12 @@ WITHICON = 1
# GCC stuff
CC = gcc
CPP = g++
OBJ = .o
LIB = .a
EXE = .exe
SUBMAKEFILE = makefile.mgw
LIB_EXT = .a
OBJ_DIR = obj/mingw32
SUBMAKEFILE = makefile.mgw
ifndef CROSSCOMPILE
DLLWRAP = dllwrap

View File

@ -19,13 +19,12 @@ RC = rc
OBJ = .obj
EXE = .exe
LIB_EXT = .lib
OBJ_DIR = obj/msvc
include makefile.lst
CFLAGS = -nologo \
-I. -Isrc -Ithird_party -W1 -Gd -O2 \
-I. -Isrc -Ithird_party -W1 -Gd -O2 -EHa \
-I$(LIBFREETYPE_DIR)/include \
-I$(LIBJPEG_DIR) \
-I$(LIBPNG_DIR) \
@ -138,7 +137,7 @@ ASE_DEPS = $(ASE_OBJS) $(THIRD_PARTY_LIBS)
######################################################################
# Rules to build the object files
$(OBJ_DIR)/%$(OBJ): %.c
$(OBJ_DIR)/%$(OBJ): %.cpp
$(CC) $(CFLAGS) -Fo$@ -c $<
$(OBJ_DIR)/art.%$(OBJ): %.c

View File

@ -14,20 +14,20 @@ CFLAGS="-I. \
rm -f makefile.dep
$GCC $CFLAGS \
src/*.c \
src/commands/*.c \
src/commands/fx/*.c \
src/console/*.c \
src/core/*.c \
src/dialogs/*.c \
src/effect/*.c \
src/file/*.c \
src/file/*/*.c \
src/intl/*.c \
src/jinete/*.c \
src/modules/*.c \
src/raster/*.c \
src/util/*.c \
src/widgets/*.c \
src/widgets/editor/*.c \
src/*.cpp \
src/commands/*.cpp \
src/commands/fx/*.cpp \
src/console/*.cpp \
src/core/*.cpp \
src/dialogs/*.cpp \
src/effect/*.cpp \
src/file/*.cpp \
src/file/*/*.cpp \
src/intl/*.cpp \
src/jinete/*.cpp \
src/modules/*.cpp \
src/raster/*.cpp \
src/util/*.cpp \
src/widgets/*.cpp \
src/widgets/editor/*.cpp \
| sed -e 's/^\([a-z_\-]*\.o\)/obj\/mingw32\/\1/' >> makefile.dep

View File

@ -1,6 +1,6 @@
#! /bin/sh
find src third_party \
\( -name '*.[ch]' \) -print | \
\( -name '*.[ch]' -o -name '*.cpp' \) -print | \
sed -e "/_old/D" | \
etags -

View File

@ -115,7 +115,7 @@ static char *read_authors_txt(const char *filename)
if (size > 0) {
f = fopen(dir->path, "r");
if (f) {
txt = jmalloc0(size+2);
txt = (char *)jmalloc0(size+2);
fread(txt, 1, size, f);
fclose(f);
}

View File

@ -25,6 +25,7 @@
#include "commands/commands.h"
#include "console/console.h"
#include "core/app.h"
#include "dialogs/options.h"
#include "modules/gui.h"
#include "modules/palettes.h"
@ -238,7 +239,7 @@ static bool alert_msg_proc(JWidget widget, JMessage msg)
seconds_to_accept = MAX(0, seconds_to_accept);
usprintf(buf, "In %d seconds the screen will be restored.", seconds_to_accept);
jwidget_set_text(labels->end->next->next->data, buf);
jwidget_set_text((JWidget)labels->end->next->next->data, buf);
if (seconds_to_accept == 0) {
jmanager_stop_timer(timer_to_accept);

View File

@ -172,7 +172,9 @@ static void cmd_configure_tools_execute(const char *argument)
HOOK(cursor_color, SIGNAL_COLORBUTTON_CHANGE, cursor_button_change_hook, 0);
HOOK(check_onionskin, JI_SIGNAL_CHECK_CHANGE, onionskin_check_change_hook, 0);
app_add_hook(APP_EXIT, jwidget_free, window);
app_add_hook(APP_EXIT,
reinterpret_cast<void(*)(void*)>(jwidget_free),
window);
}
/* default position */

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <stdio.h>
#include <allegro.h>
#include "jinete/jinete.h"

View File

@ -115,7 +115,7 @@ static void cmd_palette_editor_execute(const char *argument)
/* create current_sprite->frames palettes */
if (current_sprite) {
palettes = jmalloc(sizeof(Palette *) * current_sprite->frames);
palettes = (Palette **)jmalloc(sizeof(Palette *) * current_sprite->frames);
if (!palettes) {
jalert(_("Error<<Not enough memory||&OK"));
return;

View File

@ -66,7 +66,9 @@ static void cmd_color_curve_execute(const char *argument)
curve_add_point(the_curve, curve_point_new(0, 0));
curve_add_point(the_curve, curve_point_new(255, 255));
app_add_hook(APP_EXIT, curve_free, the_curve);
app_add_hook(APP_EXIT,
reinterpret_cast<void(*)(void*)>(curve_free),
the_curve);
}
image = GetImage(current_sprite);

View File

@ -175,7 +175,7 @@ static void listbox_fill_convmatg(JWidget listbox)
JLink link;
JI_LIST_FOR_EACH(get_convmatr_stock(), link) {
convmatr = link->data;
convmatr = reinterpret_cast<ConvMatr *>(link->data);
listitem = jlistitem_new(convmatr->name);
listitem->user_data[0] = convmatr;
jwidget_add_child(listbox, listitem);
@ -186,13 +186,13 @@ static void listbox_select_current_convmatr(JWidget listbox)
{
const char *selected = get_config_string("ConvolutionMatrix",
"Selected", "");
JWidget select_this = jlist_first_data(listbox->children);
JWidget select_this = reinterpret_cast<JWidget>(jlist_first_data(listbox->children));
JWidget child = NULL;
JLink link;
if (selected && *selected) {
JI_LIST_FOR_EACH(listbox->children, link) {
child = link->data;
child = reinterpret_cast<JWidget>(link->data);
if (strcmp(jwidget_get_text(child), selected) == 0) {
select_this = child;
@ -215,7 +215,7 @@ static bool reload_select_hook(JWidget widget, void *data)
/* clean the list */
JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) {
listitem = link->data;
listitem = reinterpret_cast<JWidget>(link->data);
jwidget_remove_child(listbox, listitem);
jwidget_free(listitem);
}
@ -301,7 +301,7 @@ static bool generate_select_hook(JWidget widget, void *data)
static bool list_change_hook(JWidget widget, void *data)
{
JWidget selected = jlistbox_get_selected_child(widget);
ConvMatr *convmatr = selected->user_data[0];
ConvMatr *convmatr = reinterpret_cast<ConvMatr*>(selected->user_data[0]);
int new_target = convmatr->default_target;
set_config_string("ConvolutionMatrix", "Selected", convmatr->name);

View File

@ -115,8 +115,8 @@ void console_printf(const char *format, ...)
va_end(ap);
if (wid_console) {
const char *text;
char *final;
const char* text;
char* final;
/* open the window */
if (jwidget_is_hidden(wid_console)) {
@ -141,7 +141,7 @@ void console_printf(const char *format, ...)
if (!text)
final = jstrdup(buf);
else {
final = jmalloc(ustrlen(text) + ustrlen(buf) + 1);
final = (char*)jmalloc(ustrlen(text) + ustrlen(buf) + 1);
ustrcpy(final, empty_string);
ustrcat(final, text);

View File

@ -281,7 +281,7 @@ void app_loop(void)
PRINTF("Processing options...\n");
JI_LIST_FOR_EACH(options, link) {
option = link->data;
option = reinterpret_cast<Option*>(link->data);
switch (option->type) {
@ -364,7 +364,7 @@ void app_exit(void)
for (c=0; c<APP_EVENTS; ++c) {
if (apphooks[c] != NULL) {
JI_LIST_FOR_EACH(apphooks[c], link) {
apphook_free(link->data);
apphook_free(reinterpret_cast<AppHook*>(link->data));
}
jlist_free(apphooks[c]);
apphooks[c] = NULL;
@ -432,12 +432,12 @@ void app_refresh_screen(void)
*/
void app_realloc_sprite_list(void)
{
Sprite *sprite;
Sprite* sprite;
JLink link;
/* insert all other sprites */
JI_LIST_FOR_EACH(get_sprite_list(), link) {
sprite = link->data;
sprite = reinterpret_cast<Sprite*>(link->data);
tabs_set_text_for_tab(tabsbar,
get_filename(sprite->filename),
sprite);
@ -480,7 +480,7 @@ bool app_realloc_recent_list(void)
JLink link;
JI_LIST_FOR_EACH(get_recent_files_list(), link) {
filename = link->data;
filename = reinterpret_cast<const char*>(link->data);
menuitem = menuitem_new(get_filename(filename),
cmd_open_file,

View File

@ -40,9 +40,9 @@
DIRS *dirs_new(void)
{
DIRS *dirs;
DIRS* dirs;
dirs = jmalloc(sizeof(DIRS));
dirs = (DIRS*)jmalloc(sizeof(DIRS));
if (!dirs)
return NULL;

View File

@ -41,7 +41,6 @@
#endif
#if defined USE_PIDLS
#define COBJMACROS
#include <winalleg.h>
#include <shlobj.h>
#include <shlwapi.h>
@ -118,8 +117,8 @@ static unsigned int current_file_system_version = 0;
static HashTable *hash_thumbnail = NULL;
#ifdef USE_PIDLS
static LPMALLOC shl_imalloc = NULL;
static IShellFolder *shl_idesktop = NULL;
static IMalloc* shl_imalloc = NULL;
static IShellFolder* shl_idesktop = NULL;
#endif
/* local auxiliary routines */
@ -188,21 +187,23 @@ void file_system_exit(void)
#endif
if (hash_fileitems != NULL) {
hash_free(hash_fileitems, fileitem_free);
hash_free(hash_fileitems,
reinterpret_cast<void(*)(void*)>(fileitem_free));
hash_fileitems = NULL;
}
if (hash_thumbnail != NULL) {
hash_free(hash_thumbnail, (void *)destroy_bitmap);
hash_free(hash_thumbnail,
reinterpret_cast<void(*)(void*)>(destroy_bitmap));
hash_thumbnail = NULL;
}
#ifdef USE_PIDLS
/* relase desktop IShellFolder interface */
IShellFolder_Release(shl_idesktop);
shl_idesktop->Release();
/* release IMalloc interface */
IMalloc_Release(shl_imalloc);
shl_imalloc->Release();
shl_imalloc = NULL;
#endif
}
@ -244,9 +245,7 @@ FileItem *get_root_fileitem(void)
fileitem->pidl = pidl;
fileitem->fullpidl = pidl;
fileitem->attrib = SFGAO_FOLDER;
IShellFolder_GetAttributesOf(shl_idesktop, 1,
(LPCITEMIDLIST *)&pidl,
&fileitem->attrib);
shl_idesktop->GetAttributesOf(1, (LPCITEMIDLIST *)&pidl, &fileitem->attrib);
update_by_pidl(fileitem);
}
@ -286,11 +285,10 @@ FileItem *get_fileitem_from_path(const char *path)
return get_root_fileitem();
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, path, ustrlen(path)+1, wStr, MAX_PATH);
if (IShellFolder_ParseDisplayName(shl_idesktop,
NULL, NULL,
wStr, &cbEaten,
&fullpidl,
&attrib) != S_OK) {
if (shl_idesktop->ParseDisplayName(NULL, NULL,
wStr, &cbEaten,
&fullpidl,
&attrib) != S_OK) {
return NULL;
}
@ -396,39 +394,37 @@ JList fileitem_get_children(FileItem *fileitem)
/* printf("Loading files for %p (%s)\n", fileitem, fileitem->displayname); fflush(stdout); */
#ifdef USE_PIDLS
{
IShellFolder *pFolder = NULL;
IShellFolder* pFolder = NULL;
if (fileitem == rootitem)
pFolder = shl_idesktop;
else
IShellFolder_BindToObject(shl_idesktop,
fileitem->fullpidl,
NULL,
&IID_IShellFolder,
(LPVOID *)&pFolder);
shl_idesktop->BindToObject(fileitem->fullpidl,
NULL,
IID_IShellFolder,
(LPVOID *)&pFolder);
if (pFolder != NULL) {
IEnumIDList *pEnum = NULL;
ULONG c, fetched;
/* get the interface to enumerate subitems */
IShellFolder_EnumObjects(pFolder, win_get_window(),
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnum);
pFolder->EnumObjects(win_get_window(),
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &pEnum);
if (pEnum != NULL) {
LPITEMIDLIST itempidl[256];
SFGAOF attribs[256];
/* enumerate the items in the folder */
while (IEnumIDList_Next(pEnum, 256, itempidl, &fetched) == S_OK &&
fetched > 0) {
while (pEnum->Next(256, itempidl, &fetched) == S_OK && fetched > 0) {
/* request the SFGAO_FOLDER attribute to know what of the
item is a folder */
for (c=0; c<fetched; ++c)
attribs[c] = SFGAO_FOLDER;
if (IShellFolder_GetAttributesOf(pFolder, fetched,
(LPCITEMIDLIST *)itempidl, attribs) != S_OK) {
if (pFolder->GetAttributesOf(fetched,
(LPCITEMIDLIST *)itempidl, attribs) != S_OK) {
for (c=0; c<fetched; ++c)
attribs[c] = 0;
}
@ -459,11 +455,11 @@ JList fileitem_get_children(FileItem *fileitem)
}
}
IEnumIDList_Release(pEnum);
pEnum->Release();
}
if (pFolder != shl_idesktop)
IShellFolder_Release(pFolder);
pFolder->Release();
}
}
#else
@ -524,20 +520,23 @@ bool fileitem_has_extension(FileItem *fileitem, const char *list_of_extensions)
list_of_extensions);
}
BITMAP *fileitem_get_thumbnail(FileItem *fileitem)
BITMAP* fileitem_get_thumbnail(FileItem* fileitem)
{
assert(fileitem != NULL);
return hash_lookup(hash_thumbnail, fileitem->filename);
return reinterpret_cast<BITMAP*>(hash_lookup(hash_thumbnail, fileitem->filename));
}
void fileitem_set_thumbnail(FileItem *fileitem, BITMAP *thumbnail)
void fileitem_set_thumbnail(FileItem* fileitem, BITMAP* thumbnail)
{
BITMAP *current_thumbnail;
BITMAP* current_thumbnail;
assert(fileitem != NULL);
current_thumbnail = hash_lookup(hash_thumbnail, fileitem->filename);
current_thumbnail = reinterpret_cast<BITMAP*>
(hash_lookup(hash_thumbnail,
fileitem->filename));
if (current_thumbnail) {
destroy_bitmap(current_thumbnail);
hash_remove(hash_thumbnail, fileitem->filename);
@ -723,28 +722,25 @@ static void update_by_pidl(FileItem *fileitem)
pFolder = shl_idesktop;
else {
assert(fileitem->parent != NULL);
IShellFolder_BindToObject(shl_idesktop,
fileitem->parent->fullpidl,
NULL,
&IID_IShellFolder,
(LPVOID *)&pFolder);
shl_idesktop->BindToObject(fileitem->parent->fullpidl,
NULL,
IID_IShellFolder,
(LPVOID *)&pFolder);
}
/****************************************/
/* get the file name */
if (pFolder != NULL &&
IShellFolder_GetDisplayNameOf(pFolder,
fileitem->pidl,
SHGDN_NORMAL | SHGDN_FORPARSING,
&strret) == S_OK) {
pFolder->GetDisplayNameOf(fileitem->pidl,
SHGDN_NORMAL | SHGDN_FORPARSING,
&strret) == S_OK) {
StrRetToBuf(&strret, fileitem->pidl, pszName, MAX_PATH);
fileitem->filename = jstrdup(pszName);
}
else if (IShellFolder_GetDisplayNameOf(shl_idesktop,
fileitem->fullpidl,
SHGDN_NORMAL | SHGDN_FORPARSING,
&strret) == S_OK) {
else if (shl_idesktop->GetDisplayNameOf(fileitem->fullpidl,
SHGDN_NORMAL | SHGDN_FORPARSING,
&strret) == S_OK) {
StrRetToBuf(&strret, fileitem->fullpidl, pszName, MAX_PATH);
fileitem->filename = jstrdup(pszName);
}
@ -755,18 +751,16 @@ static void update_by_pidl(FileItem *fileitem)
/****************************************/
/* get the name to display */
if (pFolder != NULL &&
IShellFolder_GetDisplayNameOf(pFolder,
fileitem->pidl,
SHGDN_INFOLDER,
&strret) == S_OK) {
if (pFolder &&
pFolder->GetDisplayNameOf(fileitem->pidl,
SHGDN_INFOLDER,
&strret) == S_OK) {
StrRetToBuf(&strret, fileitem->pidl, pszName, MAX_PATH);
fileitem->displayname = jstrdup(pszName);
}
else if (IShellFolder_GetDisplayNameOf(shl_idesktop,
fileitem->fullpidl,
SHGDN_INFOLDER,
&strret) == S_OK) {
else if (shl_idesktop->GetDisplayNameOf(fileitem->fullpidl,
SHGDN_INFOLDER,
&strret) == S_OK) {
StrRetToBuf(&strret, fileitem->fullpidl, pszName, MAX_PATH);
fileitem->displayname = jstrdup(pszName);
}
@ -775,7 +769,7 @@ static void update_by_pidl(FileItem *fileitem)
}
if (pFolder != NULL && pFolder != shl_idesktop) {
IShellFolder_Release(pFolder);
pFolder->Release();
}
}
@ -790,7 +784,7 @@ static LPITEMIDLIST concat_pidl(LPITEMIDLIST pidlHead, LPITEMIDLIST pidlTail)
cb1 = get_pidl_size(pidlHead) - sizeof(pidlHead->mkid.cb);
cb2 = get_pidl_size(pidlTail);
pidlNew = (LPITEMIDLIST)IMalloc_Alloc(shl_imalloc, cb1 + cb2);
pidlNew = (LPITEMIDLIST)shl_imalloc->Alloc(cb1 + cb2);
if (pidlNew) {
CopyMemory(pidlNew, pidlHead, cb1);
CopyMemory(((LPSTR)pidlNew) + cb1, pidlTail, cb2);
@ -838,7 +832,7 @@ static LPITEMIDLIST get_last_pidl(LPITEMIDLIST pidl)
if (pidlLast) {
ULONG sz = get_pidl_size(pidlLast);
pidlNew = (LPITEMIDLIST)IMalloc_Alloc(shl_imalloc, sz);
pidlNew = (LPITEMIDLIST)shl_imalloc->Alloc(sz);
CopyMemory(pidlNew, pidlLast, sz);
}
@ -848,7 +842,7 @@ static LPITEMIDLIST get_last_pidl(LPITEMIDLIST pidl)
static LPITEMIDLIST clone_pidl(LPITEMIDLIST pidl)
{
ULONG sz = get_pidl_size(pidl);
LPITEMIDLIST pidlNew = (LPITEMIDLIST)IMalloc_Alloc(shl_imalloc, sz);
LPITEMIDLIST pidlNew = (LPITEMIDLIST)shl_imalloc->Alloc(sz);
CopyMemory(pidlNew, pidl, sz);
@ -873,7 +867,7 @@ static LPITEMIDLIST remove_last_pidl(LPITEMIDLIST pidl)
static void free_pidl(LPITEMIDLIST pidl)
{
IMalloc_Free(shl_imalloc, pidl);
shl_imalloc->Free(pidl);
}
static char *get_key_for_pidl(LPITEMIDLIST pidl)
@ -906,10 +900,9 @@ static char *get_key_for_pidl(LPITEMIDLIST pidl)
/* printf("***\n"); fflush(stdout); */
pidl = clone_pidl(pidl);
while (pidl->mkid.cb > 0) {
if (IShellFolder_GetDisplayNameOf(shl_idesktop,
pidl,
SHGDN_INFOLDER | SHGDN_FORPARSING,
&strret) == S_OK) {
if (shl_idesktop->GetDisplayNameOf(pidl,
SHGDN_INFOLDER | SHGDN_FORPARSING,
&strret) == S_OK) {
StrRetToBuf(&strret, pidl, pszName, MAX_PATH);
/* printf("+ %s\n", pszName); fflush(stdout); */
@ -939,13 +932,13 @@ static char *get_key_for_pidl(LPITEMIDLIST pidl)
#endif
}
static FileItem *get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_not)
static FileItem* get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_not)
{
char *key;
FileItem *fileitem;
char* key;
FileItem* fileitem;
key = get_key_for_pidl(fullpidl);
fileitem = hash_lookup(hash_fileitems, key);
fileitem = reinterpret_cast<FileItem*>(hash_lookup(hash_fileitems, key));
jfree(key);
if (fileitem)
@ -959,9 +952,8 @@ static FileItem *get_fileitem_by_fullpidl(LPITEMIDLIST fullpidl, bool create_if_
fileitem->fullpidl = clone_pidl(fullpidl);
fileitem->attrib = SFGAO_FOLDER;
IShellFolder_GetAttributesOf(shl_idesktop, 1,
(LPCITEMIDLIST *)&fileitem->fullpidl,
&fileitem->attrib);
shl_idesktop->GetAttributesOf(1, (LPCITEMIDLIST *)&fileitem->fullpidl,
&fileitem->attrib);
{
LPITEMIDLIST parent_fullpidl = clone_pidl(fileitem->fullpidl);

View File

@ -97,10 +97,10 @@ enum {
typedef struct AniEditor
{
Sprite *sprite;
Sprite* sprite;
int state;
Layer *selected_layer;
Layer **layers;
Layer* selected_layer;
Layer** layers;
int nlayers;
int scroll_x;
int scroll_y;
@ -121,19 +121,19 @@ typedef struct AniEditor
static JWidget current_anieditor = NULL;
static JWidget anieditor_new(Sprite *sprite);
static JWidget anieditor_new(Sprite* sprite);
static int anieditor_type(void);
static AniEditor *anieditor_data(JWidget widget);
static AniEditor* anieditor_data(JWidget widget);
static bool anieditor_msg_proc(JWidget widget, JMessage msg);
static void anieditor_setcursor(JWidget widget, int x, int y);
static void anieditor_get_drawable_layers(JWidget widget, JRect clip, int *first_layer, int *last_layer);
static void anieditor_get_drawable_frames(JWidget widget, JRect clip, int *first_frame, int *last_frame);
static void anieditor_get_drawable_layers(JWidget widget, JRect clip, int* first_layer, int* last_layer);
static void anieditor_get_drawable_frames(JWidget widget, JRect clip, int* first_frame, int* last_frame);
static void anieditor_draw_header(JWidget widget, JRect clip);
static void anieditor_draw_header_frame(JWidget widget, JRect clip, int frame);
static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y1, int x2, int y2,
bool is_hot, bool is_clk,
const char *line1, int align1,
const char *line2, int align2);
const char* line1, int align1,
const char* line2, int align2);
static void anieditor_draw_separator(JWidget widget, JRect clip);
static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index);
static void anieditor_draw_layer_padding(JWidget widget);
@ -146,9 +146,9 @@ static void anieditor_show_cel(JWidget widget, int layer, int frame);
static void anieditor_show_current_cel(JWidget widget);
static void anieditor_clean_clk(JWidget widget);
static void anieditor_set_scroll(JWidget widget, int x, int y, bool use_refresh_region);
static int anieditor_get_layer_index(JWidget widget, Layer *layer);
static int anieditor_get_layer_index(JWidget widget, Layer* layer);
static void icon_rect(BITMAP *icon, int x1, int y1, int x2, int y2, bool is_selected, bool is_hot, bool is_clk);
static void icon_rect(BITMAP* icon, int x1, int y1, int x2, int y2, bool is_selected, bool is_hot, bool is_clk);
bool animation_editor_is_movingcel(void)
{
@ -162,7 +162,7 @@ bool animation_editor_is_movingcel(void)
*/
void switch_between_animation_and_sprite_editor(void)
{
Sprite *sprite = current_sprite;
Sprite* sprite = current_sprite;
JWidget window;
JWidget anieditor;
int layer;
@ -197,10 +197,10 @@ void switch_between_animation_and_sprite_editor(void)
The Animation Editor
*********************************************************************/
static JWidget anieditor_new(Sprite *sprite)
static JWidget anieditor_new(Sprite* sprite)
{
JWidget widget = jwidget_new(anieditor_type());
AniEditor *anieditor = jnew0(AniEditor, 1);
AniEditor* anieditor = jnew0(AniEditor, 1);
anieditor->sprite = sprite;
anieditor->state = STATE_STANDBY;
@ -230,14 +230,14 @@ static int anieditor_type(void)
return type;
}
static AniEditor *anieditor_data(JWidget widget)
static AniEditor* anieditor_data(JWidget widget)
{
return jwidget_get_data(widget, anieditor_type());
return reinterpret_cast<AniEditor*>(jwidget_get_data(widget, anieditor_type()));
}
static bool anieditor_msg_proc(JWidget widget, JMessage msg)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
switch (msg->type) {
@ -456,8 +456,8 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
/* is the mouse on a layer's label? */
if (mx < anieditor->separator_x) {
BITMAP *icon1 = get_gfx(GFX_BOX_SHOW);
BITMAP *icon2 = get_gfx(GFX_BOX_UNLOCK);
BITMAP* icon1 = get_gfx(GFX_BOX_SHOW);
BITMAP* icon2 = get_gfx(GFX_BOX_UNLOCK);
int x1, y1, x2, y2, y_mid;
x1 = 0;
@ -834,7 +834,7 @@ static void anieditor_setcursor(JWidget widget, int x, int y)
static void anieditor_get_drawable_layers(JWidget widget, JRect clip, int *first_layer, int *last_layer)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
*first_layer = 0;
*last_layer = anieditor->nlayers-1;
@ -842,7 +842,7 @@ static void anieditor_get_drawable_layers(JWidget widget, JRect clip, int *first
static void anieditor_get_drawable_frames(JWidget widget, JRect clip, int *first_frame, int *last_frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
*first_frame = 0;
*last_frame = anieditor->sprite->frames-1;
@ -850,7 +850,7 @@ static void anieditor_get_drawable_frames(JWidget widget, JRect clip, int *first
static void anieditor_draw_header(JWidget widget, JRect clip)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
/* bool is_hot = (anieditor->hot_part == PART_HEADER_LAYER); */
/* bool is_clk = (anieditor->clk_part == PART_HEADER_LAYER); */
int x1, y1, x2, y2;
@ -870,7 +870,7 @@ static void anieditor_draw_header(JWidget widget, JRect clip)
static void anieditor_draw_header_frame(JWidget widget, JRect clip, int frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
bool is_hot = (anieditor->hot_part == PART_HEADER_FRAME &&
anieditor->hot_frame == frame);
bool is_clk = (anieditor->clk_part == PART_HEADER_FRAME &&
@ -974,7 +974,7 @@ static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y
static void anieditor_draw_separator(JWidget widget, JRect clip)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
bool is_hot = (anieditor->hot_part == PART_SEPARATOR);
int x1, y1, x2, y2;
@ -993,7 +993,7 @@ static void anieditor_draw_separator(JWidget widget, JRect clip)
static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
Layer *layer = anieditor->layers[layer_index];
BITMAP *icon1 = get_gfx(layer_is_readable(layer) ? GFX_BOX_SHOW: GFX_BOX_HIDE);
BITMAP *icon2 = get_gfx(layer_is_writable(layer) ? GFX_BOX_UNLOCK: GFX_BOX_LOCK);
@ -1090,7 +1090,7 @@ static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index)
static void anieditor_draw_layer_padding(JWidget widget)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int layer_index = anieditor->nlayers-1;
int x1, y1, x2, y2;
@ -1111,7 +1111,7 @@ static void anieditor_draw_layer_padding(JWidget widget)
static void anieditor_draw_cel(JWidget widget, JRect clip, int layer_index, int frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
Layer *layer = anieditor->layers[layer_index];
bool selected_layer = (layer == anieditor->sprite->layer);
bool is_hot = (anieditor->hot_part == PART_CEL &&
@ -1223,7 +1223,7 @@ static void anieditor_draw_cel(JWidget widget, JRect clip, int layer_index, int
static bool anieditor_draw_part(JWidget widget, int part, int layer, int frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
switch (part) {
case PART_NOTHING:
@ -1263,7 +1263,7 @@ static bool anieditor_draw_part(JWidget widget, int part, int layer, int frame)
static void anieditor_regenerate_layers(JWidget widget)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int c;
if (anieditor->layers != NULL) {
@ -1275,7 +1275,7 @@ static void anieditor_regenerate_layers(JWidget widget)
/* here we build an array with all the layers */
if (anieditor->nlayers > 0) {
anieditor->layers = jmalloc(sizeof(Layer *) * anieditor->nlayers);
anieditor->layers = (Layer**)jmalloc(sizeof(Layer*) * anieditor->nlayers);
for (c=0; c<anieditor->nlayers; c++)
anieditor->layers[c] = sprite_index2layer(anieditor->sprite,
@ -1285,7 +1285,7 @@ static void anieditor_regenerate_layers(JWidget widget)
static void anieditor_hot_this(JWidget widget, int hot_part, int hot_layer, int hot_frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int old_hot_part;
/* if the part, layer or frame change */
@ -1318,7 +1318,7 @@ static void anieditor_hot_this(JWidget widget, int hot_part, int hot_layer, int
static void anieditor_center_cel(JWidget widget, int layer, int frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int target_x = (widget->rc->x1 + anieditor->separator_x + anieditor->separator_w + widget->rc->x2)/2 - FRMSIZE/2;
int target_y = (widget->rc->y1 + HDRSIZE + widget->rc->y2)/2 - LAYSIZE/2;
int scroll_x = widget->rc->x1 + anieditor->separator_x + anieditor->separator_w + FRMSIZE*frame - target_x;
@ -1329,7 +1329,7 @@ static void anieditor_center_cel(JWidget widget, int layer, int frame)
static void anieditor_show_cel(JWidget widget, int layer, int frame)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int scroll_x, scroll_y;
int x1, y1, x2, y2;
@ -1362,7 +1362,7 @@ static void anieditor_show_cel(JWidget widget, int layer, int frame)
static void anieditor_show_current_cel(JWidget widget)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int layer = anieditor_get_layer_index(widget, anieditor->sprite->layer);
if (layer >= 0)
anieditor_show_cel(widget, layer, anieditor->sprite->frame);
@ -1370,7 +1370,7 @@ static void anieditor_show_current_cel(JWidget widget)
static void anieditor_clean_clk(JWidget widget)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int clk_part = anieditor->clk_part;
anieditor->clk_part = PART_NOTHING;
@ -1382,7 +1382,7 @@ static void anieditor_clean_clk(JWidget widget)
static void anieditor_set_scroll(JWidget widget, int x, int y, bool use_refresh_region)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int old_scroll_x = 0;
int old_scroll_y = 0;
int max_scroll_x;
@ -1456,9 +1456,9 @@ static void anieditor_set_scroll(JWidget widget, int x, int y, bool use_refresh_
}
}
static int anieditor_get_layer_index(JWidget widget, Layer *layer)
static int anieditor_get_layer_index(JWidget widget, Layer* layer)
{
AniEditor *anieditor = anieditor_data(widget);
AniEditor* anieditor = anieditor_data(widget);
int i;
for (i=0; i<anieditor->nlayers; i++)

View File

@ -86,7 +86,9 @@ char *ase_file_selector(const char *message,
if (!navigation_history) {
navigation_history = jlist_new();
app_add_hook(APP_EXIT, jlist_free, navigation_history);
app_add_hook(APP_EXIT,
reinterpret_cast<void(*)(void*)>(jlist_free),
navigation_history);
}
/* 'buf' will contain the start folder path */
@ -279,7 +281,7 @@ static void update_location(JWidget window)
/* add item by item (from root to the specific current folder) */
level = 0;
JI_LIST_FOR_EACH(locations, link) {
fileitem = link->data;
fileitem = reinterpret_cast<FileItem*>(link->data);
/* indentation */
ustrcpy(buf, empty_string);
@ -404,7 +406,7 @@ static void goback_command(JWidget widget)
navigation_locked = TRUE;
fileview_set_current_folder(fileview,
navigation_position->data);
reinterpret_cast<FileItem*>(navigation_position->data));
navigation_locked = FALSE;
}
}
@ -424,7 +426,7 @@ static void goforward_command(JWidget widget)
navigation_locked = TRUE;
fileview_set_current_folder(fileview,
navigation_position->data);
reinterpret_cast<FileItem*>(navigation_position->data));
navigation_locked = FALSE;
}
}
@ -488,9 +490,9 @@ static bool location_msg_proc(JWidget widget, JMessage msg)
/* when the user change the location we have to set the
current-folder in the 'fileview' widget */
case JI_SIGNAL_COMBOBOX_SELECT: {
FileItem *fileitem =
jcombobox_get_data(widget,
jcombobox_get_selected_index(widget));
FileItem* fileitem = reinterpret_cast<FileItem*>
(jcombobox_get_data(widget,
jcombobox_get_selected_index(widget)));
if (fileitem) {
JWidget fileview = jwidget_find_name(jwidget_get_window(widget),

View File

@ -126,7 +126,7 @@ static void kill_listbox(RepoDlg *repo_dlg)
/* remove all items */
JI_LIST_FOR_EACH_SAFE(listbox->children, link, next) {
listitem = link->data;
listitem = reinterpret_cast<JWidget>(link->data);
jwidget_remove_child(repo_dlg->listbox, listitem);
@ -149,7 +149,7 @@ static int repo_listbox_type(void)
static bool repo_listbox_msg_proc(JWidget widget, JMessage msg)
{
RepoDlg *repo_dlg = jwidget_get_data(widget, repo_listbox_type());
RepoDlg* repo_dlg = reinterpret_cast<RepoDlg*>(jwidget_get_data(widget, repo_listbox_type()));
switch (msg->type) {

View File

@ -236,7 +236,7 @@ static int tips_image_type(void)
static bool tips_image_msg_proc(JWidget widget, JMessage msg)
{
if (msg->type == JM_DESTROY)
destroy_bitmap(jwidget_get_data(widget, tips_image_type()));
destroy_bitmap(reinterpret_cast<BITMAP*>(jwidget_get_data(widget, tips_image_type())));
return FALSE;
}
@ -299,7 +299,7 @@ static void tips_load_page(JWidget widget)
/* destroy old page */
if (!jlist_empty(widget->children)) {
JWidget child = jlist_first(widget->children)->data;
JWidget child = reinterpret_cast<JWidget>(jlist_first(widget->children)->data);
jwidget_remove_child(widget, child);
jwidget_free(child);
}
@ -454,7 +454,7 @@ static JWidget tips_load_box(FILE *f, char *buf, int sizeof_buf, int *take)
}
/* add chars */
text = jrealloc(text, strlen(text) + 1 + strlen(buf) + 1);
text = (char*)jrealloc(text, strlen(text) + 1 + strlen(buf) + 1);
strcat(text, " ");
strcpy(text+strlen(text), buf);
}

View File

@ -19,7 +19,7 @@
#include "config.h"
#include <allegro.h>
#include <math.h>
#include <cmath>
#include "core/core.h"
#include "modules/gui.h"
@ -33,21 +33,21 @@ static void project(Image *image, int x, int y, double dmax, double *out_x, doub
{
int center_x = image->w/2; /* center point */
int center_y = image->h/2;
int u = (x - center_x); /* vector from center to current point */
int v = (y - center_y);
double u = (x - center_x); /* vector from center to current point */
double v = (y - center_y);
int r = MIN(image->w, image->h)/2; /* radius */
double d = sqrt(u*u + v*v); /* distance from center */
double a = atan2(-v, u); /* angle with center */
double d = std::sqrt(u*u + v*v); /* distance from center */
double a = std::atan2(-v, u); /* angle with center */
#if 1
/* sphere */
double s = sin(PI*MIN(d, r)/r); /* scale factor for effect */
/* double s = cos(PI/2*MIN(d, r)/r); /\* scale factor for effect *\/ */
double s = std::sin(PI*MIN(d, r)/r); /* scale factor for effect */
/* double s = std::cos(PI/2*MIN(d, r)/r); /\* scale factor for effect *\/ */
double howmuch = 32;
/* *out_x = s * (cos(a)*howmuch*(dmax-d)/dmax); */
/* *out_y = s * (sin(a)*howmuch*(dmax-d)/dmax); */
*out_x = s * (cos(a)*howmuch*d/dmax);
*out_y = s * (sin(a)*howmuch*d/dmax);
/* *out_x = s * (std::cos(a)*howmuch*(dmax-d)/dmax); */
/* *out_y = s * (std::sin(a)*howmuch*(dmax-d)/dmax); */
*out_x = s * (std::cos(a)*howmuch*d/dmax);
*out_y = s * (std::sin(a)*howmuch*d/dmax);
#elif 0
@ -147,7 +147,7 @@ void dialogs_vector_map(void)
if (undo_is_enabled(sprite->undo))
undo_image(sprite->undo, image, 0, 0, image->w, image->h);
dmax = sqrt(image->w/2*image->w/2 + image->h/2*image->h/2);
dmax = std::sqrt(static_cast<double>(image->w/2*image->w/2 + image->h/2*image->h/2));
for (y=0; y<image->h; y++) {
for (x=0; x<image->w; x++) {
PROJECT();

View File

@ -69,7 +69,7 @@ void curve_free(Curve *curve)
JLink link;
JI_LIST_FOR_EACH(curve->points, link)
curve_point_free(link->data);
curve_point_free(reinterpret_cast<CurvePoint*>(link->data));
jlist_free(curve->points);
jfree(curve);
@ -101,10 +101,11 @@ void curve_remove_point(Curve *curve, CurvePoint *point)
static void
spline_solve(int n, float x[], float y[], float y2[])
{
float p, sig, *u;
float p, sig;
float* u;
int i, k;
u = jmalloc((n - 1) * sizeof(u[0]));
u = (float*)jmalloc((n - 1) * sizeof(u[0]));
y2[0] = u[0] = 0.0; /* set lower boundary condition to "natural" */
@ -182,8 +183,8 @@ void curve_get_values(Curve *curve, int x1, int x2, int *values)
if (link != curve->points->end) {
if (link->prev != curve->points->end) {
p = link->prev->data;
n = link->data;
p = reinterpret_cast<CurvePoint*>(link->prev->data);
n = reinterpret_cast<CurvePoint*>(link->data);
values[x-x1] = p->y + (n->y-p->y) * (x-p->x) / (n->x-p->x);
}
@ -206,7 +207,7 @@ void curve_get_values(Curve *curve, int x1, int x2, int *values)
min_x = 0;
mem = jmalloc(3 * num_points * sizeof(float));
mem = (float*)jmalloc(3 * num_points * sizeof(float));
xv = mem;
yv = mem + num_points;
y2v = mem + 2*num_points;

View File

@ -80,7 +80,7 @@ ConvMatr *convmatr_new(int w, int h)
size = convmatr->w * convmatr->h;
convmatr->data = jmalloc(sizeof(int) * size);
convmatr->data = (int*)jmalloc(sizeof(int) * size);
if (!convmatr->data) {
convmatr_free(convmatr);
return NULL;
@ -120,21 +120,21 @@ void set_convmatr(ConvMatr *convmatr)
if (data.lines != NULL)
jfree(data.lines);
data.lines = jmalloc(sizeof(unsigned char *) * convmatr->h);
data.lines = (unsigned char**)jmalloc(sizeof(unsigned char*) * convmatr->h);
}
ConvMatr *get_convmatr(void)
ConvMatr* get_convmatr(void)
{
return data.convmatr;
}
ConvMatr *get_convmatr_by_name(const char *name)
ConvMatr* get_convmatr_by_name(const char *name)
{
ConvMatr *convmatr;
ConvMatr* convmatr;
JLink link;
JI_LIST_FOR_EACH(data.matrices, link) {
convmatr = link->data;
convmatr = reinterpret_cast<ConvMatr*>(link->data);
if (strcmp(convmatr->name, name) == 0)
return convmatr;
}
@ -298,7 +298,7 @@ void clean_matrices_stock(void)
JLink link;
JI_LIST_FOR_EACH(data.matrices, link)
convmatr_free(link->data);
convmatr_free(reinterpret_cast<ConvMatr*>(link->data));
jlist_clear(data.matrices);
}

View File

@ -90,7 +90,7 @@ Effect *effect_new(Sprite *sprite, const char *name)
EffectData *effect_data;
Effect *effect;
Image *image;
void *apply;
void (*apply)(Effect*);
effect_data = get_effect_data(name);
if (!effect_data)

Some files were not shown because too many files have changed in this diff Show More