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.
\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.
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}
\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}
\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.}
\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
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;
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;
* 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
//
// 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;
} // CeditorDlg::OnClose()
+void CeditorDlg::OnButton( wxCommandEvent &event )
+{
+ wxWindow *win = (wxWindow*) event.GetEventObject();
+ OnCommand( *win, event );
+}
+
void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString widgetName;
}
// 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())
{
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))
// 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())
{
{
wxString w;
+/*
w = "NAME = (SELECT MIN(NAME) FROM ";
+*/
+ w = "NAME = (SELECT NAME FROM ";
w += Contact->tableName;
w += " WHERE NAME > '";
w += Contact->Name;
}
w += ")";
-
return(GetRec((char*) (const char*) w));
} // CeditorDlg::GetNextRec()
} // 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))
{
} // 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.
CeditorDlg(wxWindow *parent);
bool OnClose(void);
+ void OnButton( wxCommandEvent &event );
void OnCommand(wxWindow& win, wxCommandEvent& event);
void OnActivate(bool) {}; // necessary for hot keys
bool GetNextRec();
bool GetPrevRec();
bool GetRec(char *whereStr);
+
+DECLARE_EVENT_TABLE()
}; // CeditorDlg
#define EDITOR_DIALOG 199
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
void ProcessCountBtn();
bool ValidateWhereClause();
+DECLARE_EVENT_TABLE()
}; // CqueryDlg
#define QUERY_DIALOG 300
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 );
// 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)
* (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"))
{
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
}
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++)
{
strcat(sqlStmt, ")");
}
// Append the closing parentheses for the create table statement
- strcat(sqlStmt, ")");
-
+ strcat(sqlStmt, ")");
+
pDb->WriteSqlLog(sqlStmt);
#ifdef _CONSOLE
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, ", ");
}
#include "wx/bitmap.h"
#include "wx/debug.h"
#include "wx/log.h"
+#include "wx/app.h"
#ifdef wxUSE_LIBPNG
#include "../png/png.h"
#endif
{
case 8:
{
- GdkColormap *cmap = gtk_widget_get_default_colormap();
- GdkColor *colors = cmap->colors;
- int max = 3 * (65536);
- int index = -1;
-
- 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; }
+ 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) { pixel = i; max = sum; }
+ }
}
- gdk_image_put_pixel( data_image, x, y, index );
+ gdk_image_put_pixel( data_image, x, y, pixel );
break;
}
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
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++)
}
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;
}
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 );
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",
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",
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
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++)
}
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;
}
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 );
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",
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",
# endif
# endif
+#define NO_TRACE
+
# define TRACE_TYPE_APP2DM 1
# define TRACE_TYPE_DM2DRV 2
# define TRACE_TYPE_DRV2DM 3
int i, j;
char* ptr;
- j = STRLEN("/odbc.ini") + 1;
+ j = STRLEN("/iodbc.ini") + 1;
if( size < j )
{
}
#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
{
}
else
{
- strcpy( buf, "odbc.ini" );
+ strcpy( buf, "iodbc.ini" );
}
}
return NULL;
}
- sprintf( buf + i, "/odbc.ini");
+ sprintf( buf + i, "/iodbc.ini");
return buf;
# else
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
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)
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxGLCanvas(parent, id, pos, size, style, name)
{
+ m_init = FALSE;
}
TestGLCanvas::~TestGLCanvas(void)
// 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);
// 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);
+}
+
{
public:
bool OnInit(void);
- void InitGL(void);
};
// Define a new frame type
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnEraseBackground(wxEraseEvent& event);
+ void InitGL(void);
+
+ private:
+
+ bool m_init;
DECLARE_EVENT_TABLE()
};
$(CPP) `wx-config --cflags` `gtk-config --cflags` -I../../src -c ../../src/glcanvas.cpp
clean:
- rm -f *.o penguin
+ rm -f *.o Penguin