now MSW stuff is complete

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-05-20 14:21:00 +00:00
parent 2bda0e1738
commit bbf1f0e5cf
118 changed files with 9265 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1997
# Updated:
# Copyright: (c) 1997, Julian Smart
#
# "%W% %G%"
#
# Makefile : Builds simple plugin example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
# Application is a DLL
DLL=1
EXTRAINC=/I$(WXDIR)\utils\nplugin\src
!include $(WXDIR)\src\ntwxwin.mak
THISDIR = $(WXDIR)\utils\nplugin\smples\simple
PROGRAM=npsimple32
PLUGINLIB=$(WXDIR)\utils\nplugin\lib\nplugin.lib
OBJECTS = simple.obj
all: $(PROGRAM).dll
$(PROGRAM): $(PROGRAM).exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.nt dllnp FINAL=$(FINAL)
cd $(THISDIR)
# Update the dynamic link library
$(PROGRAM).dll: $(DUMMYOBJ) $(OBJECTS) $(WXDIR)\lib\wx.lib $(PLUGINLIB) $(PROGRAM).res $(PROGRAM).def
$(link) $(LINKFLAGS) \
-out:$(PROGRAM).dll \
-def:$(PROGRAM).def \
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res $(WXDIR)\lib\wx.lib $(PLUGINLIB) \
$(guilibsdll) msvcrt.lib shell32.lib comctl32.lib ctl3d32.lib
simple.obj: simple.$(SRCSUFF) $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
copy:
copy npsimple32.dll "c:\program files\Netscape\Navigator\program\plugins"
copy npsimple32.dll "c:\program files\Internet Explorer\plugins"
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb
-erase *.dll
-erase *.exp
-erase *.lib
-erase *.ilk

View File

@@ -0,0 +1,9 @@
LIBRARY NPSIMPLE32
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3

View File

@@ -0,0 +1,44 @@
#include "wx/msw/wx.rc"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "Julian Smart\0"
VALUE "FileDescription", "wxWindows simple example plugin file\0"
VALUE "FileVersion", "0.0.0.1\0"
VALUE "InternalName", "wxWindows Simple Plugin\0"
VALUE "LegalCopyright", "Copyright Julian Smart 1997\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename","npsimple32.dll\0"
VALUE "ProductName", "wxWindows Simple Plugin Sample\0"
VALUE "ProductVersion", "0.0.0.1\0"
VALUE "MIMEType", "wxsimple/mime-type\0"
VALUE "FileExtents", "smp\0"
VALUE "FileOpenName", "wxWindows Simple (*.smp)\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

View File

@@ -0,0 +1,174 @@
/*
* File: simple.cpp
* Purpose: Minimal wxWindows plugin
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
/* static const char sccsid[] = "%W% %G%"; */
#ifdef __GNUG__
#pragma implementation
#pragma interface
#endif
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <fstream.h>
#include "NPApp.h"
#include "NPFrame.h"
// Define a new application type
class MyApp: public wxPluginApp
{ public:
virtual wxFrame *OnInit(void);
virtual wxPluginFrame* OnNewInstance(const wxPluginData& data);
};
// Define a new frame type
class MyFrame: public wxPluginFrame
{ public:
MyFrame(const wxPluginData& data);
public:
// Let's paint directly onto the 'frame'; we don't need a subwindow
void OnPaint(wxPaintEvent& event);
void OnDraw(wxDC& dc);
void OnMouseEvent(wxMouseEvent& event);
// Called when the file has been downloaded
virtual void OnNPNewFile(NPStream *stream, const wxString& fname);
void CentreStrings(wxDC& dc);
DECLARE_EVENT_TABLE()
protected:
wxStringList m_strings;
long m_xpos;
long m_ypos;
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE(MyFrame::OnSize)
EVT_PAINT(MyFrame::OnPaint)
EVT_MOUSE_EVENTS(MyFrame::OnMouseEvent)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
// No app initialisation necessary, and for a plugin there is no
// top frame.
wxFrame *MyApp::OnInit(void)
{
return NULL;
}
// Called whenever a new plugin instance is called. We could check
// various things here in 'data' but we won't bother.
wxPluginFrame* MyApp::OnNewInstance(const wxPluginData& data)
{
// Implicitly added to list of plugin frames
return new MyFrame(data);
}
// My frame constructor
MyFrame::MyFrame(const wxPluginData& data):
wxPluginFrame(data)
{
m_xpos = -1;
m_ypos = -1;
}
void MyFrame::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
OnDraw(dc);
}
void MyFrame::OnDraw(wxDC& dc)
{
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
int w, h;
GetClientSize(&w, &h);
dc.DrawRectangle(0, 0, w, h);
wxFont swissFont(10, wxSWISS, wxNORMAL, wxNORMAL);
dc.SetFont(swissFont);
dc.SetBackgroundMode(wxTRANSPARENT);
CentreStrings(dc);
}
// Called when the file has been downloaded
void MyFrame::OnNPNewFile(NPStream *stream, const wxString& fname)
{
ifstream str(fname);
char buf[201];
while ( !str.eof() )
{
buf[0] = 0;
str.getline(buf, 200);
if ( buf[0] != 0 )
m_strings.Add(buf);
}
Refresh();
}
void MyFrame::CentreStrings(wxDC& dc)
{
int y = 5;
int cw, ch;
GetClientSize(&cw, &ch);
wxNode *node = m_strings.First();
while ( node )
{
char *s = (char *)node->Data();
long w, h;
dc.GetTextExtent(s, &w, &h);
int x = wxMax(0, (cw - w)/2);
dc.DrawText(s, x, y);
y += h + (h/2);
node = node->Next();
}
}
// This implements a tiny doodling program. Drag the mouse using
// the left button.
void MyFrame::OnMouseEvent(wxMouseEvent& event)
{
long x, y;
event.Position(&x, &y);
wxClientDC dc(this);
if (m_xpos > -1 && m_ypos > -1 && event.Dragging() && event.LeftIsDown())
{
dc.SetPen(wxBLACK_PEN);
dc.SetBrush(wxTRANSPARENT_BRUSH);
dc.DrawLine(m_xpos, m_ypos, x, y);
}
m_xpos = x;
m_ypos = y;
}