image update

listbox fix
  iODBC fixes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1378 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-01-12 17:53:45 +00:00
parent 4a1acb45b0
commit f6fcbb63d0
19 changed files with 304 additions and 144 deletions

View File

@@ -42,11 +42,11 @@ and forth without loss in that respect.
Creates an image with the given width and height.
\func{}{wxImage}{\param{const wxString\& }{name}, \param{long}{ type = wxIMAGE\_TYPE\_PNG}}
\func{}{wxImage}{\param{const wxString\& }{name}, \param{long}{ type = wxBITMAP\_TYPE\_PNG}}
Loads an image from a file.
\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxIMAGE\_TYPE\_PNG}}
\func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxBITMAP\_TYPE\_PNG}}
Loads an image from an input stream.
@@ -64,8 +64,8 @@ Loads an image from an input stream.
\twocolwidtha{5cm}
\begin{twocollist}
\twocolitem{{\bf \indexit{wxIMAGE\_TYPE\_BMP}}}{Load a Windows bitmap file.}
\twocolitem{{\bf \indexit{wxIMAGE\_TYPE\_PNG}}}{Load a PNG bitmap file.}
\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_BMP}}}{Load a Windows bitmap file.}
\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_PNG}}}{Load a PNG bitmap file.}
\end{twocollist}
The validity of these flags depends on the platform and wxWindows configuration.
@@ -111,10 +111,9 @@ This function is called by wxWindows on exit.
Converts the image to a platform-specific bitmap object. This has to be done
to actually display an image as you cannot draw an image directly on a window.
The resulting bitmap will use the colour depth of the current system which entails
that a (crude) colour reduction has to take place. Especially when converting
to 8-bit (or even less) bitmaps, the routine is slow and will reduce the
quality of the resulting bitmap. A proper set of colour reduction methods has
not yet been written.
that a (crude) colour reduction has to take place. When in 8-bit mode, this
routine will use a color cube created on program start-up to look up colors.
Still, the image quality won't be perfect for photo images.
\membersection{wxImage::Create}\label{wximagecreate}
@@ -156,7 +155,7 @@ Finds the handler associated with the given image type.
\docparam{extension}{The file extension, such as ``bmp".}
\docparam{imageType}{The image type, such as wxIMAGE\_TYPE\_BMP.}
\docparam{imageType}{The image type, such as wxBITMAP\_TYPE\_BMP.}
\wxheading{Return value}
@@ -291,8 +290,8 @@ The meaning of {\it stream} data is determined by the {\it type} parameter.}
\twocolwidtha{5cm}
\begin{twocollist}
\twocolitem{{\bf wxIMAGE\_TYPE\_BMP}}{Load a Windows image file.}
\twocolitem{{\bf wxIMAGE\_TYPE\_PNG}}{Load a PNG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.}
\end{twocollist}
The validity of these flags depends on the platform and wxWindows configuration.}
@@ -348,7 +347,7 @@ Saves a image in the given stream.
\twocolwidtha{5cm}
\begin{twocollist}
\twocolitem{{\bf wxIMAGE\_TYPE\_PNG}}{Save a PNG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
\end{twocollist}
The validity of these flags depends on the platform and wxWindows configuration

View File

@@ -117,15 +117,16 @@ class wxApp: public wxEvtHandler
bool ProcessIdle();
void DeletePendingObjects();
bool m_initialized;
bool m_exitOnFrameDelete;
bool m_wantDebugOutput;
wxWindow *m_topWindow;
bool m_initialized;
bool m_exitOnFrameDelete;
bool m_wantDebugOutput;
wxWindow *m_topWindow;
gint m_idleTag;
gint m_idleTag;
unsigned char *m_colorCube;
int argc;
char **argv;
int argc;
char **argv;
static wxAppInitializerFunction m_appInitFn;

View File

@@ -117,15 +117,16 @@ class wxApp: public wxEvtHandler
bool ProcessIdle();
void DeletePendingObjects();
bool m_initialized;
bool m_exitOnFrameDelete;
bool m_wantDebugOutput;
wxWindow *m_topWindow;
bool m_initialized;
bool m_exitOnFrameDelete;
bool m_wantDebugOutput;
wxWindow *m_topWindow;
gint m_idleTag;
gint m_idleTag;
unsigned char *m_colorCube;
int argc;
char **argv;
int argc;
char **argv;
static wxAppInitializerFunction m_appInitFn;

View File

@@ -478,6 +478,11 @@ bool Ccontact::FetchByName(char *name)
* An instance of Ccontact is created - "Contact" - which is used to hold the Ccontact
* object that is currently being worked with.
*/
BEGIN_EVENT_TABLE(CeditorDlg, wxPanel)
EVT_BUTTON(-1, CeditorDlg::OnButton)
END_EVENT_TABLE()
CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
{
// Since the ::OnCommand() function is overridden, this prevents the widget
@@ -616,8 +621,12 @@ CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 1, 1, 460, 455)
//
// The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s"
// to achieve a single row (in this case the first name in alphabetical order).
Contact->whereStr.Printf("NAME = 'Robert'",Contact->tableName);
/*
Contact->whereStr.Printf("NAME = (SELECT MIN(NAME) FROM %s)",Contact->tableName);
*/
// NOTE: (const char*) returns a pointer which may not be valid later, so this is short term use only
Contact->where = (char*) (const char*) Contact->whereStr;
@@ -665,6 +674,12 @@ bool CeditorDlg::OnClose()
} // CeditorDlg::OnClose()
void CeditorDlg::OnButton( wxCommandEvent &event )
{
wxWindow *win = (wxWindow*) event.GetEventObject();
OnCommand( *win, event );
}
void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString widgetName;
@@ -771,10 +786,12 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
}
// Previous record not available, retrieve first record in table
Contact->whereStr = "NAME = 'Robert' ";
/*
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += Contact->tableName;
Contact->whereStr += ")";
*/
Contact->where = (char*) (const char*) Contact->whereStr;
if (!Contact->Query())
{
@@ -825,8 +842,10 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
if (strcmp(qryWhere, (const char*) Contact->qryWhereStr))
{
Contact->orderBy = "NAME";
/*
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += CONTACT_TABLE_NAME;
*/
// Append the query where string (if there is one)
Contact->qryWhereStr = qryWhere;
if (strlen(qryWhere))
@@ -866,9 +885,12 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
// Query the first record in the table
Contact->orderBy = "NAME";
Contact->whereStr = "NAME = 'Robert' ";
/*
Contact->whereStr = "NAME = (SELECT MIN(NAME) FROM ";
Contact->whereStr += CONTACT_TABLE_NAME;
Contact->whereStr += ")";
*/
Contact->where = (char*) (const char*) Contact->whereStr;
if (!Contact->Query())
{
@@ -1188,7 +1210,10 @@ bool CeditorDlg::GetNextRec()
{
wxString w;
/*
w = "NAME = (SELECT MIN(NAME) FROM ";
*/
w = "NAME = (SELECT NAME FROM ";
w += Contact->tableName;
w += " WHERE NAME > '";
w += Contact->Name;
@@ -1203,7 +1228,6 @@ bool CeditorDlg::GetNextRec()
}
w += ")";
return(GetRec((char*) (const char*) w));
} // CeditorDlg::GetNextRec()
@@ -1458,6 +1482,10 @@ void CparameterDlg::FillDataSourceList()
} // CparameterDlg::CparameterDlg::FillDataSourceList()
BEGIN_EVENT_TABLE(CqueryDlg, wxDialog)
EVT_BUTTON(-1, CqueryDlg::OnButton)
END_EVENT_TABLE()
// CqueryDlg() constructor
CqueryDlg::CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereArg) : wxDialog (parent, QUERY_DIALOG, "Query", wxPoint(-1, -1), wxSize(480, 360))
{
@@ -1567,6 +1595,12 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereA
} // CqueryDlg() constructor
void CqueryDlg::OnButton( wxCommandEvent &event )
{
wxWindow *win = (wxWindow*) event.GetEventObject();
OnCommand( *win, event );
}
void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
// Widget pointers won't be set when the dialog is constructed.

