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,186 @@
/*
* 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 ID_HELLO 10
// 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 OnMouseEvent(wxMouseEvent& event);
void OnHello(wxCommandEvent& 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;
float m_xpos;
float m_ypos;
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE(MyFrame::OnSize)
EVT_PAINT(MyFrame::OnPaint)
EVT_MOUSE_EVENTS(MyFrame::OnMouseEvent)
EVT_BUTTON(ID_HELLO, MyFrame::OnHello)
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;
wxMenuBar *menuBar = new wxMenuBar;
wxMenu *menu = new wxMenu;
menu->Append(1, "E&xit");
menuBar->Append(menu, "&File");
SetMenuBar(menuBar);
new wxTextCtrl(this, -1, "", wxPoint(10, 30), wxSize(200, 25), wxSUNKEN_BORDER);
new wxButton(this, ID_HELLO, "Hello", wxPoint(10, 70));
}
void MyFrame::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
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();
float 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)
{
float 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;
}
void MyFrame::OnHello(wxCommandEvent& event)
{
wxMessageBox("Hello!");
}

View File

@@ -0,0 +1,59 @@
/*
* File: gui.h
* Purpose: wxWindows plugin with a few GUI elements
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
#ifndef __GUIH__
#define __GUIH__
// Define a new application type
class MyApp: public wxPluginApp
{ public:
virtual wxFrame *OnInit(void);
virtual wxPluginFrame* OnNewInstance(const wxPluginData& data);
};
class MyApp;
class MyFrame;
class MyCanvas;
class MyFrame: public wxPluginFrame
{
public:
MyFrame(const wxPluginData& data);
virtual ~MyFrame();
void OldOnMenuCommand(int id);
private:
wxMenu* fileMenu;
wxMenuBar* menuBar;
MyCanvas* leftCanvas;
MyCanvas* rightCanvas;
wxSplitterWindow* splitter;
};
class MyCanvas: public wxScrolledWindow
{
public:
MyCanvas(wxWindow* parent, int x, int y, int w, int h);
virtual ~MyCanvas();
void OnPaint(wxPaintEvent& event);
DECLARE_EVENT_TABLE()
};
// ID for the menu quit command
#define SPLIT_QUIT 1
#define SPLIT_HORIZONTAL 2
#define SPLIT_VERTICAL 3
#define SPLIT_UNSPLIT 4
#endif

View File

@@ -0,0 +1,70 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1997
# Updated:
# Copyright: (c) 1997, Julian Smart
#
# "%W% %G%"
#
# Makefile : Builds gui 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\examples\gui
PROGRAM=npgui32
PLUGINLIB=$(WXDIR)\utils\nplugin\lib\nplugin.lib
OBJECTS = gui.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
gui.obj: gui.$(SRCSUFF) gui.h $(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 npgui32.dll "c:\program files\Netscape\Navigator\program\plugins"
copy npgui32.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 NPGUI32
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 GUI example plugin file\0"
VALUE "FileVersion", "0.0.0.1\0"
VALUE "InternalName", "wxWindows GUI Plugin\0"
VALUE "LegalCopyright", "Copyright Julian Smart 1997\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename","npgui32.dll\0"
VALUE "ProductName", "wxWindows GUI Plugin Sample\0"
VALUE "ProductVersion", "0.0.0.1\0"
VALUE "MIMEType", "wxgui/mime-type\0"
VALUE "FileExtents", "gui\0"
VALUE "FileOpenName", "wxWindows GUI (*.gui)\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END