home *** CD-ROM | disk | FTP | other *** search
- //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- //
- // NetscapePlugin.cpp
- //
- //
- //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- #include "CViewText.h"
-
- #include "CPlainTextStream.h"
-
- #include <string.h>
- #include "Files.h"
- #include "Events.h"
-
- #include <LScroller.h>
- #include <LActiveScroller.h>
- #include <URegistrar.h>
- #include "CFastTextEdit.h"
-
- extern QDGlobals* gQDPtr;
-
- const PaneIDT kTopViewPaneID = 'NPlg';
- const PaneIDT kScrollerPaneID = 'NPsc';
- const PaneIDT kTextEditPaneID = 'NPtx';
-
- //======================================================================
- // CViewText::Initialize()
- //======================================================================
-
- NPError
- CViewText::Initialize( void )
- {
- NPError err = CMacPluginView::Initialize();
- if( err == NPERR_NO_ERROR )
- {
- URegistrar::RegisterClass(LScroller::class_ID, (ClassCreatorFunc) LScroller::CreateScrollerStream);
- URegistrar::RegisterClass(CFastTextEdit::class_ID, (ClassCreatorFunc) CFastTextEdit::CreateFastTextEditStream);
- URegistrar::RegisterClass(LActiveScroller::class_ID,(ClassCreatorFunc) LActiveScroller::CreateActiveScrollerStream);
- }
-
- return err;
- }
-
- //======================================================================
- // CViewText::Shutdown()
- //======================================================================
-
- NPError
- CViewText::Shutdown( void )
- {
- return NPERR_NO_ERROR;
- }
-
- //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- //
- // Object Allocation Methods
- //
- //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- //======================================================================
- // CViewText::CViewText()
- //======================================================================
-
- CViewText::CViewText( NPP instance, uint16 mode, CPluginArguments* adoptedArgs )
- : CNetscapePlugin( instance, mode, adoptedArgs )
- {
- instance->pdata = (void*) this;
- }
-
- //======================================================================
- // CViewText::~CViewText()
- //======================================================================
-
- CViewText::~CViewText()
- {
- }
-
-
- //------------------------------------------------------------------------------------
- // CViewText::Handle_Event
- //
- // Default functionality for this virtual function is to ignore all but update events,
- // and draw when those are received.
- //------------------------------------------------------------------------------------
- NPBool
- CViewText::Handle_Event( void* inEvent )
- {
- EventRecord* event = (EventRecord*) inEvent;
-
- CMacPluginView* macView = GetMacPluginView();
-
- NPBool eventHandled = false;
- switch( event->what )
- {
- case keyDown:
- case nullEvent:
- case updateEvt:
- case getFocusEvent:
- case loseFocusEvent:
- case mouseDown:
- case mouseUp:
- case activateEvt:
- eventHandled = macView->Handle_Event( *event );
- break;
- default:
- eventHandled = false;
- }
- return eventHandled;
- }
-
- //------------------------------------------------------------------------------------
- // CViewText::CreateStream:
- //------------------------------------------------------------------------------------
- CNetscapeStream*
- CViewText::CreateStream( NPMIMEType type, NPStream *stream, NPBool seekable, uint16 stype )
- {
- return new CPlainTextStream( type, stream, seekable, stype, GetTextEditView() );
- }
-
- //------------------------------------------------------------------------------------
- // CViewText::GetTextEditView:
- //------------------------------------------------------------------------------------
- LTextEdit*
- CViewText::GetTextEditView()
- {
- CMacPluginView* macView = GetMacPluginView();
- return (LTextEdit*)macView->FindPaneByID( kTextEditPaneID );
- }
-
- //------------------------------------------------------------------------------------
- // CViewText::CreatePluginView
- //------------------------------------------------------------------------------------
- CPluginView*
- CViewText::CreatePluginView( )
- {
- return new CMacPluginView( this );
- }
-
-
-
-