First cut at a interface to control the software keyboard. minimo

This commit is contained in:
dougt%meer.net 2006-04-19 19:40:48 +00:00
Родитель 8fde9bea4b
Коммит 27efb6959e
3 изменённых файлов: 101 добавлений и 4 удалений

Просмотреть файл

@ -66,6 +66,8 @@ CPPSRCS = \
nsSoftKeyBoard.cpp \
$(NULL)
XPIDLSRCS = nsISoftKeyBoard.idl
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
ifdef WINCE

Просмотреть файл

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Softkey for Minimo
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
[scriptable, uuid(0fb2c99e-fde6-4606-a1da-cb61b4144de0)]
interface nsISoftKeyBoard : nsISupports
{
void getWindowRect(out PRInt32 top, out PRInt32 bottom, out PRInt32 left, out PRInt32 right);
void setWindowRect(in PRInt32 top, in PRInt32 bottom, in PRInt32 left, in PRInt32 right);
};

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsString.h"
#include "nsIMutableArray.h"
#include "nsArray.h"
#include "nsIGenericFactory.h"
@ -79,6 +79,7 @@
#include "nsITimer.h"
#include "nsISoftKeyBoard.h"
static PRBool gUseSoftwareKeyboard;
@ -360,7 +361,7 @@ private:
};
class nsSoftKeyBoardService: public nsIObserver
class nsSoftKeyBoardService: public nsIObserver, public nsISoftKeyBoard
{
public:
nsSoftKeyBoardService();
@ -368,6 +369,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_NSISOFTKEYBOARD
nsCOMArray<nsSoftKeyBoard> mObjects;
@ -647,6 +649,52 @@ nsSoftKeyBoardService::CloseSIP()
#endif
}
NS_IMETHODIMP
nsSoftKeyBoardService::GetWindowRect(PRInt32 *top, PRInt32 *bottom, PRInt32 *left, PRInt32 *right)
{
#ifdef WINCE
if (!top || !bottom || !left || !right)
return NS_ERROR_INVALID_ARG;
HWND hWndSIP = ::FindWindow( _T( "SipWndClass" ), NULL );
if (!hWndSIP)
return NS_ERROR_NULL_POINTER;
RECT rect;
BOOL b = ::GetWindowRect(hWndSIP, &rect);
if (!b)
return NS_ERROR_UNEXPECTED;
*top = rect.top;
*bottom = rect.bottom;
*left = rect.left;
*right = rect.right;
return NS_OK;
#endif
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsSoftKeyBoardService::SetWindowRect(PRInt32 top, PRInt32 bottom, PRInt32 left, PRInt32 right)
{
#ifdef WINCE
HWND hWndSIP = ::FindWindow( _T( "SipWndClass" ), NULL );
if (!hWndSIP)
return NS_ERROR_NULL_POINTER;
SetWindowPos(hWndSIP, HWND_TOP, left, top, right-left, bottom-top, SWP_SHOWWINDOW);
return NS_OK;
#endif
return NS_ERROR_NOT_IMPLEMENTED;
}
PRBool
nsSoftKeyBoard::ShouldOpenKeyboardFor(nsIDOMEvent* aEvent)
{
@ -738,7 +786,7 @@ nsSoftKeyBoardService::~nsSoftKeyBoardService()
{
}
NS_IMPL_ISUPPORTS1(nsSoftKeyBoardService, nsIObserver)
NS_IMPL_ISUPPORTS2(nsSoftKeyBoardService, nsIObserver, nsISoftKeyBoard)
void
nsSoftKeyBoardService::HandlePref(const char* pref, nsIPrefBranch2* prefBranch)
@ -820,7 +868,7 @@ nsSoftKeyBoardService::Observe(nsISupports *aSubject, const char *aTopic, const
nsCOMPtr<nsIPrefBranch2> prefBranch = do_QueryInterface(aSubject);
nsXPIDLCString cstr;
const char* pref = NS_ConvertUTF16toUTF8(aData).get();
const char* pref = NS_ConvertUCS2toUTF8(aData).get();
HandlePref(pref, prefBranch);
return NS_OK;