зеркало из https://github.com/mozilla/gecko-dev.git
Added SetMaxTextLength method to text widget and textarea widget.
This commit is contained in:
Родитель
b6660d91ec
Коммит
22f96a82ef
|
@ -86,6 +86,15 @@ class nsITextWidget : public nsIWidget
|
|||
|
||||
virtual void SetPassword(PRBool aIsPassword) = 0;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of characters the widget can hold
|
||||
*
|
||||
* @param aChars maximum number of characters for this widget. if 0 then there isn't any limit
|
||||
*/
|
||||
|
||||
virtual void SetMaxTextLength(PRUint32 aChars) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Set the text widget to be read-only
|
||||
*
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef void* nsNativeWindow;
|
|||
*/
|
||||
|
||||
enum nsBorderStyle {
|
||||
///window border with title area
|
||||
///no border
|
||||
eBorderStyle_none,
|
||||
///dialog box border + title area
|
||||
eBorderStyle_dialog,
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include "nsString.h"
|
||||
#include <windows.h>
|
||||
|
||||
void nsTextAreaWidget::SetMaxTextLength(PRUint32 aChars) {
|
||||
nsTextHelper::SetMaxTextLength(aChars);
|
||||
}
|
||||
|
||||
PRUint32 nsTextAreaWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize) {
|
||||
return(nsTextHelper::GetText(aTextBuffer, aBufferSize));
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
BASE_IWIDGET_IMPL
|
||||
|
||||
// nsITextWidget part
|
||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||
virtual PRUint32 SetText(const nsString &aText);
|
||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||
virtual PRUint32 InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos);
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
#include <windows.h>
|
||||
|
||||
|
||||
void nsTextHelper::SetMaxTextLength(PRUint32 aChars)
|
||||
{
|
||||
::SendMessage(mWnd, EM_SETLIMITTEXT, (WPARAM) (INT)aChars, 0);
|
||||
}
|
||||
|
||||
|
||||
PRUint32 nsTextHelper::GetText(nsString& aTextBuffer, PRUint32 aBufferSize) {
|
||||
|
||||
int length = GetWindowTextLength(mWnd);
|
||||
|
|
|
@ -32,7 +32,8 @@ class nsTextHelper : public nsWindow, public nsITextWidget
|
|||
public:
|
||||
nsTextHelper(nsISupports *aOuter);
|
||||
virtual ~nsTextHelper();
|
||||
|
||||
|
||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||
virtual PRUint32 SetText(const nsString &aText);
|
||||
virtual PRUint32 InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos);
|
||||
|
@ -50,7 +51,7 @@ protected:
|
|||
|
||||
PRBool mIsPassword;
|
||||
PRBool mIsReadOnly;
|
||||
|
||||
|
||||
virtual DWORD WindowExStyle();
|
||||
|
||||
};
|
||||
|
|
|
@ -994,6 +994,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd
|
|||
textWidget->SetFont(font);
|
||||
nsString initialText("0123456789");
|
||||
textWidget->SetText(initialText);
|
||||
textWidget->SetMaxTextLength(12);
|
||||
|
||||
NS_RELEASE(textWidget);
|
||||
y += rect.height + 5;
|
||||
|
|
Загрузка…
Ссылка в новой задаче