From 2d499a89e2146e68d4adea5fb7c703c20b7cbc82 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 10 Apr 2013 23:25:37 +0200 Subject: [PATCH] dlgTextEntry: move code to TextEntry.cpp --- Makefile | 1 + build/test.mk | 1 + src/Dialogs/{TextEntry.hpp => TextEntry.cpp} | 50 ++++++++++++---------------- src/Dialogs/TextEntry.hpp | 4 +++ src/Dialogs/dlgTextEntry.cpp | 25 +------------- 5 files changed, 29 insertions(+), 52 deletions(-) copy src/Dialogs/{TextEntry.hpp => TextEntry.cpp} (51%) diff --git a/Makefile b/Makefile index 204600d5b..ee0fd2d0b 100644 --- a/Makefile +++ b/Makefile @@ -266,6 +266,7 @@ DIALOG_SOURCES = \ $(SRC)/Dialogs/Task/AlternatesListDialog.cpp \ \ $(SRC)/Dialogs/NumberEntry.cpp \ + $(SRC)/Dialogs/TextEntry.cpp \ $(SRC)/Dialogs/dlgTextEntry.cpp \ $(SRC)/Dialogs/dlgTextEntry_Keyboard.cpp \ $(SRC)/Dialogs/TimeEntry.cpp \ diff --git a/build/test.mk b/build/test.mk index a3634d639..1027ec513 100644 --- a/build/test.mk +++ b/build/test.mk @@ -1779,6 +1779,7 @@ RUN_LIST_CONTROL_DEPENDS = FORM SCREEN EVENT OS THREAD MATH UTIL $(eval $(call link-program,RunListControl,RUN_LIST_CONTROL)) RUN_TEXT_ENTRY_SOURCES = \ + $(SRC)/Dialogs/TextEntry.cpp \ $(SRC)/Dialogs/dlgTextEntry.cpp \ $(SRC)/Dialogs/dlgTextEntry_Keyboard.cpp \ $(SRC)/Dialogs/XML.cpp \ diff --git a/src/Dialogs/TextEntry.hpp b/src/Dialogs/TextEntry.cpp similarity index 51% copy from src/Dialogs/TextEntry.hpp copy to src/Dialogs/TextEntry.cpp index 48ef201e2..26922ec70 100644 --- a/src/Dialogs/TextEntry.hpp +++ b/src/Dialogs/TextEntry.cpp @@ -21,35 +21,29 @@ Copyright_License { } */ -#ifndef DIALOGS_TEXT_ENTRY_HPP -#define DIALOGS_TEXT_ENTRY_HPP - -#include "Util/StaticString.hpp" - -#include - -#include - -typedef std::function AllowedCharacters; +#include "TextEntry.hpp" +#include "DialogSettings.hpp" +#include "UIGlobals.hpp" +#include "Asset.hpp" bool -dlgTextEntryShowModal(TCHAR *text, size_t size, - const TCHAR *caption=nullptr, - AllowedCharacters ac=AllowedCharacters()); - -template -static inline bool -TextEntryDialog(StaticString &text, - const TCHAR *caption=NULL, - AllowedCharacters accb=AllowedCharacters()) +dlgTextEntryShowModal(TCHAR *text, size_t width, + const TCHAR *caption, AllowedCharacters accb) { - return dlgTextEntryShowModal(text.buffer(), text.MAX_SIZE, - caption, accb); + switch (UIGlobals::GetDialogSettings().text_input_style) { + case DialogSettings::TextInputStyle::Default: + case DialogSettings::TextInputStyle::Keyboard: + if (HasPointer()) + return dlgTextEntryKeyboardShowModal(text, width, caption, accb); + else { + dlgTextEntryHighscoreType(text, width, caption); + return true; + } + + case DialogSettings::TextInputStyle::HighScore: + dlgTextEntryHighscoreType(text, width, caption); + return true; + } + + return false; } - -bool -dlgTextEntryKeyboardShowModal(TCHAR *text, size_t size, - const TCHAR* caption=nullptr, - AllowedCharacters ac=AllowedCharacters()); - -#endif diff --git a/src/Dialogs/TextEntry.hpp b/src/Dialogs/TextEntry.hpp index 48ef201e2..7c1460f01 100644 --- a/src/Dialogs/TextEntry.hpp +++ b/src/Dialogs/TextEntry.hpp @@ -47,6 +47,10 @@ TextEntryDialog(StaticString &text, caption, accb); } +void +dlgTextEntryHighscoreType(TCHAR *text, size_t width, + const TCHAR *caption); + bool dlgTextEntryKeyboardShowModal(TCHAR *text, size_t size, const TCHAR* caption=nullptr, diff --git a/src/Dialogs/dlgTextEntry.cpp b/src/Dialogs/dlgTextEntry.cpp index b70588660..9838b5b4e 100644 --- a/src/Dialogs/dlgTextEntry.cpp +++ b/src/Dialogs/dlgTextEntry.cpp @@ -24,7 +24,6 @@ Copyright_License { #include "Dialogs/TextEntry.hpp" #include "Dialogs/XML.hpp" #include "Dialogs/CallBackTable.hpp" -#include "Dialogs/DialogSettings.hpp" #include "Screen/Canvas.hpp" #include "Screen/Key.h" #include "Form/Form.hpp" @@ -211,7 +210,7 @@ static constexpr CallBackTableEntry CallBackTable[] = { DeclareCallBackEntry(NULL) }; -static void +void dlgTextEntryHighscoreType(TCHAR *text, size_t width, const TCHAR* caption) { @@ -245,25 +244,3 @@ dlgTextEntryHighscoreType(TCHAR *text, size_t width, delete wf; } - -bool -dlgTextEntryShowModal(TCHAR *text, size_t width, - const TCHAR* caption, AllowedCharacters accb) -{ - switch (UIGlobals::GetDialogSettings().text_input_style) { - case DialogSettings::TextInputStyle::Default: - case DialogSettings::TextInputStyle::Keyboard: - if (HasPointer()) - return dlgTextEntryKeyboardShowModal(text, width, caption, accb); - else { - dlgTextEntryHighscoreType(text, width, caption); - return true; - } - - case DialogSettings::TextInputStyle::HighScore: - dlgTextEntryHighscoreType(text, width, caption); - return true; - } - - return false; -} -- 2.11.4.GIT