зеркало из https://github.com/mozilla/gecko-dev.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:
Родитель
9280678e1e
Коммит
d7d08c392b
|
@ -106,16 +106,29 @@ struct nsKeyEvent : public nsGUIEvent {
|
|||
//@{
|
||||
|
||||
#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)
|
||||
// Sent when a key is released within a window
|
||||
#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_MOVE (NS_MOUSE_MESSAGE_START)
|
||||
|
|
|
@ -104,6 +104,12 @@ class nsITextWidget : public nsIWidget
|
|||
*/
|
||||
|
||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag) = 0;
|
||||
|
||||
/**
|
||||
* Select all of the contents
|
||||
*/
|
||||
|
||||
virtual void SelectAll() = 0;
|
||||
|
||||
/**
|
||||
* Set the selection in this text component
|
||||
|
|
|
@ -22,23 +22,33 @@
|
|||
#include "nsString.h"
|
||||
#include <windows.h>
|
||||
|
||||
void nsTextAreaWidget::SetMaxTextLength(PRUint32 aChars) {
|
||||
void nsTextAreaWidget::SelectAll()
|
||||
{
|
||||
nsTextHelper::SelectAll();
|
||||
}
|
||||
|
||||
void nsTextAreaWidget::SetMaxTextLength(PRUint32 aChars)
|
||||
{
|
||||
nsTextHelper::SetMaxTextLength(aChars);
|
||||
}
|
||||
|
||||
PRUint32 nsTextAreaWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize) {
|
||||
PRUint32 nsTextAreaWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize)
|
||||
{
|
||||
return(nsTextHelper::GetText(aTextBuffer, aBufferSize));
|
||||
}
|
||||
|
||||
PRUint32 nsTextAreaWidget::SetText(const nsString &aText) {
|
||||
PRUint32 nsTextAreaWidget::SetText(const nsString &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));
|
||||
}
|
||||
|
||||
void nsTextAreaWidget::RemoveText() {
|
||||
void nsTextAreaWidget::RemoveText()
|
||||
{
|
||||
nsTextHelper::RemoveText();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
BASE_IWIDGET_IMPL
|
||||
|
||||
// nsITextWidget part
|
||||
virtual void SelectAll();
|
||||
virtual void SetMaxTextLength(PRUint32 aChars);
|
||||
virtual PRUint32 SetText(const nsString &aText);
|
||||
virtual PRUint32 GetText(nsString& aTextBuffer, PRUint32 aBufferSize);
|
||||
|
|
|
@ -82,6 +82,13 @@ PRBool nsTextHelper::SetReadOnly(PRBool aReadOnlyFlag)
|
|||
return(oldSetting);
|
||||
}
|
||||
|
||||
|
||||
void nsTextHelper::SelectAll()
|
||||
{
|
||||
::SendMessage(mWnd, EM_SETSEL, (WPARAM) 0, (LPARAM)-1);
|
||||
}
|
||||
|
||||
|
||||
void nsTextHelper::SetSelection(PRUint32 aStartSel, PRUint32 aEndSel)
|
||||
{
|
||||
::SendMessage(mWnd, EM_SETSEL, (WPARAM) (INT)aStartSel, (INT) (LPDWORD)aEndSel);
|
||||
|
|
|
@ -33,19 +33,20 @@ 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);
|
||||
virtual void RemoveText();
|
||||
virtual void SetPassword(PRBool aIsPassword);
|
||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
||||
virtual PRUint32 GetCaretPosition();
|
||||
virtual LPCTSTR WindowClass();
|
||||
virtual DWORD WindowStyle();
|
||||
virtual void SelectAll();
|
||||
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);
|
||||
virtual void RemoveText();
|
||||
virtual void SetPassword(PRBool aIsPassword);
|
||||
virtual PRBool SetReadOnly(PRBool aReadOnlyFlag);
|
||||
virtual void SetSelection(PRUint32 aStartSel, PRUint32 aEndSel);
|
||||
virtual void GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel);
|
||||
virtual void SetCaretPosition(PRUint32 aPosition);
|
||||
virtual PRUint32 GetCaretPosition();
|
||||
virtual LPCTSTR WindowClass();
|
||||
virtual DWORD WindowStyle();
|
||||
|
||||
virtual void PreCreateWidget(void *aInitData);
|
||||
|
||||
|
|
|
@ -24,23 +24,6 @@
|
|||
#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
|
||||
|
@ -51,7 +34,6 @@ nsTextWidget::nsTextWidget(nsISupports *aOuter) : nsTextHelper(aOuter)
|
|||
mBackground = NS_RGB(124, 124, 124);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsTextWidget destructor
|
||||
|
@ -61,7 +43,6 @@ nsTextWidget::~nsTextWidget()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Query interface implementation
|
||||
|
|
|
@ -47,12 +47,6 @@ public:
|
|||
// nsIWidget interface
|
||||
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:
|
||||
virtual LPCTSTR WindowClass();
|
||||
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
|
||||
|
@ -250,28 +300,10 @@ void nsWindow::Create(nsIWidget *aParent,
|
|||
SetCursor(eCursor_standard);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -359,6 +391,10 @@ void nsWindow::Create(nsNativeWindow aParent,
|
|||
VERIFY(mWnd);
|
||||
|
||||
// call the event callback to notify about creation
|
||||
nsGUIEvent event;
|
||||
InitEvent(event, NS_CREATE);
|
||||
DispatchEvent(&event);
|
||||
#if 0
|
||||
if (mEventCallback) {
|
||||
nsGUIEvent event;
|
||||
event.widget = this;
|
||||
|
@ -380,6 +416,7 @@ void nsWindow::Create(nsNativeWindow aParent,
|
|||
event.message = NS_CREATE;
|
||||
(*mEventCallback)(&event);
|
||||
}
|
||||
#endif
|
||||
|
||||
SubclassWindow(TRUE);
|
||||
}
|
||||
|
@ -954,34 +991,13 @@ BOOL nsWindow::CallMethod(MethodInfo *info)
|
|||
//-------------------------------------------------------------------------
|
||||
PRBool nsWindow::OnKey(PRUint32 aEventType, PRUint32 aKeyCode)
|
||||
{
|
||||
PRBool result = PR_TRUE;
|
||||
|
||||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
nsKeyEvent 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;
|
||||
event.keyCode = aKeyCode;
|
||||
event.isShift = mIsShiftDown;
|
||||
event.isControl = mIsControlDown;
|
||||
event.isAlt = mIsAltDown;
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
}
|
||||
|
||||
return result;
|
||||
nsKeyEvent event;
|
||||
InitEvent(event, aEventType);
|
||||
event.keyCode = aKeyCode;
|
||||
event.isShift = mIsShiftDown;
|
||||
event.isControl = mIsControlDown;
|
||||
event.isAlt = mIsAltDown;
|
||||
return(DispatchEvent(&event));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1002,31 +1018,36 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
|
||||
case WM_NOTIFY:
|
||||
// TAB change
|
||||
{
|
||||
LPNMHDR pnmh = (LPNMHDR) lParam;
|
||||
{
|
||||
LPNMHDR pnmh = (LPNMHDR) lParam;
|
||||
|
||||
if (pnmh->code == TCN_SELCHANGE) {
|
||||
DispatchEventToCallback(NS_TABCHANGE);
|
||||
result = PR_TRUE;
|
||||
if (pnmh->code == TCN_SELCHANGE) {
|
||||
nsGUIEvent event;
|
||||
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:
|
||||
// clean up.
|
||||
OnDestroy();
|
||||
result = PR_TRUE;
|
||||
if (nsnull != mEventListener) {
|
||||
printf("Destroy for window called\n");
|
||||
DispatchEvent(NS_DESTROY);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
result = OnPaint();
|
||||
if (nsnull != mEventListener) {
|
||||
DispatchEvent(NS_PAINT);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
|
@ -1135,16 +1156,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
|
||||
case WM_SETFOCUS:
|
||||
result = DispatchFocus(NS_GOTFOCUS);
|
||||
if (nsnull != mEventListener) {
|
||||
DispatchEvent(NS_GOTFOCUS);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
result = DispatchFocus(NS_LOSTFOCUS);
|
||||
if (nsnull != mEventListener) {
|
||||
DispatchEvent(NS_LOSTFOCUS);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
|
@ -1152,9 +1167,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
WINDOWPOS *wp = (LPWINDOWPOS)lParam;
|
||||
nsRect rect(wp->x, wp->y, wp->cx, wp->cy);
|
||||
result = OnResize(rect);
|
||||
if (nsnull != mEventListener) {
|
||||
DispatchEvent(NS_SIZE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_QUERYNEWPALETTE:
|
||||
|
@ -1315,30 +1327,9 @@ void nsWindow::OnDestroy()
|
|||
mToolkit = NULL;
|
||||
}
|
||||
|
||||
// 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 = NS_DESTROY;
|
||||
|
||||
(*mEventCallback)(&event);
|
||||
}
|
||||
if (nsnull != mEventListener) {
|
||||
DispatchEvent(NS_DESTROY);
|
||||
}
|
||||
nsGUIEvent event;
|
||||
InitEvent(event, NS_DESTROY);
|
||||
DispatchEvent(&event);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1359,21 +1350,8 @@ PRBool nsWindow::OnPaint()
|
|||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
nsPaintEvent 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_PAINT;
|
||||
InitEvent(event, NS_PAINT);
|
||||
|
||||
nsRect rect(ps.rcPaint.left,
|
||||
ps.rcPaint.top,
|
||||
|
@ -1387,8 +1365,7 @@ PRBool nsWindow::OnPaint()
|
|||
if (NS_OK == NSRepository::CreateInstance(kRenderingContextCID, nsnull, kRenderingContextIID, (void **)&event.renderingContext))
|
||||
{
|
||||
event.renderingContext->Init(mContext, (nsDrawingSurface)hDC);
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
|
||||
result = DispatchEvent(&event);
|
||||
NS_RELEASE(event.renderingContext);
|
||||
}
|
||||
else
|
||||
|
@ -1412,94 +1389,14 @@ PRBool nsWindow::OnResize(nsRect &aWindowRect)
|
|||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
nsSizeEvent event;
|
||||
event.widget = this;
|
||||
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();
|
||||
|
||||
InitEvent(event, NS_SIZE);
|
||||
event.windowSize = &aWindowRect;
|
||||
return ConvertStatus((*mEventCallback)(&event));
|
||||
return(DispatchEvent(&event));
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
InitEvent(event, aEventType);
|
||||
|
||||
// call the event callback
|
||||
if (nsnull != mEventCallback) {
|
||||
result = ConvertStatus((*mEventCallback)(&event));
|
||||
|
||||
result = DispatchEvent(&event);
|
||||
|
||||
//printf("**result=%d%\n",result);
|
||||
if (aEventType == NS_MOUSE_MOVE) {
|
||||
|
@ -1613,23 +1497,8 @@ PRBool nsWindow::DispatchFocus(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));
|
||||
InitEvent(event, aEventType);
|
||||
return(DispatchEvent(&event));
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
|
|
|
@ -136,8 +136,6 @@ protected:
|
|||
virtual PRBool OnKey(PRUint32 aEventType, PRUint32 aKeyCode);
|
||||
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
||||
virtual PRBool DispatchEvent(PRUint32 aEventType);
|
||||
|
||||
virtual PRBool OnScroll(UINT scrollCode, int cPos);
|
||||
virtual HBRUSH OnControlColor();
|
||||
|
||||
|
@ -146,10 +144,12 @@ protected:
|
|||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
PRBool DispatchEventToCallback(PRUint32 aEventType);
|
||||
static PRBool ConvertStatus(nsEventStatus aStatus);
|
||||
DWORD GetBorderStyle(nsBorderStyle aBorderStyle);
|
||||
|
||||
void InitEvent(nsGUIEvent& event, PRUint32 aEventType);
|
||||
PRBool DispatchEvent(nsGUIEvent* event);
|
||||
|
||||
protected:
|
||||
HWND mWnd;
|
||||
HPALETTE mPalette;
|
||||
|
|
|
@ -77,7 +77,7 @@ char * gFailedMsg = NULL;
|
|||
#define WIDGET_DLL "raptorwidget.dll"
|
||||
#define GFXWIN_DLL "raptorgfxwin.dll"
|
||||
|
||||
#define DEBUG_MOUSE 0
|
||||
#define DEBUG_MOUSE 1
|
||||
|
||||
#define NUM_COMBOBOX_ITEMS 8
|
||||
#define kSetCaret "Set Caret"
|
||||
|
@ -699,6 +699,12 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
|||
nsEventStatus result = nsEventStatus_eIgnore;
|
||||
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:
|
||||
if (DEBUG_MOUSE) printf("NS_MOUSE_ENTER 0x%X\n", aEvent->widget);
|
||||
break;
|
||||
|
@ -995,6 +1001,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd
|
|||
nsString initialText("0123456789");
|
||||
textWidget->SetText(initialText);
|
||||
textWidget->SetMaxTextLength(12);
|
||||
textWidget->SelectAll();
|
||||
|
||||
NS_RELEASE(textWidget);
|
||||
y += rect.height + 5;
|
||||
|
|
Загрузка…
Ссылка в новой задаче