Mutiple updates from SciTech for wxWindows including the following:

1. Updates to HTML applet classes in client side include syntax
2. Updates to wxUniversal for OS/2
3. Updates for better palette management on Windows
4. Misc other fixes and changes to fix build system for Watcom 11.0


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12045 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kendall Bennett
2001-10-17 22:25:56 +00:00
parent 7361f176df
commit 19193a2c85
62 changed files with 1309 additions and 658 deletions

View File

@@ -41,10 +41,9 @@ wxIncludePrep class Definition
class wxIncludePrep : public wxHtmlProcessor {
private:
//DECLARE_DYNAMIC_CLASS(wxIncludePrep);
wxString DOC_ROOT;
wxFileSystem *m_FS;
public:
wxIncludePrep() : wxHtmlProcessor() {DOC_ROOT = wxString("");}
wxIncludePrep() : wxHtmlProcessor() {}
~wxIncludePrep() {}
// Process input text and return processed result
@@ -54,8 +53,7 @@ public:
// is the processor applied to the text.
int GetPriority() const { return wxHTML_PRIORITY_SYSTEM; }
void ChangeDirectory(const wxString &dir);
wxString GetDirectory() { return DOC_ROOT; }
void ChangeDirectory(wxFileSystem *);
};

View File

@@ -5,23 +5,19 @@
* 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|
* ======================================================================
* ========================================================================
*
* The contents of this file are subject to the wxWindows License
* Version 3.0 (the "License"); 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/licence3.txt
*
* 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.
*
* ========================================================================
*
* Language: ANSI C++
* Environment: Any
@@ -66,6 +62,8 @@ public:
wxString& group,
wxString& href );
VirtualData();
// Gets
wxString GetName(){ return m_name;};
wxString GetGroup(){ return m_group;};
@@ -88,15 +86,21 @@ private:
DECLARE_CLASS(wxHtmlAppletWindow);
DECLARE_EVENT_TABLE();
bool m_mutexLock;
wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
bool m_mutexLock;
wxIncludePrep *incPreprocessor; // deleted by list it is added too in constructor
protected:
wxAppletList m_AppletList;
static wxHashTable m_Cookies;
bool m_NavBarEnabled;
wxToolBarBase *m_NavBar;
int m_NavBackId;
int m_NavForwardId;
wxString m_DocRoot;
wxPalette m_globalPalette;
// Override this so we can do proper palette management!!
virtual void OnDraw(wxDC& dc);
public:
// Constructor
wxHtmlAppletWindow(
@@ -109,7 +113,7 @@ public:
const wxSize& size = wxDefaultSize,
long style = wxHW_SCROLLBAR_AUTO,
const wxString& name = "htmlAppletWindow",
const wxString& docroot = "" );
const wxPalette& globalPalette = wxNullPalette);
// Destructor
~wxHtmlAppletWindow();
@@ -142,6 +146,14 @@ public:
// Handles backwards navigation within the HTML stack
bool HistoryBack();
// Disables Nav bars
void DisableNavBar();
// Enables Nav bars
void EnableNavBar();
void SetNavBar(wxToolBarBase *navBar);
// Broadcast a message to all applets on the page
void SendMessage(wxEvent& msg);

View File