View File

@@ -166,6 +166,7 @@ class CeditorDlg : public wxPanel
CeditorDlg(wxWindow *parent);
bool OnClose(void);
void OnButton( wxCommandEvent &event );
void OnCommand(wxWindow& win, wxCommandEvent& event);
void OnActivate(bool) {}; // necessary for hot keys
@@ -177,6 +178,8 @@ class CeditorDlg : public wxPanel
bool GetNextRec();
bool GetPrevRec();
bool GetRec(char *whereStr);
DECLARE_EVENT_TABLE()
}; // CeditorDlg
#define EDITOR_DIALOG 199
@@ -336,6 +339,7 @@ class CqueryDlg : public wxDialog
CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereArg);
void OnButton( wxCommandEvent &event );
void OnCommand(wxWindow& win, wxCommandEvent& event);
bool OnClose();
void OnActivate(bool) {}; // necessary for hot keys
@@ -346,6 +350,7 @@ class CqueryDlg : public wxDialog
void ProcessCountBtn();
bool ValidateWhereClause();
DECLARE_EVENT_TABLE()
}; // CqueryDlg
#define QUERY_DIALOG 300

View File

@@ -108,6 +108,9 @@ MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, c
image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG );
image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG );
image.SetRGB( 0, 0, 250, 0, 0 );
image.SetRGB( 1, 0, 100, 100, 100 );
image.SetRGB( 2, 0, 250, 250, 250 );
my_horse = new wxBitmap( image.ConvertToBitmap() );
image.LoadFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG );

