gui events store nsISupports; improved forms event handling

This commit is contained in:
karnaze 1998-05-27 23:58:07 +00:00
Родитель f9cc4f555c
Коммит 360710c815
6 изменённых файлов: 27 добавлений и 29 удалений

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

@ -38,6 +38,8 @@
#define ALIGN_UNSET PRUint8(-1)
static NS_DEFINE_IID(kSupportsIID, NS_ISUPPORTS_IID);
// Note: we inherit a base class operator new that zeros our memory
nsInput::nsInput(nsIAtom* aTag, nsIFormManager* aManager)
: nsHTMLContainer(aTag), mControl()
@ -56,6 +58,7 @@ nsInput::nsInput(nsIAtom* aTag, nsIFormManager* aManager)
nsInput::~nsInput()
{
NS_IF_RELEASE(mWidget);
NS_IF_RELEASE(mWidgetSupports);
if (nsnull != mName) {
delete mName;
}
@ -178,6 +181,9 @@ nsInput::SetWidget(nsIWidget* aWidget)
NS_IF_RELEASE(mWidget);
NS_IF_ADDREF(aWidget);
mWidget = aWidget;
NS_IF_RELEASE(mWidgetSupports);
mWidget->QueryInterface(kSupportsIID, (void**)&mWidgetSupports);
}
}
@ -186,12 +192,15 @@ nsrefcnt nsInput::GetRefCount() const
return mRefCnt;
}
// this is for internal use and does not do an AddRef
nsIWidget*
nsInput::GetWidget()
// these do not AddRef
nsIWidget* nsInput::GetWidget()
{
return mWidget;
}
nsISupports* nsInput::GetWidgetSupports()
{
return mWidgetSupports;
}
PRBool nsInput::GetContent(nsString& aResult) const
{

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

@ -140,7 +140,8 @@ public:
* Get the widget associated with this input
* @return the widget, not a copy
**/
nsIWidget* GetWidget();
nsIWidget* GetWidget();
nsISupports* GetWidgetSupports();
/**
* Set the widget associated with this input
@ -166,6 +167,7 @@ protected:
* Get the type of this control
*/
nsIWidget* mWidget;
nsISupports* mWidgetSupports;
nsIFormManager* mFormMan;
nsPoint mLastClickPoint;

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

@ -361,32 +361,15 @@ NS_METHOD nsInputFrame::HandleEvent(nsIPresContext& aPresContext,
nsEventStatus& aEventStatus)
{
// make sure that the widget in the event is this
static NS_DEFINE_IID(kSupportsIID, NS_ISUPPORTS_IID);
nsIWidget* thisWidget;
// XXX if there is no view, it could be an image button. Unfortunately,
// every image button will get every event.
nsIView* view;
GetView(view);
if (view != nsnull) {
nsresult result = GetWidget(view, &thisWidget);
nsISupports* thisWidgetSup;
result = thisWidget->QueryInterface(kSupportsIID, (void **)&thisWidgetSup);
if (thisWidget == nsnull) {
return nsEventStatus_eIgnore;
}
nsISupports* eventWidgetSup;
result = aEvent->widget->QueryInterface(kSupportsIID, (void **)&eventWidgetSup);
PRBool isOurEvent = (thisWidgetSup == eventWidgetSup) ? PR_TRUE : PR_FALSE;
NS_RELEASE(eventWidgetSup);
NS_RELEASE(thisWidgetSup);
NS_IF_RELEASE(view);
NS_IF_RELEASE(thisWidget);
if (!isOurEvent) {
aEventStatus = nsEventStatus_eIgnore;
return NS_OK;
}
nsInput* content = (nsInput *)mContent;
if (view && (content->GetWidgetSupports() != aEvent->widgetSupports)) {
aEventStatus = nsEventStatus_eIgnore;
NS_RELEASE(view);
return NS_OK;
}
switch (aEvent->message) {

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

@ -48,6 +48,8 @@ struct nsGUIEvent {
/// Originator of the event
nsIWidget* widget;
/// in widget relative coordinates
nsISupports* widgetSupports;
/// nsISupports of widget XXX remove the one above and rename this
nsPoint point;
/// elapsed time, in milliseconds, from the time the system was started to the time the message was created
PRUint32 time;

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

@ -52,9 +52,10 @@ protected:
//
CList m_link;
private:
nsISupports *mOuter;
private:
class InnerSupport : public nsISupports {
public:
InnerSupport() {}

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

@ -245,6 +245,7 @@ PRBool nsWindow::ConvertStatus(nsEventStatus aStatus)
void nsWindow::InitEvent(nsGUIEvent& event, PRUint32 aEventType)
{
event.widget = this;
event.widgetSupports = mOuter;
// get the message position in client coordinates and in twips
DWORD pos = ::GetMessagePos();