@@ -5,23 +5,19 @@
* 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|
* ======================================================================
* ========================================================================
*
* The contents of this file are subject to the wxWindows License
* Version 3.0 (the "License"); 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/licence3.txt
*
* 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.
*
* ========================================================================
*
* Language: ANSI C++
* Environment: Any
@@ -88,24 +84,27 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
const wxSize& size,
long style,
const wxString& name,
const wxString& docroot )
: wxHtmlWindow(parent,id,pos,size,style,name)
const wxPalette& globalPalette)
: wxHtmlWindow(parent,id,pos,size,style,name), m_globalPalette(globalPalette)
{
// Init our locks
UnLock();
// setup client navbars
if (navBar) {
m_NavBarEnabled = true;
m_NavBar = navBar;
m_NavBackId = navBackId;
m_NavForwardId = navForwardId;
}
else {
m_NavBarEnabled = false;
m_NavBar = NULL;
}
// Set up docroot
m_DocRoot = docroot;
m_NavBackId = navBackId;
m_NavForwardId = navForwardId;
// Set the key_type for applets
m_AppletList = wxAppletList(wxKEY_STRING);
@@ -114,7 +113,7 @@ wxHtmlAppletWindow::wxHtmlAppletWindow(
// deleting preprocessors is done by the code within the window
incPreprocessor = new wxIncludePrep(); // #include preprocessor
incPreprocessor->ChangeDirectory(m_DocRoot);
incPreprocessor->ChangeDirectory(m_FS); // give it access to our filesys object
wxEchoPrep * echoPreprocessor = new wxEchoPrep(); // #echo preprocessor
wxIfElsePrep * ifPreprocessor = new wxIfElsePrep();
@@ -132,6 +131,27 @@ wxHtmlAppletWindow::~wxHtmlAppletWindow()
{
}
#include "scitech.h"
/****************************************************************************
PARAMETERS:
dc - wxDC object to draw on
REMARKS:
This function handles drawing the HTML applet window. Because the standard
wxWindows classes don't properly handle palette management, we add code
in here to properly select the global palette that we use for all drawing
into the DC before we allow the regular wxWindows code to finish the
drawing process.
****************************************************************************/
void wxHtmlAppletWindow::OnDraw(
wxDC& dc)
{
// TODO: Only do this for <= 8bpp modes!
dc.SetPalette(m_globalPalette);
wxHtmlWindow::OnDraw(dc);
}
/****************************************************************************
PARAMETERS:
className - Name of the applet class to create an object for
@@ -263,24 +283,11 @@ True if page loaded successfully, false if not
REMARKS:
Remove an applet from the manager. Called during applet destruction
****************************************************************************/
#include "scitech"
bool wxHtmlAppletWindow::LoadPage(
const wxString& link)
{
wxString href(link);
// TODO: technically we allow no relative paths
// Check to see if it is a real url, if not it is a file
if (link.Mid(0, 5).CmpNoCase("http:") != 0) {
// Check for abs path. If it is not then tack on the path
// supplied at creation.
// TODO: Abs paths are only used in testing (remove this)
if (link.GetChar(1) != ':')
href = m_DocRoot + href;
}
if (link.GetChar(0) == '?'){
wxString cmd = link.BeforeFirst('=');
wxString cmdValue = link.AfterFirst('=');
@@ -329,11 +336,12 @@ bool wxHtmlAppletWindow::LoadPage(
for (wxAppletList::Node *node = m_AppletList.GetFirst(); node; node = node->GetNext())
(node->GetData())->OnLinkClicked(wxHtmlLinkInfo(href));
Show(false);
bool stat = wxHtmlWindow::LoadPage(href);
Show(true);
// Enable/Dis the navbar tools
if (m_NavBar) {
if (m_NavBarEnabled) {
m_NavBar->EnableTool(m_NavForwardId,HistoryCanForward());
m_NavBar->EnableTool(m_NavBackId,HistoryCanBack());
}
@@ -388,6 +396,37 @@ bool wxHtmlAppletWindow::HistoryBack()
return wxHtmlWindow::HistoryBack();
}
/****************************************************************************
REMARKS:
This function is used to disable the navigation bars. If you want to
toggle to the navbars off you must call this function.
****************************************************************************/
void wxHtmlAppletWindow::DisableNavBar()
{
m_NavBarEnabled = false;
}
/****************************************************************************
REMARKS:
This function is used to enable the nav bars. If you toggle the nav bars on
you must call this function.
****************************************************************************/
void wxHtmlAppletWindow::EnableNavBar()
{
m_NavBarEnabled = true;
}
/****************************************************************************
REMARKS:
This function is used to set the nav bar to a new nav bar if you deleted the
one that you were useing. Usally this happens when you toggle a nav bar
on or off.
****************************************************************************/
void wxHtmlAppletWindow::SetNavBar(wxToolBarBase *navBar)
{
m_NavBar = navBar;
}
/****************************************************************************
PARAMETERS:
msg - wxEvent message to be sent to all wxApplets
@@ -570,6 +609,18 @@ VirtualData::VirtualData(
m_href = href;
}
/****************************************************************************
PARAMETERS:
REMARKS:
VirtualData is used to store information on the virtual links.
****************************************************************************/
VirtualData::VirtualData()
{
m_name.Empty();
m_group.Empty();
m_href.Empty();
}
/****************************************************************************
PARAMETERS:
REMARKS:

View File

@@ -115,9 +115,14 @@ wxString wxEchoPrep::Process(
// grab the value from the class, put it in tag since the data is no longer needed
tag = wxEchoVariable::FindValue(cname, parms.c_str());
}
}
// remove ampersands and <> chars
tag.Replace("&", "&amp;");
tag.Replace("<", "&lt;");
tag.Replace(">", "&gt;");
output = (output.Mid(0,i) + tag + output.Mid(i));
}

View File

@@ -49,12 +49,17 @@ do not correctly pass the given return value.
****************************************************************************/
int ReverseFind(
const wxString &tstr,
const wxString &str)
const wxString &str,
int start = -1)
{
wxASSERT( str.GetStringData()->IsValid() );
// TODO could be made much quicker than that
int p = tstr.Len()-str.Len()-1;
int p2 = start-str.Len();
// if the user supplied a valid start point, use it
if (start != -1 && p > p2) p = p2;
while ( p >= 0 ) {
if ( wxStrncmp(tstr.c_str() + p, str.c_str(), str.Len()) == 0 )
return p;
@@ -64,6 +69,131 @@ int ReverseFind(
return -1;
}
/****************************************************************************
PARAMETERS:
str - text of #if statement
RETURNS:
true or false depending on how it evaluated
REMARKS:
SEE ALSO:
wxIfElseVariable
****************************************************************************/
bool ParseIfStatementValue(wxString &str) {
// Find out if the tag has parenthesis
// recursive to parse the text within the parenthesis,
// replacing the text with 1 or 0, (hardcoded true or false)
int b;
while ((b = str.Find('(')) != -1) {
int e;
// Find the matching parenthesis
int nextbeg, nextend;
int parencount = 1, min = b+1;
do {
nextbeg = str.find('(', min);
nextend = str.find(')', min);
if (nextbeg < nextend && nextbeg != wxString::npos) {
parencount++;
min = nextbeg+1;
}
else {
parencount--;
min = nextend+1;
}
if (nextend == wxString::npos) {
#ifdef CHECKED
wxMessageBox("wxHTML #if\\else error: Unmatched parenthesis in #if expression.","Error",wxICON_ERROR);
#endif
return true;
}
// once parencount reaches 0 again we have found our matchin )
} while (parencount > 0);
e = nextend;
// Extract the expression from the parenthesis block and recurse
// to solve it.
wxString tag;
tag = str.Mid(b+1, e-b-1);
bool val = ParseIfStatementValue(tag);
// Add extra spaces just in case of NOT(VAL)
if (val) str = str.Mid(0, b) + " 1" + str.Mid(e+1);
else str = str.Mid(0, b) + " 0" + str.Mid(e+1);
}
// Remove spaces from left and right
str.Trim(false);
str.Trim(true);
// Convert text method of operators "AND" and "OR" to c style
// this makes only one special case necessary for each later on
str.Replace(" AND ", "&&");
str.Replace(" OR ", "||");
// We use ReverseFind so that the whole left expression gets evaluated agains
// the right single item, creating a left -> right evaluation
// Search for || operators, recurse to solve (so we don't have to handle special cases here)
int and, or;
and = ReverseFind(str, "&&");
or = ReverseFind(str, "||");
if ( (and != -1) || (or != -1) ) {
wxString tag1, tag2;
// handle the rightmost first to force left->right evaluation
if (and > or) {
return (
ParseIfStatementValue(tag2 = str.Mid(and+2)) &&
ParseIfStatementValue(tag1 = str.Mid(0, and)) );
}
else {
return (
ParseIfStatementValue(tag2 = str.Mid(or+2)) ||
ParseIfStatementValue(tag1 = str.Mid(0, or)) );
}
}
// By the time we get to this place in the function we are guarenteed to have a single
// variable operation, perhaps with a NOT or ! operator
bool notval = false;
// search for a NOT or ! operator
if (str.Mid(0, 1) == "!") {
str.Remove(0, 1);
str.Trim(false); // trim spaces from left
notval = true;
}
else if (str.Mid(0,4).CmpNoCase("NOT ") == 0) {
str.Remove(0, 4);
str.Trim(false); // trim any extra spaces from left
notval = true;
}
// now all we have left is the name of the class or a hardcoded 0 or 1
if (str == "") {
#ifdef CHECKED
wxMessageBox("wxHTML #if\\else error: Empty expression in #if\\#elif statement.","Error",wxICON_ERROR);
#endif
return true;
}
// check for hardcoded 0 and 1 cases, (these are used by parenthesis catcher)
// this just decomplicates the recursion algorithm
if (str == "0") return notval;
if (str == "1") return !notval;
// Grab the value from the variable class identified by cname
bool value = wxIfElseVariable::FindValue(str);
if (notval) value = !value;
return value;
}
/****************************************************************************
PARAMETERS:
text - HTML to process for if/else blocks
@@ -72,7 +202,7 @@ RETURNS:
The string containing the processed HTML
REMARKS:
This function replaces #if, #else, and #endif directives with the text
This function replaces #if, #else, #elif, and #endif directives with the text
contained within the blocks, dependant on the value of the given boolean
variable. The variable is created by making a sub class of wxIfElseVariable.
Dynamic class construction is used at run time internally to create an instance
@@ -86,19 +216,81 @@ wxString wxIfElsePrep::Process(
{
int b;
char ft[] = "<!--#if ";
char ftnot[] = "<!--#if NOT ";
char ftend[] = "<!--#endif-->";
char ftelse[] = "<!--#else-->";
char ftnot[] = "<!--#if not ";
char ftnot2[] = "<!--#if !";
// make a copy so we can replace text as we go without affecting the original
char ftelif[] = "<!--#elif ";
// make a copy so we can replace text as we go without affecting the original
wxString output = text;
// Avoid duplication of our parsing code by turning any #elif blocks into appropriate
// else/if blocks
while ((b = ReverseFind(output.Lower(), ftelif)) != -1) {
int e;
// Replace beginning of block
e = output.find("-->", b + strlen(ftelif));
if (e == wxString::npos) {
#ifdef CHECKED
wxMessageBox("wxHTML #elif error: Premature end of file while parsing #elif.","Error",wxICON_ERROR);
#endif
break;
}
// Convert to lower case so find is easy, grab everything after #elif tag
wxString remains = (output.Mid(e+strlen("-->"))).Lower();
// find matching else or endif
int nextif, nextendif;
int ifcount = 1, min = 0;
do {
nextif = remains.find(ft, min);
nextendif = remains.find(ftend, min);
if (nextif < nextendif && nextif != wxString::npos) {
ifcount++;
min = nextif+1;
}
else {
ifcount--;
min = nextendif+1;
}
if (nextendif == wxString::npos) {
#ifdef CHECKED
wxMessageBox("wxHTML #elif error: Premature end of file before finding #endif.","Error",wxICON_ERROR);
#endif
break;
}
// once ifcount reaches 0 again we have found our matchin #endif
} while (ifcount > 0);
// If it couldn't be found die gracefully
if (nextendif == wxString::npos) {
// We already displayed a message, just break all the way out
break;
}
int elifsize = e - (b + strlen(ftelif)) + strlen("-->");
// Create the #if/else block, removing the #elif code
output = output.Mid(0, b) +
wxString(wxString(ftelse)+wxString(ft)) +
output.Mid(b+strlen(ftelif), elifsize+nextendif) +
wxString(ftend) +
output.Mid(b+strlen(ftelif)+elifsize+nextendif);
}
// Parse out the if else blocks themselves
while ((b = ReverseFind(output.Lower(), ft)) != -1) {
// Loop until every #if directive is found
// We search from the end of the string so that #if statements will properly recurse
// and we avoid the hassle of matching statements with the correct <!--#endif-->
bool notval = false;
int off = 0;
int end, c, n;
int end;
wxString usecode, code;
wxString cname;
wxString tag;
@@ -106,15 +298,6 @@ wxString wxIfElsePrep::Process(
code = wxString("");
if (output.Mid(b, strlen(ftnot) ).CmpNoCase(ftnot) == 0 ) {
notval = true;
off = 4;
}
else if (output.Mid(b, strlen(ftnot2) ).CmpNoCase(ftnot2) == 0 ) {
notval = true;
off = 1;
}
// grab the tag and get the name of the variable
end = (output.Mid(b)).Find("-->");
if (end == -1) {
@@ -125,30 +308,14 @@ wxString wxIfElsePrep::Process(
}
end += 3;
tag = output.Mid(b, end);
// remove the <!--#if and --> sections from the tag before passing it on to be parsed
tag = output.Mid(b+strlen(ft), end-strlen(ft)-3);
output.Remove(b, end);
c = tag.Find("-->");
n = c;
// find the classname
c = (tag.Mid(8+off, n-(8+off))).Find(" ");
if (c == -1) n -= (8+off);
else n = c;
cname = tag.Mid(8+off, n);
cname.Trim(false);
c = cname.Find("\"");
if (c != -1) cname = cname.Mid(c+1);
c = cname.Find("\"");
if (c != -1) cname = cname.Mid(0, c);
// Grab the value from the variable class identified by cname
value = wxIfElseVariable::FindValue(cname);
if (notval) value = !value;
value = ParseIfStatementValue(tag);
// Find the end of the tag (<!--#endif-->) and copy it all into the variable code
end = ((output.Mid(b)).Lower()).Find("<!--#endif-->");
end = ((output.Mid(b)).Lower()).Find(ftend);
if (end == -1) {
#ifdef CHECKED
wxMessageBox("wxHTML #if error: Premature end of file while searching for matching #endif.","Error",wxICON_ERROR);
@@ -157,14 +324,14 @@ wxString wxIfElsePrep::Process(
}
code = output.Mid(b, end);
output.Remove(b, end+13); // remove the entire #if block from original document
output.Remove(b, end+strlen(ftend)); // remove the entire #if block from original document
// Find out if there is an else statement
end = (code.Lower()).Find("<!--#else-->");
end = (code.Lower()).Find(ftelse);
if (end != -1) {
if (!value) {
// Use the else statement
usecode = code.Mid(end+12);
usecode = code.Mid(end+strlen(ftelse));
}
else {
// Use statement before #else

View File

@@ -59,8 +59,6 @@ wxString wxIncludePrep::Process(
int i;
char ft[] = "<!--#include virtual=";
wxFileSystem *fs = new wxFileSystem;
fs->ChangePathTo(DOC_ROOT, true);
int openedcount = 0;
@@ -92,11 +90,12 @@ wxString wxIncludePrep::Process(
// remove the #include tag
output.Remove(i, n+21+3);
wxFSFile * file = fs->OpenFile(DOC_ROOT + fname);
wxFSFile * file;
file = m_FS->OpenFile(fname);
if (!file) {
#ifdef CHECKED
wxMessageBox(wxString("wxHTML #include error: File not Found ") + DOC_ROOT + fname + wxString("."),"Error",wxICON_ERROR);
wxMessageBox(wxString("wxHTML #include error: File not Found ") + fname + wxString("."),"Error",wxICON_ERROR);
#endif
delete file;
continue;
@@ -125,7 +124,6 @@ wxString wxIncludePrep::Process(
delete file;
}
delete fs;
return output;
}
@@ -138,9 +136,8 @@ This function sets the directory to get included HTML files from. The default
value is the current directory. Directorys may be given as a relative path.
****************************************************************************/
void wxIncludePrep::ChangeDirectory(
const wxString &dir)
wxFileSystem *fs)
{
DOC_ROOT = dir;
m_FS = fs;
}