View File

@@ -353,7 +353,7 @@ bool wxTable::query(int queryType, bool forUpdate, bool distinct, char *pSqlStmt
// Make sure the cursor is closed first
if (! CloseCursor(hstmt))
return(FALSE);
// Execute the SQL SELECT statement
if (SQLExecDirect(hstmt, (UCHAR FAR *) (queryType == DB_SELECT_STATEMENT ? pSqlStmt : sqlStmt),
SQL_NTS) != SQL_SUCCESS)
@@ -667,10 +667,16 @@ bool wxTable::CreateTable(void)
* (sqlstate = 42000) rather than an S0002. */
/* PostgreSQL 6.4.0 returns "08S01" or in written form
"ERROR: Relation ... Does Not Exist, Robert Roebling */
"ERROR: Relation ... Does Not Exist", Robert Roebling */
/* MySQL 3.23.33b returns "S1000" or in written form
"ERROR: Unknown table ...", Robert Roebling */
/* This routine is bullshit, Robert Roebling */
pDb->GetNextError(henv, hdbc, hstmt);
if (strcmp(pDb->sqlState, "S0002") &&
strcmp(pDb->sqlState, "S1000") &&
strcmp(pDb->sqlState, "42000") &&
strcmp(pDb->sqlState, "08S01"))
{
@@ -753,6 +759,14 @@ bool wxTable::CreateTable(void)
sprintf(s, "(%d)", colDefs[i].SzDataObj);
strcat(sqlStmt, s);
}
#ifdef __WXGTK__
if (colDefs[i].KeyField)
{
strcat(sqlStmt, " NOT NULL");
}
#endif
needComma = TRUE;
}
// If there is a primary key defined, include it in the create statement
@@ -766,9 +780,15 @@ bool wxTable::CreateTable(void)
}
if (j) // Found a keyfield
{
#ifndef __WXGTK__
/* MySQL goes out on this one. We also declare the relevant key NON NULL above */
strcat(sqlStmt, ",CONSTRAINT ");
strcat(sqlStmt, tableName);
strcat(sqlStmt, "_PIDX PRIMARY KEY (");
#else
strcat(sqlStmt, ", PRIMARY KEY (");
#endif
// List column name(s) of column(s) comprising the primary key
for (i = j = 0; i < noCols; i++)
{
@@ -782,8 +802,8 @@ bool wxTable::CreateTable(void)
strcat(sqlStmt, ")");
}
// Append the closing parentheses for the create table statement
strcat(sqlStmt, ")");
strcat(sqlStmt, ")");
pDb->WriteSqlLog(sqlStmt);
#ifdef _CONSOLE
@@ -830,10 +850,15 @@ bool wxTable::CreateIndex(char * idxName, bool unique, int noIdxCols, CidxDef *p
for (int i = 0; i < noIdxCols; i++)
{
strcat(sqlStmt, pIdxDefs[i].ColName);
/* Postgres doesnt cope with ASC */
#ifndef __WXGTK__
if (pIdxDefs[i].Ascending)
strcat(sqlStmt, " ASC");
else
strcat(sqlStmt, " DESC");
#endif
if ((i + 1) < noIdxCols)
strcat(sqlStmt, ", ");
}

View File

@@ -22,6 +22,7 @@
#include "wx/bitmap.h"
#include "wx/debug.h"
#include "wx/log.h"
#include "wx/app.h"
#ifdef wxUSE_LIBPNG
#include "../png/png.h"
#endif
@@ -1383,21 +1384,29 @@ wxBitmap wxImage::ConvertToBitmap() const
{
case 8:
{
GdkColormap *cmap = gtk_widget_get_default_colormap();
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
int pixel = -1;
if (wxTheApp->m_colorCube)
{
pixel = wxTheApp->m_colorCube
[ ((r & 0xf8) << 7) + ((g & 0xf8) << 2) + ((b & 0xf8) >> 3) ];
}
else
{
GdkColormap *cmap = gtk_widget_get_default_colormap();
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
for (int i = 0; i < cmap->size; i++)
{
int rdiff = (r << 8) - colors[i].red;
int gdiff = (g << 8) - colors[i].green;
int bdiff = (b << 8) - colors[i].blue;
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
for (int i = 0; i < cmap->size; i++)
{
int rdiff = (r << 8) - colors[i].red;
int gdiff = (g << 8) - colors[i].green;
int bdiff = (b << 8) - colors[i].blue;
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { pixel = i; max = sum; }
}
}
gdk_image_put_pixel( data_image, x, y, index );
gdk_image_put_pixel( data_image, x, y, pixel );
break;
}

View File

@@ -161,17 +161,23 @@ wxApp::wxApp()
m_idleTag = 0;
m_topWindow = (wxWindow *) NULL;
m_exitOnFrameDelete = TRUE;
m_colorCube = (unsigned char*) NULL;
wxTheApp = this;
}
wxApp::~wxApp(void)
{
gtk_idle_remove( m_idleTag );
if (m_colorCube) free(m_colorCube);
}
bool wxApp::InitVisual()
{
return TRUE;
/* Nothing to do for 15, 16, 24, 32 bit displays */
GdkVisual *visual = gdk_visual_get_system();
if (visual->depth > 8) return TRUE;
/* this initiates the standard palette as defined by GdkImlib
in the GNOME libraries. it ensures that all GNOME applications
@@ -179,6 +185,7 @@ bool wxApp::InitVisual()
can use several rather graphics-heavy applications at the
same time */
/*
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
for (int i = 0; i < 64; i++)
@@ -193,6 +200,41 @@ bool wxApp::InitVisual()
}
gtk_widget_set_default_colormap( cmap );
*/
/* initialize color cube for 8-bit color reduction dithering */
GdkColormap *cmap = gtk_widget_get_default_colormap();
m_colorCube = (unsigned char*)malloc(32 * 32 * 32);
for (int r = 0; r < 32; r++)
{
for (int g = 0; g < 32; g++)
{
for (int b = 0; b < 32; b++)
{
int rr = (r << 3) | (r >> 2);
int gg = (g << 3) | (g >> 2);
int bb = (b << 3) | (b >> 2);
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
for (int i = 0; i < cmap->size; i++)
{
int rdiff = ((rr << 8) - colors[i].red);
int gdiff = ((gg << 8)- colors[i].green);
int bdiff = ((bb << 8)- colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
m_colorCube[ (r*1024) + (g*32) + b ] = index;
}
}
}
return TRUE;
}

View File

@@ -169,26 +169,26 @@ void wxColour::CalcPixel( GdkColormap *cmap )
if ((M_COLDATA->m_hasPixel) && (M_COLDATA->m_colormap == cmap)) return;
M_COLDATA->FreeColour();
GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap;
if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
for (int i = 0; i < cmap->size; i++)
GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap;
if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
int rdiff = (M_COLDATA->m_color.red - colors[i].red);
int gdiff = (M_COLDATA->m_color.green - colors[i].green);
int bdiff = (M_COLDATA->m_color.blue - colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
M_COLDATA->m_hasPixel = TRUE;
M_COLDATA->m_color.pixel = index;
}
for (int i = 0; i < cmap->size; i++)
{
int rdiff = (M_COLDATA->m_color.red - colors[i].red);
int gdiff = (M_COLDATA->m_color.green - colors[i].green);
int bdiff = (M_COLDATA->m_color.blue - colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
M_COLDATA->m_hasPixel = TRUE;
M_COLDATA->m_color.pixel = index;
}
else
{
M_COLDATA->m_hasPixel = gdk_color_alloc( cmap, &M_COLDATA->m_color );

View File

@@ -239,13 +239,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
}
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(list_item),
"key_press_event",
@@ -306,13 +303,10 @@ void wxListBox::AppendCommon( const wxString &item )
if (m_widgetStyle) ApplyWidgetStyle();
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
}
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(list_item),
"key_press_event",

View File

@@ -161,17 +161,23 @@ wxApp::wxApp()
m_idleTag = 0;
m_topWindow = (wxWindow *) NULL;
m_exitOnFrameDelete = TRUE;
m_colorCube = (unsigned char*) NULL;
wxTheApp = this;
}
wxApp::~wxApp(void)
{
gtk_idle_remove( m_idleTag );
if (m_colorCube) free(m_colorCube);
}
bool wxApp::InitVisual()
{
return TRUE;
/* Nothing to do for 15, 16, 24, 32 bit displays */
GdkVisual *visual = gdk_visual_get_system();
if (visual->depth > 8) return TRUE;
/* this initiates the standard palette as defined by GdkImlib
in the GNOME libraries. it ensures that all GNOME applications
@@ -179,6 +185,7 @@ bool wxApp::InitVisual()
can use several rather graphics-heavy applications at the
same time */
/*
GdkColormap *cmap = gdk_colormap_new( gdk_visual_get_system(), TRUE );
for (int i = 0; i < 64; i++)
@@ -193,6 +200,41 @@ bool wxApp::InitVisual()
}
gtk_widget_set_default_colormap( cmap );
*/
/* initialize color cube for 8-bit color reduction dithering */
GdkColormap *cmap = gtk_widget_get_default_colormap();
m_colorCube = (unsigned char*)malloc(32 * 32 * 32);
for (int r = 0; r < 32; r++)
{
for (int g = 0; g < 32; g++)
{
for (int b = 0; b < 32; b++)
{
int rr = (r << 3) | (r >> 2);
int gg = (g << 3) | (g >> 2);
int bb = (b << 3) | (b >> 2);
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
for (int i = 0; i < cmap->size; i++)
{
int rdiff = ((rr << 8) - colors[i].red);
int gdiff = ((gg << 8)- colors[i].green);
int bdiff = ((bb << 8)- colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
m_colorCube[ (r*1024) + (g*32) + b ] = index;
}
}
}
return TRUE;
}

View File

@@ -169,26 +169,26 @@ void wxColour::CalcPixel( GdkColormap *cmap )
if ((M_COLDATA->m_hasPixel) && (M_COLDATA->m_colormap == cmap)) return;
M_COLDATA->FreeColour();
GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap;
if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
for (int i = 0; i < cmap->size; i++)
GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap;
if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
int rdiff = (M_COLDATA->m_color.red - colors[i].red);
int gdiff = (M_COLDATA->m_color.green - colors[i].green);
int bdiff = (M_COLDATA->m_color.blue - colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
GdkColor *colors = cmap->colors;
int max = 3 * (65536);
int index = -1;
M_COLDATA->m_hasPixel = TRUE;
M_COLDATA->m_color.pixel = index;
}
for (int i = 0; i < cmap->size; i++)
{
int rdiff = (M_COLDATA->m_color.red - colors[i].red);
int gdiff = (M_COLDATA->m_color.green - colors[i].green);
int bdiff = (M_COLDATA->m_color.blue - colors[i].blue);
int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
if (sum < max) { index = i; max = sum; }
}
M_COLDATA->m_hasPixel = TRUE;
M_COLDATA->m_color.pixel = index;
}
else
{
M_COLDATA->m_hasPixel = gdk_color_alloc( cmap, &M_COLDATA->m_color );

View File

@@ -239,13 +239,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
}
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(list_item),
"key_press_event",
@@ -306,13 +303,10 @@ void wxListBox::AppendCommon( const wxString &item )
if (m_widgetStyle) ApplyWidgetStyle();
if (m_hasCheckBoxes)
{
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
}
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(list_item),
"key_press_event",

View File

@@ -7,6 +7,8 @@
# endif
# endif
#define NO_TRACE
# define TRACE_TYPE_APP2DM 1
# define TRACE_TYPE_DM2DRV 2
# define TRACE_TYPE_DRV2DM 3

View File

@@ -122,7 +122,7 @@ getinitfile(char* buf, int size)
int i, j;
char* ptr;
j = STRLEN("/odbc.ini") + 1;
j = STRLEN("/iodbc.ini") + 1;
if( size < j )
{
@@ -130,13 +130,13 @@ getinitfile(char* buf, int size)
}
#ifdef FIX_INI_FILE
sprintf( buf, "%s/odbc.ini", DIR_INI_FILE );
sprintf( buf, "%s/iodbc.ini", DIR_INI_FILE );
#else
# ifdef OS2
*buf = '\0';
if( NULL != getenv("ODBC_INI") )
if( NULL != getenv("IODBC_INI") )
{
strcpy( buf, getenv("ODBC_INI") );
strcpy( buf, getenv("IODBC_INI") );
}
else
{
@@ -151,7 +151,7 @@ getinitfile(char* buf, int size)
}
else
{
strcpy( buf, "odbc.ini" );
strcpy( buf, "iodbc.ini" );
}
}
@@ -166,7 +166,7 @@ getinitfile(char* buf, int size)
return NULL;
}
sprintf( buf + i, "/odbc.ini");
sprintf( buf + i, "/iodbc.ini");
return buf;
# else
@@ -189,8 +189,8 @@ getinitfile(char* buf, int size)
return NULL;
}
sprintf( buf, "%s%s", ptr, "/.odbc.ini");
/* i.e. searching ~/.odbc.ini */
sprintf( buf, "%s%s", ptr, "/.iodbc.ini");
/* i.e. searching ~/.iodbc.ini */
# endif
# endif
#endif

View File

@@ -52,33 +52,12 @@ bool MyApp::OnInit(void)
frame->m_canvas = new TestGLCanvas(frame, -1, wxPoint(0, 0), wxSize(200, 200));
// InitGL();
// Show the frame
frame->Show(TRUE);
return TRUE;
}
void MyApp::InitGL(void)
{
/* set viewing projection */
glMatrixMode(GL_PROJECTION);
glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
/* position viewer */
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0F, 0.0F, -2.0F);
/* position object */
glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
IMPLEMENT_APP(MyApp)
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
@@ -114,6 +93,7 @@ TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxGLCanvas(parent, id, pos, size, style, name)
{
m_init = FALSE;
}
TestGLCanvas::~TestGLCanvas(void)
@@ -126,11 +106,17 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event )
// OnPaint handlers must always create a wxPaintDC.
wxPaintDC dc(this);
if ( !GetContext() )
return;
if (!GetContext()) return;
SetCurrent();
/* init OpenGL once, but after SetCurrent */
if (!m_init)
{
InitGL();
m_init = TRUE;
}
/* clear color and depth buffers */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -181,3 +167,22 @@ void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
// Do nothing, to avoid flashing.
}
void TestGLCanvas::InitGL(void)
{
/* set viewing projection */
glMatrixMode(GL_PROJECTION);
glFrustum(-0.5F, 0.5F, -0.5F, 0.5F, 1.0F, 3.0F);
/* position viewer */
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0F, 0.0F, -2.0F);
/* position object */
glRotatef(30.0F, 1.0F, 0.0F, 0.0F);
glRotatef(30.0F, 0.0F, 1.0F, 0.0F);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}

View File

@@ -19,7 +19,6 @@ class MyApp: public wxApp
{
public:
bool OnInit(void);
void InitGL(void);
};
// Define a new frame type
@@ -48,6 +47,11 @@ class TestGLCanvas: public wxGLCanvas
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void InitGL(void);
private:
bool m_init;
DECLARE_EVENT_TABLE()
};

View File

@@ -20,4 +20,4 @@ glcanvas.o: ../../src/glcanvas.cpp
$(CPP) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
clean:
rm -f *.o penguin
rm -f *.o Penguin