diff --git a/src/gui/widget/keyboard_input.cpp b/src/gui/widget/keyboard_input.cpp index af2280334..2310ef6c4 100644 --- a/src/gui/widget/keyboard_input.cpp +++ b/src/gui/widget/keyboard_input.cpp @@ -191,7 +191,7 @@ CKeyboardInput::CKeyboardInput(const neutrino_locale_t Name, std::string* Value, observ = Observ; hint_1 = Hint_1; hint_2 = Hint_2; - inputString = new CInputString(inputSize); + inputString = NULL; layout = NULL; selected = 0; caps = 0; @@ -204,14 +204,14 @@ CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int name = NONEXISTANT_LOCALE; head = Name; valueString = Value; - inputSize = Size; + inputSize = Size; iconfile = Icon ? Icon : ""; observ = Observ; hint_1 = Hint_1; hint_2 = Hint_2; - inputString = new CInputString(inputSize); + inputString = NULL; layout = NULL; selected = 0; caps = 0; @@ -221,7 +221,6 @@ CKeyboardInput::CKeyboardInput(const std::string &Name, std::string *Value, int CKeyboardInput::~CKeyboardInput() { - delete inputString; } #define BORDER_OFFSET 20 @@ -249,6 +248,12 @@ void CKeyboardInput::init() width = std::max(iwidth, kwidth); width = std::min(width, (int) frameBuffer->getScreenWidth()); + if (!inputSize || (iwidth > width)) { /* auto calc inputSize */ + inputSize = (width - 2*offset) / input_w; + iwidth = inputSize*input_w + 2*offset; + } + inputString = new CInputString(inputSize); + int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head); if (!(iconfile.empty())) { @@ -596,6 +601,9 @@ int CKeyboardInput::exec(CMenuTarget* parent, const std::string &) *valueString = inputString->getValue(); + delete inputString; + inputString = NULL; + if ((observ) && (msg == CRCInput::RC_red)) observ->changeNotify(name, (void *) valueString->c_str()); diff --git a/src/gui/widget/keyboard_input.h b/src/gui/widget/keyboard_input.h index 45657d5dd..10e74aac3 100644 --- a/src/gui/widget/keyboard_input.h +++ b/src/gui/widget/keyboard_input.h @@ -124,8 +124,8 @@ class CKeyboardInput : public CMenuTarget virtual void setLayout(); public: - CKeyboardInput(const neutrino_locale_t Name, std::string* Value, int Size, CChangeObserver* Observ = NULL, const char * const Icon = NULL, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE); - CKeyboardInput(const std::string &Name, std::string* Value, int Size, CChangeObserver* Observ = NULL, const char * const Icon = NULL, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE); + CKeyboardInput(const neutrino_locale_t Name, std::string* Value, int Size = 0, CChangeObserver* Observ = NULL, const char * const Icon = NULL, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE); + CKeyboardInput(const std::string &Name, std::string* Value, int Size = 0, CChangeObserver* Observ = NULL, const char * const Icon = NULL, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE); ~CKeyboardInput(); void hide();