2 * Copyright (C) 2012-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
24 #include "threads/Timer.h"
27 enum FILTERING { FILTERING_NONE = 0, FILTERING_CURRENT, FILTERING_SEARCH };
28 typedef void (*char_callback_t) (CGUIKeyboard *ref, const std::string &typedString);
30 #ifdef TARGET_WINDOWS // disable 4355: 'this' used in base member initializer list
32 #pragma warning(disable: 4355)
35 class CGUIKeyboard : public ITimerCallback
38 CGUIKeyboard():m_idleTimer(this){};
39 virtual ~CGUIKeyboard(){ };
43 * \brief each native keyboard needs to implement this function with the following behaviour:
45 * \param pCallback implementation should call this on each keypress with the current whole string
46 * \param initialString implementation should show that initialstring
47 * \param typedstring returns the typed string after close if return is true
48 * \param heading implementation should show a heading (e.x. "search for a movie")
49 * \param bHiddenInput if true the implementation should obfuscate the user input (e.x. by printing "*" for each char)
51 * \return - true if typedstring is valid and user has confirmed input - false if typedstring is undefined and user canceled the input
54 virtual bool ShowAndGetInput(char_callback_t pCallback,
55 const std::string &initialString,
56 std::string &typedString,
57 const std::string &heading,
58 bool bHiddenInput = false) = 0;
61 *\brief This call should cancel a currently shown keyboard dialog. The implementation should
62 * return false from the modal ShowAndGetInput once anyone calls this metohod.
64 virtual void Cancel() = 0;
66 virtual int GetWindowId() const {return 0;}
68 // CTimer Interface for autoclose
69 virtual void OnTimeout()
74 // helpers for autoclose function
75 void startAutoCloseTimer(unsigned int autoCloseMs)
77 if ( autoCloseMs > 0 )
78 m_idleTimer.Start(autoCloseMs, false);
81 void resetAutoCloseTimer()
83 if (m_idleTimer.IsRunning())
84 m_idleTimer.Restart();
87 virtual bool SetTextToKeyboard(const std::string &text, bool closeKeyboard = false) { return false; }