Initial check in of wxApplet code to CVS
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9971 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
83
include/wx/applet/applet.h
Normal file
83
include/wx/applet/applet.h
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ======================================================================
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* | |
|
||||||
|
* |This copyrighted computer code is a proprietary trade secret of |
|
||||||
|
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
||||||
|
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
||||||
|
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
||||||
|
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
||||||
|
* |written authorization from SciTech to possess or use this code, you |
|
||||||
|
* |may be subject to civil and/or criminal penalties. |
|
||||||
|
* | |
|
||||||
|
* |If you received this code in error or you would like to report |
|
||||||
|
* |improper use, please immediately contact SciTech Software, Inc. at |
|
||||||
|
* |530-894-8400. |
|
||||||
|
* | |
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* ======================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the wxApplet class
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_APPLET_H
|
||||||
|
#define __WX_APPLET_H
|
||||||
|
|
||||||
|
#include "wx/panel.h"
|
||||||
|
#include "wx/applet/window.h"
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Defines the abstract base class for wxApplet objects.
|
||||||
|
****************************************************************************/
|
||||||
|
class wxApplet : public wxPanel {
|
||||||
|
private:
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxApplet);
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxHtmlAppletWindow *m_Parent;
|
||||||
|
|
||||||
|
// Special handler for background erase messages
|
||||||
|
void OnEraseBackground(wxEraseEvent&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor (called during dynamic creation)
|
||||||
|
wxApplet() { m_Parent = NULL; }
|
||||||
|
|
||||||
|
// Psuedo virtual constructor
|
||||||
|
virtual bool Create(
|
||||||
|
wxHtmlAppletWindow *parent,
|
||||||
|
const wxSize& size,
|
||||||
|
long style = wxTAB_TRAVERSAL | wxNO_BORDER);
|
||||||
|
|
||||||
|
// Virtual destructor
|
||||||
|
virtual ~wxApplet();
|
||||||
|
|
||||||
|
// Handle HTML navigation to a new URL
|
||||||
|
virtual void OnLinkClicked(const wxHtmlLinkInfo& link) = 0;
|
||||||
|
|
||||||
|
// Handle HTML navigation forward command in applet
|
||||||
|
virtual void OnHistoryForward() = 0;
|
||||||
|
|
||||||
|
// Handle HTML navigation back command in applet
|
||||||
|
virtual void OnHistoryBack() = 0;
|
||||||
|
|
||||||
|
// Handle messages from the wxAppletManager and other applets
|
||||||
|
virtual void OnMessage(wxEvent& msg) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __WX_APPLET_H
|
||||||
|
|
||||||
114
include/wx/applet/window.h
Normal file
114
include/wx/applet/window.h
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ======================================================================
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* | |
|
||||||
|
* |This copyrighted computer code is a proprietary trade secret of |
|
||||||
|
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
||||||
|
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
||||||
|
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
||||||
|
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
||||||
|
* |written authorization from SciTech to possess or use this code, you |
|
||||||
|
* |may be subject to civil and/or criminal penalties. |
|
||||||
|
* | |
|
||||||
|
* |If you received this code in error or you would like to report |
|
||||||
|
* |improper use, please immediately contact SciTech Software, Inc. at |
|
||||||
|
* |530-894-8400. |
|
||||||
|
* | |
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* ======================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the wxHtmlAppletWindow class
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_APPLET_WINDOW_H
|
||||||
|
#define __WX_APPLET_WINDOW_H
|
||||||
|
|
||||||
|
#include "wx/html/htmlwin.h"
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
// Declare a linked list of wxApplet pointers
|
||||||
|
class wxApplet;
|
||||||
|
WX_DECLARE_LIST(wxApplet, wxAppletList);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
MEMBERS:
|
||||||
|
appletModules - List of register applet modules
|
||||||
|
appletList - List of all active applets instances
|
||||||
|
cookies - Hash table for managing cookies
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
Defines the class for wxAppletWindow. This class is derived from the
|
||||||
|
wxHtmlWindow class and extends it with functionality to handle embedded
|
||||||
|
wxApplet's on the HTML pages.
|
||||||
|
****************************************************************************/
|
||||||
|
class wxHtmlAppletWindow : public wxHtmlWindow {
|
||||||
|
private:
|
||||||
|
DECLARE_CLASS(wxHtmlAppletWindow);
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxAppletList m_AppletList;
|
||||||
|
wxHashTable m_Cookies;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
wxHtmlAppletWindow(
|
||||||
|
wxWindow *parent,
|
||||||
|
wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxHW_SCROLLBAR_AUTO,
|
||||||
|
const wxString& name = "htmlAppletWindow");
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
~wxHtmlAppletWindow();
|
||||||
|
|
||||||
|
// Create an instance of an applet based on it's class name
|
||||||
|
wxApplet *CreateApplet(
|
||||||
|
const wxString& className,
|
||||||
|
const wxSize& size);
|
||||||
|
|
||||||
|
// Find an instance of an applet based on it's class name
|
||||||
|
wxApplet *FindApplet(const wxString& className);
|
||||||
|
|
||||||
|
// Remove an applet from the window. Called during applet destruction
|
||||||
|
bool RemoveApplet(const wxApplet *applet);
|
||||||
|
|
||||||
|
// Load a new URL page
|
||||||
|
bool LoadPage(const wxString& hRef);
|
||||||
|
|
||||||
|
// Called when users clicked on hypertext link.
|
||||||
|
void OnLinkClicked(const wxHtmlLinkInfo& link);
|
||||||
|
|
||||||
|
// Handles forward navigation within the HTML stack
|
||||||
|
bool HistoryForward();
|
||||||
|
|
||||||
|
// Handles backwards navigation within the HTML stack
|
||||||
|
bool HistoryBack();
|
||||||
|
|
||||||
|
// Broadcast a message to all applets on the page
|
||||||
|
void SendMessage(wxEvent& msg);
|
||||||
|
|
||||||
|
// Register a cookie of data in the applet manager
|
||||||
|
bool RegisterCookie(const wxString& name,wxObject *cookie);
|
||||||
|
|
||||||
|
// UnRegister a cookie of data in the applet manager
|
||||||
|
bool UnRegisterCookie(const wxString& name);
|
||||||
|
|
||||||
|
// Find a cookie of data given it's public name
|
||||||
|
wxObject *FindCookie(const wxString& name);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __WX_APPLET_WINDOW_H
|
||||||
|
|
||||||
10
samples/applet/about.html
Normal file
10
samples/applet/about.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>Scitech Display Doctor</title></head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<BODY BGCOLOR="#FFFFFF" >
|
||||||
|
<center><IMG SRC="biglogo.bmp"></center>
|
||||||
|
<hr>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
155
samples/applet/applet.cpp
Normal file
155
samples/applet/applet.cpp
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows licence; you
|
||||||
|
* may not use this file except in compliance with the License. You may
|
||||||
|
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Main wxApplet sample program
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
#include "wx/applet/window.h"
|
||||||
|
#include "applet.h"
|
||||||
|
|
||||||
|
/*---------------------------- Global variables ---------------------------*/
|
||||||
|
|
||||||
|
// Define the event tables for handling application frame events
|
||||||
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
||||||
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
|
// the application object during program execution (it's better than using a
|
||||||
|
// static object for many reasons) and also declares the accessor function
|
||||||
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
||||||
|
// not wxApp)
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
/*------------------------- Implementation --------------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
title - Title for the frame window
|
||||||
|
pos - Position to place to frame window
|
||||||
|
size - Size of the frame window
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
Application frame window constructor
|
||||||
|
****************************************************************************/
|
||||||
|
MyFrame::MyFrame(
|
||||||
|
const wxString& title,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size)
|
||||||
|
: wxFrame(NULL, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
// Create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
wxMenu *menuNav = new wxMenu;
|
||||||
|
menuFile->Append(Minimal_Quit, "E&xit");
|
||||||
|
menuNav->Append(Minimal_Back, "Go &back");
|
||||||
|
menuNav->Append(Minimal_Forward, "Go &forward");
|
||||||
|
|
||||||
|
// Now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
menuBar->Append(menuNav, "&Navigate");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
CreateStatusBar(2);
|
||||||
|
|
||||||
|
// Create the HTML window
|
||||||
|
html = new wxHtmlAppletWindow(this);
|
||||||
|
html->SetRelatedFrame(this, "wxApplet Demo: '%s'");
|
||||||
|
html->SetRelatedStatusBar(1);
|
||||||
|
html->LoadPage("index.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Event handler for the 'Exit' menu item
|
||||||
|
****************************************************************************/
|
||||||
|
void MyFrame::OnQuit(
|
||||||
|
wxCommandEvent&)
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Event handler for the 'About' menu item
|
||||||
|
****************************************************************************/
|
||||||
|
void MyFrame::OnAbout(
|
||||||
|
wxCommandEvent&)
|
||||||
|
{
|
||||||
|
// TODO: Bring up and about html page!
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Event handler for the 'Go back' menu item
|
||||||
|
****************************************************************************/
|
||||||
|
void MyFrame::OnBack(
|
||||||
|
wxCommandEvent&)
|
||||||
|
{
|
||||||
|
if (!html -> HistoryBack())
|
||||||
|
wxMessageBox("You reached prehistory era!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Event handler for the 'Go forward' menu item
|
||||||
|
****************************************************************************/
|
||||||
|
void MyFrame::OnForward(
|
||||||
|
wxCommandEvent&)
|
||||||
|
{
|
||||||
|
if (!html -> HistoryForward())
|
||||||
|
wxMessageBox("No more items in history!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
`Main program' equivalent: the program execution "starts" here
|
||||||
|
****************************************************************************/
|
||||||
|
bool MyApp::OnInit()
|
||||||
|
{
|
||||||
|
// Create the main application window
|
||||||
|
MyFrame *frame = new MyFrame("wxApplet testing application",
|
||||||
|
wxPoint(50, 50), wxSize(640, 480));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
frame->Show(TRUE);
|
||||||
|
SetTopWindow(frame);
|
||||||
|
|
||||||
|
// Success: wxApp::OnRun() will be called to run the application
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
78
samples/applet/applet.h
Normal file
78
samples/applet/applet.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows licence; you
|
||||||
|
* may not use this file except in compliance with the License. You may
|
||||||
|
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Main wxApplet sample program header file
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __SAMPLE_H
|
||||||
|
|
||||||
|
/*------------------------------ Constants --------------------------------*/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
// Menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Back,
|
||||||
|
Minimal_Forward,
|
||||||
|
|
||||||
|
// Controls start here (the numbers are, of course, arbitrary)
|
||||||
|
Minimal_Text = 1000,
|
||||||
|
};
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Define a new application type, each program should derive a class from wxApp
|
||||||
|
****************************************************************************/
|
||||||
|
class MyApp : public wxApp {
|
||||||
|
public:
|
||||||
|
// Initialise the application on startup
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Define a new frame type: this is going to be our main frame
|
||||||
|
****************************************************************************/
|
||||||
|
class MyFrame : public wxFrame {
|
||||||
|
private:
|
||||||
|
DECLARE_EVENT_TABLE() // Declare event table
|
||||||
|
wxHtmlAppletWindow *html; // Pointer to the html applet window
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
|
// Event handlers
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
void OnBack(wxCommandEvent& event);
|
||||||
|
void OnForward(wxCommandEvent& event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __SAMPLE_H
|
||||||
|
|
||||||
2
samples/applet/applet.rc
Normal file
2
samples/applet/applet.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
||||||
172
samples/applet/combobox.cpp
Normal file
172
samples/applet/combobox.cpp
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows licence; you
|
||||||
|
* may not use this file except in compliance with the License. You may
|
||||||
|
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Combobox wrapper. This file implements the custom
|
||||||
|
* combo boxes used for this sample program.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
#include "combobox.h"
|
||||||
|
|
||||||
|
/*------------------------- Implementation --------------------------------*/
|
||||||
|
|
||||||
|
ComboBox::ComboBox(
|
||||||
|
wxWindow *parent,
|
||||||
|
int listid,
|
||||||
|
int textid)
|
||||||
|
: m_Parent(parent), m_ListBoxId(listid), m_TextCtrlId(textid)
|
||||||
|
{
|
||||||
|
m_ListBox = wxDynamicCast(m_Parent->FindWindow(listid),wxListBox);
|
||||||
|
m_TextCtrl = wxDynamicCast(m_Parent->FindWindow(textid),wxTextCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ComboBox::GetListBoxId()
|
||||||
|
{
|
||||||
|
return m_ListBoxId;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ComboBox::GetSelection()
|
||||||
|
{
|
||||||
|
return m_ListBox->GetSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString ComboBox::GetStringSelection()
|
||||||
|
{
|
||||||
|
return m_ListBox->GetStringSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ComboBox::SetStringSelection(const wxString& s, bool select)
|
||||||
|
{
|
||||||
|
select = TRUE;
|
||||||
|
select = m_ListBox->SetStringSelection(s, select);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
return select;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Select(int n)
|
||||||
|
{
|
||||||
|
m_ListBox->Select(n);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Deselect(int n)
|
||||||
|
{
|
||||||
|
m_ListBox->Deselect(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Insert(const wxString& item, int pos)
|
||||||
|
{
|
||||||
|
m_ListBox->Insert(item,pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Insert(const wxString& item, int pos, void *clientData)
|
||||||
|
{
|
||||||
|
m_ListBox->Insert(item, pos, clientData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Insert(const wxString& item, int pos, wxClientData *clientData)
|
||||||
|
{
|
||||||
|
m_ListBox->Insert(item, pos, clientData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::InsertItems(int nItems, const wxString *items, int pos)
|
||||||
|
{
|
||||||
|
m_ListBox->InsertItems(nItems, items, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::InsertItems(const wxArrayString& items, int pos)
|
||||||
|
{
|
||||||
|
m_ListBox->InsertItems(items, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Set(int n, const wxString* items, void **clientData)
|
||||||
|
{
|
||||||
|
m_ListBox->Set(n, items, clientData);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Set(const wxArrayString& items, void **clientData)
|
||||||
|
{
|
||||||
|
m_ListBox->Set(items, clientData);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
int ComboBox::FindString(const wxString &s)
|
||||||
|
{
|
||||||
|
return (m_ListBox->FindString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::SetFirstItem(int n)
|
||||||
|
{
|
||||||
|
m_ListBox->SetFirstItem(n);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::SetFirstItem(const wxString &s)
|
||||||
|
{
|
||||||
|
m_ListBox->SetFirstItem(s);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Append(const wxString &item)
|
||||||
|
{
|
||||||
|
m_ListBox->Append(item);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Append(const wxString& item, void *clientData)
|
||||||
|
{
|
||||||
|
m_ListBox->Append(item, clientData);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Append(const wxString& item, wxClientData *clientData)
|
||||||
|
{
|
||||||
|
m_ListBox->Append(item, clientData);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Clear()
|
||||||
|
{
|
||||||
|
m_ListBox->Clear();
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::Delete(int n)
|
||||||
|
{
|
||||||
|
m_ListBox->Delete(n);
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComboBox::OnChange(wxCommandEvent &)
|
||||||
|
{
|
||||||
|
m_TextCtrl->SetValue(GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
98
samples/applet/combobox.h
Normal file
98
samples/applet/combobox.h
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the wxWindows licence; you
|
||||||
|
* may not use this file except in compliance with the License. You may
|
||||||
|
* obtain a copy of the License at http://www.wxwindows.org/licence.htm
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an
|
||||||
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
* implied. See the License for the specific language governing
|
||||||
|
* rights and limitations under the License.
|
||||||
|
*
|
||||||
|
* The Original Code is Copyright (C) 2001 SciTech Software, Inc.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is SciTech Software, Inc.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* ========================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Combobox wrapper. This header file defines the custom
|
||||||
|
* combo boxes used for this sample program.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __COMBOBOX_H
|
||||||
|
#define __COMBOBOX_H
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Defines a Custom ComboBox. This combobox is a portable implementation of
|
||||||
|
the msw combobox control. It is made of the wxWindows textctrl primitive and
|
||||||
|
the listbox primitive. This object does not create or display the controls,
|
||||||
|
it provides the relationship and underlying behavior layer for the primitives
|
||||||
|
allready created via wxDesigner.
|
||||||
|
****************************************************************************/
|
||||||
|
class ComboBox {
|
||||||
|
private:
|
||||||
|
int m_ListBoxId;
|
||||||
|
int m_TextCtrlId;
|
||||||
|
wxWindow *m_Parent;
|
||||||
|
wxListBox *m_ListBox;
|
||||||
|
wxTextCtrl *m_TextCtrl;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor
|
||||||
|
ComboBox(wxWindow *parent, int,int);
|
||||||
|
|
||||||
|
// Returns the id of the listbox: listBoxId.
|
||||||
|
int GetListBoxId();
|
||||||
|
|
||||||
|
// Inserts: Used to insert items into the listbox
|
||||||
|
void Insert(const wxString& item, int pos);
|
||||||
|
void Insert(const wxString& item, int pos, void *clientData);
|
||||||
|
void Insert(const wxString& item, int pos, wxClientData *clientData);
|
||||||
|
void InsertItems(int nItems, const wxString *items, int pos);
|
||||||
|
void InsertItems(const wxArrayString& items, int pos);
|
||||||
|
|
||||||
|
// Sets: Used to set items in the combo box
|
||||||
|
void Set(int n, const wxString* items, void **clientData );
|
||||||
|
void Set(const wxArrayString& items, void **clientData);
|
||||||
|
int FindString(const wxString &s);
|
||||||
|
|
||||||
|
// Selections: Used to get/de/select items in the listbox
|
||||||
|
void Select(int n);
|
||||||
|
void Deselect(int n);
|
||||||
|
int GetSelection();
|
||||||
|
wxString GetStringSelection();
|
||||||
|
bool SetStringSelection(const wxString& s, bool select);
|
||||||
|
|
||||||
|
// Set the specified item at the first visible item or scroll to max
|
||||||
|
// range.
|
||||||
|
void SetFirstItem(int n);
|
||||||
|
void SetFirstItem(const wxString& s);
|
||||||
|
|
||||||
|
// Append items to the listbox
|
||||||
|
void Append(const wxString& item);
|
||||||
|
void Append(const wxString& item, void *clientData);
|
||||||
|
void Append(const wxString& item, wxClientData *clientData);
|
||||||
|
|
||||||
|
// Deleting items from the list box
|
||||||
|
void Clear();
|
||||||
|
void Delete(int n);
|
||||||
|
|
||||||
|
// OnChange event function (called from SDD dialog box code, see: dialog.h) Mimic
|
||||||
|
// msw combobox behavior: Click on listbox item it shows in textbox.
|
||||||
|
void OnChange(wxCommandEvent &event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __COMBOBOX_H
|
||||||
|
|
||||||
BIN
samples/applet/dialogs.wdr
Normal file
BIN
samples/applet/dialogs.wdr
Normal file
Binary file not shown.
106
samples/applet/dialogs_wdr.cpp
Normal file
106
samples/applet/dialogs_wdr.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Source code generated by wxDesigner from file: dialogs.wdr
|
||||||
|
// Do not modify this file, all changes will be lost!
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "dialogs_wdr.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Include private header
|
||||||
|
#include "dialogs_wdr.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Implement window functions
|
||||||
|
|
||||||
|
wxSizer *MonitorDialogFunc( wxPanel *parent, bool call_fit, bool set_sizer )
|
||||||
|
{
|
||||||
|
wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
|
||||||
|
|
||||||
|
wxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxStaticText *item3 = new wxStaticText( parent, ID_TEXT_MANUFACTURER, "Manufacturer:", wxDefaultPosition, wxSize(180,-1), 0 );
|
||||||
|
item3->SetForegroundColour( *wxBLACK );
|
||||||
|
item3->SetBackgroundColour( *wxWHITE );
|
||||||
|
item2->Add( item3, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item2->Add( 10, 20, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
|
wxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxStaticText *item5 = new wxStaticText( parent, ID_TEXT_MODEL, "Model:", wxDefaultPosition, wxSize(250,-1), 0 );
|
||||||
|
item5->SetForegroundColour( *wxBLACK );
|
||||||
|
item5->SetBackgroundColour( *wxWHITE );
|
||||||
|
item4->Add( item5, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item1->Add( item4, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
|
wxSizer *item6 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxTextCtrl *item7 = new wxTextCtrl( parent, ID_TEXTCTRL_MFTR, "", wxDefaultPosition, wxSize(190,-1), wxTE_READONLY );
|
||||||
|
item7->SetForegroundColour( *wxBLACK );
|
||||||
|
item7->SetBackgroundColour( *wxWHITE );
|
||||||
|
item6->Add( item7, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item6->Add( 15, 20, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item1->Add( item6, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
wxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxTextCtrl *item9 = new wxTextCtrl( parent, ID_TEXTCTRL_MDL, "", wxDefaultPosition, wxSize(260,-1), wxTE_READONLY );
|
||||||
|
item8->Add( item9, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item1->Add( item8, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
wxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxString *strs11 = (wxString*) NULL;
|
||||||
|
wxListBox *item11 = new wxListBox( parent, ID_LISTBOX_MFTR, wxDefaultPosition, wxSize(190,150), 0, strs11, wxLB_SORT|wxLB_ALWAYS_SB );
|
||||||
|
item10->Add( item11, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item10->Add( 15, 20, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item1->Add( item10, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
wxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxString *strs13 = (wxString*) NULL;
|
||||||
|
wxListBox *item13 = new wxListBox( parent, ID_LISTBOX_MDL, wxDefaultPosition, wxSize(260,150), 0, strs13, wxLB_SORT|wxLB_NEEDED_SB );
|
||||||
|
item13->SetForegroundColour( *wxBLACK );
|
||||||
|
item13->SetBackgroundColour( *wxWHITE );
|
||||||
|
item12->Add( item13, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item1->Add( item12, 0, wxALIGN_CENTRE, 5 );
|
||||||
|
|
||||||
|
item0->Add( item1, 0, wxALIGN_CENTRE, 15 );
|
||||||
|
|
||||||
|
if (set_sizer)
|
||||||
|
{
|
||||||
|
parent->SetAutoLayout( TRUE );
|
||||||
|
parent->SetSizer( item0 );
|
||||||
|
if (call_fit)
|
||||||
|
{
|
||||||
|
item0->Fit( parent );
|
||||||
|
item0->SetSizeHints( parent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implement bitmap functions
|
||||||
|
|
||||||
|
|
||||||
|
// End of generated file
|
||||||
42
samples/applet/dialogs_wdr.h
Normal file
42
samples/applet/dialogs_wdr.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Header generated by wxDesigner from file: dialogs.wdr
|
||||||
|
// Do not modify this file, all changes will be lost!
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef __WDR_dialogs_H__
|
||||||
|
#define __WDR_dialogs_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface "dialogs_wdr.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Include wxWindows' headers
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/image.h>
|
||||||
|
#include <wx/statline.h>
|
||||||
|
#include <wx/spinbutt.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
#include <wx/splitter.h>
|
||||||
|
#include <wx/listctrl.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
|
||||||
|
// Declare window functions
|
||||||
|
|
||||||
|
#define ID_TEXT_MANUFACTURER 10000
|
||||||
|
#define ID_TEXT_MODEL 10001
|
||||||
|
#define ID_TEXTCTRL_MFTR 10
|
||||||
|
#define ID_TEXTCTRL_MDL 20
|
||||||
|
#define ID_LISTBOX_MFTR 11
|
||||||
|
#define ID_LISTBOX_MDL 21
|
||||||
|
wxSizer *MonitorDialogFunc( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );
|
||||||
|
|
||||||
|
// Declare bitmap functions
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// End of generated file
|
||||||
20
samples/applet/index.html
Normal file
20
samples/applet/index.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>Widgets demo</title></head>
|
||||||
|
<body>
|
||||||
|
<h3>wxHtmlWidgetCell demonstration</h3>
|
||||||
|
|
||||||
|
There is binded window somewhere around. Enjoy it.
|
||||||
|
|
||||||
|
<A HREF="about.html">About...</A>
|
||||||
|
|
||||||
|
<insert "wxChipsetName">
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<center>
|
||||||
|
<embed applet="MonitorApplet" width=100 height=100>
|
||||||
|
</center>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
221
samples/applet/monitorapplet.cpp
Normal file
221
samples/applet/monitorapplet.cpp
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ======================================================================
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* | |
|
||||||
|
* |This copyrighted computer code is a proprietary trade secret of |
|
||||||
|
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
||||||
|
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
||||||
|
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
||||||
|
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
||||||
|
* |written authorization from SciTech to possess or use this code, you |
|
||||||
|
* |may be subject to civil and/or criminal penalties. |
|
||||||
|
* | |
|
||||||
|
* |If you received this code in error or you would like to report |
|
||||||
|
* |improper use, please immediately contact SciTech Software, Inc. at |
|
||||||
|
* |530-894-8400. |
|
||||||
|
* | |
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* ======================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Main wxApplet class implementation
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
// Include private headers
|
||||||
|
#include "monitorapplet.h"
|
||||||
|
|
||||||
|
/*---------------------------- Global variables ---------------------------*/
|
||||||
|
|
||||||
|
// Implement the dynamic class so it can be constructed dynamically
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(MonitorApplet, wxApplet);
|
||||||
|
|
||||||
|
// Event handler table.
|
||||||
|
BEGIN_EVENT_TABLE(MonitorApplet, wxApplet)
|
||||||
|
EVT_LISTBOX(ID_LISTBOX_MFTR, MonitorApplet::OnChange)
|
||||||
|
EVT_LISTBOX(ID_LISTBOX_MDL, MonitorApplet::OnChange)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Include database of known monitors. Normally this would come from a
|
||||||
|
// real database on disk, but for this simple example we hard code all
|
||||||
|
// the values into a table.
|
||||||
|
#include "monitors.c"
|
||||||
|
|
||||||
|
/*------------------------- Implementation --------------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Constructor called during dynamic creation. Simple initialise all
|
||||||
|
internal values for the class so that it can be properly created later
|
||||||
|
via the virtual Create member function.
|
||||||
|
****************************************************************************/
|
||||||
|
MonitorApplet::MonitorApplet()
|
||||||
|
{
|
||||||
|
m_Mfr = NULL;
|
||||||
|
m_Model = NULL;
|
||||||
|
m_Data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Psuedo virtual constructor for the MonitorApplet class.
|
||||||
|
****************************************************************************/
|
||||||
|
bool MonitorApplet::Create(
|
||||||
|
wxHtmlAppletWindow *parent,
|
||||||
|
const wxSize& size,
|
||||||
|
long style)
|
||||||
|
{
|
||||||
|
bool ret = wxApplet::Create(parent, size, style);
|
||||||
|
if (ret) {
|
||||||
|
// Read our cookie or create it if it does not exist
|
||||||
|
if ((m_Data = (MonitorData*)parent->FindCookie(MONITOR_COOKIE_NAME)) == NULL) {
|
||||||
|
m_Data = new MonitorData;
|
||||||
|
memset(&m_Data->m_Monitor,0,sizeof(m_Data->m_Monitor));
|
||||||
|
parent->RegisterCookie(MONITOR_COOKIE_NAME,m_Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create all the controls and initialise them
|
||||||
|
MonitorDialogFunc(this,true,true);
|
||||||
|
if ((m_Mfr = new ComboBox(this , ID_LISTBOX_MFTR, ID_TEXTCTRL_MFTR)) == NULL)
|
||||||
|
return false;
|
||||||
|
if ((m_Model = new ComboBox(this , ID_LISTBOX_MDL, ID_TEXTCTRL_MDL)) == NULL)
|
||||||
|
return false;
|
||||||
|
ReadMfrList();
|
||||||
|
ReadModelList(true);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Destructor for the MonitorApplet class.
|
||||||
|
****************************************************************************/
|
||||||
|
MonitorApplet::~MonitorApplet()
|
||||||
|
{
|
||||||
|
delete m_Mfr;
|
||||||
|
delete m_Model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Save the current state for the applet to our cookie
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::SaveCurrentState()
|
||||||
|
{
|
||||||
|
// Read currently selected strings into cookie
|
||||||
|
strcpy(m_Data->m_Monitor.m_Mfr,m_Mfr->GetStringSelection());
|
||||||
|
strcpy(m_Data->m_Monitor.m_Model,m_Model->GetStringSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Handles user navigation away from the applet via an HTML link
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::OnLinkClicked(
|
||||||
|
const wxHtmlLinkInfo&)
|
||||||
|
{
|
||||||
|
SaveCurrentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Handles user navigation away from the applet via the history forward command
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::OnHistoryForward()
|
||||||
|
{
|
||||||
|
SaveCurrentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Handles user navigation away from the applet via the history back command
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::OnHistoryBack()
|
||||||
|
{
|
||||||
|
SaveCurrentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Handles inter applet communication messages
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::OnMessage(
|
||||||
|
wxEvent& msg)
|
||||||
|
{
|
||||||
|
msg.Skip(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::OnChange(
|
||||||
|
wxCommandEvent &evt)
|
||||||
|
{
|
||||||
|
if (evt.GetId() == m_Mfr->GetListBoxId()) {
|
||||||
|
m_Mfr->OnChange(evt);
|
||||||
|
ReadModelList(true);
|
||||||
|
}
|
||||||
|
else if (evt.GetId() == m_Model->GetListBoxId()) {
|
||||||
|
m_Model->OnChange(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Updates the manufacturer list for the dialog box from the database.
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::ReadMfrList()
|
||||||
|
{
|
||||||
|
char buf[80] = "";
|
||||||
|
int i,selected = 0;
|
||||||
|
MonitorEntry *m;
|
||||||
|
|
||||||
|
m_Mfr->Clear();
|
||||||
|
for (m = m_Monitors,i = 0; m->m_Mfr[0] != 0; m++) {
|
||||||
|
if (stricmp(buf,m->m_Mfr) != 0) {
|
||||||
|
m_Mfr->Append(m->m_Mfr);
|
||||||
|
if (stricmp(m_Data->m_Monitor.m_Mfr,m->m_Mfr) == 0)
|
||||||
|
selected = i;
|
||||||
|
strcpy(buf,m->m_Mfr);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_Mfr->Select(selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Updates the model list for the dialog box for the currently selected
|
||||||
|
manufacturer type.
|
||||||
|
****************************************************************************/
|
||||||
|
void MonitorApplet::ReadModelList(
|
||||||
|
bool selectCurrent)
|
||||||
|
{
|
||||||
|
int i,selected = 0;
|
||||||
|
MonitorEntry *m;
|
||||||
|
wxString mfrStr;
|
||||||
|
|
||||||
|
mfrStr = m_Mfr->GetStringSelection();
|
||||||
|
m_Model->Clear();
|
||||||
|
for (m = m_Monitors,i = 0; m->m_Mfr[0] != 0; m++) {
|
||||||
|
if (stricmp(mfrStr,m->m_Mfr) == 0) {
|
||||||
|
m_Model->Append(m->m_Model);
|
||||||
|
if (selectCurrent && stricmp(m_Data->m_Monitor.m_Model,m->m_Model) == 0)
|
||||||
|
selected = i;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_Model->Select(selected);
|
||||||
|
}
|
||||||
|
|
||||||
114
samples/applet/monitorapplet.h
Normal file
114
samples/applet/monitorapplet.h
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ======================================================================
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* | |
|
||||||
|
* |This copyrighted computer code is a proprietary trade secret of |
|
||||||
|
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
||||||
|
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
||||||
|
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
||||||
|
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
||||||
|
* |written authorization from SciTech to possess or use this code, you |
|
||||||
|
* |may be subject to civil and/or criminal penalties. |
|
||||||
|
* | |
|
||||||
|
* |If you received this code in error or you would like to report |
|
||||||
|
* |improper use, please immediately contact SciTech Software, Inc. at |
|
||||||
|
* |530-894-8400. |
|
||||||
|
* | |
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* ======================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Header file for the MonitorApplet class
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __WX_MONITORAPPLET_H
|
||||||
|
#define __WX_MONITORAPPLET_H
|
||||||
|
|
||||||
|
#include "wx/applet/applet.h"
|
||||||
|
#include "combobox.h"
|
||||||
|
#include "dialogs_wdr.h"
|
||||||
|
|
||||||
|
/*--------------------------- Class Definitions ---------------------------*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Structure defining the simple monitor database records.
|
||||||
|
****************************************************************************/
|
||||||
|
struct MonitorEntry {
|
||||||
|
char m_Mfr[60];
|
||||||
|
char m_Model[60];
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Defines our wxMonitorData cookie object that is stored to maintain state
|
||||||
|
information for this MonitorApplet.
|
||||||
|
****************************************************************************/
|
||||||
|
class MonitorData : public wxObject {
|
||||||
|
public:
|
||||||
|
MonitorEntry m_Monitor;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Name used to track the monitor data cookie
|
||||||
|
#define MONITOR_COOKIE_NAME "MonitorData"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Defines our wxMonitor applet class
|
||||||
|
****************************************************************************/
|
||||||
|
class MonitorApplet : public wxApplet {
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(MonitorApplet);
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ComboBox *m_Mfr;
|
||||||
|
ComboBox *m_Model;
|
||||||
|
MonitorData *m_Data;
|
||||||
|
static MonitorEntry m_Monitors[];
|
||||||
|
|
||||||
|
// Flush the current state to a cookie
|
||||||
|
void SaveCurrentState();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructor (called during dynamic creation)
|
||||||
|
MonitorApplet();
|
||||||
|
|
||||||
|
// Psuedo virtual constructor
|
||||||
|
virtual bool Create(
|
||||||
|
wxHtmlAppletWindow *parent,
|
||||||
|
const wxSize& size,
|
||||||
|
long style);
|
||||||
|
|
||||||
|
// Virtual destructor
|
||||||
|
virtual ~MonitorApplet();
|
||||||
|
|
||||||
|
// Handle HTML navigation to a new URL
|
||||||
|
virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
|
||||||
|
|
||||||
|
// Handle HTML navigation forward command in applet
|
||||||
|
virtual void OnHistoryForward();
|
||||||
|
|
||||||
|
// Handle HTML navigation back command in applet
|
||||||
|
virtual void OnHistoryBack();
|
||||||
|
|
||||||
|
// Handle messages from the wxAppletManager and other applets
|
||||||
|
virtual void OnMessage(wxEvent& msg);
|
||||||
|
|
||||||
|
// Update the model and menufacturer lists
|
||||||
|
void ReadMfrList();
|
||||||
|
void ReadModelList(bool selectCurrent);
|
||||||
|
|
||||||
|
// Event handlers
|
||||||
|
void OnChange(wxCommandEvent &event);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __WX_MONITORAPPLET_H
|
||||||
|
|
||||||
3572
samples/applet/monitors.c
Normal file
3572
samples/applet/monitors.c
Normal file
File diff suppressed because it is too large
Load Diff
86
src/applet/applet.cpp
Normal file
86
src/applet/applet.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ======================================================================
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* | |
|
||||||
|
* |This copyrighted computer code is a proprietary trade secret of |
|
||||||
|
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
||||||
|
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
||||||
|
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
||||||
|
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
||||||
|
* |written authorization from SciTech to possess or use this code, you |
|
||||||
|
* |may be subject to civil and/or criminal penalties. |
|
||||||
|
* | |
|
||||||
|
* |If you received this code in error or you would like to report |
|
||||||
|
* |improper use, please immediately contact SciTech Software, Inc. at |
|
||||||
|
* |530-894-8400. |
|
||||||
|
* | |
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* ======================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Main wxApplet class implementation
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
// Include private headers
|
||||||
|
#include "wx/applet/applet.h"
|
||||||
|
|
||||||
|
/*------------------------- Implementation --------------------------------*/
|
||||||
|
|
||||||
|
// Empty event handler. We include this event handler simply so that
|
||||||
|
// sub-classes of wxApplet can reference wxApplet in the event tables
|
||||||
|
// that they create as necessary.
|
||||||
|
BEGIN_EVENT_TABLE(wxApplet, wxPanel)
|
||||||
|
EVT_ERASE_BACKGROUND(wxApplet::OnEraseBackground)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Implement the abstract class functions
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxApplet, wxPanel);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Psuedo virtual constructor for the wxApplet class.
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxApplet::Create(
|
||||||
|
wxHtmlAppletWindow *parent,
|
||||||
|
const wxSize& size,
|
||||||
|
long style)
|
||||||
|
{
|
||||||
|
bool ret = wxPanel::Create(parent, -1, wxDefaultPosition, size, style);
|
||||||
|
if (ret) {
|
||||||
|
m_Parent = parent;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Destructor for the wxApplet class.
|
||||||
|
****************************************************************************/
|
||||||
|
wxApplet::~wxApplet()
|
||||||
|
{
|
||||||
|
m_Parent->RemoveApplet(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Special handler for background erase messages. We do nothing in here which
|
||||||
|
causes the background to not be erased which is exactly what we want. All
|
||||||
|
the wxApplet classes display over an HTML window, so we want the HTML
|
||||||
|
background to show through.
|
||||||
|
****************************************************************************/
|
||||||
|
void wxApplet::OnEraseBackground(wxEraseEvent&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
371
src/applet/appletwindow.cpp
Normal file
371
src/applet/appletwindow.cpp
Normal file
@@ -0,0 +1,371 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* wxWindows HTML Applet Package
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* ======================================================================
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* | |
|
||||||
|
* |This copyrighted computer code is a proprietary trade secret of |
|
||||||
|
* |SciTech Software, Inc., located at 505 Wall Street, Chico, CA 95928 |
|
||||||
|
* |USA (www.scitechsoft.com). ANY UNAUTHORIZED POSSESSION, USE, |
|
||||||
|
* |VIEWING, COPYING, MODIFICATION OR DISSEMINATION OF THIS CODE IS |
|
||||||
|
* |STRICTLY PROHIBITED BY LAW. Unless you have current, express |
|
||||||
|
* |written authorization from SciTech to possess or use this code, you |
|
||||||
|
* |may be subject to civil and/or criminal penalties. |
|
||||||
|
* | |
|
||||||
|
* |If you received this code in error or you would like to report |
|
||||||
|
* |improper use, please immediately contact SciTech Software, Inc. at |
|
||||||
|
* |530-894-8400. |
|
||||||
|
* | |
|
||||||
|
* |REMOVAL OR MODIFICATION OF THIS HEADER IS STRICTLY PROHIBITED BY LAW|
|
||||||
|
* ======================================================================
|
||||||
|
*
|
||||||
|
* Language: ANSI C++
|
||||||
|
* Environment: Any
|
||||||
|
*
|
||||||
|
* Description: Main wxHtmlAppletWindow class implementation
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
// For compilers that support precompilation
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
// Include private headers
|
||||||
|
#include "wx/applet/applet.h"
|
||||||
|
|
||||||
|
/*------------------------- Implementation --------------------------------*/
|
||||||
|
|
||||||
|
// Empty event handler. We include this event handler simply so that
|
||||||
|
// sub-classes of wxApplet can reference wxApplet in the event tables
|
||||||
|
// that they create as necessary.
|
||||||
|
BEGIN_EVENT_TABLE(wxHtmlAppletWindow, wxHtmlWindow)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Implement the class functions for wxHtmlAppletWindow
|
||||||
|
IMPLEMENT_CLASS(wxHtmlAppletWindow, wxHtmlWindow);
|
||||||
|
|
||||||
|
// Define the wxAppletList implementation
|
||||||
|
#include "wx/listimpl.cpp"
|
||||||
|
WX_DEFINE_LIST(wxAppletList);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Constructor for the applet window class.
|
||||||
|
****************************************************************************/
|
||||||
|
wxHtmlAppletWindow::wxHtmlAppletWindow(
|
||||||
|
wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name)
|
||||||
|
: wxHtmlWindow(parent,id,pos,size,style,name)
|
||||||
|
{
|
||||||
|
// Ensure all cookie data is destroyed when window is killed
|
||||||
|
m_Cookies.DeleteContents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Destructor for the applet window class.
|
||||||
|
****************************************************************************/
|
||||||
|
wxHtmlAppletWindow::~wxHtmlAppletWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
className - Name of the applet class to create an object for
|
||||||
|
size - Initial size of the applet to be created
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
Pointer to the wxApplet created, or NULL if unable to create the applet.
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function is used to create new wxApplet objects dynamically based on the
|
||||||
|
class name as a string. This allows instances of wxApplet classes to be
|
||||||
|
created dynamically based on string values embedded in the custom tags of an
|
||||||
|
HTML page.
|
||||||
|
****************************************************************************/
|
||||||
|
wxApplet *wxHtmlAppletWindow::CreateApplet(
|
||||||
|
const wxString& className,
|
||||||
|
const wxSize& size)
|
||||||
|
{
|
||||||
|
// We presently only allow one applet per page of the same class!
|
||||||
|
if (m_AppletList.Find(className))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Dynamically create the class instance at runtime
|
||||||
|
wxClassInfo *info = wxClassInfo::FindClass(className.c_str());
|
||||||
|
if (!info)
|
||||||
|
return NULL;
|
||||||
|
wxObject *obj = info->CreateObject();
|
||||||
|
if (!obj)
|
||||||
|
return NULL;
|
||||||
|
wxApplet *applet = wxDynamicCast(obj,wxApplet);
|
||||||
|
if (!applet)
|
||||||
|
return NULL;
|
||||||
|
if (!applet->Create(this,size)) {
|
||||||
|
delete applet;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
m_AppletList.Append(className,applet);
|
||||||
|
return applet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
appletName - Name of the applet class to find
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
Pointer to the wxApplet found, or NULL if not found.
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
Find an instance of an applet based on it's name
|
||||||
|
****************************************************************************/
|
||||||
|
wxApplet *wxHtmlAppletWindow::FindApplet(
|
||||||
|
const wxString& appletName)
|
||||||
|
{
|
||||||
|
wxAppletList::Node *node = m_AppletList.Find(appletName);
|
||||||
|
if (!node)
|
||||||
|
return NULL;
|
||||||
|
return node->GetData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
applet - Pointer to the applet object to remove from the list
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
True if the applet was found and removed, false if not. The applet itself
|
||||||
|
is *not* destroyed!
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
Remove an applet from the manager. Called during applet destruction
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::RemoveApplet(
|
||||||
|
const wxApplet *applet)
|
||||||
|
{
|
||||||
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) {
|
||||||
|
if (node->GetData() == applet) {
|
||||||
|
m_AppletList.DeleteNode(node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
URL - New URL for the page to load
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
True if page loaded successfully, false if not
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
Remove an applet from the manager. Called during applet destruction
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::LoadPage(
|
||||||
|
const wxString& hRef)
|
||||||
|
{
|
||||||
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
|
||||||
|
(node->GetData())->OnLinkClicked(hRef);
|
||||||
|
return wxHtmlWindow::LoadPage(hRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
URL - String URL that we are navigating to
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
Called when the user navigates to a new URL from the current page. We simply
|
||||||
|
call the LoadPage function above to load the new page and display it.
|
||||||
|
****************************************************************************/
|
||||||
|
void wxHtmlAppletWindow::OnLinkClicked(
|
||||||
|
const wxHtmlLinkInfo& link)
|
||||||
|
{
|
||||||
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
|
||||||
|
(node->GetData())->OnLinkClicked(link);
|
||||||
|
wxHtmlWindow::LoadPage(link.GetHref());
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Called when the user navigates forward within the HTML history stack.
|
||||||
|
We call all the applets in turn allowing them to handle the navigation
|
||||||
|
command prior to being destructed when the current page is destroyed.
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::HistoryForward()
|
||||||
|
{
|
||||||
|
if (!HistoryCanForward())
|
||||||
|
return false;
|
||||||
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
|
||||||
|
(node->GetData())->OnHistoryForward();
|
||||||
|
return wxHtmlWindow::HistoryForward();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Called when the user navigates backwards within the HTML history stack.
|
||||||
|
We call all the applets in turn allowing them to handle the navigation
|
||||||
|
command prior to being destructed when the current page is destroyed.
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::HistoryBack()
|
||||||
|
{
|
||||||
|
if (!HistoryCanBack())
|
||||||
|
return false;
|
||||||
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
|
||||||
|
(node->GetData())->OnHistoryBack();
|
||||||
|
return wxHtmlWindow::HistoryBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
msg - wxEvent message to be sent to all wxApplets
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function is called by the wxApplet's when they need to send a message
|
||||||
|
to all other applets on the current page. This is the primary form of
|
||||||
|
communication between applets on the page if they need to inform each
|
||||||
|
other of internal information.
|
||||||
|
|
||||||
|
Note that the event handling terminates as soon as the first wxApplet
|
||||||
|
handles the event. If the event should be handled by all wxApplet's,
|
||||||
|
the event handlers for the applets should not reset the wxEvent::Skip()
|
||||||
|
value (ie: by default it is true).
|
||||||
|
****************************************************************************/
|
||||||
|
void wxHtmlAppletWindow::SendMessage(
|
||||||
|
wxEvent& msg)
|
||||||
|
{
|
||||||
|
// Preset the skip flag
|
||||||
|
msg.Skip();
|
||||||
|
|
||||||
|
// Process all applets in turn and send them the message
|
||||||
|
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext()) {
|
||||||
|
(node->GetData())->OnMessage(msg);
|
||||||
|
if (!msg.GetSkipped())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
msg - wxEvent message to be sent to all wxApplets
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
True if new cookie was added, false if cookie with same name already exists.
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function is called by the wxApplet's when they need register a cookie
|
||||||
|
of data in the applet window's cookie table. Cookies are arbitrary data
|
||||||
|
objects that are references by unique name's by the wxApplet. These
|
||||||
|
values can be used to store and retrieve data that needs to remain
|
||||||
|
persisent across invocations of the wxApplet. Ie: The first time an
|
||||||
|
applet is created it would use the cookie to store data to maintain
|
||||||
|
it's present state so that if you navigated back to the same page
|
||||||
|
is would be able to re-load the prior state as though the applet
|
||||||
|
was never actually destructed.
|
||||||
|
|
||||||
|
Note: If a cookie with the same name already exists, this function returns
|
||||||
|
false. Hence if you wish to replace a cookie you should first call
|
||||||
|
UnRegisterCookie to ensure the cookie is deleted and then call this
|
||||||
|
function.
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::RegisterCookie(
|
||||||
|
const wxString& name,
|
||||||
|
wxObject *cookie)
|
||||||
|
{
|
||||||
|
// Fail if the named cookie already exists!
|
||||||
|
if (m_Cookies.Get(name))
|
||||||
|
return false;
|
||||||
|
m_Cookies.Put(name,cookie);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
msg - wxEvent message to be sent to all wxApplets
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
True if found and deleted, false if not found in table.
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function is called by the wxApplet's when they need de-register a
|
||||||
|
cookie of data in the applet window's cookie table. The data in the
|
||||||
|
cookie itself is also deleted before it is removed from the table.
|
||||||
|
****************************************************************************/
|
||||||
|
bool wxHtmlAppletWindow::UnRegisterCookie(
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
wxObject *data = m_Cookies.Delete(name);
|
||||||
|
if (data) {
|
||||||
|
delete data;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
PARAMETERS:
|
||||||
|
msg - wxEvent message to be sent to all wxApplets
|
||||||
|
|
||||||
|
RETURNS:
|
||||||
|
Pointer to the cookie data if found, NULL if not found.
|
||||||
|
|
||||||
|
REMARKS:
|
||||||
|
This function is called by the wxApplet's when they need to find a cookie
|
||||||
|
of data given it's public name. If the cookie is not found, NULL is
|
||||||
|
returned.
|
||||||
|
****************************************************************************/
|
||||||
|
wxObject *wxHtmlAppletWindow::FindCookie(
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
return m_Cookies.Get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "wx/html/m_templ.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
REMARKS:
|
||||||
|
Implementation for the <embed> HTML tag handler. This handler takes care
|
||||||
|
of automatically constructing the wxApplet objects of the appropriate
|
||||||
|
class based on the <embed> tag information.
|
||||||
|
****************************************************************************/
|
||||||
|
TAG_HANDLER_BEGIN(Embed, "EMBED")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
wxWindow *wnd;
|
||||||
|
wxHtmlAppletWindow *appletWindow;
|
||||||
|
wxApplet *applet;
|
||||||
|
int width, height;
|
||||||
|
int floatPercent = 0;
|
||||||
|
|
||||||
|
wnd = m_WParser->GetWindow();
|
||||||
|
if ((appletWindow = wxDynamicCast(wnd,wxHtmlAppletWindow)) != NULL) {
|
||||||
|
tag.ScanParam("WIDTH", "%i", &width);
|
||||||
|
tag.ScanParam("HEIGHT", "%i", &height);
|
||||||
|
if (tag.HasParam("FLOAT"))
|
||||||
|
tag.ScanParam("FLOAT", "%i", &floatPercent);
|
||||||
|
if (tag.HasParam("APPLET")) {
|
||||||
|
if ((applet = appletWindow->CreateApplet(tag.GetParam("APPLET"), wxSize(width, height))) != NULL) {
|
||||||
|
applet->Show(true);
|
||||||
|
m_WParser->OpenContainer()->InsertCell(new wxHtmlWidgetCell(applet,floatPercent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tag.HasParam("TEXT")) {
|
||||||
|
// TODO: Somehow get the text returned from this class displayed on the page!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(Embed)
|
||||||
|
|
||||||
|
TAGS_MODULE_BEGIN(Embed)
|
||||||
|
TAGS_MODULE_ADD(Embed)
|
||||||
|
TAGS_MODULE_END(Embed)
|
||||||
|
|
||||||
34
src/applet/makefile
Normal file
34
src/applet/makefile
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (C) 1999 SciTech Software
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Descripton: Generic makefile for the SciTech wxApplet library
|
||||||
|
#
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
# We are building with the Win32 version
|
||||||
|
|
||||||
|
USE_RTTI := 1
|
||||||
|
USE_CPPEXCEPT := 1
|
||||||
|
PRECOMP_HDR := wx/wxprec.h
|
||||||
|
CFLAGS += -D__WIN95__ -D__WXMSW__ -D__WINDOWS__
|
||||||
|
|
||||||
|
# Define the library name and objects
|
||||||
|
|
||||||
|
LIBFILE = wxapplet$L
|
||||||
|
LIBCLEAN = *.il? *.dll *.lib
|
||||||
|
OBJECTS := applet$O appletwindow$O
|
||||||
|
|
||||||
|
# Define the sample program to be compiled
|
||||||
|
|
||||||
|
EXELIBS = wxwin$L png$L jpeg$L tiff$L xpm$L ddstereo$L comctl32$L uuid$L
|
||||||
|
SAMP_OBJECTS = sample$O sample$R monitorapplet$O
|
||||||
|
|
||||||
|
sample$E: $(SAMP_OBJECTS) $(LIBFILE)
|
||||||
|
|
||||||
|
DEPEND_OBJ = $(OBJECTS) $(SAMP_OBJECTS)
|
||||||
|
DEPEND_SRC = sample
|
||||||
|
.SOURCE: sample
|
||||||
|
.INCLUDE: "$(SCITECH)\makedefs\common.mk"
|
||||||
|
|
||||||
Reference in New Issue
Block a user