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
// 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 *);
};
* 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
wxString& group,
wxString& href );
+ VirtualData();
+
// Gets
wxString GetName(){ return m_name;};
wxString GetGroup(){ return m_group;};
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(
const wxSize& size = wxDefaultSize,
long style = wxHW_SCROLLBAR_AUTO,
const wxString& name = "htmlAppletWindow",
- const wxString& docroot = "" );
+ const wxPalette& globalPalette = wxNullPalette);
// Destructor
~wxHtmlAppletWindow();
// 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);
* 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
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);
// 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();
{
}
+#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
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('=');
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());
}
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
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:
// 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("&", "&");
+ tag.Replace("<", "<");
+ tag.Replace(">", ">");
+
output = (output.Mid(0,i) + tag + output.Mid(i));
}
****************************************************************************/
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;
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
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
{
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;
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) {
}
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);
}
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
int i;
char ft[] = "<!--#include virtual=";
- wxFileSystem *fs = new wxFileSystem;
- fs->ChangePathTo(DOC_ROOT, true);
int openedcount = 0;
// 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;
delete file;
}
- delete fs;
return output;
}
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;
}
// suppress some Watcom C++ warnings
#ifdef __WATCOMC__
-# pragma warning 849 9 // Disable 'virtual function hidden'
-# pragma warning 549 9 // Disable 'operand contains compiler generated information'
+# pragma warning 849 9 // Disable 'virtual function hidden'
+# pragma warning 549 9 // Disable 'operand contains compiler generated information'
#endif // __VISUALC__
// suppress some Salford C++ warnings
#elif defined(__WXPM__)
-# if (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
+# if defined (__WATCOMC__)
+
+# ifdef WXMAKINGDLL
+# define WXDLLEXPORT __declspec( dllexport )
+# define WXDLLEXPORT_DATA(type) __declspec( dllexport ) type
+# define WXDLLEXPORT_CTORFN
+// __declspec(dllimport) prepends __imp to imported symbols. We do NOT want that!
+//# elif defined(WXUSINGDLL)
+//# define WXDLLEXPORT __declspec( dllimport )
+//# define WXDLLEXPORT_DATA(type) __declspec( dllimport ) type
+//# define WXDLLEXPORT_CTORFN
+# else
+# define WXDLLEXPORT
+# define WXDLLEXPORT_DATA(type) type
+# define WXDLLEXPORT_CTORFN
+# endif
+
+# elif (!(defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )))
# ifdef WXMAKINGDLL
# define WXDLLEXPORT _Export
// WIN32 graphics types for OS/2 GPI
// RGB under OS2 is more like a PALETTEENTRY struct under Windows so we need a real RGB def
-#define OS2RGB(r,g,b) ((DWORD ((BYTE) (b) | ((WORD) (g) << 8)) | (((DWORD)(BYTE)(r)) << 16)))
+// WARNING: The OS/2 headers typedef BYTE simply as 'char'; if the default is signed, all
+// hell will break loose!
+//#define OS2RGB(r,g,b) ((DWORD ((BYTE) (b) | ((WORD) (g) << 8)) | (((DWORD)(BYTE)(r)) << 16)))
+#define OS2RGB(r,g,b) ((DWORD)((unsigned char)(b) | ((unsigned char)(g) << 8)) | ((unsigned char)(r) << 16))
typedef unsigned long COLORREF;
#define GetBValue(rgb) ((BYTE)((rgb) >> 16))
#elif defined(__WIN32__)
typedef int (__stdcall *WXFARPROC)();
#elif defined(__WXPM__)
-# if defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )
+# if (defined(__VISAGECPP__) && (__IBMCPP__ < 400 || __IBMC__ < 400 )) || defined (__WATCOMC__)
// VA 3.0 for some reason needs base data types when typedefing a proc proto???
typedef void* (_System *WXFARPROC)(unsigned long, unsigned long, void*, void*);
# else
// calls layout for layout constraints and sizers
void OnSize(wxSizeEvent& event);
+ virtual void InitDialog();
+
WX_DECLARE_CONTROL_CONTAINER();
protected:
#endif
#endif // _WX_HTMLWIN_H_
+
// Set's the DC used for parsing. If SetDC() is not called,
// parsing won't proceed
- virtual void SetDC(wxDC *dc, double pixel_scale = 1.0)
+ virtual void SetDC(wxDC *dc, double pixel_scale = 1.0)
{ m_DC = dc; m_PixelScale = pixel_scale; }
wxDC *GetDC() {return m_DC;}
// height/width. They return h/w of default font
// for this DC. If you want actual values, call
// GetDC()->GetChar...()
-
+
// returns associated wxWindow
wxWindow *GetWindow() {return m_Window;}
// sets fonts to be used when displaying HTML page.
void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
-
+
// Adds tags module. see wxHtmlTagsModule for details.
static void AddModule(wxHtmlTagsModule *module);
+
// make conversion from wxColour and COLORREF a bit less painful
inline COLORREF wxColourToRGB(const wxColour& c)
{
- return RGB(c.Red(), c.Green(), c.Blue());
+ return PALETTERGB(c.Red(), c.Green(), c.Blue());
}
inline void wxRGBToColour(wxColour& c, COLORREF rgb)
#ifndef _WX_APP_H_
#define _WX_APP_H_
+#ifdef __WATCOMC__
+
+#include <sys/ioctl.h>
+#include <sys/select.h>
+
+#else
+
#include <sys/time.h>
#include <sys/types.h>
#define INCL_ORDERS
#endif
+#endif
+
#include "wx/event.h"
#include "wx/icon.h"
,unsigned char cBlue
);
+ wxColour( unsigned long colRGB ) { Set(colRGB); }
+
//
// Implicit conversion from the colour name
//
{
long lModalStyle = lStyle ? wxDIALOG_MODAL : wxDIALOG_MODELESS ;
+ bModal = false;
Create( pParent
,-1
,rsTitle
(void)Create(nSize, nFamily, nStyle, nWeight, bUnderlined, rsFace, vEncoding);
}
- wxFont(const wxNativeFontInfo& rInfo)
- {
- Init();
-
- (void)Create( rInfo.pointSize
- ,rInfo.family
- ,rInfo.style
- ,rInfo.weight
- ,rInfo.underlined
- ,rInfo.faceName
- ,rInfo.encoding
- );
- }
+ wxFont(const wxNativeFontInfo& rInfo);
bool Create( int nSize
,int nFamily
virtual void Iconize(bool bIconize = TRUE);
virtual bool IsIconized(void) const;
virtual void Restore(void);
+#if wxUSE_MENUS_NATIVE
virtual void SetMenuBar(wxMenuBar* pMenubar);
+#endif
virtual void SetIcon(const wxIcon& rIcon);
virtual bool ShowFullScreen( bool bShow
,long lStyle = wxFULLSCREEN_ALL
,int nWeight
);
+#if wxUSE_MENUS_NATIVE
// helper
void DetachMenuBar(void);
-
-#if wxUSE_MENUS_NATIVE
// perform MSW-specific action when menubar is changed
virtual void AttachMenuBar(wxMenuBar* pMenubar);
// a plug in for MDI frame classes which need to do something special when
class WXDLLEXPORT wxWindow;
// array of notebook pages
-typedef wxWindow WXDLLEXPORT wxNotebookPage; // so far, any window can be a page
WX_DEFINE_ARRAY(wxNotebookPage *, wxArrayNBPages);
// ----------------------------------------------------------------------------
,const wxPoint& rBottomRight
);
wxRegion(const wxRect& rRect);
- wxRegion(WXHRGN hRegion); // Hangs on to this region
+ wxRegion(WXHRGN hRegion, WXHDC hPS); // Hangs on to this region
wxRegion();
~wxRegion();
,int* pExternalLeading = (int *)NULL
,const wxFont* pTheFont = (const wxFont *)NULL
) const;
+#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu* pMenu
,int nX
,int nY
);
+#endif // wxUSE_MENUS_NATIVE
virtual void SetScrollbar( int nOrient
,int nPos
) const;
#endif // wxUSE_CARET
+#ifndef __WXUNIVERSAL__
// Native resource loading (implemented in src/os2/nativdlg.cpp)
// FIXME: should they really be all virtual?
virtual bool LoadNativeDialog( wxWindow* pParent
);
wxWindow* GetWindowChild1(wxWindowID vId);
wxWindow* GetWindowChild(wxWindowID vId);
+#endif //__WXUNIVERSAL__
// implementation from now on
// --------------------------
) const;
#endif // WXWIN_COMPATIBILITY
+#ifndef __WXUNIVERSAL__
// Create an appropriate wxWindow from a HWND
virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
,WXHWND hWnd
// Make sure the window style reflects the HWND style (roughly)
virtual void AdoptAttributesFromHWND(void);
+#endif
// Setup background and foreground colours correctly
virtual void SetupColours(void);
#include "wx/window.h"
#if wxUSE_POPUPWIN
-
// ----------------------------------------------------------------------------
// wxPopupWindow: a special kind of top level window used for popup menus,
// combobox popups and such.
const wxSize& size);
};
+
// include the real class declaration
#ifdef __WXMSW__
#include "wx/msw/popupwin.h"
+#elif __WXPM__
+ #include "wx/os2/popupwin.h"
#elif __WXGTK__
#include "wx/gtk/popupwin.h"
#elif __WXMGL__
// ----------------------------------------------------------------------------
// undef everything
// ----------------------------------------------------------------------------
-#ifdef __WXMAC__
+#if defined(__WXMAC__)
#define wxUSE_GUI 1
#define WXWIN_COMPATIBILITY 0
#define wxUSE_FFILE 1
#define wxUSE_TEXTFILE 0
#define wxUSE_INTL 0
-#define wxUSE_MENUS 0 // was 1
+#define wxUSE_MENUS 0 // was 1
#define wxUSE_TOOLBAR 0
#define wxUSE_TOOLBAR_NATIVE 0
#define wxUSE_TOOLBAR_SIMPLE 0
#define wxUSE_DYNAMIC_CLASSES 1
+#elif defined(__WXPM__)
+
+#define wxUSE_GUI 1
+#define WXWIN_COMPATIBILITY 0
+#define wxICON_IS_BITMAP 0
+#define wxFONT_SIZE_COMPATIBILITY 0
+#define wxDIALOG_UNIT_COMPATIBILITY 0
+#define wxUSE_DEBUG_CONTEXT 0
+#define wxUSE_MEMORY_TRACING 0
+#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
+#define wxUSE_DEBUG_NEW_ALWAYS 0
+#define wxUSE_ON_FATAL_EXCEPTION 0
+
+#define wxUSE_UNICODE 0
+#define wxUSE_WCHAR_T 0
+#define wxUSE_LOG 1
+#define wxUSE_LOGGUI 1
+#define wxUSE_LOGWINDOW 1
+#define wxUSE_LOG_DIALOG 0
+#define wxUSE_THREADS 0
+#define wxUSE_STREAMS 0
+#define wxUSE_STD_IOSTREAM 0
+#define wxUSE_SERIAL 0
+#define wxUSE_LONGLONG 1
+#define wxUSE_TIMER 1
+#define wxUSE_STOPWATCH 1
+#define wxUSE_TIMEDATE 0
+#define wxUSE_DATETIME 1
+#define wxUSE_CONFIG 0
+#define wxUSE_CONFIG_NATIVE 0
+#define wxUSE_DIALUP_MANAGER 0
+#define wxUSE_DYNLIB_CLASS 0
+#define wxUSE_SOCKETS 0
+#define wxUSE_FILESYSTEM 0
+#define wxUSE_FS_ZIP 0
+#define wxUSE_FS_INET 0
+#define wxUSE_ZIPSTREAM 0
+#define wxUSE_ZLIB 0
+#define wxUSE_APPLE_IEEE 0
+#define wxUSE_FILE 1
+#define wxUSE_FFILE 1
+#define wxUSE_TEXTFILE 0
+#define wxUSE_INTL 0
+#define wxUSE_MENUS 1
+#define wxUSE_TOOLBAR 0
+#define wxUSE_TOOLBAR_NATIVE 0
+#define wxUSE_TOOLBAR_SIMPLE 0
+#define wxUSE_NOTEBOOK 1
+#define wxUSE_FONTMAP 0
+#define wxUSE_MIMETYPE 0
+#define wxUSE_IMAGE 1
+#define wxUSE_SYSTEM_OPTIONS 1
+
+#define wxUSE_CONTROLS 1
+#define wxUSE_POPUPWIN 1
+#define wxUSE_BUTTON 1
+#define wxUSE_BMPBUTTON 1
+#define wxUSE_CALENDARCTRL 0
+#define wxUSE_CARET 1
+#define wxUSE_CHECKBOX 1
+#define wxUSE_CHECKLISTBOX 1
+#define wxUSE_CHOICE 0
+#define wxUSE_COMBOBOX 1
+#define wxUSE_GAUGE 1
+#define wxUSE_IMAGLIST 1
+#define wxUSE_LISTBOX 1
+#define wxUSE_LISTCTRL 0
+#define wxUSE_RADIOBOX 1
+#define wxUSE_RADIOBTN 1
+#define wxUSE_SASH 0
+#define wxUSE_SCROLLBAR 1
+#define wxUSE_SLIDER 1
+#define wxUSE_SPINBTN 1
+#define wxUSE_SPINCTRL 1
+#define wxUSE_STATBOX 1
+#define wxUSE_STATLINE 1
+#define wxUSE_STATTEXT 1
+#define wxUSE_STATBMP 1
+//#define wxUSE_STATUSBAR 0
+#define wxUSE_TEXTCTRL 1
+#define wxUSE_TOOLTIPS 0
+#define wxUSE_TREECTRL 0
+
+#define wxUSE_NATIVE_STATUSBAR 0
+#define wxUSE_BUTTONBAR 0
+#define wxUSE_GRID 0
+#define wxUSE_NEW_GRID 0
+#define wxUSE_VALIDATORS 0
+#define wxUSE_DC_CACHEING 1
+#define wxUSE_ACCEL 1
+#define wxUSE_GENERIC_DIALOGS_IN_MSW 0
+#define wxUSE_COMMON_DIALOGS 0
+#define wxUSE_TEXTDLG 0
+#define wxUSE_PROGRESSDLG 0
+#define wxUSE_BUSYINFO 0
+#define wxUSE_DIRDLG 0
+#define wxUSE_FONTDLG 0
+#define wxUSE_FILEDLG 0
+#define wxUSE_COLOURDLG 0
+#define wxUSE_TEXTDLG 0
+#define wxUSE_CHOICEDLG 0
+#define wxUSE_NUMBERDLG 0
+#define wxUSE_STARTUP_TIPS 0
+#define wxUSE_MSGDLG 1
+#define wxUSE_SPLITTER 1
+#define wxUSE_TAB_DIALOG 0
+
+#define wxUSE_METAFILE 0
+#define wxUSE_ENH_METAFILE 0
+#define wxUSE_WIN_METAFILES_ALWAYS 0
+#define wxUSE_DOC_VIEW_ARCHITECTURE 0
+#define wxUSE_MDI_ARCHITECTURE 0
+#define wxUSE_PRINTING_ARCHITECTURE 0
+#define wxUSE_HTML 0
+#define wxUSE_PLOT 0
+#define wxUSE_GLCANVAS 0
+#define wxUSE_TREELAYOUT 0
+#define wxUSE_IPC 0
+#define wxUSE_HELP 0
+#define wxUSE_MS_HTML_HELP 0
+#define wxUSE_WXHTML_HELP 0
+#define wxUSE_RESOURCES 0
+#define wxUSE_CONSTRAINTS 1
+#define wxUSE_CLIPBOARD 0
+#define wxUSE_DATAOBJ 1
+#define wxUSE_SPLINES 0
+#define wxUSE_DRAG_AND_DROP 0
+#define wxUSE_XPM_IN_MSW 1
+#define wxUSE_XPM 1
+#define wxUSE_IMAGE_LOADING_IN_MSW 1
+#define wxUSE_RESOURCE_LOADING_IN_MSW 0
+#define wxUSE_WX_RESOURCES 0
+#define wxUSE_POSTSCRIPT 0
+#define wxUSE_AFM_FOR_POSTSCRIPT 0
+#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 0
+#define wxUSE_ODBC 0
+#define wxODBC_FWD_ONLY_CURSORS 0
+#define wxODBC_BACKWARD_COMPATABILITY 0
+#define REMOVE_UNUSED_ARG 1
+#define wxUSE_IOSTREAMH 0
+#define wxUSE_LIBPNG 0
+#define wxUSE_LIBJPEG 0
+#define wxUSE_LIBTIFF 0
+#define wxUSE_GIF 0
+#define wxUSE_PNM 0
+#define wxUSE_PCX 0
+#define wxUSE_MFC 0
+#define wxUSE_OLE 0
+#define wxUSE_CTL3D 0
+#define wxUSE_ITSY_BITSY 0
+#define wxUSE_DYNAMIC_CLASSES 1
+
+#define wxUSE_JOYSTICK 1
+#define wxUSE_REGEX 0
+#define wxUSE_STATUSBAR 1
+
#else
#define wxUSE_GUI 1
ICON 1 PRELOAD "mondros2.ico"
-#include "..\\..\\include\wx\os2\wx.rc"
+#include "wx/os2/wx.rc"
-#define MINIMAL_QUIT 1
-#define MINIMAL_ABOUT 102
+#define MINIMAL_QUIT 1
+#define MINIMAL_ABOUT 102
info = CLASSINFO(wxWindowGTK);
# elif defined(__WXMGL__)
info = CLASSINFO(wxWindowMGL);
+# elif defined(__WXPM__)
+ info = CLASSINFO(wxWindowOS2);
# elif defined(__WXMAC__)
info = CLASSINFO(wxWindowMac);
# elif defined(__WXMOTIF__)
+#include "wx/defs.h"
#include "wx/setup.h"
#include <math.h>
// OS/2 supports that have them (HPFS, FAT32) and security (HPFS386)
static const wxChar *szMktempSuffix = wxT("XXX");
m_strTemp << strName << szMktempSuffix;
+ // Temporarily remove - MN
+ #ifndef __WATCOMC__
::DosCreateDir(m_strTemp.GetWriteBuf(MAX_PATH), NULL);
+ #endif
#else // Windows
wxString strPath;
wxSplitPath(strName, &strPath, NULL, NULL);
// This seems wrong to me, but there is no fix. since
// "MacOS:MyText.txt" is absolute whereas "MyDir:MyText.txt"
// is not. Or maybe ":MyDir:MyText.txt" has to be used? RR.
-
+
if (filename.Find(':') != wxNOT_FOUND && filename[0] != ':')
return TRUE ;
}
//
// NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite
return ::CopyFile(file1, file2, !overwrite) != 0;
+#elif defined(__WXPM__)
+ if (::DosCopy(file2, file2, overwrite ? DCPY_EXISTING : 0) == 0)
+ return TRUE;
+ else
+ return FALSE;
#else // !Win32
wxStructStat fbuf;
#elif defined(__WXPM__)
if (::DosCreateDir((PSZ)dirname, NULL) != 0) // enhance for EAB's??
#else // !MSW and !OS/2 VAC++
- (void)perm;
+ (void)perm;
if ( wxMkDir(wxFNSTRINGCAST wxFNCONV(dirname)) != 0 )
#endif // !MSW/MSW
{
#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
#elif defined(__WXMAC__) && !defined(__UNIX__)
- FSSpec cwdSpec ;
- FCBPBRec pb;
- OSErr error;
- Str255 fileName ;
- pb.ioNamePtr = (StringPtr) &fileName;
- pb.ioVRefNum = 0;
- pb.ioRefNum = LMGetCurApRefNum();
- pb.ioFCBIndx = 0;
- error = PBGetFCBInfoSync(&pb);
- if ( error == noErr )
- {
- cwdSpec.vRefNum = pb.ioFCBVRefNum;
- cwdSpec.parID = pb.ioFCBParID;
- cwdSpec.name[0] = 0 ;
- wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
-
- strcpy( buf , res ) ;
- buf[res.length()-1]=0 ;
- }
- else
- buf[0] = 0 ;
- /*
- this version will not always give back the application directory on mac
- enum
- {
- SFSaveDisk = 0x214, CurDirStore = 0x398
- };
- FSSpec cwdSpec ;
-
- FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
- wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
- strcpy( buf , res ) ;
- */
- if (0) {
-#elif(__VISAGECPP__)
+ FSSpec cwdSpec ;
+ FCBPBRec pb;
+ OSErr error;
+ Str255 fileName ;
+ pb.ioNamePtr = (StringPtr) &fileName;
+ pb.ioVRefNum = 0;
+ pb.ioRefNum = LMGetCurApRefNum();
+ pb.ioFCBIndx = 0;
+ error = PBGetFCBInfoSync(&pb);
+ if ( error == noErr )
+ {
+ cwdSpec.vRefNum = pb.ioFCBVRefNum;
+ cwdSpec.parID = pb.ioFCBParID;
+ cwdSpec.name[0] = 0 ;
+ wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
+
+ strcpy( buf , res ) ;
+ buf[res.length()-1]=0 ;
+ }
+ else
+ buf[0] = 0 ;
+ /*
+ this version will not always give back the application directory on mac
+ enum
+ {
+ SFSaveDisk = 0x214, CurDirStore = 0x398
+ };
+ FSSpec cwdSpec ;
+
+ FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
+ wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
+ strcpy( buf , res ) ;
+ */
+ if (0) {
+#elif defined(__VISAGECPP__) || (defined (__OS2__) && defined (__WATCOMC__))
APIRET rc;
rc = ::DosQueryCurrentDir( 0 // current drive
,buf
#include "wx/intl.h"
#include "wx/module.h"
+#ifdef __WATCOMC__
+#ifdef LINKAGEMODE
+#undef LINKAGEMODE
+#define LINKAGEMODE __cdecl
+#endif
+#endif
//-----------------------------------------------------------------------------
// wxTIFFHandler
//-----------------------------------------------------------------------------
static tsize_t LINKAGEMODE
_tiffNullProc(thandle_t WXUNUSED(handle),
- tdata_t WXUNUSED(buf),
- tsize_t WXUNUSED(size))
+ tdata_t WXUNUSED(buf),
+ tsize_t WXUNUSED(size))
{
return (tsize_t) -1;
}
unsigned char *ptr = image->GetData();
for (int row = 0; row < image->GetHeight(); row++)
{
- if (buf)
- memcpy(buf, ptr, image->GetWidth());
+ if (buf)
+ memcpy(buf, ptr, image->GetWidth());
- if (TIFFWriteScanline(tif, buf ? buf : ptr, (uint32)row, 0) < 0)
+ if (TIFFWriteScanline(tif, buf ? buf : ptr, (uint32)row, 0) < 0)
{
- if (verbose)
- wxLogError( _("TIFF: Error writing image.") );
+ if (verbose)
+ wxLogError( _("TIFF: Error writing image.") );
TIFFClose( tif );
if (buf)
// Created: 22/6/2000
// RCS-ID: $Id$
// Copyright: (c) Thomas G. Lane, Vaclav Slavik, Julian Smart
-// Licence: wxWindows licence + JPEG library licence
+// Licence: wxWindows licence + JPEG library licence
/////////////////////////////////////////////////////////////////////////////
/*
#include <stdlib.h>
#include <string.h>
-#if defined(__VISAGECPP__)
+#if defined(__OS2__)
#define RGB_RED_OS2 0
#define RGB_GREEN_OS2 1
#define RGB_BLUE_OS2 2
JSAMPLE *sample_range_limit, *srl_orig;
} j_decompress;
+#ifdef __WINDOWS__
+ #define JMETHOD(type,methodname,arglist) type (__cdecl methodname) arglist
+#else
+ #define JMETHOD(type,methodname,arglist) type (methodname) arglist
+#endif
+
typedef j_decompress *j_decompress_ptr;
+struct jpeg_color_quantizer {
+ JMETHOD(void, start_pass, (j_decompress_ptr cinfo, bool is_pre_scan));
+ JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
+ JSAMPARRAY input_buf, JSAMPARRAY output_buf,
+ int num_rows));
+ JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
+ JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
+};
+
+
/*
* probably need to change these scale factors.
*/
-#define R_SCALE 2 /* scale R distances by this much */
-#define G_SCALE 3 /* scale G distances by this much */
-#define B_SCALE 1 /* and B by this much */
+#define R_SCALE 2 /* scale R distances by this much */
+#define G_SCALE 3 /* scale G distances by this much */
+#define B_SCALE 1 /* and B by this much */
/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined
* in jmorecfg.h. As the code stands, it will do the right thing for R,G,B
* you'll probably want to tweak the histogram sizes too.
*/
-#if defined(__VISAGECPP__)
+#if defined(__OS2__)
#if RGB_RED_OS2 == 0
#define C0_SCALE R_SCALE
/* These will do the right thing for either R,G,B or B,G,R color order,
* but you may not like the results for other color orders.
*/
-#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */
-#define HIST_C1_BITS 6 /* bits of precision in G histogram */
-#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */
+#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */
+#define HIST_C1_BITS 6 /* bits of precision in G histogram */
+#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */
/* Number of elements along histogram axes. */
#define HIST_C0_ELEMS (1<<HIST_C0_BITS)
#define C2_SHIFT (BITS_IN_JSAMPLE-HIST_C2_BITS)
-typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */
+typedef UINT16 histcell; /* histogram cell; prefer an unsigned type */
-typedef histcell * histptr; /* for pointers to histogram cells */
+typedef histcell * histptr; /* for pointers to histogram cells */
typedef histcell hist1d[HIST_C2_ELEMS]; /* typedefs for the array */
-typedef hist1d * hist2d; /* type for the 2nd-level pointers */
-typedef hist2d * hist3d; /* type for top-level pointer */
+typedef hist1d * hist2d; /* type for the 2nd-level pointers */
+typedef hist2d * hist3d; /* type for top-level pointer */
/* Declarations for Floyd-Steinberg dithering.
* Errors are accumulated into the array fserrors[], at a resolution of
* 1/16th of a pixel count. The error at a given pixel is propagated
* to its not-yet-processed neighbors using the standard F-S fractions,
- * ... (here) 7/16
- * 3/16 5/16 1/16
+ * ... (here) 7/16
+ * 3/16 5/16 1/16
* We work left-to-right on even rows, right-to-left on odd rows.
*
* We can get away with a single array (holding one row's worth of errors)
*/
#if BITS_IN_JSAMPLE == 8
-typedef INT16 FSERROR; /* 16 bits should be enough */
-typedef int LOCFSERROR; /* use 'int' for calculation temps */
+typedef INT16 FSERROR; /* 16 bits should be enough */
+typedef int LOCFSERROR; /* use 'int' for calculation temps */
#else
-typedef INT32 FSERROR; /* may need more than 16 bits */
-typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */
+typedef INT32 FSERROR; /* may need more than 16 bits */
+typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */
#endif
-typedef FSERROR *FSERRPTR; /* pointer to error array (in storage!) */
+typedef FSERROR *FSERRPTR; /* pointer to error array (in storage!) */
/* Private subobject */
} pub;
/* Space for the eventually created colormap is stashed here */
- JSAMPARRAY sv_colormap; /* colormap allocated at init time */
- int desired; /* desired # of colors = size of colormap */
+ JSAMPARRAY sv_colormap; /* colormap allocated at init time */
+ int desired; /* desired # of colors = size of colormap */
/* Variables for accumulating image statistics */
- hist3d histogram; /* pointer to the histogram */
+ hist3d histogram; /* pointer to the histogram */
- bool needs_zeroed; /* true if next pass must zero histogram */
+ bool needs_zeroed; /* true if next pass must zero histogram */
/* Variables for Floyd-Steinberg dithering */
- FSERRPTR fserrors; /* accumulated errors */
- bool on_odd_row; /* flag to remember which row we are on */
- int * error_limiter; /* table for clamping the applied error */
+ FSERRPTR fserrors; /* accumulated errors */
+ bool on_odd_row; /* flag to remember which row we are on */
+ int * error_limiter; /* table for clamping the applied error */
} my_cquantizer;
typedef my_cquantizer * my_cquantize_ptr;
void
prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
- JSAMPARRAY output_buf, int num_rows)
+ JSAMPARRAY output_buf, int num_rows)
{
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
register JSAMPROW ptr;
/* get pixel value and index into the histogram */
histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT]
- [GETJSAMPLE(ptr[1]) >> C1_SHIFT]
- [GETJSAMPLE(ptr[2]) >> C2_SHIFT];
+ [GETJSAMPLE(ptr[1]) >> C1_SHIFT]
+ [GETJSAMPLE(ptr[2]) >> C2_SHIFT];
/* increment, check for overflow and undo increment if so. */
if (++(*histp) <= 0)
(*histp)--;
if (c0max > c0min)
for (c0 = c0min; c0 <= c0max; c0++)
for (c1 = c1min; c1 <= c1max; c1++) {
- histp = & histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c0min = c0min = c0;
- goto have_c0min;
- }
+ histp = & histogram[c0][c1][c2min];
+ for (c2 = c2min; c2 <= c2max; c2++)
+ if (*histp++ != 0) {
+ boxp->c0min = c0min = c0;
+ goto have_c0min;
+ }
}
have_c0min:
if (c0max > c0min)
for (c0 = c0max; c0 >= c0min; c0--)
for (c1 = c1min; c1 <= c1max; c1++) {
- histp = & histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c0max = c0max = c0;
- goto have_c0max;
- }
+ histp = & histogram[c0][c1][c2min];
+ for (c2 = c2min; c2 <= c2max; c2++)
+ if (*histp++ != 0) {
+ boxp->c0max = c0max = c0;
+ goto have_c0max;
+ }
}
have_c0max:
if (c1max > c1min)
for (c1 = c1min; c1 <= c1max; c1++)
for (c0 = c0min; c0 <= c0max; c0++) {
- histp = & histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c1min = c1min = c1;
- goto have_c1min;
- }
+ histp = & histogram[c0][c1][c2min];
+ for (c2 = c2min; c2 <= c2max; c2++)
+ if (*histp++ != 0) {
+ boxp->c1min = c1min = c1;
+ goto have_c1min;
+ }
}
have_c1min:
if (c1max > c1min)
for (c1 = c1max; c1 >= c1min; c1--)
for (c0 = c0min; c0 <= c0max; c0++) {
- histp = & histogram[c0][c1][c2min];
- for (c2 = c2min; c2 <= c2max; c2++)
- if (*histp++ != 0) {
- boxp->c1max = c1max = c1;
- goto have_c1max;
- }
+ histp = & histogram[c0][c1][c2min];
+ for (c2 = c2min; c2 <= c2max; c2++)
+ if (*histp++ != 0) {
+ boxp->c1max = c1max = c1;
+ goto have_c1max;
+ }
}
have_c1max:
if (c2max > c2min)
for (c2 = c2min; c2 <= c2max; c2++)
for (c0 = c0min; c0 <= c0max; c0++) {
- histp = & histogram[c0][c1min][c2];
- for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
- if (*histp != 0) {
- boxp->c2min = c2min = c2;
- goto have_c2min;
- }
+ histp = & histogram[c0][c1min][c2];
+ for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
+ if (*histp != 0) {
+ boxp->c2min = c2min = c2;
+ goto have_c2min;
+ }
}
have_c2min:
if (c2max > c2min)
for (c2 = c2max; c2 >= c2min; c2--)
for (c0 = c0min; c0 <= c0max; c0++) {
- histp = & histogram[c0][c1min][c2];
- for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
- if (*histp != 0) {
- boxp->c2max = c2max = c2;
- goto have_c2max;
- }
+ histp = & histogram[c0][c1min][c2];
+ for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS)
+ if (*histp != 0) {
+ boxp->c2max = c2max = c2;
+ goto have_c2max;
+ }
}
have_c2max:
for (c1 = c1min; c1 <= c1max; c1++) {
histp = & histogram[c0][c1][c2min];
for (c2 = c2min; c2 <= c2max; c2++, histp++)
- if (*histp != 0) {
- ccount++;
- }
+ if (*histp != 0) {
+ ccount++;
+ }
}
boxp->colorcount = ccount;
}
int
median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
- int desired_colors)
+ int desired_colors)
/* Repeatedly select and split the largest box until we have enough boxes */
{
int n,lb;
} else {
b1 = find_biggest_volume(boxlist, numboxes);
}
- if (b1 == NULL) /* no splittable boxes left! */
+ if (b1 == NULL) /* no splittable boxes left! */
break;
- b2 = &boxlist[numboxes]; /* where new box will go */
+ b2 = &boxlist[numboxes]; /* where new box will go */
/* Copy the color bounds to the new box. */
b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max;
b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min;
for (c1 = c1min; c1 <= c1max; c1++) {
histp = & histogram[c0][c1][c2min];
for (c2 = c2min; c2 <= c2max; c2++) {
- if ((count = *histp++) != 0) {
- total += count;
- c0total += ((c0 << C0_SHIFT) + ((1<<C0_SHIFT)>>1)) * count;
- c1total += ((c1 << C1_SHIFT) + ((1<<C1_SHIFT)>>1)) * count;
- c2total += ((c2 << C2_SHIFT) + ((1<<C2_SHIFT)>>1)) * count;
- }
+ if ((count = *histp++) != 0) {
+ total += count;
+ c0total += ((c0 << C0_SHIFT) + ((1<<C0_SHIFT)>>1)) * count;
+ c1total += ((c1 << C1_SHIFT) + ((1<<C1_SHIFT)>>1)) * count;
+ c2total += ((c2 << C2_SHIFT) + ((1<<C2_SHIFT)>>1)) * count;
+ }
}
}
static int
find_nearby_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
- JSAMPLE colorlist[])
+ JSAMPLE colorlist[])
/* Locate the colormap entries close enough to an update box to be candidates
* for the nearest entry to some cell(s) in the update box. The update box
* is specified by the center coordinates of its first cell. The number of
int centerc0, centerc1, centerc2;
int i, x, ncolors;
INT32 minmaxdist, min_dist, max_dist, tdist;
- INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */
+ INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */
/* Compute true coordinates of update box's upper corner and center.
* Actually we compute the coordinates of the center of the upper-corner
/* within cell range so no contribution to min_dist */
min_dist = 0;
if (x <= centerc0) {
- tdist = (x - maxc0) * C0_SCALE;
- max_dist = tdist*tdist;
+ tdist = (x - maxc0) * C0_SCALE;
+ max_dist = tdist*tdist;
} else {
- tdist = (x - minc0) * C0_SCALE;
- max_dist = tdist*tdist;
+ tdist = (x - minc0) * C0_SCALE;
+ max_dist = tdist*tdist;
}
}
} else {
/* within cell range so no contribution to min_dist */
if (x <= centerc1) {
- tdist = (x - maxc1) * C1_SCALE;
- max_dist += tdist*tdist;
+ tdist = (x - maxc1) * C1_SCALE;
+ max_dist += tdist*tdist;
} else {
- tdist = (x - minc1) * C1_SCALE;
- max_dist += tdist*tdist;
+ tdist = (x - minc1) * C1_SCALE;
+ max_dist += tdist*tdist;
}
}
} else {
/* within cell range so no contribution to min_dist */
if (x <= centerc2) {
- tdist = (x - maxc2) * C2_SCALE;
- max_dist += tdist*tdist;
+ tdist = (x - maxc2) * C2_SCALE;
+ max_dist += tdist*tdist;
} else {
- tdist = (x - minc2) * C2_SCALE;
- max_dist += tdist*tdist;
+ tdist = (x - minc2) * C2_SCALE;
+ max_dist += tdist*tdist;
}
}
- mindist[i] = min_dist; /* save away the results */
+ mindist[i] = min_dist; /* save away the results */
if (max_dist < minmaxdist)
minmaxdist = max_dist;
}
static void
find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
- int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])
+ int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[])
/* Find the closest colormap entry for each cell in the update box,
* given the list of candidate colors prepared by find_nearby_colors.
* Return the indexes of the closest entries in the bestcolor[] array.
{
int ic0, ic1, ic2;
int i, icolor;
- register INT32 * bptr; /* pointer into bestdist[] array */
- JSAMPLE * cptr; /* pointer into bestcolor[] array */
- INT32 dist0, dist1; /* initial distance values */
- register INT32 dist2; /* current distance in inner loop */
- INT32 xx0, xx1; /* distance increments */
+ register INT32 * bptr; /* pointer into bestdist[] array */
+ JSAMPLE * cptr; /* pointer into bestcolor[] array */
+ INT32 dist0, dist1; /* initial distance values */
+ register INT32 dist2; /* current distance in inner loop */
+ INT32 xx0, xx1; /* distance increments */
register INT32 xx2;
- INT32 inc0, inc1, inc2; /* initial values for increments */
+ INT32 inc0, inc1, inc2; /* initial values for increments */
/* This array holds the distance to the nearest-so-far color for each cell */
INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
dist1 = dist0;
xx1 = inc1;
for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) {
- dist2 = dist1;
- xx2 = inc2;
- for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) {
- if (dist2 < *bptr) {
- *bptr = dist2;
- *cptr = (JSAMPLE) icolor;
- }
- dist2 += xx2;
- xx2 += 2 * STEP_C2 * STEP_C2;
- bptr++;
- cptr++;
- }
- dist1 += xx1;
- xx1 += 2 * STEP_C1 * STEP_C1;
+ dist2 = dist1;
+ xx2 = inc2;
+ for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) {
+ if (dist2 < *bptr) {
+ *bptr = dist2;
+ *cptr = (JSAMPLE) icolor;
+ }
+ dist2 += xx2;
+ xx2 += 2 * STEP_C2 * STEP_C2;
+ bptr++;
+ cptr++;
+ }
+ dist1 += xx1;
+ xx1 += 2 * STEP_C1 * STEP_C1;
}
dist0 += xx0;
xx0 += 2 * STEP_C0 * STEP_C0;
{
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram;
- int minc0, minc1, minc2; /* lower left corner of update box */
+ int minc0, minc1, minc2; /* lower left corner of update box */
int ic0, ic1, ic2;
- register JSAMPLE * cptr; /* pointer into bestcolor[] array */
- register histptr cachep; /* pointer into main cache array */
+ register JSAMPLE * cptr; /* pointer into bestcolor[] array */
+ register histptr cachep; /* pointer into main cache array */
/* This array lists the candidate colormap indexes. */
JSAMPLE colorlist[MAXNUMCOLORS];
- int numcolors; /* number of candidate colors */
+ int numcolors; /* number of candidate colors */
/* This array holds the actually closest colormap index for each cell. */
JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
/* Determine the actually nearest colors. */
find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist,
- bestcolor);
+ bestcolor);
/* Save the best color numbers (plus 1) in the main cache array */
- c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */
+ c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */
c1 <<= BOX_C1_LOG;
c2 <<= BOX_C2_LOG;
cptr = bestcolor;
for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) {
cachep = & histogram[c0+ic0][c1+ic1][c2];
for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) {
- *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1);
+ *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1);
}
}
}
void
pass2_no_dither (j_decompress_ptr cinfo,
- JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
+ JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
/* This version performs no dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
/* If we have not seen this color before, find nearest colormap entry */
/* and update the cache */
if (*cachep == 0)
- fill_inverse_cmap(cinfo, c0,c1,c2);
+ fill_inverse_cmap(cinfo, c0,c1,c2);
/* Now emit the colormap index for this cell */
*outptr++ = (JSAMPLE) (*cachep - 1);
}
void
pass2_fs_dither (j_decompress_ptr cinfo,
- JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
+ JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
/* This version performs Floyd-Steinberg dithering */
{
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram;
- register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */
+ register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */
LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */
LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */
- register FSERRPTR errorptr; /* => fserrors[] at column before current */
- JSAMPROW inptr; /* => current input pixel */
- JSAMPROW outptr; /* => current output pixel */
+ register FSERRPTR errorptr; /* => fserrors[] at column before current */
+ JSAMPROW inptr; /* => current input pixel */
+ JSAMPROW outptr; /* => current output pixel */
histptr cachep;
- int dir; /* +1 or -1 depending on direction */
- int dir3; /* 3*dir, for advancing inptr & errorptr */
+ int dir; /* +1 or -1 depending on direction */
+ int dir3; /* 3*dir, for advancing inptr & errorptr */
int row;
JDIMENSION col;
JDIMENSION width = cinfo->output_width;
outptr = output_buf[row];
if (cquantize->on_odd_row) {
/* work right to left in this row */
- inptr += (width-1) * 3; /* so point to rightmost pixel */
+ inptr += (width-1) * 3; /* so point to rightmost pixel */
outptr += width-1;
dir = -1;
dir3 = -3;
/* If we have not seen this color before, find nearest colormap */
/* entry and update the cache */
if (*cachep == 0)
- fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT);
+ fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT);
/* Now emit the colormap index for this cell */
{ register int pixcode = *cachep - 1;
- *outptr = (JSAMPLE) pixcode;
- /* Compute representation error for this pixel */
- cur0 -= GETJSAMPLE(colormap0[pixcode]);
- cur1 -= GETJSAMPLE(colormap1[pixcode]);
- cur2 -= GETJSAMPLE(colormap2[pixcode]);
+ *outptr = (JSAMPLE) pixcode;
+ /* Compute representation error for this pixel */
+ cur0 -= GETJSAMPLE(colormap0[pixcode]);
+ cur1 -= GETJSAMPLE(colormap1[pixcode]);
+ cur2 -= GETJSAMPLE(colormap2[pixcode]);
}
/* Compute error fractions to be propagated to adjacent pixels.
* Add these into the running sums, and simultaneously shift the
*/
{ register LOCFSERROR bnexterr, delta;
- bnexterr = cur0; /* Process component 0 */
- delta = cur0 * 2;
- cur0 += delta; /* form error * 3 */
- errorptr[0] = (FSERROR) (bpreverr0 + cur0);
- cur0 += delta; /* form error * 5 */
- bpreverr0 = belowerr0 + cur0;
- belowerr0 = bnexterr;
- cur0 += delta; /* form error * 7 */
- bnexterr = cur1; /* Process component 1 */
- delta = cur1 * 2;
- cur1 += delta; /* form error * 3 */
- errorptr[1] = (FSERROR) (bpreverr1 + cur1);
- cur1 += delta; /* form error * 5 */
- bpreverr1 = belowerr1 + cur1;
- belowerr1 = bnexterr;
- cur1 += delta; /* form error * 7 */
- bnexterr = cur2; /* Process component 2 */
- delta = cur2 * 2;
- cur2 += delta; /* form error * 3 */
- errorptr[2] = (FSERROR) (bpreverr2 + cur2);
- cur2 += delta; /* form error * 5 */
- bpreverr2 = belowerr2 + cur2;
- belowerr2 = bnexterr;
- cur2 += delta; /* form error * 7 */
+ bnexterr = cur0; /* Process component 0 */
+ delta = cur0 * 2;
+ cur0 += delta; /* form error * 3 */
+ errorptr[0] = (FSERROR) (bpreverr0 + cur0);
+ cur0 += delta; /* form error * 5 */
+ bpreverr0 = belowerr0 + cur0;
+ belowerr0 = bnexterr;
+ cur0 += delta; /* form error * 7 */
+ bnexterr = cur1; /* Process component 1 */
+ delta = cur1 * 2;
+ cur1 += delta; /* form error * 3 */
+ errorptr[1] = (FSERROR) (bpreverr1 + cur1);
+ cur1 += delta; /* form error * 5 */
+ bpreverr1 = belowerr1 + cur1;
+ belowerr1 = bnexterr;
+ cur1 += delta; /* form error * 7 */
+ bnexterr = cur2; /* Process component 2 */
+ delta = cur2 * 2;
+ cur2 += delta; /* form error * 3 */
+ errorptr[2] = (FSERROR) (bpreverr2 + cur2);
+ cur2 += delta; /* form error * 5 */
+ bpreverr2 = belowerr2 + cur2;
+ belowerr2 = bnexterr;
+ cur2 += delta; /* form error * 7 */
}
/* At this point curN contains the 7/16 error value to be propagated
* to the next pixel on the current line, and all the errors for the
* next line have been shifted over. We are therefore ready to move on.
*/
- inptr += dir3; /* Advance pixel pointers to next column */
+ inptr += dir3; /* Advance pixel pointers to next column */
outptr += dir;
- errorptr += dir3; /* advance errorptr to current column */
+ errorptr += dir3; /* advance errorptr to current column */
}
/* Post-loop cleanup: we must unload the final error values into the
* final fserrors[] entry. Note we need not unload belowerrN because
int in, out;
table = (int *) malloc((MAXJSAMPLE*2+1) * sizeof(int));
- table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
+ table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */
cquantize->error_limiter = table;
#define STEPSIZE ((MAXJSAMPLE+1)/16)
{
size_t arraysize = (size_t) ((cinfo->output_width + 2) *
- (3 * sizeof(FSERROR)));
+ (3 * sizeof(FSERROR)));
/* Allocate Floyd-Steinberg workspace if we didn't already. */
if (cquantize->fserrors == NULL)
- cquantize->fserrors = (INT16*) malloc(arraysize);
+ cquantize->fserrors = (INT16*) malloc(arraysize);
/* Initialize the propagated errors to zero. */
memset((void *) cquantize->fserrors, 0, arraysize);
/* Make the error-limit table if we didn't already. */
if (cquantize->error_limiter == NULL)
- init_error_limit(cinfo);
+ init_error_limit(cinfo);
cquantize->on_odd_row = FALSE;
}
if (cquantize->needs_zeroed) {
for (i = 0; i < HIST_C0_ELEMS; i++) {
memset((void *) histogram[i], 0,
- HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
+ HIST_C1_ELEMS*HIST_C2_ELEMS * sizeof(histcell));
}
cquantize->needs_zeroed = FALSE;
}
int i;
cquantize = (my_cquantize_ptr) malloc(sizeof(my_cquantizer));
- cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
+ cinfo->cquantize = (jpeg_color_quantizer *) cquantize;
cquantize->pub.start_pass = start_pass_2_quant;
cquantize->pub.new_color_map = new_color_map_2_quant;
- cquantize->fserrors = NULL; /* flag optional arrays not allocated */
+ cquantize->fserrors = NULL; /* flag optional arrays not allocated */
cquantize->error_limiter = NULL;
table = (JSAMPLE *) malloc((5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * sizeof(JSAMPLE));
cinfo->srl_orig = table;
- table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
+ table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
cinfo->sample_range_limit = table;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */
memset(table - (MAXJSAMPLE+1), 0, (MAXJSAMPLE+1) * sizeof(JSAMPLE));
/* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE) i;
- table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
+ table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
/* End of simple table, rest of first half of post-IDCT table */
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
table[i] = MAXJSAMPLE;
/* Second half of post-IDCT table */
memset(table + (2 * (MAXJSAMPLE+1)), 0,
- (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
+ (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
memcpy(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
- cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
+ cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
}
int h = src.GetHeight();
int windowsSystemColourCount = 20;
+
int paletteShift = 0;
// Shift the palette up by the number of Windows system colours,
// do NOT just shut off these warnings, drop me a line instead at
// <guille@iies.es>
- #if defined(__VISUALC__)
+ #if defined(__VISUALC__) || defined (__WATCOMC__)
#pragma message("wxStopWatch will be up to second resolution!")
#elif defined(__BORLANDC__)
#pragma message "wxStopWatch will be up to second resolution!"
- #else
+ #elif
#warning "wxStopWatch will be up to second resolution!"
#endif // compiler
#endif
*/
-
+#include "wx/defs.h"
#include "wx/setup.h"
#if wxUSE_ZLIB && wxUSE_ZIPSTREAM
const char *c;
char *c2;
char szFileName2[UNZ_MAXFILENAMEINZIP+1];
-
+
uLong num_fileSaved;
uLong pos_in_central_dirSaved;
- for (c = szFileName, c2 = szFileName2; *c != '\0'; c++, c2++)
+ for (c = szFileName, c2 = szFileName2; *c != '\0'; c++, c2++)
if (*c == '\\') *c2 = '/';
else *c2 = *c;
*c2 = '\0';
{
}
+void wxPanel::InitDialog()
+{
+ wxInitDialogEvent event(GetId());
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+}
+
// ----------------------------------------------------------------------------
// event handlers
// ----------------------------------------------------------------------------
void wxHtmlWindow::OnCellClicked(wxHtmlCell *cell,
wxCoord x, wxCoord y,
const wxMouseEvent& event)
-{
+{
wxCHECK_RET( cell, _T("can't be called with NULL cell") );
cell->OnMouseClick(this, x, y, event);
#include "wx/html/forcelnk.h"
FORCE_WXHTML_MODULES()
-#endif
+#endif
\ No newline at end of file
if (depth == -1) depth = wxDisplayDepth();
SetDepth( depth );
+ // Copy the palette from the source image
+ SetPalette(image.GetPalette());
+
// create a DIB header
int headersize = sizeof(BITMAPINFOHEADER);
BITMAPINFO *lpDIBh = (BITMAPINFO *) malloc( headersize );
#if wxUSE_PALETTE
if (m_oldPalette)
{
- ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
+ ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, FALSE);
}
m_oldPalette = 0;
#endif // wxUSE_PALETTE
height = bmp.GetHeight();
HBITMAP hbmpMask = 0;
+ HPALETTE oldPal = 0;
if ( useMask )
{
if (wxSystemOptions::GetOptionInt(wxT("no-maskblt")) == 0)
#endif
{
+ HDC cdc = GetHdc();
HDC hdcMem = ::CreateCompatibleDC(GetHdc());
::SelectObject(hdcMem, GetHbitmapOf(bmp));
-
- ok = ::MaskBlt(GetHdc(), x, y, width, height,
+ if (bmp.GetPalette() && (::GetDeviceCaps(cdc,BITSPIXEL) <= 8)) {
+ oldPal = ::SelectPalette( hdcMem, (HPALETTE)bmp.GetPalette()->GetHPALETTE(), FALSE);
+ ::RealizePalette(hdcMem);
+ }
+ ok = ::MaskBlt(cdc, x, y, width, height,
hdcMem, 0, 0,
hbmpMask, 0, 0,
MAKEROP4(SRCCOPY, DSTCOPY)) != 0;
+ if (oldPal)
+ ::SelectPalette(hdcMem, oldPal, FALSE);
::DeleteDC(hdcMem);
}
::SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() );
}
+ if (bmp.GetPalette() && (::GetDeviceCaps(cdc,BITSPIXEL) <= 8)) {
+ oldPal = ::SelectPalette( memdc, (HPALETTE)bmp.GetPalette()->GetHPALETTE(), FALSE);
+ ::RealizePalette(memdc);
+ }
::SelectObject( memdc, hbitmap );
::BitBlt( cdc, x, y, width, height, memdc, 0, 0, SRCCOPY);
+ if (oldPal)
+ ::SelectPalette(memdc, oldPal, FALSE);
::DeleteDC( memdc );
::SetTextColor(GetHdc(), old_textground);
// that's not yet selected out.
if (m_oldPalette)
{
- ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, TRUE);
+ ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, FALSE);
m_oldPalette = 0;
}
// the original colourmap
if (m_oldPalette)
{
- ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, TRUE);
+ ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, FALSE);
m_oldPalette = 0;
}
if (m_palette.Ok() && m_palette.GetHPALETTE())
{
- HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), TRUE);
+ HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), FALSE);
if (!m_oldPalette)
m_oldPalette = (WXHPALETTE) oldPal;
#include "wx/utils.h"
#endif
-#if wxUSE_GAUGE
+#if wxUSE_GAUGE
#include "wx/msw/gaugemsw.h"
#include "wx/msw/private.h"
wOrient = ZYZG_ORIENT_LEFTTORIGHT;
else
wOrient = ZYZG_ORIENT_BOTTOMTOTOP;
-
+
SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0);
SendMessage(wx_button, ZYZG_SETRANGE, range, 0);
- SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
- SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+ SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, PALETTERGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
+ SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
//SetBezelFace(1);
//SetShadowWidth(1);
if ( !wxControl::SetForegroundColour(col) )
return FALSE;
- SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
+ SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, PALETTERGB(col.Red(), col.Green(), col.Blue()));
return TRUE;
}
if ( !wxControl::SetBackgroundColour(col) )
return FALSE;
- SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
+ SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, PALETTERGB(col.Red(), col.Green(), col.Blue()));
return TRUE;
}
/** zyz3d.c
*
- * DESCRIPTION:
+ * DESCRIPTION:
* This module contains functions for creating nifty 3D borders
* around controls like zYzGauge.
*
/** void FAR PASCAL Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth)
*
- * DESCRIPTION:
+ * DESCRIPTION:
* This function draws a flat frame with the current button-face
* color.
*
/** void FAR PASCAL Draw3DRect(HDC, LPRECT, WORD, WORD)
*
- * DESCRIPTION:
+ * DESCRIPTION:
* Draws a 3D rectangle that is shaded. wFlags can be used to
* control how the rectangle looks.
*
/** void FAR PASCAL Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
*
- * DESCRIPTION:
+ * DESCRIPTION:
* Draws a 3D line that can be used to make a 3D box.
*
* ARGUMENTS:
** cjp */
void FAR PASCAL Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
- WORD wShadowWidth, WORD wFlags)
+ WORD wShadowWidth, WORD wFlags)
{
HBRUSH hOldBrush;
HPEN hOldPen;
Point[0].x = x;
Point[0].y = y;
- /* To do this we'll simply draw a polygon with four sides, using
+ /* To do this we'll simply draw a polygon with four sides, using
* the appropriate brush. I dare you to ask me why this isn't a
* switch/case!
*/
/* select 'dark' brush if 'in'--'light' for 'out' */
fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
}
-
+
/* well maybe it's for the right side? */
else if (wFlags & DRAW3D_RIGHTLINE)
{
/** zyzgauge.c
*
- * DESCRIPTION:
+ * DESCRIPTION:
* Yet another 'Gas Gauge Custom Control.' This control gives you
* a 'progress bar' class (named zYzGauge) for use in your applications.
* You can set the range, position, font, color, orientation, and 3d
/* static global variables */
static wxChar gszzYzGaugeClass[] = wxT("zYzGauge");
-
+
/* window word position definitions */
#define ZYZG_WW_PZYZGAUGE 0
#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
#define APIENTRY FAR PASCAL
#endif
-
+
#ifdef __WIN32__
#define _EXPORT /**/
#else
/** BOOL FAR PASCAL gaugeInit(HINSTANCE hInstance)
*
- * DESCRIPTION:
+ * DESCRIPTION:
* Registers the window class for the zYzGauge control. Performs
* other initialization for the zYzGauge text control. This must
* be done before the zYzGauge control is used--or it will fail
static BOOL fRegistered = FALSE;
WNDCLASS wc;
HDC hdc;
-
+
/* assume already registered if not first instance */
if (fRegistered)
return (TRUE);
}
/* good! we have color: blue foreground, white background */
- else
+ else
{
rgbDefTextColor = RGB(0, 0, 255);
rgbDefBkColor = RGB(255, 255, 255);
/** static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
*
- * DESCRIPTION:
+ * DESCRIPTION:
* This function is responsible for painting the zYzGauge control.
*
* ARGUMENTS:
/* add all the other pixels into the border width */
Offset += (2 * pgauge->wWidth3D) + pgauge->wWidthBezelFace + 1;
}
-
+
/* dup--one rc for 'how much filled', one rc for 'how much empty' */
rc2 = rc1;
dwExtent = size.cx;
#else
dwExtent = GetTextExtent(hdc, ach, wGomerX = lstrlen(ach));
-#endif
+#endif
/* Draw the finished (ie the percent done) side of box. If
/* unselect the font */
SelectObject(hdc, hFont);
} /* gaugePaint() */
-
+
/** LRESULT FAR PASCAL gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
*
- * DESCRIPTION:
+ * DESCRIPTION:
* This is the control's window procedure. Its purpose is to handle
* special messages for this custom control.
*
* ZYZG_SETORIENTATION : Sets the orientation of the gauge. This
* can be one of the ZYZG_ORIENT_?? msgs.
*
- * ZYZG_GETORIENTATION : Gets the current orientation of the
+ * ZYZG_GETORIENTATION : Gets the current orientation of the
* gauge.
*
* ZYZG_SETPOSITION : Sets the current position of the gauge.
return TRUE;
// wxColor <-> RGB
- #define ToRGB(col) RGB(col.Red(), col.Green(), col.Blue())
+ #define ToRGB(col) PALETTERGB(col.Red(), col.Green(), col.Blue())
#define UnRGB(col) GetRValue(col), GetGValue(col), GetBValue(col)
// set the colors
#ifdef __WIN32__
-static DWORD wxExecuteThread(wxExecuteData *data)
+static DWORD __stdcall wxExecuteThread(void *arg)
{
+ wxExecuteData *data = (wxExecuteData*)arg;
+
WaitForSingleObject(data->hProcess, INFINITE);
// get the exit code
DWORD tid;
HANDLE hThread = ::CreateThread(NULL,
0,
- (LPTHREAD_START_ROUTINE)wxExecuteThread,
+ wxExecuteThread,
(void *)data,
0,
&tid);
#ifdef __EMX__
-#include <sys\ioctl.h>
-#include <sys\select.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
#else
#include <nerrno.h>
-#include <ioctl.h>
-#include <select.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/time.h>
-#endif // ndef for __EMX__
+#endif //
#ifndef __EMX__
#define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
-int _System bsdselect(int,
- struct fd_set *,
- struct fd_set *,
- struct fd_set *,
- struct timeval *);
-
+extern "C" int _System bsdselect(int,
+ struct fd_set *,
+ struct fd_set *,
+ struct fd_set *,
+ struct timeval *);
#endif
#if wxUSE_THREADS
HAB vHab
)
{
- APIRET rc;
ERRORID vError = 0L;
wxString sError;
ERRORID vError;
wxString sError;
+ if (!wxAppBase::OnInitGui())
+ return FALSE;
+
m_hMq = ::WinCreateMsgQueue(vHabmain, 0);
if (!m_hMq)
{
wxLogDebug(sError);
return FALSE;
}
+
return TRUE;
} // end of wxApp::OnInitGui
// automated DC cache management: clear the cached DCs and bitmap
// if it's likely that the app has finished with them, that is, we
// get an idle event and we're not dragging anything.
- if (!::WinGetKeyState(MK_LBUTTON) &&
- !::WinGetKeyState(MK_MBUTTON) &&
- !::WinGetKeyState(MK_RBUTTON))
+ if (!::WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) &&
+ !::WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) &&
+ !::WinGetKeyState(HWND_DESKTOP, VK_BUTTON2))
wxDC::ClearCache();
#endif // wxUSE_DC_CACHEING
#else // !wxUSE_DRAG_AND_DROP
*/
return FALSE;
+#else
+ return FALSE;
#endif // wxUSE_DRAG_AND_DROP/!wxUSE_DRAG_AND_DROP
}
#else
*/
return FALSE;
+#else
+ return FALSE;
#endif
}
#include "wx/log.h"
#include "wx/icon.h"
#include "wx/msgdlg.h"
+ #include "wx/module.h"
#endif
#include "wx/dcprint.h"
, int nHeight
)
{
- int nDepth = 24 // we'll fix this later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
+ int nDepth = 24; // we'll fix this later ::GetDeviceCaps((HDC) dc, PLANES) * ::GetDeviceCaps((HDC) dc, BITSPIXEL);
wxNode* pNode = m_svBitmapCache.First();
BITMAPINFOHEADER2 vBmpHdr;
// in wxUniv build we must manually do some DC adjustments usually
// performed by Windows for us
#ifdef __WXUNIVERSAL__
- wxPoint ptOrigin = m_canvas->GetClientAreaOrigin();
+ wxPoint ptOrigin = m_pCanvas->GetClientAreaOrigin();
if ( ptOrigin.x || ptOrigin.y )
{
// no need to shift DC origin if shift is null
}
// clip the DC to avoid overwriting the non client area
- SetClippingRegion(wxPoint(0, 0), m_canvas->GetClientSize());
+ SetClippingRegion(wxPoint(0, 0), m_pCanvas->GetClientSize());
#endif // __WXUNIVERSAL__
} // end of wxClientDC::InitDC
m_isBeingDeleted = TRUE;
wxTopLevelWindows.DeleteObject(this);
Show(FALSE);
- if (!IsModal)
+ if (!IsModal())
wxModelessWindows.DeleteObject(this);
//
#include <sys/types.h>
#define INCL_DOSFILEMGR
+#define INCL_DOSERRORS
#include <os2.h>
#ifdef __EMX__
#include "wx/os2/private.h"
#include "wx/cmndata.h"
-#include <math.h>
#include <stdlib.h>
#include <string.h>
// wxFont
// ----------------------------------------------------------------------------
+wxFont::wxFont(const wxNativeFontInfo& rInfo)
+ {
+ Init();
+
+ (void)Create( rInfo.pointSize
+ ,rInfo.family
+ ,rInfo.style
+ ,rInfo.weight
+ ,rInfo.underlined
+ ,rInfo.faceName
+ ,rInfo.encoding
+ );
+ }
+
+
void wxFont::Init()
{
if ( wxTheFontList )
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxUSE_FONTMAP
+
#ifndef WX_PRECOMP
#include "wx/font.h"
#endif
}
*/
+#endif // wxUSE_FONTMAP
,&vInfo
))
{
- if ( !wxTheFontMapper->GetAltForEncoding( vEncoding
- ,&vInfo
- ))
+#if wxUSE_FONTMAP
+ if (!wxTheFontMapper->GetAltForEncoding(vEncoding, &vInfo))
+#endif // wxUSE_FONTMAP
{
//
// Unsupported encoding, replace with the default
extern wxWindowList wxModelessWindows;
extern wxList WXDLLEXPORT wxPendingDelete;
extern wxChar wxFrameClassName[];
+
+#if wxUSE_MENUS_NATIVE
extern wxMenu *wxCurrentPopupMenu;
+#endif
-extern void wxAssociateWinWithHandle( HWND hWnd
- ,wxWindow* pWin
+extern void wxAssociateWinWithHandle( HWND hWnd
+ ,wxWindowOS2* pWin
);
// ----------------------------------------------------------------------------
} // end of wxFrameOS2::PositionStatusBar
#endif // wxUSE_STATUSBAR
+#if wxUSE_MENUS_NATIVE
void wxFrameOS2::DetachMenuBar()
{
if (m_frameMenuBar)
wxMenuBar* pMenubar
)
{
+ wxFrameBase::AttachMenuBar(pMenubar);
+
m_frameMenuBar = pMenubar;
if (!pMenubar)
}
::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
} // end of wxFrameOS2::InternalSetMenuBar
+#endif // wxUSE_MENUS_NATIVE
//
// Responds to colour changes, and passes event on to children
m_lFsStyle = lStyle;
#if wxUSE_TOOLBAR
- wxToolBar* pTheToolBar = GetToolBar();
+ wxToolBar* pTheToolBar = GetToolBar();
#endif //wxUSE_TOOLBAR
#if wxUSE_STATUSBAR
- wxStatusBar* pTheStatusBar = GetStatusBar();
+ wxStatusBar* pTheStatusBar = GetStatusBar();
#endif //wxUSE_STATUSBAR
int nDummyWidth;
//
wxMenuBar* pMenuBar = GetMenuBar();
- if (!pMenuBar )
+ if (!pMenuBar)
return FALSE;
-#if wxUSE_ACCEL
+#if wxUSE_ACCEL && wxUSE_MENUS_NATIVE
const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
return rAcceleratorTable.Translate(GetHWND(), pMsg);
#else
//
if (nCmd == CMDSRC_MENU || nCmd == CMDSRC_ACCELERATOR)
{
+#if wxUSE_MENUS_NATIVE
if (wxCurrentPopupMenu)
{
wxMenu* pPopupMenu = wxCurrentPopupMenu;
return pPopupMenu->OS2Command( nCmd
,nId
);
+ return TRUE;
}
+#endif
if (ProcessCommand(nId))
{
AddHandler(new wxBMPResourceHandler);
AddHandler(new wxBMPFileHandler);
+#if wxUSE_XPM_IN_OS2
AddHandler(new wxXPMFileHandler);
AddHandler(new wxXPMDataHandler);
+#endif
AddHandler(new wxICOResourceHandler);
AddHandler(new wxICOFileHandler);
#define BSD_SELECT /* use Berkley Sockets select */
#include <assert.h>
-#include <sys\types.h>
+#include <sys/types.h>
#ifdef __EMX__
#include <sys/time.h>
#else
-#include <utils.h>
-#include <sys\time.h>
+#include <string.h>
+
+#include <sys/time.h>
#include <types.h>
-#include <in.h>
+#include <netinet/in.h>
#include <netdb.h>
#include <nerrno.h>
#if defined(__VISAGECPP__) && __IBMCPP__ < 400
-#include <machine\endian.h>
+#include <machine/endian.h>
#include <socket.h>
#include <ioctl.h>
#include <select.h>
#else
-#include <sys\socket.h>
-#include <sys\ioctl.h>
-#include <sys\select.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
#ifdef __EMX__
#define soclose(a) close(a)
#endif
#endif
-#include <string.h>
#include <stdio.h>
#if (defined(__VISAGECPP__) && __IBMCPP__ < 400) || defined(__EMX__)
# ifdef min
#endif
#include <stddef.h>
#include <ctype.h>
+#include <stdlib.h>
#include <signal.h>
return GSOCK_IOERR;
}
- ioctl(sck->m_fd, FIONBIO, &arg);
+ ioctl(sck->m_fd, FIONBIO, (char*)&arg, sizeof(arg));
_GSocket_Enable_Events(sck);
/* Bind to the local address,
return NULL;
}
- ioctl(connection->m_fd, FIONBIO, &arg);
+ ioctl(connection->m_fd, FIONBIO, (char*)&arg, sizeof(arg));
_GSocket_Enable_Events(connection);
return connection;
return GSOCK_IOERR;
}
- ioctl(sck->m_fd, FIONBIO, &arg);
+ ioctl(sck->m_fd, FIONBIO, (char*)&arg, sizeof(arg));
_GSocket_Enable_Events(sck);
/* Connect it to the peer address, with a timeout (see below) */
ret = connect(sck->m_fd, sck->m_peer->m_addr, sck->m_peer->m_len);
printf("connect on %d to %X (%d) returned %d, errno = %d\n",
- sck->m_fd, sck->m_peer->m_addr, sck->m_peer->m_len, ret, errno);
+ sck->m_fd, sck->m_peer->m_addr, sck->m_peer->m_len, ret, errno);
if (ret == -1)
{
err = errno;
return GSOCK_IOERR;
}
- ioctl(sck->m_fd, FIONBIO, &arg);
+ ioctl(sck->m_fd, FIONBIO, (char*)&arg, sizeof(arg));
_GSocket_Enable_Events(sck);
/* Bind to the local address,
if ((flags & (1 << count)) != 0)
{
printf("Setting callback no %d for socket at %X to address %X,data %X\n",
- count, socket, callback, cdata);
+ count, socket, callback, cdata);
socket->m_cbacks[count] = callback;
socket->m_data[count] = cdata;
}
if ((flags & (1 << count)) != 0)
{
printf("Removing callback no %d for socket at %X",
- count, socket);
+ count, socket);
socket->m_cbacks[count] = NULL;
socket->m_data[count] = NULL;
}
ret = send(socket->m_fd, buffer, size, 0);
UNMASK_SIGNAL();
#else
- ret = send(socket->m_fd, buffer, size, 0);
+ ret = send(socket->m_fd, (char *)buffer, size, 0);
#endif
return ret;
}
ret = sendto(socket->m_fd, buffer, size, 0, addr, len);
UNMASK_SIGNAL();
#else
- ret = sendto(socket->m_fd, buffer, size, 0, addr, len);
+ ret = sendto(socket->m_fd, (char *)buffer, size, 0, addr, len);
#endif
/* Frees memory allocated from _GAddress_translate_to */
{
#else
/* Use gethostbyname by default */
- int val = 1; //VA doesn't like constants in conditional expressions at all
- if (val)
+// int val = 1; //VA doesn't like constants in conditional expressions at all
+ if (1)
{
#endif
struct in_addr *array_addr;
# include <fstream>
#endif
+#define INCL_PM
+#include <os2.h>
+
#include "wx/palette.h"
#include "wx/bitmap.h"
#include "wx/utils.h"
-#define INCL_PM
-#include <os2.h>
-
#include "wx/os2/pngread.h"
extern "C" {
-#include "../png/png.h"
+#include "png.h"
}
extern "C" void png_read_init PNGARG((png_structp png_ptr));
// Author: David Webster
// Modified by:
// Created: 10/15/99
-// RCS-ID: $Id$
+// RCS-ID: $Id$
// Copyright: (c) Davdi Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/window.h"
#include "wx/os2/private.h"
- IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
- IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
+ IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
//-----------------------------------------------------------------------------
// wxRegionRefData implementation
wxRegionRefData()
{
m_hRegion = 0;
+ m_hPS = 0;
}
wxRegionRefData(const wxRegionRefData& rData)
} // end of wxRegion::wxRegion
wxRegion::wxRegion(
- WXHRGN hRegion
+ WXHRGN hRegion,
+ WXHDC hPS
)
{
m_refData = new wxRegionRefData;
M_REGION = (HRGN) hRegion;
+ (((wxRegionRefData*)m_refData)->m_hPS) = hPS;
} // end of wxRegion::wxRegion
wxRegion::wxRegion(
if (m_refData)
{
RECTL vRect;
+ APIRET rc;
- ::GpiQueryRegionBox( ((wxRegionRefData*)m_refData)->m_hPS
+ rc = ::GpiQueryRegionBox( ((wxRegionRefData*)m_refData)->m_hPS
,M_REGION
,&vRect
);
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/gdicmn.h"
+#include "wx/module.h"
#endif
#include "wx/settings.h"
#ifndef WX_PRECOMP
#include "wx/textctrl.h"
+ #include "wx/scrolwin.h"
#include "wx/settings.h"
#include "wx/brush.h"
#include "wx/utils.h"
# include <fstream>
#endif
-#if defined(__EMX__) && !defined(MLE_INDEX)
+#if !defined(MLE_INDEX)
#define MLE_INDEX 0
#define MLE_RGB 1
#endif
#include <stdio.h>
#include "wx/module.h"
+#include "wx/intl.h"
+#include "wx/utils.h"
+#include "wx/log.h"
#include "wx/thread.h"
#define INCL_DOSSEMAPHORES
, int nType
)
{
-#ifndef __EMX__
+#if defined(__VISAGECPP__)
long lrc;
// UPM procs return 0 on success
lrc = U32ELOCU((unsigned char*)zBuf, (unsigned long *)&nType);
// Return TRUE if we have a colour display
bool wxColourDisplay()
{
+#if 0
HPS hpsScreen;
HDC hdcScreen;
LONG lColors;
hdcScreen = ::GpiQueryDevice(hpsScreen);
::DevQueryCaps(hdcScreen, CAPS_COLORS, 1L, &lColors);
return(lColors > 1L);
+#else
+ // I don't see how the PM display could not be color. Besides, this
+ // was leaking DCs and PSs!!! MN
+ return true;
+#endif
}
// Returns depth of screen
HDC hdcScreen;
LONG lPlanes;
LONG lBitsPerPixel;
- LONG nDepth;
-
- hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
- hdcScreen = ::GpiQueryDevice(hpsScreen);
- ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes);
- ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitsPerPixel);
-
- nDepth = (int)(lPlanes * lBitsPerPixel);
- DevCloseDC(hdcScreen);
+ static LONG nDepth = 0;
+
+ // The screen colordepth ain't gonna change. No reason to query
+ // it over and over!
+ if (!nDepth) {
+ hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
+ hdcScreen = ::GpiQueryDevice(hpsScreen);
+ ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes);
+ ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitsPerPixel);
+
+ nDepth = (int)(lPlanes * lBitsPerPixel);
+ ::DevCloseDC(hdcScreen);
+ ::WinReleasePS(hpsScreen);
+ }
return (nDepth);
}
{
HPS hpsScreen;
HDC hdcScreen;
- LONG lWidth;
- LONG lHeight;
-
- hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
- hdcScreen = ::GpiQueryDevice(hpsScreen);
- ::DevQueryCaps(hdcScreen, CAPS_WIDTH, 1L, &lWidth);
- ::DevQueryCaps(hdcScreen, CAPS_HEIGHT, 1L, &lHeight);
- DevCloseDC(hdcScreen);
+ static LONG lWidth = 0;
+ static LONG lHeight = 0;
+
+ // The screen size ain't gonna change either so just cache the values
+ if (!lWidth) {
+ hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
+ hdcScreen = ::GpiQueryDevice(hpsScreen);
+ ::DevQueryCaps(hdcScreen, CAPS_WIDTH, 1L, &lWidth);
+ ::DevQueryCaps(hdcScreen, CAPS_HEIGHT, 1L, &lHeight);
+ ::DevCloseDC(hdcScreen);
+ ::WinReleasePS(hpsScreen);
+ }
*pWidth = (int)lWidth;
*pHeight = (int)lHeight;
}
,1L
,(PLONG)pHeight
);
+ ::DevCloseDC(hdcScreen);
+ ::WinReleasePS(hpsScreen);
}
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
#include "wx/listbox.h"
#include "wx/button.h"
#include "wx/msgdlg.h"
+ #include "wx/scrolwin.h"
#include <stdio.h>
#endif
// ---------------------------------------------------------------------------
//
-// The last Windows message we got (MT-UNSAFE)
+// The last PM message we got (MT-UNSAFE)
//
QMSG s_currentMsg;
+#if wxUSE_MENUS_NATIVE
wxMenu* wxCurrentPopupMenu = NULL;
-extern wxList WXDLLEXPORT wxPendingDelete;
+#endif // wxUSE_MENUS_NATIVE
+
#if !defined(__VISAGECPP__) || (__IBMCPP__ < 400)
extern wxChar wxCanvasClassName[];
#endif
const char *wxGetMessageName(int message);
#endif //__WXDEBUG__
-void wxRemoveHandleAssociation(wxWindow* pWin);
-void wxAssociateWinWithHandle( HWND hWnd
- ,wxWindow* pWin
+void wxRemoveHandleAssociation(wxWindowOS2* pWin);
+void wxAssociateWinWithHandle( HWND hWnd
+ ,wxWindowOS2* pWin
);
wxWindow* wxFindWinFromHandle(WXHWND hWnd);
// This magical function is used to translate VK_APPS key presses to right
// mouse clicks
//
+// Unused?
+#if 0
static void TranslateKbdEventToMouse( wxWindow* pWin
,int* pX
,int* pY
,MPARAM* pFlags
);
-
+#endif
//
// get the current state of SHIFT/CTRL keys
//
// event tables
// ---------------------------------------------------------------------------
+// in wxUniv-OS/2 this class is abstract because it doesn't have DoPopupMenu()
+// method
+#ifdef __WXUNIVERSAL__
+ IMPLEMENT_ABSTRACT_CLASS(wxWindowOS2, wxWindowBase)
+#else // __WXPM__
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
+#endif // __WXUNIVERSAL__/__WXPM__
-BEGIN_EVENT_TABLE(wxWindow, wxWindowBase)
+BEGIN_EVENT_TABLE(wxWindowOS2, wxWindowBase)
EVT_ERASE_BACKGROUND(wxWindowOS2::OnEraseBackground)
EVT_SYS_COLOUR_CHANGED(wxWindowOS2::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindowOS2::OnInitDialog)
// implementation
// ===========================================================================
+// ---------------------------------------------------------------------------
+// wxWindow utility functions
+// ---------------------------------------------------------------------------
+
//
// Find an item given the PM Window id
//
long lId
) const
{
- wxControl* pItem = wxDynamicCast( this
- ,wxControl
- );
+#if wxUSE_CONTROLS
+ wxControl* pItem = wxDynamicCast(this, wxControl);
if (pItem)
{
//
// I it we or one of our "internal" children?
//
- if (pItem->GetId() == lId ||
- (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND))
+ if (pItem->GetId() == lId
+#ifndef __WXUNIVERSAL__
+ || (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND)
+#endif
+ )
{
return pItem;
}
}
+#endif // wxUSE_CONTROLS
wxWindowList::Node* pCurrent = GetChildren().GetFirst();
if (pWnd)
return(pWnd);
- if (!bControlOnly || pParent->IsKindOf(CLASSINFO(wxControl)))
+ if (!bControlOnly
+#if wxUSE_CONTROLS
+ || pParent->IsKindOf(CLASSINFO(wxControl))
+#endif // wxUSE_CONTROLS
+ )
{
wxWindow* pItem = pCurrent->GetData();
pFrame->SetLastFocus((wxWindow*)NULL);
}
}
+
+ DestroyChildren();
+
if (m_parent)
m_parent->RemoveChild(this);
- DestroyChildren();
if (m_hWnd)
{
}
} // end of wxWindowOS2::~wxWindowOS2
+// real construction (Init() must have been called before!)
bool wxWindowOS2::Create(
wxWindow* pParent
, wxWindowID vId
{
HWND hParent = NULLHANDLE;
wxPoint vPos = rPos; // The OS/2 position
- ULONG ulCreateFlags = 0L;
+ ULONG ulCreateFlags = 0;
+ WXDWORD dwExStyle = 0;
wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
ulCreateFlags |= WS_VISIBLE;
+#ifdef __WXUNIVERSAL__
+ // no 3d effects, we draw them ourselves
+ WXDWORD exStyle = 0;
+#else // !wxUniversal
if (lStyle & wxCLIP_SIBLINGS)
ulCreateFlags |= WS_CLIPSIBLINGS;
//
//
bool bWant3D;
- WXDWORD dwExStyle = Determine3DEffects( WS_EX_CLIENTEDGE
- ,&bWant3D
- );
+ dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D);
+
+#endif
//
// Add the simple border style as we'll use this to draw borders
if (lStyle & wxSIMPLE_BORDER)
dwExStyle |= wxSIMPLE_BORDER;
+ if (lStyle & wxPOPUP_WINDOW)
+ {
+ // a popup window floats on top of everything
+//TODO: fix this...
+// exStyle |= WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
+
+ // it is also created hidden as other top level windows
+ ulCreateFlags &= ~WS_VISIBLE;
+ m_isShown = FALSE;
+ }
+
//
// Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
// and no presentation parameters
void wxWindowOS2::SetFocus()
{
HWND hWnd = GetHwnd();
+ wxCHECK_RET( hWnd, _T("can't set focus to invalid window") );
if (hWnd)
::WinSetFocus(HWND_DESKTOP, hWnd);
pChild->Enable(bEnable);
pNode = pNode->GetNext();
}
- return(TRUE);
+ return TRUE;
} // end of wxWindowOS2::Enable
bool wxWindowOS2::Show(
{
::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
}
- return(TRUE);
+ return TRUE;
} // end of wxWindowOS2::Show
void wxWindowOS2::Raise()
wxChar zFont[128];
sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
- return(::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont));
+ return (bool)::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont);
}
return(TRUE);
}
return FALSE;
}
- wxASSERT_MSG( m_cursor.Ok(),
- wxT("cursor must be valid after call to the base version"));
+ if ( m_cursor.Ok() ) {
+ HWND hWnd = GetHwnd();
+ POINTL vPoint;
+ RECTL vRect;
- HWND hWnd = GetHwnd();
- POINTL vPoint;
- RECTL vRect;
- HPS hPS;
- HRGN hRGN;
-
- hPS = ::WinGetPS(hWnd);
-
- ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
- ::WinQueryWindowRect(hWnd, &vRect);
-
- hRGN = ::GpiCreateRegion(hPS, 1L, &vRect);
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
+ ::WinQueryWindowRect(hWnd, &vRect);
- if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy())
- {
- ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
+ if (::WinPtInRect(vHabmain, &vRect, &vPoint) && !wxIsBusy())
+ {
+ ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
+ }
}
return TRUE;
} // end of wxWindowOS2::SetCursor
void wxWindowOS2::SetScrollPos(
int nOrient
, int nPos
-, bool bRefresh
+, bool WXUNUSED(bRefresh)
)
{
if (nOrient == wxHORIZONTAL )
::WinSendMsg(m_hWndScrollBarHorz, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
else
::WinSendMsg(m_hWndScrollBarVert, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
-} // end of wxWindowOS2::SetScrollPos(
+} // end of wxWindowOS2::SetScrollPos
void wxWindowOS2::SetScrollbar(
int nOrient
, int nPos
, int nThumbVisible
, int nRange
-, bool bRefresh
+, bool WXUNUSED(bRefresh)
)
{
int nOldRange = nRange - nThumbVisible;
} // end of wxWindowOS2::SetupColours
void wxWindowOS2::OnIdle(
- wxIdleEvent& rEvent
+ wxIdleEvent& WXUNUSED(rEvent)
)
{
//
void wxWindowOS2::Clear()
{
- wxClientDC vDc(this);
+ wxClientDC vDc((wxWindow*)this);
wxBrush vBrush( GetBackgroundColour()
,wxSOLID
);
// We may be faking the client origin. So a window that's really at (0,
// 30) may appear (to wxWin apps) to be at (0, 0).
//
- wxPoint vPt(pParent->GetClientAreaOrigin());
+ if (pParent) {
+ wxPoint vPt(pParent->GetClientAreaOrigin());
- vPoint.x -= vPt.x;
- vPoint.y -= vPt.y;
+ vPoint.x -= vPt.x;
+ vPoint.y -= vPt.y;
+ }
}
if (pX)
) const
{
HWND hWnd = GetHwnd();
- SWP vSwp;
+ POINTL ptl;
+
+ ptl.x = pX ? *pX : 0;
+ ptl.y = pY ? *pY : 0;
- ::WinQueryWindowPos(hWnd, &vSwp);
+ ::WinMapWindowPoints(HWND_DESKTOP, hWnd, &ptl, 1);
if (pX)
- *pX -= vSwp.x;
+ *pX = ptl.x;
if (pY)
- *pY -= vSwp.y;
+ *pY = ptl.y;
+
} // end of wxWindowOS2::DoScreenToClient
void wxWindowOS2::DoClientToScreen(
) const
{
HWND hWnd = GetHwnd();
- SWP vSwp;
+ POINTL ptl;
- ::WinQueryWindowPos(hWnd, &vSwp);
+ ptl.x = pX ? *pX : 0;
+ ptl.y = pY ? *pY : 0;
+
+ ::WinMapWindowPoints(hWnd, HWND_DESKTOP, &ptl, 1);
if (pX)
- *pX += vSwp.x;
+ *pX = ptl.x;
if (pY)
- *pY += vSwp.y;
+ *pY = ptl.y;
} // end of wxWindowOS2::DoClientToScreen
//
int nCurrentHeight;
wxSize vSize(-1, -1);
- GetPosition( &nCurrentX
- ,&nCurrentY
- );
- GetSize( &nCurrentWidth
- ,&nCurrentHeight
- );
+ GetPosition(&nCurrentX, &nCurrentY);
+ GetSize(&nCurrentWidth, &nCurrentHeight);
- //
// ... and don't do anything (avoiding flicker) if it's already ok
- //
- if ( nX == nCurrentX &&
- nY == nCurrentY &&
- nWidth == nCurrentWidth &&
- nHeight == nCurrentHeight
- )
+ if (nX == nCurrentX && nY == nCurrentY &&
+ nWidth == nCurrentWidth && nHeight == nCurrentHeight)
{
return;
}
if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
nY = nCurrentY;
- AdjustForParentClientOrigin( nX
- ,nY
- ,nSizeFlags
- );
+ AdjustForParentClientOrigin(nX, nY, nSizeFlags);
if (nWidth == -1)
{
{
wxWindow* pParent = GetParent();
HWND hWnd = GetHwnd();
+#if 0
HWND hParentWnd = (HWND)0;
HWND hClientWnd = (HWND)0;
RECTL vRect;
vPoint.x = vRect2.xLeft;
vPoint.y = vRect2.yBottom;
if (pParent)
- {
+ { x
vPoint.x -= vRect3.xLeft;
vPoint.y -= vRect3.yBottom;
}
+#else
+ HWND hParentWnd = (HWND)0;
+ HWND hClientWnd = (HWND)0;
+ RECTL vRect;
+ RECT vRect2;
- DoMoveWindow( vPoint.x
- ,vPoint.y
- ,nActualWidth
- ,nActualHeight
- );
+ hClientWnd = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
+ ::WinQueryWindowRect(hClientWnd, &vRect2);
+ ::WinQueryWindowRect(hWnd, &vRect2);
- wxSizeEvent vEvent( wxSize( nWidth
- ,nHeight
- )
- ,m_windowId
- );
+ if (pParent)
+ hParentWnd = (HWND) pParent->GetHWND();
+ ::WinQueryWindowRect(hWnd, &vRect);
+ //
+ // Find the difference between the entire window (title bar and all)
+ // and the client area; add this to the new client size to move the
+ // window. OS/2 is backward from windows on height
+ //
+ int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
+ int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
+
+ nActualWidth = nWidth;
+ nActualHeight = nHeight;
+ //
+ // If there's a parent, must subtract the parent's bottom left corner
+ // since MoveWindow moves relative to the parent
+ //
+ POINTL vPoint;
+
+ vPoint.x = vRect2.xLeft;
+ vPoint.y = vRect2.yBottom;
+ if (pParent)
+ {
+ ::WinMapWindowPoints(hWnd, hParentWnd, &vPoint, 1);
+ }
+#endif
+
+ DoMoveWindow(vPoint.x, vPoint.y, nActualWidth, nActualHeight);
+
+ wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::DoSetClientSize
{
HPS hPs;
FONTMETRICS vFontMetrics;
- BOOL bRc;
hPs = ::WinGetPS(GetHwnd());
HPS hPs;
hPs = ::WinGetPS(GetHwnd());
+
+ // Just prevent compiler warnings
+ wxString dummy = rString;
+ pX = pX;
+ pY = pY;
+ pDescent = pDescent;
+ pExternalLeading = pExternalLeading;
/*
// TODO: Will have to play with fonts later
// ---------------------------------------------------------------------------
// popup menu
// ---------------------------------------------------------------------------
-
+//
+#if wxUSE_MENUS_NATIVE
static void wxYieldForCommandsOnly()
{
//
//
QMSG vMsg;
- while (::WinPeekMsg( vHabmain
- ,&vMsg
- ,(HWND)0
- ,WM_COMMAND
- ,WM_COMMAND
- ,PM_REMOVE
- ) && vMsg.msg != WM_QUIT)
+ while (::WinPeekMsg(vHabmain, &vMsg, (HWND)0, WM_COMMAND,
+ WM_COMMAND,PM_REMOVE) && vMsg.msg != WM_QUIT)
{
wxTheApp->DoMessage((WXMSG*)&vMsg);
}
}
+#endif // wxUSE_MENUS_NATIVE
+#if wxUSE_MENUS_NATIVE
bool wxWindowOS2::DoPopupMenu(
wxMenu* pMenu
, int nX
,PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2 | PU_KEYBOARD
);
// we need to do it righ now as otherwise the events are never going to be
- // sent to wxCurrentPopupMenu from HandleCommand()
+ // sent to wxCurrentPopupMenu from ;()
//
// note that even eliminating (ugly) wxCurrentPopupMenu global wouldn't
// help and we'd still need wxYieldForCommandsOnly() as the menu may be
pMenu->SetInvokingWindow(NULL);
return TRUE;
} // end of wxWindowOS2::DoPopupMenu
+#endif // wxUSE_MENUS_NATIVE
// ===========================================================================
// pre/post message processing
)
{
if (m_fnOldWndProc)
- return (MRESULT)m_fnOldWndProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
+ return (MRESULT)m_fnOldWndProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
else
- return ::WinDefWindowProc(GetHWND(), (ULONG)uMsg, (MPARAM)wParam, (MPARAM)lParam);
+ return ::WinDefWindowProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
} // end of wxWindowOS2::OS2DefWindowProc
bool wxWindowOS2::OS2ProcessMessage(
WXMSG* pMsg
)
{
+// wxUniversal implements tab traversal itself
+#ifndef __WXUNIVERSAL__
QMSG* pQMsg = (QMSG*)pMsg;
if (m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL))
if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
return TRUE;
}
+#else
+ pMsg = pMsg; // just shut up the compiler
+#endif // __WXUNIVERSAL__
#if wxUSE_TOOLTIPS
if ( m_tooltip )
WXMSG* pMsg
)
{
-#if wxUSE_ACCEL
+#if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
return m_acceleratorTable.Translate(m_hWnd, pMsg);
#else
+ pMsg = pMsg;
return FALSE;
#endif //wxUSE_ACCEL
} // end of wxWindowOS2::OS2TranslateMessage
// Hook for new window just as it's being created, when the window isn't yet
// associated with the handle
//
-wxWindow* wxWndHook = NULL;
+wxWindowOS2* wxWndHook = NULL;
//
// Main window proc
wxGetMessageName(ulMsg), wParam, lParam);
#endif // __WXDEBUG__
- wxWindow* pWnd = wxFindWinFromHandle((WXHWND)hWnd);
+ wxWindowOS2* pWnd = wxFindWinFromHandle((WXHWND)hWnd);
//
// When we get the first message for the HWND we just created, we associate
// Did we process the uMsg?
//
bool bProcessed = FALSE;
- bool bAllow;
MRESULT mResult;
- WXHICON hIcon;
- WXHBRUSH hBrush;
//
// For most messages we should return 0 when we do process the message
if (uKeyFlags & KC_KEYUP)
{
- bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
+ //TODO: check if the cast to WXWORD isn't causing trouble
+ bProcessed = HandleKeyUp((WXWORD)wParam, lParam);
break;
}
else // keydown event
// return 0 now (we've handled it). DON't RETURN
// we still need to process further
//
- HandleKeyDown((WXDWORD)wParam, lParam);
+ HandleKeyDown((WXWORD)wParam, lParam);
if (uKeyFlags & KC_VIRTUALKEY)
{
USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
case VK_DOWN:
case VK_UP:
default:
- bProcessed = HandleChar((WXDWORD)wParam, lParam);
+ bProcessed = HandleChar((WXWORD)wParam, lParam);
}
break;
}
else // WM_CHAR -- Always an ASCII character
{
- bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
+ bProcessed = HandleChar((WXWORD)wParam, lParam, TRUE);
break;
}
}
// Dialog window proc
//
MRESULT wxDlgProc(
- HWND hWnd
+ HWND WXUNUSED(hWnd)
, UINT uMsg
-, MPARAM wParam
-, MPARAM lParam)
+, MPARAM WXUNUSED(wParam)
+, MPARAM WXUNUSED(lParam))
{
if (uMsg == WM_INITDLG)
{
void wxAssociateWinWithHandle(
HWND hWnd
-, wxWindow* pWin
+, wxWindowOS2* pWin
)
{
//
} // end of wxAssociateWinWithHandle
void wxRemoveHandleAssociation(
- wxWindow* pWin
+ wxWindowOS2* pWin
)
{
wxWinHandleList->DeleteObject(pWin);
void wxWindowOS2::OS2DetachWindowMenu()
{
+#ifndef __WXUNIVERSAL__
if (m_hMenu)
{
HMENU hMenu = (HMENU)m_hMenu;
}
}
}
+#endif // __WXUNIVERSAL__
} // end of wxWindowOS2::OS2DetachWindowMenu
bool wxWindowOS2::OS2Create(
, long lWidth
, long lHeight
, WXHWND hOwner
-, WXHWND hZOrder
+, WXHWND WXUNUSED(hZOrder)
, unsigned long ulId
, void* pCtlData
, void* pPresParams
// Find parent's size, if it exists, to set up a possible default
// panel size the size of the parent window
//
- RECTL vParentRect;
- HWND hWndClient;
-
lX1 = lX;
lY1 = lY;
if (lWidth > -1L)
}
}
+ HWND parent;
+ if ( GetWindowStyleFlag() & wxPOPUP_WINDOW )
+ {
+ // popup windows should have desktop as parent because they shouldn't
+ // be limited to the parents client area as child windows usually are
+ parent = HWND_DESKTOP;
+ }
+ else if ( hParent )
+ {
+ parent = hParent;
+ }
+ else
+ {
+ // top level window
+ parent = NULL;
+ }
+
//
// We will either have a registered class via string name or a standard PM Class via a long
//
- m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
- ,zClass
- ,(PSZ)zTitle ? zTitle : wxT("")
- ,(ULONG)dwStyle
- ,(LONG)lX1
- ,(LONG)lY1
- ,(LONG)lWidth
- ,(LONG)lHeight
- ,hOwner
- ,HWND_TOP
- ,(ULONG)nControlId
- ,pCtlData
- ,pPresParams
- );
+ m_hWnd = (WXHWND)::WinCreateWindow(parent, zClass,
+ (PSZ)zTitle ? zTitle : wxT(""),
+ dwStyle, lX1, lY1, lWidth, lHeight,
+ hOwner, HWND_TOP, (ULONG)nControlId,
+ pCtlData, pPresParams);
+
if (!m_hWnd)
{
vError = ::WinGetLastError(vHabmain);
// ---------------------------------------------------------------------------
bool wxWindowOS2::HandleCreate(
- WXLPCREATESTRUCT vCs
+ WXLPCREATESTRUCT WXUNUSED(vCs)
, bool* pbMayCreate
)
{
- wxWindowCreateEvent vEvent(this);
+ wxWindowCreateEvent vEvent((wxWindow*)this);
(void)GetEventHandler()->ProcessEvent(vEvent);
*pbMayCreate = TRUE;
bool wxWindowOS2::HandleDestroy()
{
- wxWindowDestroyEvent vEvent(this);
+ wxWindowDestroyEvent vEvent((wxWindow*)this);
(void)GetEventHandler()->ProcessEvent(vEvent);
bool wxWindowOS2::HandleShow(
bool bShow
-, int nStatus
+, int WXUNUSED(nStatus)
)
{
- wxShowEvent vEvent( GetId()
- ,bShow
- );
+ wxShowEvent vEvent(GetId(), bShow);
vEvent.m_eventObject = this;
return GetEventHandler()->ProcessEvent(vEvent);
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleInitDialog
-bool wxWindowOS2::HandleEndDrag(WXWPARAM wParam)
+bool wxWindowOS2::HandleEndDrag(WXWPARAM WXUNUSED(wParam))
{
// TODO: We'll handle drag and drop later
return FALSE;
}
bool wxWindowOS2::HandleSetCursor(
- USHORT vId
+ USHORT WXUNUSED(vId)
, WXHWND hPointer
)
{
, WXDRAWITEMSTRUCT* pItemStruct
)
{
+#if wxUSE_OWNER_DRAWN
wxDC vDc;
-#if wxUSE_OWNER_DRAWN
+#if wxUSE_MENUS_NATIVE
//
// Is it a menu item?
//
// otherwise, we'd have to do it ourselves.
//
}
+#endif // wxUSE_MENUS_NATIVE
wxWindow* pItem = FindItem(vId);
{
return ((wxControl *)pItem)->OS2OnDraw(pItemStruct);
}
+#else
+ vId = vId;
+ pItemStruct = pItemStruct;
#endif
return FALSE;
} // end of wxWindowOS2::OS2OnDrawItem
, WXMEASUREITEMSTRUCT* pItemStruct
)
{
+#if wxUSE_OWNER_DRAWN
//
// Is it a menu item?
//
{
return ((wxControl *)pItem)->OS2OnMeasure(pItemStruct);
}
+#else
+ lId = lId;
+ pItemStruct = pItemStruct;
+#endif // wxUSE_OWNER_DRAWN
return FALSE;
}
} // end of wxWindowOS2::HandleSysColorChange
bool wxWindowOS2::HandleCtlColor(
- WXHBRUSH* phBrush
+ WXHBRUSH* WXUNUSED(phBrush)
)
{
//
} // end of wxWindowOS2::HandleCtlColor
bool wxWindowOS2::HandleWindowParams(
- PWNDPARAMS pWndParams
-, WXLPARAM lParam
+ PWNDPARAMS WXUNUSED(pWndParams)
+, WXLPARAM WXUNUSED(lParam)
)
{
// TODO: I'll do something here, just not sure what yet
}
// Define for each class of dialog and control
-WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC hDC,
- WXHWND hWnd,
- WXUINT nCtlColor,
- WXUINT message,
- WXWPARAM wParam,
- WXLPARAM lParam)
+WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC),
+ WXHWND WXUNUSED(hWnd),
+ WXUINT WXUNUSED(nCtlColor),
+ WXUINT WXUNUSED(message),
+ WXWPARAM WXUNUSED(wParam),
+ WXLPARAM WXUNUSED(lParam))
{
return (WXHBRUSH)0;
}
} // end of wxWindowOS2::HandlePaletteChanged
bool wxWindowOS2::HandlePresParamChanged(
- WXWPARAM wParam
+ WXWPARAM WXUNUSED(wParam)
)
{
//
bool wxWindowOS2::HandlePaint()
{
- HRGN hRgn = NULLHANDLE;
- wxPaintEvent vEvent;
+ HRGN hRgn;
+ wxPaintEvent vEvent(m_windowId);
HPS hPS;
RECTL vRect;
+ bool bProcessed;
+
+ // Create empty region
+ // TODO: get HPS somewhere else if possible
+ hPS = ::WinGetPS(GetHwnd());
+ hRgn = ::GpiCreateRegion(hPS, 0, NULL);
- if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_NULL)
+ if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_ERROR)
{
wxLogLastError("CreateRectRgn");
return FALSE;
}
- m_updateRegion = wxRegion(hRgn);
+ m_updateRegion = wxRegion(hRgn, hPS);
+
vEvent.SetEventObject(this);
- if (!GetEventHandler()->ProcessEvent(vEvent))
+ bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+
+ if (!bProcessed)
{
HPS hPS;
);
if(hPS)
{
+#if 0
::GpiCreateLogColorTable( hPS
,0L
,LCOLF_CONSECRGB
,(LONG)wxTheColourDatabase->m_nSize
,(PLONG)wxTheColourDatabase->m_palTable
);
+#endif
::GpiCreateLogColorTable( hPS
,0L
,LCOLF_RGB
::WinEndPaint(hPS);
}
}
- return (GetEventHandler()->ProcessEvent(vEvent));
+
+ ::GpiDestroyRegion(hPS, hRgn);
+ ::WinReleasePS(hPS);
+
+ return GetEventHandler()->ProcessEvent(vEvent); //bProcessed;
} // end of wxWindowOS2::HandlePaint
bool wxWindowOS2::HandleEraseBkgnd(
)
{
SWP vSwp;
+ bool rc;
::WinQueryWindowPos(GetHwnd(), &vSwp);
if (vSwp.fl & SWP_MINIMIZE)
wxDC vDC;
vDC.m_hPS = (HPS)hDC; // this is really a PS
- vDC.SetWindow(this);
+ vDC.SetWindow((wxWindow*)this);
vDC.BeginDrawing();
wxEraseEvent vEvent(m_windowId, &vDC);
vEvent.SetEventObject(this);
- bool rc = GetEventHandler()->ProcessEvent(vEvent);
+ rc = GetEventHandler()->ProcessEvent(vEvent);
vDC.EndDrawing();
vDC.m_hPS = NULLHANDLE;
{
RECTL vRect;
HPS hPS = rEvent.m_dc->m_hPS;
+ APIRET rc;
+ LONG lColor = m_backgroundColour.GetPixel();
- ::WinQueryWindowRect(GetHwnd(), &vRect);
- ::WinFillRect(hPS, &vRect, m_backgroundColour.GetPixel());
+ rc = ::WinQueryWindowRect(GetHwnd(), &vRect);
+ rc = ::WinFillRect(hPS, &vRect, lColor);
} // end of wxWindowOS2::OnEraseBackground
// ---------------------------------------------------------------------------
, int nY
)
{
- wxMoveEvent vEvent( wxPoint( nX
- ,nY
- )
- ,m_windowId
- );
+ wxMoveEvent vEvent(wxPoint(nX, nY), m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
, WXUINT WXUNUSED(nFlag)
)
{
- wxSizeEvent vEvent( wxSize( nWidth
- ,nHeight
- )
- ,m_windowId
- );
+ wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
, WXHWND hControl
)
{
+#if wxUSE_MENUS_NATIVE
if (wxCurrentPopupMenu)
{
wxMenu* pPopupMenu = wxCurrentPopupMenu;
wxCurrentPopupMenu = NULL;
return pPopupMenu->OS2Command(wCmd, wId);
}
+#endif // wxUSE_MENUS_NATIVE
wxWindow* pWin = FindItem(wId);
}
if (pWin)
- return pWin->OS2Command( wCmd
- ,wId
- );
+ return pWin->OS2Command(wCmd, wId);
+
return FALSE;
} // end of wxWindowOS2::HandleCommand
bool wxWindowOS2::HandleSysCommand(
WXWPARAM wParam
-, WXLPARAM lParam
+, WXLPARAM WXUNUSED(lParam)
)
{
//
// ---------------------------------------------------------------------------
// mouse events
// ---------------------------------------------------------------------------
-
+//TODO!!! check against MSW
void wxWindowOS2::InitMouseEvent(
wxMouseEvent& rEvent
, int nX
// ===========================================================================
void wxGetCharSize(
- WXHWND hWnd
-, int* pX
-, int* pY
-,wxFont* pTheFont
+ WXHWND WXUNUSED(hWnd)
+, int* WXUNUSED(pX)
+, int* WXUNUSED(pY)
+,wxFont* WXUNUSED(pTheFont)
)
{
// TODO: we'll do this later
#endif // __WXDEBUG__
+// Unused?
+#if 0
static void TranslateKbdEventToMouse(
wxWindow* pWin
, int* pX
pWin->ScreenToClient(pX, pY);
} // end of TranslateKbdEventToMouse
+#endif
// Find the wxWindow at the current mouse position, returning the mouse
// position.
wxWindow* wxFindWindowAtPointer(
- wxPoint& rPt
+ wxPoint& WXUNUSED(rPt)
)
{
return wxFindWindowAtPoint(wxGetMousePosition());
#if wxUSE_XPM_IN_OS2
#define FOR_MSW 1
- #include "../xpm/xpm.h"
+ #include "xpm.h"
#endif
#include "wx/xpmhand.h"
// the menubar is positioned above the client size, hence the negative
// y coord
wxCoord heightMbar = m_frameMenuBar->GetSize().y;
- m_frameMenuBar->SetSize(0, -heightMbar,
+ m_frameMenuBar->SetSize(0,
+#ifdef __WXPM__
+ GetClientSize().y - heightMbar,
+#else
+ -heightMbar,
+#endif
GetClientSize().x, heightMbar);
}
}
{
wxPoint pt = wxFrameBase::GetClientAreaOrigin();
-#if wxUSE_MENUS
+#if wxUSE_MENUS && !defined(__WXPM__)
if ( m_frameMenuBar )
{
pt.y += m_frameMenuBar->GetSize().y;
};
void (wxRenderer::*pfn)(wxDC&, wxDirection, const wxRect&, int) =
- scrollbarLike ? &wxRenderer::DrawScrollbarArrow
- : &wxRenderer::DrawArrow;
+ scrollbarLike ? wxRenderer::DrawScrollbarArrow
+ : wxRenderer::DrawArrow;
(m_control->GetRenderer()->*pfn)
(
nameDefTheme = _T("gtk");
#elif defined(__WXMGL__)
nameDefTheme = _T("win32");
+ #elif defined(__WXPM__)
+ nameDefTheme = _T("win32");
#endif
}
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowGTK)
#elif defined(__WXMGL__)
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowMGL)
+#elif defined(__WXPM__)
+ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowOS2)
#endif
BEGIN_EVENT_TABLE(wxWindow, wxWindowNative)