зеркало из https://github.com/mozilla/pjs.git
Added SelectAll member function to nsITextWidget
Fixed Select(start, stop) for nsITextWidget and nsITextAreaWidget Added NS_MOVE event Cleanup up nsWindow.cpp by centralizing code to initialize events and dispatch events.
This commit is contained in:
Родитель
c0bdf6358a
Коммит
2b0df5e66e
|
@ -106,16 +106,29 @@ struct nsKeyEvent : public nsGUIEvent {
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
#define NS_WINDOW_START 100
|
#define NS_WINDOW_START 100
|
||||||
#define NS_CREATE (NS_WINDOW_START)
|
|
||||||
#define NS_DESTROY (NS_WINDOW_START + 1)
|
|
||||||
#define NS_SIZE (NS_WINDOW_START + 2)
|
|
||||||
#define NS_GOTFOCUS (NS_WINDOW_START + 3)
|
|
||||||
#define NS_LOSTFOCUS (NS_WINDOW_START + 4)
|
|
||||||
#define NS_PAINT (NS_WINDOW_START + 30)
|
|
||||||
|
|
||||||
|
// Sent when window is created
|
||||||
|
#define NS_CREATE (NS_WINDOW_START)
|
||||||
|
// Sent when window is destroyed
|
||||||
|
#define NS_DESTROY (NS_WINDOW_START + 1)
|
||||||
|
// Sent when the window is resized
|
||||||
|
#define NS_SIZE (NS_WINDOW_START + 2)
|
||||||
|
// Sent when window gains focus
|
||||||
|
#define NS_GOTFOCUS (NS_WINDOW_START + 3)
|
||||||
|
// Sent when window loses focus
|
||||||
|
#define NS_LOSTFOCUS (NS_WINDOW_START + 4)
|
||||||
|
// Sent when the window needs to be repainted
|
||||||
|
#define NS_PAINT (NS_WINDOW_START + 30)
|
||||||
|
// Sent when a key is pressed down within a window
|
||||||
#define NS_KEY_UP (NS_WINDOW_START + 32)
|
#define NS_KEY_UP (NS_WINDOW_START + 32)
|
||||||
|
// Sent when a key is released within a window
|
||||||
#define NS_KEY_DOWN (NS_WINDOW_START + 33)
|
#define NS_KEY_DOWN (NS_WINDOW_START + 33)
|
||||||
#define NS_TABCHANGE (NS_WINDOW_START + 34)
|
// Sent when the window has been moved to a new location.
|
||||||
|
// The events point contains the x, y location in screen coordinates
|
||||||
|
#define NS_MOVE (NS_WINDOW_START + 34)
|
||||||
|
|
||||||
|
// Sent when a tab control's selected tab has changed
|
||||||
|
#define NS_TABCHANGE (NS_WINDOW_START + 35)
|
||||||
|
|
||||||
#define NS_MOUSE_MESSAGE_START 300
|
#define NS_MOUSE_MESSAGE_START 300
|
||||||
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
|
#define NS_MOUSE_MOVE (NS_MOUSE_MESSAGE_START)
|
||||||
|
|
|
@ -104,6 +104,12 @@ class nsITextWidget : public nsIWidget
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag) = 0;
|
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select all of the contents
|
||||||
|
*/
|
||||||
|
|
||||||
|
virtual void SelectAll() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the selection in this text component
|
* Set the selection in this text component
|
||||||
|
|
|
@ -22,23 +22,33 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
void nsTextAreaWidget::SetMaxTextLength(PRUint32 aChars) {
|
void nsTextAreaWidget::SelectAll()
|
||||||
|
{
|
||||||
|
nsTextHelper::SelectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void nsTextAreaWidget::SetMaxTextLength(PRUint32 aChars)
|
||||||
|
{
|
||||||
nsTextHelper::SetMaxTextLength(aChars);
|
nsTextHelper::SetMaxTextLength(aChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint32 nsTextAreaWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize) {
|
PRUint32 nsTextAreaWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize)
|
||||||
|
{
|
||||||
return(nsTextHelper::GetText(aTextBuffer, aBufferSize));
|
return(nsTextHelper::GetText(aTextBuffer, aBufferSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint32 nsTextAreaWidget::SetText(const nsString &aText) {
|
PRUint32 nsTextAreaWidget::SetText(const nsString &aText)
|
||||||
|
{
|
||||||
return(nsTextHelper::SetText(aText));
|
return(nsTextHelper::SetText(aText));
|
||||||
}
|
}
|
||||||
|
|
||||||
PRUint32 nsTextAreaWidget::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos) {
|
PRUint32 nsTextAreaWidget::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos)
|
||||||
|
{
|
||||||
return(nsTextHelper::InsertText(aText, aStartPos, aEndPos));
|
return(nsTextHelper::InsertText(aText, aStartPos, aEndPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsTextAreaWidget::RemoveText() {
|
void nsTextAreaWidget::RemoveText()
|
||||||
|
{
|
||||||
nsTextHelper::RemoveText();
|
nsTextHelper::RemoveText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
BASE_IWIDGET_IMPL
|
BASE_IWIDGET_IMPL
|
||||||
|
|
||||||
// nsITextWidget part
|
// nsITextWidget part
|
||||||
|
virtual void SelectAll();
|
||||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||||
virtual PRUint32 SetText(const nsString &aText);
|
virtual PRUint32 SetText(const nsString &aText);
|
||||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||||
|
|
|
@ -82,6 +82,13 @@ PRBool nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag)
|
||||||
return(oldSetting);
|
return(oldSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void nsTextHelper::SelectAll()
|
||||||
|
{
|
||||||
|
::SendMessage(mWnd, EM_SETSEL, (WPARAM) 0, (LPARAM)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
void nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
||||||
{
|
{
|
||||||
::SendMessage(mWnd, EM_SETSEL, (WPARAM) (INT)aStartSel, (INT) (LPDWORD)aEndSel);
|
::SendMessage(mWnd, EM_SETSEL, (WPARAM) (INT)aStartSel, (INT) (LPDWORD)aEndSel);
|
||||||
|
|
|
@ -33,19 +33,20 @@ public:
|
||||||
nsTextHelper(nsISupports *aOuter);
|
nsTextHelper(nsISupports *aOuter);
|
||||||
virtual ~nsTextHelper();
|
virtual ~nsTextHelper();
|
||||||
|
|
||||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
virtual void SelectAll();
|
||||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
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);
|
virtual PRUint32 SetText(const nsString &aText);
|
||||||
virtual void RemoveText();
|
virtual PRUint32 InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos);
|
||||||
virtual void SetPassword(PRBool aIsPassword);
|
virtual void RemoveText();
|
||||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
virtual void SetPassword(PRBool aIsPassword);
|
||||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
||||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||||
virtual PRUint32 GetCaretPosition();
|
virtual void SetCaretPosition(PRUint32 aPosition);
|
||||||
virtual LPCTSTR WindowClass();
|
virtual PRUint32 GetCaretPosition();
|
||||||
virtual DWORD WindowStyle();
|
virtual LPCTSTR WindowClass();
|
||||||
|
virtual DWORD WindowStyle();
|
||||||
|
|
||||||
virtual void PreCreateWidget(void *aInitData);
|
virtual void PreCreateWidget(void *aInitData);
|
||||||
|
|
||||||
|
|
|
@ -24,23 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
void nsTextWidget::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsTextWidget::GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void nsTextWidget::SetCaretPosition(PRUint32 aPosition)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
PRUint32 nsTextWidget::GetCaretPosition()
|
|
||||||
{
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// nsTextWidget constructor
|
// nsTextWidget constructor
|
||||||
|
@ -51,7 +34,6 @@ nsTextWidget::nsTextWidget(nsISupports *aOuter) : nsTextHelper(aOuter)
|
||||||
mBackground = NS_RGB(124, 124, 124);
|
mBackground = NS_RGB(124, 124, 124);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// nsTextWidget destructor
|
// nsTextWidget destructor
|
||||||
|
@ -61,7 +43,6 @@ nsTextWidget::~nsTextWidget()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Query interface implementation
|
// Query interface implementation
|
||||||
|
|
|
@ -47,12 +47,6 @@ public:
|
||||||
// nsIWidget interface
|
// nsIWidget interface
|
||||||
BASE_IWIDGET_IMPL
|
BASE_IWIDGET_IMPL
|
||||||
|
|
||||||
// nsITextWidget part
|
|
||||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
|
||||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
|
||||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
|
||||||
virtual PRUint32 GetCaretPosition();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual LPCTSTR WindowClass();
|
virtual LPCTSTR WindowClass();
|
||||||
virtual DWORD WindowStyle();
|
virtual DWORD WindowStyle();
|
||||||
|
|
|
@ -64,6 +64,56 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Initialize an event to dispatch
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType)
|
||||||
|
{
|
||||||
|
event.widget = this;
|
||||||
|
|
||||||
|
// get the message position in client coordinates and in twips
|
||||||
|
DWORD pos = ::GetMessagePos();
|
||||||
|
POINT cpos;
|
||||||
|
|
||||||
|
cpos.x = LOWORD(pos);
|
||||||
|
cpos.y = HIWORD(pos);
|
||||||
|
|
||||||
|
::ScreenToClient(mWnd, &cpos);
|
||||||
|
|
||||||
|
event.point.x = cpos.x;
|
||||||
|
event.point.y = cpos.y;
|
||||||
|
|
||||||
|
event.time = ::GetMessageTime();
|
||||||
|
event.message = aEventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Invokes callback and ProcessEvent method on Event Listener object
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
PRBool nsWindow::DispatchEvent(nsGUIEvent* event)
|
||||||
|
{
|
||||||
|
PRBool result = PR_FALSE;
|
||||||
|
|
||||||
|
if (nsnull != mEventCallback) {
|
||||||
|
result = ConvertStatus((*mEventCallback)(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dispatch to event listener if event was not consumed
|
||||||
|
if ((result != PR_TRUE) && (nsnull != mEventListener)) {
|
||||||
|
return ConvertStatus(mEventListener->ProcessEvent(*event));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// the nsWindow procedure for all nsWindows in this toolkit
|
// the nsWindow procedure for all nsWindows in this toolkit
|
||||||
|
@ -250,28 +300,10 @@ void nsWindow::Create(nsIWidget *aParent,
|
||||||
SetCursor(eCursor_standard);
|
SetCursor(eCursor_standard);
|
||||||
|
|
||||||
// call the event callback to notify about creation
|
// call the event callback to notify about creation
|
||||||
if (mEventCallback) {
|
|
||||||
nsGUIEvent event;
|
|
||||||
event.widget = this;
|
|
||||||
|
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
|
|
||||||
//
|
|
||||||
event.message = NS_CREATE;
|
|
||||||
(*mEventCallback)(&event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
nsGUIEvent event;
|
||||||
|
InitEvent(event, NS_CREATE);
|
||||||
|
DispatchEvent(&event);
|
||||||
SubclassWindow(TRUE);
|
SubclassWindow(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +391,10 @@ void nsWindow::Create(nsNativeWindow aParent,
|
||||||
VERIFY(mWnd);
|
VERIFY(mWnd);
|
||||||
|
|
||||||
// call the event callback to notify about creation
|
// call the event callback to notify about creation
|
||||||
|
nsGUIEvent event;
|
||||||
|
InitEvent(event, NS_CREATE);
|
||||||
|
DispatchEvent(&event);
|
||||||
|
#if 0
|
||||||
if (mEventCallback) {
|
if (mEventCallback) {
|
||||||
nsGUIEvent event;
|
nsGUIEvent event;
|
||||||
event.widget = this;
|
event.widget = this;
|
||||||
|
@ -380,6 +416,7 @@ void nsWindow::Create(nsNativeWindow aParent,
|
||||||
event.message = NS_CREATE;
|
event.message = NS_CREATE;
|
||||||
(*mEventCallback)(&event);
|
(*mEventCallback)(&event);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SubclassWindow(TRUE);
|
SubclassWindow(TRUE);
|
||||||
}
|
}
|
||||||
|
@ -954,34 +991,13 @@ BOOL nsWindow::CallMethod(MethodInfo *info)
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode)
|
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode)
|
||||||
{
|
{
|
||||||
PRBool result = PR_TRUE;
|
nsKeyEvent event;
|
||||||
|
InitEvent(event, aEventType);
|
||||||
// call the event callback
|
event.keyCode = aKeyCode;
|
||||||
if (mEventCallback) {
|
event.isShift = mIsShiftDown;
|
||||||
nsKeyEvent event;
|
event.isControl = mIsControlDown;
|
||||||
event.widget = this;
|
event.isAlt = mIsAltDown;
|
||||||
|
return(DispatchEvent(&event));
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = aEventType;
|
|
||||||
event.keyCode = aKeyCode;
|
|
||||||
event.isShift = mIsShiftDown;
|
|
||||||
event.isControl = mIsControlDown;
|
|
||||||
event.isAlt = mIsAltDown;
|
|
||||||
result = ConvertStatus((*mEventCallback)(&event));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1002,31 +1018,36 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
// TAB change
|
// TAB change
|
||||||
{
|
{
|
||||||
LPNMHDR pnmh = (LPNMHDR) lParam;
|
LPNMHDR pnmh = (LPNMHDR) lParam;
|
||||||
|
|
||||||
if (pnmh->code == TCN_SELCHANGE) {
|
if (pnmh->code == TCN_SELCHANGE) {
|
||||||
DispatchEventToCallback(NS_TABCHANGE);
|
nsGUIEvent event;
|
||||||
result = PR_TRUE;
|
InitEvent(event, NS_TABCHANGE);
|
||||||
|
DispatchEvent(&event);
|
||||||
|
result = PR_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
case WM_MOVE: // Window moved
|
||||||
|
{
|
||||||
|
nsGUIEvent event;
|
||||||
|
InitEvent(event, NS_MOVE);
|
||||||
|
event.point.x = (int)LOWORD(lParam); // horizontal position in screen coordinates
|
||||||
|
event.point.y = (int)HIWORD(lParam); // vertical position in screen coordinates
|
||||||
|
DispatchEvent(&event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
// clean up.
|
// clean up.
|
||||||
OnDestroy();
|
OnDestroy();
|
||||||
result = PR_TRUE;
|
result = PR_TRUE;
|
||||||
if (nsnull != mEventListener) {
|
|
||||||
printf("Destroy for window called\n");
|
|
||||||
DispatchEvent(NS_DESTROY);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
result = OnPaint();
|
result = OnPaint();
|
||||||
if (nsnull != mEventListener) {
|
|
||||||
DispatchEvent(NS_PAINT);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
|
@ -1135,16 +1156,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||||
|
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
result = DispatchFocus(NS_GOTFOCUS);
|
result = DispatchFocus(NS_GOTFOCUS);
|
||||||
if (nsnull != mEventListener) {
|
|
||||||
DispatchEvent(NS_GOTFOCUS);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
result = DispatchFocus(NS_LOSTFOCUS);
|
result = DispatchFocus(NS_LOSTFOCUS);
|
||||||
if (nsnull != mEventListener) {
|
|
||||||
DispatchEvent(NS_LOSTFOCUS);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_WINDOWPOSCHANGED:
|
case WM_WINDOWPOSCHANGED:
|
||||||
|
@ -1152,9 +1167,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||||
WINDOWPOS *wp = (LPWINDOWPOS)lParam;
|
WINDOWPOS *wp = (LPWINDOWPOS)lParam;
|
||||||
nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
|
nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
|
||||||
result = OnResize(rect);
|
result = OnResize(rect);
|
||||||
if (nsnull != mEventListener) {
|
|
||||||
DispatchEvent(NS_SIZE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_QUERYNEWPALETTE:
|
case WM_QUERYNEWPALETTE:
|
||||||
|
@ -1315,30 +1327,9 @@ void nsWindow::OnDestroy()
|
||||||
mToolkit = NULL;
|
mToolkit = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the event callback
|
nsGUIEvent event;
|
||||||
if (mEventCallback) {
|
InitEvent(event, NS_DESTROY);
|
||||||
nsGUIEvent event;
|
DispatchEvent(&event);
|
||||||
event.widget = this;
|
|
||||||
|
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = NS_DESTROY;
|
|
||||||
|
|
||||||
(*mEventCallback)(&event);
|
|
||||||
}
|
|
||||||
if (nsnull != mEventListener) {
|
|
||||||
DispatchEvent(NS_DESTROY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1359,21 +1350,8 @@ PRBool nsWindow::OnPaint()
|
||||||
// call the event callback
|
// call the event callback
|
||||||
if (mEventCallback) {
|
if (mEventCallback) {
|
||||||
nsPaintEvent event;
|
nsPaintEvent event;
|
||||||
event.widget = this;
|
|
||||||
|
|
||||||
DWORD pos = ::GetMessagePos();
|
InitEvent(event, NS_PAINT);
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = NS_PAINT;
|
|
||||||
|
|
||||||
nsRect rect(ps.rcPaint.left,
|
nsRect rect(ps.rcPaint.left,
|
||||||
ps.rcPaint.top,
|
ps.rcPaint.top,
|
||||||
|
@ -1387,8 +1365,7 @@ PRBool nsWindow::OnPaint()
|
||||||
if (NS_OK == NSRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext))
|
if (NS_OK == NSRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext))
|
||||||
{
|
{
|
||||||
event.renderingContext->Init(mContext, (nsDrawingSurface)hDC);
|
event.renderingContext->Init(mContext, (nsDrawingSurface)hDC);
|
||||||
result = ConvertStatus((*mEventCallback)(&event));
|
result = DispatchEvent(&event);
|
||||||
|
|
||||||
NS_RELEASE(event.renderingContext);
|
NS_RELEASE(event.renderingContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1412,94 +1389,14 @@ PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
||||||
// call the event callback
|
// call the event callback
|
||||||
if (mEventCallback) {
|
if (mEventCallback) {
|
||||||
nsSizeEvent event;
|
nsSizeEvent event;
|
||||||
event.widget = this;
|
InitEvent(event, NS_SIZE);
|
||||||
event.message = NS_SIZE;
|
|
||||||
|
|
||||||
// get the message position in client coordinates and in twips
|
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
|
|
||||||
event.windowSize = &aWindowRect;
|
event.windowSize = &aWindowRect;
|
||||||
return ConvertStatus((*mEventCallback)(&event));
|
return(DispatchEvent(&event));
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Invokes ProcessEvent method on Event Listener object
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
PRBool nsWindow::DispatchEvent(PRUint32 aEventType)
|
|
||||||
{
|
|
||||||
if (nsnull == mEventListener) {
|
|
||||||
return PR_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGUIEvent event;
|
|
||||||
event.widget = this;
|
|
||||||
|
|
||||||
// get the message position in client coordinates and in twips
|
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = aEventType;
|
|
||||||
|
|
||||||
return ConvertStatus(mEventListener->ProcessEvent(event));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Invokes ProcessEvent method on Event Listener object
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
PRBool nsWindow::DispatchEventToCallback(PRUint32 aEventType)
|
|
||||||
{
|
|
||||||
// call the event callback
|
|
||||||
if (mEventCallback) {
|
|
||||||
nsGUIEvent event;
|
|
||||||
event.widget = this;
|
|
||||||
|
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = aEventType;
|
|
||||||
|
|
||||||
return(ConvertStatus((*mEventCallback)(&event)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return(PR_FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@ -1517,25 +1414,12 @@ PRBool nsWindow::DispatchMouseEvent(PRUint32 aEventType)
|
||||||
|
|
||||||
// nsMouseEvent event;
|
// nsMouseEvent event;
|
||||||
nsGUIEvent event;
|
nsGUIEvent event;
|
||||||
event.widget = this;
|
InitEvent(event, aEventType);
|
||||||
|
|
||||||
// get the message position in client coordinates and in twips
|
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = aEventType;
|
|
||||||
|
|
||||||
// call the event callback
|
// call the event callback
|
||||||
if (nsnull != mEventCallback) {
|
if (nsnull != mEventCallback) {
|
||||||
result = ConvertStatus((*mEventCallback)(&event));
|
|
||||||
|
result = DispatchEvent(&event);
|
||||||
|
|
||||||
//printf("**result=%d%\n",result);
|
//printf("**result=%d%\n",result);
|
||||||
if (aEventType == NS_MOUSE_MOVE) {
|
if (aEventType == NS_MOUSE_MOVE) {
|
||||||
|
@ -1613,23 +1497,8 @@ PRBool nsWindow::DispatchFocus(PRUint32 aEventType)
|
||||||
// call the event callback
|
// call the event callback
|
||||||
if (mEventCallback) {
|
if (mEventCallback) {
|
||||||
nsGUIEvent event;
|
nsGUIEvent event;
|
||||||
event.widget = this;
|
InitEvent(event, aEventType);
|
||||||
|
return(DispatchEvent(&event));
|
||||||
DWORD pos = ::GetMessagePos();
|
|
||||||
POINT cpos;
|
|
||||||
|
|
||||||
cpos.x = LOWORD(pos);
|
|
||||||
cpos.y = HIWORD(pos);
|
|
||||||
|
|
||||||
::ScreenToClient(mWnd, &cpos);
|
|
||||||
|
|
||||||
event.point.x = cpos.x;
|
|
||||||
event.point.y = cpos.y;
|
|
||||||
|
|
||||||
event.time = ::GetMessageTime();
|
|
||||||
event.message = aEventType;
|
|
||||||
|
|
||||||
return ConvertStatus((*mEventCallback)(&event));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
|
@ -136,8 +136,6 @@ protected:
|
||||||
virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode);
|
virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode);
|
||||||
|
|
||||||
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
||||||
virtual PRBool DispatchEvent(PRUint32 aEventType);
|
|
||||||
|
|
||||||
virtual PRBool OnScroll(UINT scrollCode, int cPos);
|
virtual PRBool OnScroll(UINT scrollCode, int cPos);
|
||||||
virtual HBRUSH OnControlColor();
|
virtual HBRUSH OnControlColor();
|
||||||
|
|
||||||
|
@ -146,10 +144,12 @@ protected:
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam);
|
LPARAM lParam);
|
||||||
|
|
||||||
PRBool DispatchEventToCallback(PRUint32 aEventType);
|
|
||||||
static PRBool ConvertStatus(nsEventStatus aStatus);
|
static PRBool ConvertStatus(nsEventStatus aStatus);
|
||||||
DWORD GetBorderStyle(nsBorderStyle aBorderStyle);
|
DWORD GetBorderStyle(nsBorderStyle aBorderStyle);
|
||||||
|
|
||||||
|
void InitEvent(nsGUIEvent& event, PRUint32 aEventType);
|
||||||
|
PRBool DispatchEvent(nsGUIEvent* event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HWND mWnd;
|
HWND mWnd;
|
||||||
HPALETTE mPalette;
|
HPALETTE mPalette;
|
||||||
|
|
|
@ -77,7 +77,7 @@ char * gFailedMsg = NULL;
|
||||||
#define WIDGET_DLL "raptorwidget.dll"
|
#define WIDGET_DLL "raptorwidget.dll"
|
||||||
#define GFXWIN_DLL "raptorgfxwin.dll"
|
#define GFXWIN_DLL "raptorgfxwin.dll"
|
||||||
|
|
||||||
#define DEBUG_MOUSE 0
|
#define DEBUG_MOUSE 1
|
||||||
|
|
||||||
#define NUM_COMBOBOX_ITEMS 8
|
#define NUM_COMBOBOX_ITEMS 8
|
||||||
#define kSetCaret "Set Caret"
|
#define kSetCaret "Set Caret"
|
||||||
|
@ -699,6 +699,12 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
||||||
nsEventStatus result = nsEventStatus_eIgnore;
|
nsEventStatus result = nsEventStatus_eIgnore;
|
||||||
switch(aEvent->message) {
|
switch(aEvent->message) {
|
||||||
|
|
||||||
|
case NS_MOVE:
|
||||||
|
char str[256];
|
||||||
|
sprintf(str, "Moved window to %d,%d", aEvent->point.x, aEvent->point.y);
|
||||||
|
statusText->SetText(str);
|
||||||
|
break;
|
||||||
|
|
||||||
case NS_MOUSE_ENTER:
|
case NS_MOUSE_ENTER:
|
||||||
if (DEBUG_MOUSE) printf("NS_MOUSE_ENTER 0x%X\n", aEvent->widget);
|
if (DEBUG_MOUSE) printf("NS_MOUSE_ENTER 0x%X\n", aEvent->widget);
|
||||||
break;
|
break;
|
||||||
|
@ -995,6 +1001,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd
|
||||||
nsString initialText("0123456789");
|
nsString initialText("0123456789");
|
||||||
textWidget->SetText(initialText);
|
textWidget->SetText(initialText);
|
||||||
textWidget->SetMaxTextLength(12);
|
textWidget->SetMaxTextLength(12);
|
||||||
|
textWidget->SelectAll();
|
||||||
|
|
||||||
NS_RELEASE(textWidget);
|
NS_RELEASE(textWidget);
|
||||||
y += rect.height + 5;
|
y += rect.height + 5;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче