This commit is contained in:
dcone%netscape.com 1998-08-11 20:17:06 +00:00
Родитель 19a57e8289
Коммит 91b3551004
2 изменённых файлов: 172 добавлений и 11 удалений

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

@ -18,13 +18,8 @@
#include "nsAppShell.h"
#include "nsIAppShell.h"
#include "nsWindow.h"
#include <stdlib.h>
#include <Fonts.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Traps.h>
#include <Events.h>
#include <Menus.h>
//XtAppContext gAppContext;
@ -40,7 +35,6 @@ NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID);
void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
{
mDispatchListener = aDispatchListener;
mToolKit = new nsToolkit();
}
//-------------------------------------------------------------------------
@ -51,7 +45,7 @@ void nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
void nsAppShell::Create(int* argc, char ** argv)
{
mToolKit = new nsToolkit();
}
//-------------------------------------------------------------------------
@ -66,16 +60,78 @@ EventRecord theevent;
RgnHandle fMouseRgn=NULL;
long sleep=0;
PRInt16 haveevent;
WindowPtr whichwindow;
#define SUSPENDRESUMEMESSAGE 0x01
#define MOUSEMOVEDMESSAGE 0xFA
mRunning = TRUE;
while(mRunning)
{
haveevent = WaitNextEvent(everyEvent,&theevent,sleep,fMouseRgn);
haveevent = ::WaitNextEvent(everyEvent,&theevent,sleep,fMouseRgn);
if(haveevent)
{
switch(theevent.what)
{
case nullEvent:
IdleWidgets();
break;
case diskEvt:
if(theevent.message<0)
{
// error, bad disk mount
}
break;
case keyUp:
break;
case keyDown:
case autoKey:
doKey(&theevent);
break;
this->Exit();
break;
case mouseDown:
DoMouseDown(&theevent);
break;
case mouseUp:
break;
case updateEvt:
whichwindow = (WindowPtr)theevent.message;
break;
case activateEvt:
whichwindow = (WindowPtr)theevent.message;
if(theevent.modifiers & activeFlag)
{
::BringToFront(whichwindow);
::HiliteWindow(whichwindow,TRUE);
}
else
{
::HiliteWindow(whichwindow,FALSE);
}
break;
case osEvt:
unsigned char evtype;
whichwindow = (WindowPtr)theevent.message;
evtype = (unsigned char) (theevent.message>>24)&0x00ff;
switch(evtype)
{
case MOUSEMOVEDMESSAGE:
break;
case SUSPENDRESUMEMESSAGE:
if(theevent.message&0x00000001)
{
// resume message
}
else
{
// suspend message
}
}
break;
}
}
}
@ -86,6 +142,96 @@ PRInt16 haveevent;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Handle and pass on Idle events
//
//-------------------------------------------------------------------------
void nsAppShell::IdleWidgets()
{
WindowPtr whichwindow;
PRInt16 partcode;
nsWindow *thewindow;
nsIWidget *thewidget;
whichwindow = ::FrontWindow();
while(whichwindow)
{
// idle the widget
thewindow = (nsWindow*)(((WindowPeek)whichwindow)->refCon);
whichwindow = (WindowPtr)((WindowPeek)whichwindow)->nextWindow;
}
}
//-------------------------------------------------------------------------
//
// Handle the mousedown event
//
//-------------------------------------------------------------------------
void nsAppShell::DoMouseDown(EventRecord *aTheEvent)
{
WindowPtr whichwindow;
PRInt16 partcode;
nsWindow *thewindow;
nsIWidget *thewidget;
partcode = FindWindow(aTheEvent->where,&whichwindow);
if(whichwindow!=0)
{
thewindow = (nsWindow*)(((WindowPeek)whichwindow)->refCon);
thewidget = thewindow->FindWidgetHit(aTheEvent->where);
switch(partcode)
{
case inSysWindow:
break;
case inContent:
break;
case inDrag:
break;
case inGrow:
break;
case inGoAway:
break;
case inZoomIn:
case inZoomOut:
break;
case inMenuBar:
break;
}
}
}
//-------------------------------------------------------------------------
//
// Handle the key events
//
//-------------------------------------------------------------------------
void nsAppShell::doKey(EventRecord *aTheEvent)
{
char ch;
WindowPtr whichwindow;
ch = (char)(aTheEvent->message & charCodeMask);
if(aTheEvent->modifiers&cmdKey)
{
// do a menu key command
}
else
{
whichwindow = FrontWindow();
if(whichwindow)
{
// generate a keydown event for the widget
}
}
}
//-------------------------------------------------------------------------
//
// Exit a message handler loop

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

@ -21,6 +21,12 @@
#include "nsIAppShell.h"
#include "nsToolKit.h"
#include <Fonts.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Traps.h>
#include <Events.h>
#include <Menus.h>
/**
@ -30,12 +36,19 @@
class nsAppShell : public nsIAppShell
{
private:
//Widget mTopLevel;
//XtAppContext mAppContext;
nsDispatchListener* mDispatchListener;
nsToolkit* mToolKit;
PRBool mRunning;
// CLASS METHODS
private:
void DoMouseDown(EventRecord *aTheEvent);
void IdleWidgets();
void doKey(EventRecord *aTheEvent);
public:
nsAppShell();
virtual ~nsAppShell();
@ -48,6 +61,8 @@ class nsAppShell : public nsIAppShell
virtual nsresult Run();
virtual void Exit();
virtual void SetDispatchListener(nsDispatchListener* aDispatchListener);
virtual void* GetNativeData(PRUint32 aDataType);