From a2718f83e4f8d49cef52d0aef30cd52aad8c674b Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 22 Aug 2014 01:32:13 -0300 Subject: [PATCH] Remove Allegro dependency from several files --- src/app/color_utils.cpp | 2 -- src/app/ui/color_bar.cpp | 1 + src/app/ui/editor/editor.h | 2 -- src/app/ui/palette_view.cpp | 2 +- src/app/ui/palette_view.h | 1 - src/app/ui/skin/skin_theme.h | 1 - src/app/util/clipboard.cpp | 8 ++------ src/app/util/clipboard_win32.h | 22 +++++++++++++++------- src/app/util/msk_file.cpp | 30 ++++++++++++------------------ src/app/widget_loader.cpp | 29 ++++++++++++++--------------- 10 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/app/color_utils.cpp b/src/app/color_utils.cpp index 09b32b658..67c8f0fa2 100644 --- a/src/app/color_utils.cpp +++ b/src/app/color_utils.cpp @@ -20,8 +20,6 @@ #include "config.h" #endif -#include - #include "app/color.h" #include "app/color_utils.h" #include "app/modules/palettes.h" diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index c3fa7d194..f5f7c0401 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -37,6 +37,7 @@ #include "ui/graphics.h" #include "ui/menu.h" #include "ui/paint_event.h" +#include "ui/system.h" #include diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h index 164066491..1c346985d 100644 --- a/src/app/ui/editor/editor.h +++ b/src/app/ui/editor/editor.h @@ -36,8 +36,6 @@ #define MIN_ZOOM 0 #define MAX_ZOOM 5 -struct BITMAP; - namespace raster { class Sprite; class Layer; diff --git a/src/app/ui/palette_view.cpp b/src/app/ui/palette_view.cpp index fd6a011d7..94743c8e9 100644 --- a/src/app/ui/palette_view.cpp +++ b/src/app/ui/palette_view.cpp @@ -281,7 +281,7 @@ void PaletteView::onPaint(ui::PaintEvent& ev) int x, y, u, v; int c, color; Palette* palette = get_current_palette(); - int bordercolor = makecol(255, 255, 255); + gfx::Color bordercolor = gfx::rgba(255, 255, 255); g->fillRect(gfx::rgba(0 , 0, 0), bounds); diff --git a/src/app/ui/palette_view.h b/src/app/ui/palette_view.h index 55f7e406d..950e570f4 100644 --- a/src/app/ui/palette_view.h +++ b/src/app/ui/palette_view.h @@ -24,7 +24,6 @@ #include "base/signal.h" #include "ui/widget.h" -#include #include namespace app { diff --git a/src/app/ui/skin/skin_theme.h b/src/app/ui/skin/skin_theme.h index 6a20734fa..13e10fc81 100644 --- a/src/app/ui/skin/skin_theme.h +++ b/src/app/ui/skin/skin_theme.h @@ -26,7 +26,6 @@ #include "gfx/color.h" #include "gfx/fwd.h" #include "ui/manager.h" -#include "ui/system.h" #include "ui/theme.h" #include diff --git a/src/app/util/clipboard.cpp b/src/app/util/clipboard.cpp index 425735d89..7e973d384 100644 --- a/src/app/util/clipboard.cpp +++ b/src/app/util/clipboard.cpp @@ -45,14 +45,10 @@ #include "app/util/clipboard.h" #include "app/util/misc.h" #include "raster/raster.h" -#include "ui/ui.h" #include "undo/undo_history.h" -#include -#include - -#if defined ALLEGRO_WINDOWS - #include +#if defined WIN32 + #include #include "app/util/clipboard_win32.h" #endif diff --git a/src/app/util/clipboard_win32.h b/src/app/util/clipboard_win32.h index be6098069..9238c2b36 100644 --- a/src/app/util/clipboard_win32.h +++ b/src/app/util/clipboard_win32.h @@ -18,6 +18,11 @@ // included by clipboard.cpp +#include "raster/color_scales.h" +#include "she/display.h" +#include "she/system.h" +#include "ui/alert.h" + #ifndef LCS_WINDOWS_COLOR_SPACE #define LCS_WINDOWS_COLOR_SPACE 'Win ' #endif @@ -54,7 +59,8 @@ static bool win32_clipboard_contains_bitmap() */ static void set_win32_clipboard_bitmap(Image* image, Palette* palette) { - if (!OpenClipboard(win_get_window())) + HWND hwnd = static_cast(she::instance()->defaultDisplay()->nativeHandle()); + if (!OpenClipboard(hwnd)) return; if (!EmptyClipboard()) { @@ -183,7 +189,8 @@ static void get_win32_clipboard_bitmap(Image*& image, Palette*& palette) if (!win32_clipboard_contains_bitmap()) return; - if (!OpenClipboard(win_get_window())) + HWND hwnd = static_cast(she::instance()->defaultDisplay()->nativeHandle()); + if (!OpenClipboard(hwnd)) return; BITMAPINFO* bi = (BITMAPINFO*)GetClipboardData(CF_DIB); @@ -278,9 +285,9 @@ static void get_win32_clipboard_bitmap(Image*& image, Palette*& palette) for (int x=0; xwidth(); ++x) { b1 = *(src++); b2 = *(src++); - b = _rgb_scale_5[((b1 & 0xf800) >> 11)]; - g = _rgb_scale_6[((b2 & 0x07e0) >> 5)]; - r = _rgb_scale_5[(b2 & 0x001f)]; + b = scale_5bits_to_8bits((b1 & 0xf800) >> 11); + g = scale_6bits_to_8bits((b2 & 0x07e0) >> 5); + r = scale_5bits_to_8bits(b2 & 0x001f); put_pixel_fast(image, x, y, rgba(r, g, b, 255)); } src += padding; @@ -339,8 +346,9 @@ static bool get_win32_clipboard_bitmap_size(gfx::Size& size) { bool result = false; - if (win32_clipboard_contains_bitmap() && - OpenClipboard(win_get_window())) { + HWND hwnd = static_cast(she::instance()->defaultDisplay()->nativeHandle()); + + if (win32_clipboard_contains_bitmap() && OpenClipboard(hwnd)) { BITMAPINFO* bi = (BITMAPINFO*)GetClipboardData(CF_DIB); if (bi) { size.w = bi->bmiHeader.biWidth; diff --git a/src/app/util/msk_file.cpp b/src/app/util/msk_file.cpp index fa3f3aa82..e4b7ac9ab 100644 --- a/src/app/util/msk_file.cpp +++ b/src/app/util/msk_file.cpp @@ -20,9 +20,10 @@ #include "config.h" #endif -#include - #include "app/util/pic_file.h" +#include "base/cfile.h" +#include "base/file_handle.h" +#include "base/fs.h" #include "base/unique_ptr.h" #include "raster/image.h" #include "raster/mask.h" @@ -34,29 +35,22 @@ using namespace raster; // Loads a MSK file (Animator and Animator Pro format) Mask* load_msk_file(const char* filename) { -#if (MAKE_VERSION(4, 2, 1) >= MAKE_VERSION(ALLEGRO_VERSION, \ - ALLEGRO_SUB_VERSION, \ - ALLEGRO_WIP_VERSION)) - int orig_size = file_size(filename); -#else - int orig_size = file_size_ex(filename); -#endif + int orig_size = base::file_size(filename); int i, c, u, v, byte, magic, size; - Mask *mask = NULL; - PACKFILE *f; + Mask* mask = NULL; - f = pack_fopen(filename, F_READ); + FILE* f = base::open_file_raw(filename, "r"); if (!f) return NULL; - size = pack_igetl(f); - magic = pack_igetw(f); + size = base::fgetl(f); + magic = base::fgetw(f); // Animator Pro MSK format if ((size == orig_size) && (magic == 0x9500)) { int x, y; - pack_fclose(f); + fclose(f); // Just load an Animator Pro PIC file base::UniquePtr image(load_pic_file(filename, &x, &y, NULL)); @@ -70,7 +64,7 @@ Mask* load_msk_file(const char* filename) u = v = 0; for (i=0; i<8000; i++) { - byte = pack_getc (f); + byte = getc(f); for (c=0; c<8; c++) { mask->bitmap()->putPixel(u, v, byte & (1<<(7-c))); u++; @@ -80,10 +74,10 @@ Mask* load_msk_file(const char* filename) } } } - pack_fclose(f); + fclose(f); } else { - pack_fclose(f); + fclose(f); } return mask; diff --git a/src/app/widget_loader.cpp b/src/app/widget_loader.cpp index f18348835..7fd9fe851 100644 --- a/src/app/widget_loader.cpp +++ b/src/app/widget_loader.cpp @@ -36,7 +36,6 @@ #include "tinyxml.h" -#include #include #include #include @@ -177,11 +176,11 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget for (c=0; c<4; ++c) b[c] = 0; - for (tok=ustrtok(bevel, " "), c=0; + for (tok=strtok(bevel, " "), c=0; tok; - tok=ustrtok(NULL, " "), ++c) { + tok=strtok(NULL, " "), ++c) { if (c < 4) - b[c] = ustrtol(tok, NULL, 10); + b[c] = strtol(tok, NULL, 10); } base_free(bevel); @@ -545,34 +544,34 @@ static int convert_align_value_to_flags(const char *value) char *tok, *ptr = base_strdup(value); int flags = 0; - for (tok=ustrtok(ptr, " "); + for (tok=strtok(ptr, " "); tok != NULL; - tok=ustrtok(NULL, " ")) { - if (ustrcmp(tok, "horizontal") == 0) { + tok=strtok(NULL, " ")) { + if (strcmp(tok, "horizontal") == 0) { flags |= JI_HORIZONTAL; } - else if (ustrcmp(tok, "vertical") == 0) { + else if (strcmp(tok, "vertical") == 0) { flags |= JI_VERTICAL; } - else if (ustrcmp(tok, "left") == 0) { + else if (strcmp(tok, "left") == 0) { flags |= JI_LEFT; } - else if (ustrcmp(tok, "center") == 0) { + else if (strcmp(tok, "center") == 0) { flags |= JI_CENTER; } - else if (ustrcmp(tok, "right") == 0) { + else if (strcmp(tok, "right") == 0) { flags |= JI_RIGHT; } - else if (ustrcmp(tok, "top") == 0) { + else if (strcmp(tok, "top") == 0) { flags |= JI_TOP; } - else if (ustrcmp(tok, "middle") == 0) { + else if (strcmp(tok, "middle") == 0) { flags |= JI_MIDDLE; } - else if (ustrcmp(tok, "bottom") == 0) { + else if (strcmp(tok, "bottom") == 0) { flags |= JI_BOTTOM; } - else if (ustrcmp(tok, "homogeneous") == 0) { + else if (strcmp(tok, "homogeneous") == 0) { flags |= JI_HOMOGENEOUS; } }