diff --git a/src/app/app_menus.cpp b/src/app/app_menus.cpp index 912008f36..0b0f9adc3 100644 --- a/src/app/app_menus.cpp +++ b/src/app/app_menus.cpp @@ -35,13 +35,13 @@ #include "app/ui/main_window.h" #include "app/util/filetoks.h" #include "base/bind.h" +#include "base/path.h" #include "ui/ui.h" #include "tinyxml.h" -#include -#include -#include -#include + +#include +#include namespace app { @@ -251,7 +251,9 @@ bool AppMenus::rebuildRecentList() params.set("filename", filename); - menuitem = new AppMenuItem(get_filename(filename), cmd_open_file, ¶ms); + menuitem = new AppMenuItem( + base::get_file_name(filename).c_str(), + cmd_open_file, ¶ms); submenu->addChild(menuitem); } } @@ -389,8 +391,9 @@ void AppMenus::applyShortcutToMenuitemsWithCommand(Menu* menu, Command *command, Command* mi_command = menuitem->getCommand(); Params* mi_params = menuitem->getParams(); - if (mi_command && - ustricmp(mi_command->short_name(), command->short_name()) == 0 && + if ((mi_command) && + (base::string_to_lower(mi_command->short_name()) == + base::string_to_lower(command->short_name())) && ((mi_params && *mi_params == *params) || (Params() == *params))) { // Set the accelerator to be shown in this menu-item diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp index 51066022e..2a36ad12e 100644 --- a/src/app/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -36,8 +36,6 @@ #include "raster/stock.h" #include "ui/ui.h" -#include - namespace app { using namespace ui; diff --git a/src/app/commands/cmd_change_pixel_format.cpp b/src/app/commands/cmd_change_pixel_format.cpp index d1c34eda4..a0a042ae8 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -32,8 +32,6 @@ #include "raster/image.h" #include "raster/sprite.h" -#include - namespace app { class ChangePixelFormatCommand : public Command { diff --git a/src/app/commands/cmd_goto_frame.cpp b/src/app/commands/cmd_goto_frame.cpp index 5c892ce73..9bce24d06 100644 --- a/src/app/commands/cmd_goto_frame.cpp +++ b/src/app/commands/cmd_goto_frame.cpp @@ -30,8 +30,6 @@ #include "raster/sprite.h" #include "ui/window.h" -#include - namespace app { using namespace ui; @@ -124,7 +122,7 @@ protected: void onLoadParams(Params* params) override { std::string frame = params->get("frame"); - if (!frame.empty()) m_frame = ustrtol(frame.c_str(), NULL, 10); + if (!frame.empty()) m_frame = strtol(frame.c_str(), NULL, 10); else m_frame = 0; } diff --git a/src/app/commands/cmd_grid.cpp b/src/app/commands/cmd_grid.cpp index 3b77638a3..1fef2f770 100644 --- a/src/app/commands/cmd_grid.cpp +++ b/src/app/commands/cmd_grid.cpp @@ -33,8 +33,6 @@ #include "app/ui_context.h" #include "ui/window.h" -#include - namespace app { using namespace ui; @@ -89,12 +87,11 @@ protected: void onExecute(Context* context) { IDocumentSettings* docSettings = context->settings()->getDocumentSettings(context->activeDocument()); - char buf[512]; - docSettings->setSnapToGrid(docSettings->getSnapToGrid() ? false: true); - usprintf(buf, "Snap to grid: %s", - (docSettings->getSnapToGrid() ? "On": "Off")); + char buf[512]; + sprintf(buf, "Snap to grid: %s", + (docSettings->getSnapToGrid() ? "On": "Off")); StatusBar::instance()->setStatusText(250, buf); } diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp index df60b938c..3db83150e 100644 --- a/src/app/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -48,8 +48,6 @@ #include "raster/stock.h" #include "ui/ui.h" -#include - namespace app { using namespace ui; diff --git a/src/app/commands/cmd_new_file.cpp b/src/app/commands/cmd_new_file.cpp index 6ab7dd771..8d7f9b83e 100644 --- a/src/app/commands/cmd_new_file.cpp +++ b/src/app/commands/cmd_new_file.cpp @@ -47,9 +47,6 @@ #include "generated_new_sprite.h" -#include -#include - using namespace ui; namespace app { @@ -194,7 +191,7 @@ void NewFileCommand::onExecute(Context* context) // Show the sprite to the user base::UniquePtr doc(new Document(sprite)); sprite.release(); - usprintf(buf, "Sprite-%04d", ++_sprite_counter); + sprintf(buf, "Sprite-%04d", ++_sprite_counter); doc->setFilename(buf); doc->setContext(context); doc.release(); diff --git a/src/app/commands/cmd_play_animation.cpp b/src/app/commands/cmd_play_animation.cpp index 07df4af92..c33498dd0 100644 --- a/src/app/commands/cmd_play_animation.cpp +++ b/src/app/commands/cmd_play_animation.cpp @@ -35,7 +35,6 @@ #include "app/ui/editor/editor.h" #include "app/ui/main_window.h" #include "app/ui/mini_editor.h" -#include "raster/conversion_alleg.h" #include "raster/image.h" #include "raster/palette.h" #include "raster/sprite.h" diff --git a/src/app/commands/cmd_rotate.cpp b/src/app/commands/cmd_rotate.cpp index 12d183afa..dcd250e26 100644 --- a/src/app/commands/cmd_rotate.cpp +++ b/src/app/commands/cmd_rotate.cpp @@ -40,8 +40,6 @@ #include "raster/stock.h" #include "ui/ui.h" -#include - namespace app { class RotateCommand : public Command { @@ -193,7 +191,7 @@ void RotateCommand::onLoadParams(Params* params) m_flipMask = (target == "mask"); if (params->has_param("angle")) { - m_angle = ustrtol(params->get("angle").c_str(), NULL, 10); + m_angle = strtol(params->get("angle").c_str(), NULL, 10); } } diff --git a/src/app/commands/cmd_save_mask.cpp b/src/app/commands/cmd_save_mask.cpp index 3367f3ad1..867dfd7ab 100644 --- a/src/app/commands/cmd_save_mask.cpp +++ b/src/app/commands/cmd_save_mask.cpp @@ -20,12 +20,12 @@ #include "config.h" #endif -#include - #include "app/commands/command.h" #include "app/context_access.h" #include "app/file_selector.h" #include "app/util/msk_file.h" +#include "base/fs.h" +#include "base/path.h" #include "raster/mask.h" #include "raster/sprite.h" #include "ui/alert.h" @@ -66,11 +66,11 @@ void SaveMaskCommand::onExecute(Context* context) if (filename.empty()) return; - /* does the file exist? */ - if (exists(filename.c_str())) { + // Does the file exist? + if (base::is_file(filename.c_str())) { /* ask if the user wants overwrite the file? */ ret = ui::Alert::show("Warning< #include namespace app { @@ -113,10 +112,10 @@ void SpritePropertiesCommand::onExecute(Context* context) type->setText(imgtype_text.c_str()); // Sprite size (width and height) - usprintf(buf, "%dx%d (%s)", - sprite->width(), - sprite->height(), - base::get_pretty_memory_size(sprite->getMemSize()).c_str()); + sprintf(buf, "%dx%d (%s)", + sprite->width(), + sprite->height(), + base::get_pretty_memory_size(sprite->getMemSize()).c_str()); size->setText(buf); diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index ab642e652..c0c75acec 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -42,8 +42,6 @@ #include "raster/stock.h" #include "ui/ui.h" -#include - #define PERC_FORMAT "%.1f" namespace app { diff --git a/src/app/commands/cmd_switch_colors.cpp b/src/app/commands/cmd_switch_colors.cpp index 4cbeb9352..29b21c216 100644 --- a/src/app/commands/cmd_switch_colors.cpp +++ b/src/app/commands/cmd_switch_colors.cpp @@ -20,8 +20,6 @@ #include "config.h" #endif -#include - #include "app/app.h" #include "app/commands/command.h" #include "app/ui/color_bar.h" diff --git a/src/app/commands/commands.cpp b/src/app/commands/commands.cpp index ddc23017b..af2571354 100644 --- a/src/app/commands/commands.cpp +++ b/src/app/commands/commands.cpp @@ -20,16 +20,15 @@ #include "config.h" #endif -/* #include */ -#include -#include -#include - -#include "ui/ui.h" +#include "app/commands/commands.h" #include "app/commands/command.h" -#include "app/commands/commands.h" #include "app/console.h" +#include "base/string.h" +#include "ui/ui.h" + +#include +#include namespace app { @@ -58,10 +57,8 @@ CommandsModule::~CommandsModule() { ASSERT(m_instance == this); - for (CommandsList::iterator - it = m_commands.begin(); it != m_commands.end(); ++it) { - delete *it; - } + for (Command* cmd : m_commands) + delete cmd; m_commands.clear(); m_instance = NULL; @@ -78,10 +75,10 @@ Command* CommandsModule::getCommandByName(const char* name) if (!name) return NULL; - for (CommandsList::iterator - it = m_commands.begin(); it != m_commands.end(); ++it) { - if (ustricmp((*it)->short_name(), name) == 0) - return *it; + std::string lname = base::string_to_lower(name); + for (Command* cmd : m_commands) { + if (base::string_to_lower(cmd->short_name()) == lname) + return cmd; } return NULL; diff --git a/src/app/data_recovery.cpp b/src/app/data_recovery.cpp index 51145a49e..ba2892931 100644 --- a/src/app/data_recovery.cpp +++ b/src/app/data_recovery.cpp @@ -23,13 +23,12 @@ #include "app/data_recovery.h" #include "app/backup.h" +#include "app/document.h" +#include "app/ini_file.h" +#include "app/ui_context.h" #include "base/fs.h" #include "base/path.h" #include "base/temp_dir.h" -#include "app/document.h" -#include "app/ui_context.h" - -#include namespace app { diff --git a/src/app/file/bmp_format.cpp b/src/app/file/bmp_format.cpp index 475e9d907..5c83c07e3 100644 --- a/src/app/file/bmp_format.cpp +++ b/src/app/file/bmp_format.cpp @@ -29,8 +29,6 @@ #include "base/file_handle.h" #include "raster/raster.h" -#include - namespace app { using namespace base; diff --git a/src/app/file/fli_format.cpp b/src/app/file/fli_format.cpp index 808260701..e887fe7ea 100644 --- a/src/app/file/fli_format.cpp +++ b/src/app/file/fli_format.cpp @@ -29,8 +29,7 @@ #include "base/file_handle.h" #include "raster/raster.h" -#include -#include +#include namespace app { diff --git a/src/app/file/ico_format.cpp b/src/app/file/ico_format.cpp index fea20cdaa..c03abea34 100644 --- a/src/app/file/ico_format.cpp +++ b/src/app/file/ico_format.cpp @@ -30,8 +30,6 @@ #include "base/file_handle.h" #include "raster/raster.h" -#include - namespace app { using namespace base; diff --git a/src/app/file/pcx_format.cpp b/src/app/file/pcx_format.cpp index 75d006ab9..8f197e281 100644 --- a/src/app/file/pcx_format.cpp +++ b/src/app/file/pcx_format.cpp @@ -29,8 +29,6 @@ #include "base/file_handle.h" #include "raster/raster.h" -#include - namespace app { using namespace base; diff --git a/src/app/file/tga_format.cpp b/src/app/file/tga_format.cpp index 00c0e194d..8387cc060 100644 --- a/src/app/file/tga_format.cpp +++ b/src/app/file/tga_format.cpp @@ -30,8 +30,6 @@ #include "base/file_handle.h" #include "raster/raster.h" -#include - namespace app { using namespace base; diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index ad5f4e2cb..4002a9a09 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -20,6 +20,7 @@ #include "config.h" #endif +#include "app/ini_file.h" #include "app/modules/gui.h" #include "app/resource_finder.h" #include "app/ui/skin/button_icon_impl.h" @@ -33,6 +34,7 @@ #include "base/bind.h" #include "base/fs.h" #include "base/shared_ptr.h" +#include "base/string.h" #include "css/sheet.h" #include "gfx/border.h" #include "gfx/point.h" @@ -47,8 +49,6 @@ #include "tinyxml.h" -#include - #define BGCOLOR (getWidgetBgColor(widget)) namespace app { @@ -1082,7 +1082,6 @@ void SkinTheme::paintEntry(PaintEvent& ev) int scroll, caret, state, selbeg, selend; std::string textString = widget->getText() + widget->getSuffix(); int suffixIndex = widget->getTextLength(); - const char* text = textString.c_str(); int c, ch, x, y, w; int caret_x; @@ -1107,8 +1106,11 @@ void SkinTheme::paintEntry(PaintEvent& ev) x = bounds.x + widget->border_width.l; y = bounds.y + bounds.h/2 - widget->getTextHeight()/2; - for (c=scroll; ugetat(text, c); c++) { - ch = password ? '*': ugetat(text, c); + base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin()); + int textlen = base::utf8_length(textString); + + for (c=scroll, utf8_it+=scroll; cgetClientBounds(); bool password = widget->isPassword(); int scroll, caret, state, selbeg, selend; - const char *text = widget->getText().c_str(); + const std::string& textString = widget->getText(); int c, ch, x, y, w; int caret_x; @@ -1566,8 +1568,11 @@ void SkinTheme::paintComboBoxEntry(ui::PaintEvent& ev) x = bounds.x + widget->border_width.l; y = bounds.y + bounds.h/2 - widget->getTextHeight()/2; - for (c=scroll; ugetat(text, c); c++) { - ch = password ? '*': ugetat(text, c); + base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin()); + int textlen = base::utf8_length(textString); + + for (c=scroll, utf8_it+=scroll; c -#include - namespace app { UIContext* UIContext::m_instance = NULL;