// WARNING: Be certain that you do not free this handle
// directly with SQLFreeEnv(). Use either the
// method ::FreeHenv() or delete the DbConnectInf.
- DbConnectInf = new wxDbConnectInf(NULL, params.ODBCSource, params.UserName,
+ DbConnectInf = new wxDbConnectInf(NULL, params.ODBCSource, params.UserName,
params.Password, params.DirPath);
if (!DbConnectInf || !DbConnectInf->GetHenv())
wxMessageBox(wxT("Unable to initialize the editor dialog for some reason"),wxT("Error..."),wxOK | wxICON_EXCLAMATION);
Close();
}
- }
+ }
else
{
wxMessageBox(wxT("Unable to create the editor dialog for some reason"),wxT("Error..."),wxOK | wxICON_EXCLAMATION);
* Constructor note: If no wxDb object is passed in, a new connection to the database
* is created for this instance of Ccontact. This can be a slow process depending
* on the database engine being used, and some database engines have a limit on the
- * number of connections (either hard limits, or license restricted) so care should
- * be used to use as few connections as is necessary.
+ * number of connections (either hard limits, or license restricted) so care should
+ * be used to use as few connections as is necessary.
*
- * IMPORTANT: Objects which share a wxDb pointer are ALL acted upon whenever a member
- * function of pDb is called (i.e. CommitTrans() or RollbackTrans(), so if modifying
+ * IMPORTANT: Objects which share a wxDb pointer are ALL acted upon whenever a member
+ * function of pDb is called (i.e. CommitTrans() or RollbackTrans(), so if modifying
* or creating a table objects which use the same pDb, know that all the objects
* will be committed or rolled back when any of the objects has this function call made.
*/
Ccontact::Ccontact (wxDb *pwxDb) : wxDbTable(pwxDb ? pwxDb : wxDbGetConnection(wxGetApp().DbConnectInf),
- CONTACT_TABLE_NAME, CONTACT_NO_COLS, wxT(""),
+ CONTACT_TABLE_NAME, CONTACT_NO_COLS, wxEmptyString,
!wxDB_QUERY_ONLY, wxGetApp().DbConnectInf->GetDefaultDir())
{
// This is used to represent whether the database connection should be released
// when this instance of the object is deleted. If using the same connection
- // for multiple instance of database objects, then the connection should only be
+ // for multiple instance of database objects, then the connection should only be
// released when the last database instance using the connection is deleted
freeDbConn = !pwxDb;
-
+
if (GetDb())
GetDb()->SetSqlLogging(sqlLogON);
/*
* Handles setting up all the connections for the interface from the wxDbTable
- * functions to interface to the data structure used to store records in
+ * functions to interface to the data structure used to store records in
* memory, and for all the column definitions that define the table structure
*/
void Ccontact::SetupColumns()
bool Ccontact::CreateIndexes(bool recreate)
{
- // This index could easily be accomplished with an "orderBy" clause,
+ // This index could easily be accomplished with an "orderBy" clause,
// but is done to show how to construct a non-primary index.
wxString indexName;
wxDbIdxDef idxDef[2];
* 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(wxID_ANY, CeditorDlg::OnButton)
EVT_CLOSE(CeditorDlg::OnCloseWindow)
END_EVENT_TABLE()
-
+
CeditorDlg::CeditorDlg(wxWindow *parent) : wxPanel (parent, 0, 0, 537, 480)
{
// Since the ::OnCommand() function is overridden, this prevents the widget
void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& WXUNUSED(event))
{
wxString widgetName;
-
+
widgetName = win.GetName();
if (!widgetPtrsSet)
if (Ok && wxGetApp().Contact->Delete())
{
- // NOTE: Deletions are not finalized until a CommitTrans() is performed.
- // If the commit were not performed, the program will continue to
+ // NOTE: Deletions are not finalized until a CommitTrans() is performed.
+ // If the commit were not performed, the program will continue to
// show the table contents as if they were deleted until this instance
- // of Ccontact is deleted. If the Commit wasn't performed, the
+ // of Ccontact is deleted. If the Commit wasn't performed, the
// database will automatically Rollback the changes when the database
// connection is terminated
wxGetApp().Contact->GetDb()->CommitTrans();
tStr = wxT("ODBC error during Query()\n\n");
wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__),
wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
-
+
SetMode(mView);
return;
}
wxGetApp().Contact->whereStr = wxT("NAME = (SELECT MIN(NAME) FROM ");
wxGetApp().Contact->whereStr += CONTACT_TABLE_NAME;
}
-
+
// Append the query where string (if there is one)
wxGetApp().Contact->qryWhereStr = qryWhere;
if (wxStrlen(qryWhere))
bool CeditorDlg::Initialize()
{
- // Create the data structure and a new database connection.
+ // Create the data structure and a new database connection.
// (As there is not a pDb being passed in the constructor, a new database
// connection is created)
wxGetApp().Contact = new Ccontact();
return false;
}
- // Check if the table exists or not. If it doesn't, ask the user if they want to
+ // Check if the table exists or not. If it doesn't, ask the user if they want to
// create the table. Continue trying to create the table until it exists, or user aborts
- while (!wxGetApp().Contact->GetDb()->TableExists((wxChar *)CONTACT_TABLE_NAME,
- wxGetApp().DbConnectInf->GetUserID(),
+ while (!wxGetApp().Contact->GetDb()->TableExists((wxChar *)CONTACT_TABLE_NAME,
+ wxGetApp().DbConnectInf->GetUserID(),
wxGetApp().DbConnectInf->GetDefaultDir()))
{
wxString tStr;
wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__TFILE__,__LINE__),
wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
}
- else
+ else
#endif
if (!wxGetApp().Contact->GetDb()->TableExists(CONTACT_TABLE_NAME,
wxGetApp().Contact->GetDb()->GetUsername(),
pDataTypesBtn = new wxButton(this, EDITOR_DIALOG_DATATYPES, wxT("Data&types"), wxPoint(430, 337), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DataTypesBtn"));
pDbDiagsBtn = new wxButton(this, EDITOR_DIALOG_DB_DIAGS, wxT("DB Dia&gs"), wxPoint(430, 387), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DbDiagsBtn"));
- // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to
+ // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to
// handle all widget processing
widgetPtrsSet = true;
- // Setup the orderBy and where clauses to return back a single record as the result set,
+ // Setup the orderBy and where clauses to return back a single record as the result set,
// as there will only be one record being shown on the dialog at a time, this optimizes
// network traffic by only returning a one row result
-
+
wxGetApp().Contact->SetOrderByClause(wxT("NAME")); // field name to sort by
// The wxString "whereStr" is not a member of the wxDbTable object, it is a member variable
// length string, and then after the string is built, the wxDbTable member variable "where" is
// assigned the pointer to the constructed string.
//
- // The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s"
+ // 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).
-
+
if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES &&
wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL)
{
else
wxGetApp().Contact->SetWhereClause(wxT(""));
- // Perform the Query to get the result set.
- // NOTE: If there are no rows returned, that is a valid result, so Query() would return true.
+ // Perform the Query to get the result set.
+ // NOTE: If there are no rows returned, that is a valid result, so Query() would return true.
// Only if there is a database error will Query() come back as false
if (!wxGetApp().Contact->Query())
{
// Since Query succeeded, now get the row that was returned
if (!wxGetApp().Contact->GetNext())
- // If the GetNext() failed at this point, then there are no rows to retrieve,
- // so clear the values in the members of "Contact" so that PutData() blanks the
+ // If the GetNext() failed at this point, then there are no rows to retrieve,
+ // so clear the values in the members of "Contact" so that PutData() blanks the
// widgets on the dialog
wxGetApp().Contact->Initialize();
/*
if (!invalid)
{
- wxGetApp().Contact->JoinDate.month = mm;
- wxGetApp().Contact->JoinDate.day = dd;
- wxGetApp().Contact->JoinDate.year = yyyy;
+ wxGetApp().Contact->JoinDate.month = (SQLUSMALLINT)mm;
+ wxGetApp().Contact->JoinDate.day = (SQLUSMALLINT)dd;
+ wxGetApp().Contact->JoinDate.year = (SQLSMALLINT)yyyy;
}
else
{
wxStrcpy(wxGetApp().Contact->Country,pCountryTxt->GetValue());
wxStrcpy(wxGetApp().Contact->PostalCode,pPostalCodeTxt->GetValue());
- wxGetApp().Contact->Contributions = wxAtoi(pContribTxt->GetValue());
+ wxGetApp().Contact->Contributions = (UCHAR)wxAtoi(pContribTxt->GetValue());
wxGetApp().Contact->LinesOfCode = wxAtol(pLinesTxt->GetValue());
wxGetApp().Contact->NativeLanguage = (enum Language) pNativeLangChoice->GetSelection();
if (mode == mCreate)
{
- RETCODE result = wxGetApp().Contact->Insert();
+ RETCODE result = (RETCODE)wxGetApp().Contact->Insert();
failed = (result != DB_SUCCESS);
if (failed)
pParamSaveBtn = new wxButton(this, PARAMETER_DIALOG_SAVE, wxT("&Save"), wxPoint(310, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("ParamSaveBtn"));
pParamCancelBtn = new wxButton(this, PARAMETER_DIALOG_CANCEL, wxT("C&ancel"), wxPoint(310, 66), wxSize( 70, 35), 0, wxDefaultValidator, wxT("ParamCancelBtn"));
- // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to
+ // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to
// handle all widget processing
widgetPtrsSet = true;
if (!saved)
{
bool Ok = (wxMessageBox(wxT("No changes have been saved.\n\nAre you sure you wish exit the parameter screen?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES);
-
+
if (!Ok)
{
event.Veto();
return;
}
-
+
wxGetApp().params = savedParamSettings;
}
void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& WXUNUSED(event))
{
wxString widgetName;
-
+
widgetName = win.GetName();
if (!widgetPtrsSet)
}
else
return false;
-
+
tStr = pParamUserNameTxt->GetValue();
if (tStr.Length() > (sizeof(wxGetApp().params.UserName)-1))
{
EVT_CLOSE(CqueryDlg::OnCloseWindow)
END_EVENT_TABLE()
-
+
// CqueryDlg() constructor
-CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[],
+CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[],
const wxString &pWhereArg) :
wxDialog (parent, QUERY_DIALOG, wxT("Query"), wxDefaultPosition, wxSize(480, 360))
{
} // CqueryDlg() constructor
-CqueryDlg::~CqueryDlg()
-{
-} // CqueryDlg::~CqueryDlg() destructor
-
-
void CqueryDlg::OnButton(wxCommandEvent &event)
{
wxWindow *win = (wxWindow*) event.GetEventObject();
// Build the expression and append it to the where clause window
wxString s = pQueryCol1Choice->GetStringSelection();
-
+
if (pQueryNotCheck->GetValue() && (oper != qryOpEQ))
s += wxT(" NOT");
-
+
switch(oper)
{
case qryOpEQ:
if (!dbTable) // wxDbTable object needs to be created and opened
{
- dbTable = new wxDbTable(pDB, masterTableName, 0, wxT(""),
- !wxDB_QUERY_ONLY,
+ dbTable = new wxDbTable(pDB, masterTableName, 0, wxEmptyString,
+ !wxDB_QUERY_ONLY,
wxGetApp().DbConnectInf->GetDefaultDir());
if (!dbTable)
{
grid->RegisterDataType(wxGRID_VALUE_CHOICEINT,
new wxGridCellEnumRenderer,
new wxGridCellEnumEditor);
-
- wxString NativeLangChoice( wxString::Format(wxT("%s:%s,%s,%s,%s,%s"),wxGRID_VALUE_CHOICEINT,
+
+ wxString NativeLangChoice( wxString::Format(wxT("%s:%s,%s,%s,%s,%s"),wxGRID_VALUE_CHOICEINT,
wxT("English"),
wxT("French"),
wxT("German"),
wxT("Spanish"),
- wxT("Other") ));
+ wxT("Other") ));
#endif
// Columns must match the sequence specified in SetColDef() calls
new wxDbGridColInfo(10,wxGRID_VALUE_NUMBER,wxT("Lines Of Code"),
#ifdef CHOICEINT
new wxDbGridColInfo(11,NativeLangChoice, wxT("Native Language"),NULL))))))))))));
-#else
+#else
new wxDbGridColInfo(11,wxGRID_VALUE_NUMBER,wxT("Native Language"),NULL))))))))))));
#endif
//
// This class contains the actual data members that are used for transferring
-// data back and forth from the database to the program.
+// data back and forth from the database to the program.
//
// NOTE: The object described in this class is just for example purposes, and has no
// real meaning other than to show each type of field being used by the database
// all combined in this one class.
//
class Ccontact : public wxDbTable, public CstructContact
-{
+{
private:
// Used to keep track of whether this class had a wxDb instance
- // passed in to it or not. If an existing wxDb instance was not
+ // passed in to it or not. If an existing wxDb instance was not
// passed in at Ccontact creation time, then when the Ccontact
// instance is deleted, the connection will be freed as Ccontact
// created its own connection when it was created.
void SetupColumns();
public:
- // Used in places where we need to construct a WHERE clause to
+ // Used in places where we need to construct a WHERE clause to
// be passed to the SetWhereClause() function. From example,
// where building the WHERE clause requires using ::Printf()
// to build the string.
// Define a new frame type
class DatabaseDemoFrame: public wxFrame
-{
+{
private:
CeditorDlg *pEditorDlg;
CparameterDlg *pParamDlg;
void OnAbout(wxCommandEvent& event);
#if wxUSE_GRID
void OnDbGridTable( wxCommandEvent& );
-#endif
+#endif
void CreateDataTable(bool recreate);
void BuildEditorDialog();
void BuildParameterDialog(wxWindow *parent);
// Pointer to the main database connection used in the program. This
// pointer would normally be used for doing things as database lookups
// for user login names and passwords, getting workstation settings, etc.
- //
+ //
// ---> IMPORTANT <---
- //
+ //
// For each database object created which uses this wxDb pointer
// connection to the database, when a CommitTrans() or RollBackTrans()
// will commit or rollback EVERY object which uses this wxDb pointer.
- //
- // To allow each table object (those derived from wxDbTable) to be
+ //
+ // To allow each table object (those derived from wxDbTable) to be
// individually committed or rolled back, you MUST use a different
- // instance of wxDb in the constructor of the table. Doing so creates
+ // instance of wxDb in the constructor of the table. Doing so creates
// more overhead, and will use more database connections (some DBs have
// connection limits...), so use connections sparringly.
- //
+ //
// It is recommended that one "main" database connection be created for
// the entire program to use for READ-ONLY database accesses, but for each
// table object which will do a CommitTrans() or RollbackTrans() that a
// new wxDb object be created and used for it.
wxDb *READONLY_DB;
- // Contains the ODBC connection information used by
+ // Contains the ODBC connection information used by
// all database connections
wxDbConnectInf *DbConnectInf;
{
private:
// Used to indicate whether all of the widget pointers (defined
- // below) have been initialized to point to the memory for
+ // below) have been initialized to point to the memory for
// the named widget. Used as a safeguard from using the widget
// before it has been initialized.
bool widgetPtrsSet;
- // Used when the EDIT button has been pressed to maintain the
- // original name that was displayed in the editor before the
+ // Used when the EDIT button has been pressed to maintain the
+ // original name that was displayed in the editor before the
// EDIT button was pressed, so that if CANCEL is pressed, a
// FetchByName() can be done to retrieve the original data
// to repopulate the dialog.
// retrieved from the editor dialog
bool Save();
- // Database functions for changing the data that is to
+ // Database functions for changing the data that is to
// be displayed on the dialog. GetNextRec()/GetPrevRec()
// provide database independent methods that do not require
// backward scrolling cursors to obtain the record that
bool GetNextRec();
bool GetPrevRec();
bool GetRec(const wxString &whereStr);
-
+
DECLARE_EVENT_TABLE()
}; // CeditorDlg
{
private:
// Used to indicate whether all of the widget pointers (defined
- // below) have been initialized to point to the memory for
+ // below) have been initialized to point to the memory for
// the named widget. Used as a safeguard from using the widget
// before it has been initialized.
bool widgetPtrsSet;
enum DialogModes mode;
- // Have the parameters been saved yet, or do they
+ // Have the parameters been saved yet, or do they
// need to be saved to update the params on disk
bool saved;
public:
// Used to indicate whether all of the widget pointers (defined
- // below) have been initialized to point to the memory for
+ // below) have been initialized to point to the memory for
// the named widget. Used as a safeguard from using the widget
// before it has been initialized.
bool widgetPtrsSet;
wxTextCtrl *pFocusTxt;
CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], const wxString &pWhereArg);
- ~CqueryDlg();
+ ~CqueryDlg(){};
void OnButton( wxCommandEvent &event );
void OnCommand(wxWindow& win, wxCommandEvent& event);
wxChar * const langDBINF_STORED_PROC = wxT("Stored Procedures = ");
wxChar * const langDBINF_MAX_HDBC = wxT("Max # of Db connections = ");
wxChar * const langDBINF_MAX_HSTMT = wxT("Max # of cursors (per db connection) = ");
-wxChar * const langDBINF_UNLIMITED = wxT("Unlimited or Unknown");
+wxChar * const langDBINF_UNLIMITED = wxT("Unlimited or Unknown");
wxChar * const langDBINF_API_LVL = wxT("ODBC API conformance level = ");
wxChar * const langDBINF_CLI_LVL = wxT("Client (SAG) conformance level = ");
wxChar * const langDBINF_SQL_LVL = wxT("SQL conformance level = ");
Member functions for the classes defined in LISTDB.H
This class is used to present a generic ListBox lookup window for
- use with any of the object creation/selection choice widgets. This
+ use with any of the object creation/selection choice widgets. This
dialog window will present a (possibly) scrolling list of values
that come from a data table source. Based on the object type passed
in the constructor, a ListBox is built to present the user with a
For each object (database) type that is to be used, an overridden
constructor should be written to appropriately link to the proper
data table/object for building the list.
-
+
The data table record access is all handled through the routines
in this module, interfacing with the methods defined in wxDbTable.
have opened the table prior to passing them in the dialog
constructor, and the 'where' query should already have been set
and performed before creating this dialog instance.
-
+
// SYNOPSIS STOP
*/
msg.Append (wxT("\nODBC errors:\n"));
msg += wxT("\n");
-
+
// Display errors for this connection
int i;
for (i = 0; i < DB_MAX_ERROR_HISTORY; i++)
// Clookup constructor
Clookup::Clookup(wxChar *tblName, wxChar *colName, wxDb *pDb, const wxString &defDir)
- : wxDbTable(pDb, tblName, 1, wxT(""), !wxDB_QUERY_ONLY,
+ : wxDbTable(pDb, tblName, 1, wxEmptyString, !wxDB_QUERY_ONLY,
defDir)
{
// Clookup2 constructor
Clookup2::Clookup2(wxChar *tblName, wxChar *colName1, wxChar *colName2,
wxDb *pDb, const wxString &defDir)
- : wxDbTable(pDb, tblName, (1 + (wxStrlen(colName2) > 0)), wxT(""),
+ : wxDbTable(pDb, tblName, (UWORD)(1 + (wxStrlen(colName2) > 0)), wxEmptyString,
!wxDB_QUERY_ONLY, defDir)
{
wxASSERT(pDb);
int i = 0;
- SetColDefs (i, colName1, DB_DATA_TYPE_VARCHAR, lookupCol1, SQL_C_CHAR, LOOKUP_COL_LEN+1, false, false);
+ SetColDefs ((UWORD)i, colName1, DB_DATA_TYPE_VARCHAR, lookupCol1, SQL_C_CHAR, LOOKUP_COL_LEN+1, false, false);
if (wxStrlen(colName2) > 0)
- SetColDefs (++i, colName2, DB_DATA_TYPE_VARCHAR, lookupCol2, SQL_C_CHAR, LOOKUP_COL_LEN+1, false, false);
+ SetColDefs ((UWORD)(++i), colName2, DB_DATA_TYPE_VARCHAR, lookupCol2, SQL_C_CHAR, LOOKUP_COL_LEN+1, false, false);
} // Clookup2()
: wxDialog (parent, LOOKUP_DIALOG, wxT("Select..."), wxDefaultPosition, wxSize(400, 290))
{
wxBeginBusyCursor();
-
+
wxStrcpy(ListDB_Selection,wxT(""));
widgetPtrsSet = false;
lookup = 0;
//
ClookUpDlg::ClookUpDlg(wxWindow *parent, wxChar *windowTitle, wxChar *tableName,
wxChar *dispCol1, wxChar *dispCol2, wxChar *where, wxChar *orderBy,
- wxDb *pDb, const wxString &defDir, bool distinctValues,
+ wxDb *pDb, const wxString &defDir, bool distinctValues,
wxChar *selectStmt, int maxLenCol1, bool allowOk)
: wxDialog (parent, LOOKUP_DIALOG, wxT("Select..."), wxDefaultPosition, wxSize(400, 290))
{
wxBeginBusyCursor();
-
+
wxStrcpy(ListDB_Selection,wxT(""));
wxStrcpy(ListDB_Selection2,wxT(""));
widgetPtrsSet = false;
{
wxSize sz = GetClientSize();
wxRect rect(0, 0, sz.x, sz.y);
-
+
if (event.GetDC())
{
wxGetApp().TileBitmap(rect, *(event.GetDC()), wxGetApp().GetBackgroundBitmap());
#else
wxIcon icon(wxICON(dragicon));
#endif
-
+
m_dragImage = new wxDragImage(icon, wxCursor(wxCURSOR_HAND));
break;
}
// The offset between the top-left of the shape image and the current shape position
wxPoint beginDragHotSpot = m_dragStartPos - m_draggedShape->GetPosition();
-
+
// Now we do this inside the implementation: always assume
// coordinates relative to the capture window (client coordinates)
//if (fullScreen)
// beginDragHotSpot -= ClientToScreen(wxPoint(0, 0));
-
+
if (!m_dragImage->BeginDrag(beginDragHotSpot, this, fullScreen))
{
delete m_dragImage;
m_dragImage = (wxDragImage*) NULL;
m_dragMode = TEST_DRAG_NONE;
-
+
} else
{
m_dragImage->Move(event.GetPosition());
wxRect rect2(shape->GetRect());
dc.SetClippingRegion(rect2.x, rect2.y, rect2.width, rect2.height);
-
+
wxGetApp().TileBitmap(rect, dc, wxGetApp().GetBackgroundBitmap());
dc.DestroyClippingRegion();
file_menu->Append( wxID_ABOUT, _T("&About..."));
file_menu->AppendCheckItem( TEST_USE_SCREEN, _T("&Use whole screen for dragging"), _T("Use whole screen"));
file_menu->Append( wxID_EXIT, _T("E&xit"));
-
+
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append(file_menu, _T("&File"));
SetIcon(wxICON(mondrian));
SetMenuBar( menu_bar );
-
+
#if wxUSE_STATUSBAR
CreateStatusBar(2);
int widths[] = { -1, 100 };
SetStatusWidths( 2, widths );
#endif // wxUSE_STATUSBAR
-
+
m_canvas = new MyCanvas( this, wxID_ANY, wxPoint(0,0), wxSize(10,10) );
}
{
(void)wxMessageBox( _T("wxDragImage demo\n")
_T("Julian Smart (c) 2000"),
- _T("About wxDragImage Demo"),
+ _T("About wxDragImage Demo"),
wxICON_INFORMATION | wxOK );
}
{
int w = bitmap.GetWidth();
int h = bitmap.GetHeight();
-
+
int i, j;
for (i = rect.x; i < rect.x + rect.width; i += w)
{
m_show = true;
}
-DragShape::~DragShape()
-{
-}
-
bool DragShape::HitTest(const wxPoint& pt) const
{
wxRect rect(GetRect());
{
wxMemoryDC memDC;
memDC.SelectObject(m_bitmap);
-
+
dc.Blit(m_pos.x, m_pos.y, m_bitmap.GetWidth(), m_bitmap.GetHeight(),
& memDC, 0, 0, op, true);
{
public:
DragShape(const wxBitmap& bitmap);
- ~DragShape();
+ ~DragShape(){};
//// Operations
wxMemoryDC memdc2;
memdc2.SelectObject(bitmap2);
- wxBrush yellowBrush(wxColour(255, 255, 0), wxSOLID);
+ wxColour clr(255, 255, 0);
+ wxBrush yellowBrush(clr, wxSOLID);
memdc2.SetBackground(yellowBrush);
memdc2.Clear();
- wxPen yellowPen(wxColour(255, 255, 0), 1, wxSOLID);
+ wxPen yellowPen(clr, 1, wxSOLID);
// Now draw a white rectangle with red outline. It should
// entirely eclipse the yellow background.
if ( m_owner->m_textureBackground) {
if ( ! m_owner->m_backgroundBrush.Ok() ) {
- wxBrush b(wxColour(0,128,0), wxSOLID);
+ wxColour clr(0,128,0);
+ wxBrush b(clr, wxSOLID);
dc.SetBackground(b);
}
}
case WXK_RIGHT: m_text += wxT( "<RIGHT>" ); break;
case WXK_DOWN: m_text += wxT( "<DOWN>" ); break;
case WXK_RETURN: m_text += wxT( "<ENTER>" ); break;
- default: m_text += event.m_keyCode; break;
+ default: m_text += (wxChar)event.m_keyCode; break;
}
-
+
}
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.SetTextForeground(*wxBLUE);
dc.DrawText(_T("This text is drawn from OnPaint"), 65, 65);
-
+
wxString tmp;
tmp.Printf( _T("Hit any key to display more text: %s"), m_text.c_str() );
int w,h;
#include "wx/splitter.h"
#include "wx/textfile.h"
+#ifdef __WXMAC__
#undef wxFontDialog
#include "wx/mac/fontdlg.h"
+#endif
// ----------------------------------------------------------------------------
// private classes
{
public:
MyCanvas( wxWindow *parent );
- virtual ~MyCanvas();
+ virtual ~MyCanvas(){};
// accessors for the frame
const wxFont& GetTextFont() const { return m_font; }
{
}
-MyCanvas::~MyCanvas()
-{
-}
-
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
wxPaintDC dc(this);
{
for ( int j = 0; j < 32; j++ )
{
- wxChar c = 32 * (i + 1) + j;
+ wxChar c = (wxChar)(32 * (i + 1) + j);
long charWidth, charHeight;
dc.GetTextExtent(c, &charWidth, &charHeight);
{
// Check the new Refresh function by passing it a rectangle
// which exactly fits the grid.
- wxRect r(wxPoint(0, 0), grid->GetSize());
+ wxPoint pt(0, 0);
+ wxRect r(pt, grid->GetSize());
grid->SetDefaultCellBackgroundColour(col);
grid->Refresh(true, &r);
}
return headers[col];
}
-BugsGridTable::BugsGridTable()
-{
-}
-
// ----------------------------------------------------------------------------
// BugsGridFrame
// ----------------------------------------------------------------------------
class BugsGridTable : public wxGridTableBase
{
public:
- BugsGridTable();
+ BugsGridTable(){};
virtual int GetNumberRows();
virtual int GetNumberCols();
{
unsigned char *cmap = new unsigned char [256];
for ( int i = 0; i < 256; i++ )
- cmap[i] = i;
+ cmap[i] = (unsigned char)i;
image.SetPalette(wxPalette(256, cmap, cmap, cmap));
delete cmap;
tmp << i ;
wxLogError(tmp);
}
- else
+ else
my_horse_ani [i] = wxBitmap( image );
}
#endif // wxUSE_ICO_CUR
wxFile file(dir + _T("horse.bmp"));
if ( file.IsOpened() )
{
- off_t len = file.Length();
+ size_t len = (size_t)file.Length();
void *data = malloc(len);
if ( file.Read(data, len) != len )
wxLogError(_T("Reading bitmap file failed"));
// For testing transparency
dc.SetBrush( *wxRED_BRUSH );
dc.DrawRectangle( 20, 2220, 560, 68 );
-
+
dc.DrawText(_T("XPM bitmap"), 30, 2230 );
if ( m_bmpSmileXpm.Ok() )
dc.DrawBitmap(m_bmpSmileXpm, 30, 2250, true);
dc.DrawText(_T("XPM icon"), 110, 2230 );
if ( m_iconSmileXpm.Ok() )
dc.DrawIcon(m_iconSmileXpm, 110, 2250);
-
- // testing icon -> bitmap conversion
+
+ // testing icon -> bitmap conversion
wxBitmap to_blit( m_iconSmileXpm );
if (to_blit.Ok())
{
dc.SetUserScale( 2, 2 );
dc.DrawBitmap( to_blit, (int)(300/2), (int)(2250/2), true );
dc.SetUserScale( 1.0, 1.0 );
-
+
dc.DrawText( _T("Blit"), 400, 2230);
wxMemoryDC blit_dc;
blit_dc.SelectObject( to_blit );
original.GetBlue( x*2, y*2+1 ) +
original.GetBlue( x*2+1, y*2+1 );
blue = blue/4;
- anti.SetRGB( x, y, red, green, blue );
+ anti.SetRGB( x, y, (unsigned char)red, (unsigned char)green, (unsigned char)blue );
}
my_anti = new wxBitmap(anti);
}
localeInfo.Printf(_("Language: %s\nSystem locale name:\n%s\nCanonical locale name: %s\n"),
locale.c_str(), sysname.c_str(), canname.c_str() );
- wxMessageDialog
- (
- this,
- wxString(_("I18n sample\n(c) 1998, 1999 Vadim Zeitlin and Julian Smart"))
- + wxT("\n\n")
- + localeInfo,
- _("About Internat"),
- wxOK | wxICON_INFORMATION
- ).ShowModal();
+ wxMessageDialog dlg(
+ this,
+ wxString(_("I18n sample\n(c) 1998, 1999 Vadim Zeitlin and Julian Smart"))
+ + wxT("\n\n")
+ + localeInfo,
+ _("About Internat"),
+ wxOK | wxICON_INFORMATION
+ );
+ dlg.ShowModal();
}
void MyFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
ymax += abs(ymin);
pt.y += abs(ymin);
}
-
+
// Scale to canvas size
int cw, ch;
GetSize(&cw, &ch);
canvas = new MyCanvas(this);
}
-MyFrame::~MyFrame()
-{
- // Empty
-}
-
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
MyCanvas *canvas;
MyFrame(wxFrame *parent, const wxString& title,
const wxPoint& pos, const wxSize& size, const long style);
- ~MyFrame();
+ ~MyFrame(){};
void OnActivate(wxActivateEvent& event);
void OnQuit(wxCommandEvent& event);
IMPLEMENT_APP(MyApp)
-MyApp::MyApp()
-{
-}
-
bool MyApp::OnInit()
{
// Create the main frame window
EVT_MENU(LAYOUT_TEST_SIZER, MyFrame::TestFlexSizers)
EVT_MENU(LAYOUT_TEST_NB_SIZER, MyFrame::TestNotebookSizers)
- EVT_MENU(LAYOUT_TEST_GB_SIZER, MyFrame::TestGridBagSizer)
+ EVT_MENU(LAYOUT_TEST_GB_SIZER, MyFrame::TestGridBagSizer)
END_EVENT_TABLE()
// Define my frame constructor
GBS_SHOW_BTN,
GBS_MOVE_BTN1,
GBS_MOVE_BTN2,
-
+
GBS_MAX,
};
m_panel = p;
m_gbs = new wxGridBagSizer();
-
+
m_gbs->Add( new wxStaticText(p, wxID_ANY, gbsDescription),
POS(0,0), SPAN(1, 7),
wxALIGN_CENTER | wxALL, 5);
-
+
m_gbs->Add( TEXTCTRL("pos(1,0)"), POS(1,0) );
m_gbs->Add( TEXTCTRL("pos(1,1)"), POS(1,1) );
m_gbs->Add( TEXTCTRL("pos(2,0)"), POS(2,0) );
m_gbs->Add( TEXTCTRL("pos(5,4)"), POS(5,4), wxDefaultSpan, wxEXPAND );
m_gbs->Add( TEXTCTRL("pos(6,5)"), POS(6,5), wxDefaultSpan, wxEXPAND );
m_gbs->Add( TEXTCTRL("pos(7,6)"), POS(7,6) );
-
+
//m_gbs->Add( TEXTCTRL("bad position"), POS(4,3) ); // Test for assert
//m_gbs->Add( TEXTCTRL("bad position"), POS(5,3) ); // Test for assert
m_moveBtn2 = new wxButton(p, GBS_MOVE_BTN2, _T("Move this to (3,6)"));
m_gbs->Add( m_moveBtn1, POS(10,2) );
m_gbs->Add( m_moveBtn2, POS(10,3) );
-
+
m_hideBtn = new wxButton(p, GBS_HIDE_BTN, _T("Hide this item -->"));
m_gbs->Add(m_hideBtn, POS(12, 3));
m_hideTxt = new wxTextCtrl(p, wxID_ANY, _T("pos(12,4), size(150, -1)"),
wxDefaultPosition, wxSize(150,-1));
m_gbs->Add( m_hideTxt, POS(12,4) );
-
+
m_showBtn = new wxButton(p, GBS_SHOW_BTN, _T("<-- Show it again"));
m_gbs->Add(m_showBtn, POS(12, 5));
m_showBtn->Disable();
m_gbs->Add(10,10, POS(14,0));
-
+
m_gbs->AddGrowableRow(3);
m_gbs->AddGrowableCol(2);
-
+
p->SetSizerAndFit(m_gbs);
SetClientSize(p->GetSize());
}
-
+
void MyGridBagSizerFrame::OnHideBtn(wxCommandEvent&)
{
m_gbs->Hide(m_hideTxt);
m_gbs->SetItemPosition(btn, m_lastPos);
btn->SetLabel(_T("Move this to (3,6)"));
}
- else
+ else
{
if ( m_gbs->CheckForIntersection(wxGBPosition(3,6), wxGBSpan(1,1)) )
wxMessageBox(
_T("wxGridBagSizer will not allow items to be in the same cell as\n\
another item, so this operation will fail. You will also get an assert\n\
when compiled in debug mode."), _T("Warning"), wxOK | wxICON_INFORMATION);
-
+
if ( m_gbs->SetItemPosition(btn, wxGBPosition(3,6)) )
{
m_lastPos = curPos;
class MyApp: public wxApp
{
public:
- MyApp();
+ MyApp(){};
bool OnInit();
};
void TestFlexSizers(wxCommandEvent& event);
void TestNotebookSizers(wxCommandEvent& event);
void TestGridBagSizer(wxCommandEvent& event);
-
+
void OnAbout(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void OnHideBtn(wxCommandEvent&);
void OnShowBtn(wxCommandEvent&);
void OnMoveBtn(wxCommandEvent&);
-
+
private:
wxGridBagSizer* m_gbs;
wxPanel* m_panel;
wxButton* m_moveBtn1;
wxButton* m_moveBtn2;
wxGBPosition m_lastPos;
-
+
DECLARE_EVENT_TABLE()
};
// Name: styles.cpp
// Author: Robert Roebling
// Created: 04/07/02
-// Copyright:
+// Copyright:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
CreateStatusBar(1);
SetStatusText( _T("Welcome to Styles!") );
#endif // wxUSE_STATUSBAR
-
+
wxImage image;
image.LoadFile( _T("marble.jpg"), wxBITMAP_TYPE_JPEG );
-
+
wxBitmap bitmap( image );
#ifdef __WXUNIVERSAL__
SetBackground( bitmap, 0, wxTILE );
#endif
-
+
new wxStaticText( this, wxID_ANY, _T("This is text"), wxPoint( 20,50 ) );
-
+
new wxCheckBox( this, wxID_ANY, _T("This is a checkbox"), wxPoint( 20,70 ) );
}
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append( file_menu, _T("&File") );
-
+
SetMenuBar( menu_bar );
}
IMPLEMENT_APP(MyApp)
-MyApp::MyApp()
-{
-}
-
bool MyApp::OnInit()
{
wxInitAllImageHandlers();
SetVendorName(_T("Free world"));
SetAppName(_T("Styles"));
-
+
MyFrame *frame = new MyFrame( NULL, wxID_ANY, _T("Styles"), wxPoint(20,20), wxSize(500,340) );
frame->Show( true );
-
+
return true;
}
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE );
-
+
private:
void CreateMyMenuBar();
-
+
private:
void OnAbout( wxCommandEvent &event );
void OnQuit( wxCommandEvent &event );
-
+
void OnCloseWindow( wxCloseEvent &event );
-
+
private:
DECLARE_EVENT_TABLE()
};
class MyApp: public wxApp
{
public:
- MyApp();
-
+ MyApp(){};
+
virtual bool OnInit();
virtual int OnExit();
};
// Name: wxedit.cpp
// Author: Robert Roebling
// Created: 04/07/02
-// Copyright:
+// Copyright:
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU(ID_ABOUT, MyFrame::OnAbout)
-
+
EVT_MENU(ID_NEW, MyFrame::OnNew)
EVT_MENU(ID_OPEN, MyFrame::OnOpen)
EVT_MENU(ID_SAVE, MyFrame::OnSave)
EVT_MENU(ID_SAVEAS, MyFrame::OnSaveAs)
EVT_MENU(ID_QUIT, MyFrame::OnQuit)
-
+
EVT_MENU(ID_COPY, MyFrame::OnCopy)
EVT_MENU(ID_CUT, MyFrame::OnCut)
EVT_MENU(ID_PASTE, MyFrame::OnPaste)
EVT_MENU(ID_DELETE, MyFrame::OnDelete)
-
+
EVT_MENU_RANGE(ID_LAST_1, ID_LAST_3, MyFrame::OnLastFiles)
-
+
EVT_CLOSE(MyFrame::OnCloseWindow)
EVT_UPDATE_UI(wxID_ANY,MyFrame::OnUpdateUI)
END_EVENT_TABLE()
CreateStatusBar(1);
SetStatusText( _T("Welcome to wxEdit!") );
#endif // wxUSE_STATUSBAR
-
+
// Create edit control. Since it is the only
// control in the frame, it will be resized
// to file it out.
m_text = new wxTextCtrl( this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
-
+
// Read .ini file for file history etc.
wxConfig *conf = (wxConfig*) wxConfig::Get();
- int entries = 0;
+ int entries = 0;
conf->Read( _T("/History/Count"), &entries );
-
+
for (int i = 0; i < entries; i++)
{
wxString tmp;
tmp.Printf( _T("/History/File%d"), (int)i );
-
+
wxString res;
conf->Read( tmp, &res );
-
+
if (!res.empty())
AddToHistory( res );
}
void MyFrame::MakeHistory()
{
wxMenuBar *mb = GetMenuBar();
-
+
wxASSERT( mb );
int max = m_history.GetCount();
if (max > HISTORY_ENTRIES)
max = HISTORY_ENTRIES;
-
+
for (int i = 0; i < max; i++)
{
wxMenu *menu = NULL;
mb->FindItem( ID_LAST_1 + i, &menu );
wxASSERT( menu );
-
+
wxFileName fname( m_history[(size_t)i] );
menu->SetLabel( ID_LAST_1 + i, fname.GetFullName() );
}
{
// Fill menu with history index
int index = m_history.Index( fname );
-
+
if (index != wxNOT_FOUND)
m_history.RemoveAt( (size_t) index );
-
+
m_history.Insert( fname, 0 );
-
+
// Update menu
MakeHistory();
}
edit_menu->Append( ID_PASTE, _T("Paste") );
edit_menu->AppendSeparator();
edit_menu->Append( ID_DELETE, _T("Delete") );
-
+
wxMenu *history_menu = new wxMenu;
history_menu->Append( ID_LAST_1, _T("No file.") );
history_menu->Append( ID_LAST_2, _T("No file.") );
history_menu->Append( ID_LAST_3, _T("No file.") );
-
+
wxMenuBar *menu_bar = new wxMenuBar();
menu_bar->Append( file_menu, _T("&File") );
menu_bar->Append( edit_menu, _T("&Edit") );
menu_bar->Append( history_menu, _T("&History") );
-
+
SetMenuBar( menu_bar );
}
if (!m_filename.empty())
AddToHistory( m_filename );
-
+
size_t index = event.GetId() - ID_LAST_1;
-
+
if( index < m_history.GetCount() )
{
m_filename = m_history[index];
-
+
m_text->Clear();
m_text->LoadFile( m_filename );
-
+
#if wxUSE_STATUSBAR
SetStatusText( m_filename );
#endif // wxUSE_STATUSBAR
if (!Discard()) return;
m_text->Clear();
-
+
if (!m_filename.empty())
AddToHistory( m_filename );
-
+
m_filename = wxEmptyString;
-
+
#if wxUSE_STATUSBAR
SetStatusText( _T("") );
#endif // wxUSE_STATUSBAR
m_filename = dialog.GetPath();
m_text->LoadFile( m_filename );
-
+
#if wxUSE_STATUSBAR
SetStatusText( m_filename );
#endif // wxUSE_STATUSBAR
{
m_filename = dialog.GetPath();
m_text->SaveFile( m_filename );
-
+
#if wxUSE_STATUSBAR
SetStatusText( m_filename );
#endif // wxUSE_STATUSBAR
bool MyFrame::Save()
{
wxCommandEvent event;
-
+
if (m_filename.empty())
OnSaveAs( event );
else
m_text->SaveFile( m_filename );
-
+
return true;
}
{
wxMessageDialog dialog( this, _T("Text has been\nmodified! Save?"),
_T("wxEdit"), wxYES_NO|wxCANCEL|wxICON_EXCLAMATION );
-
+
int ret = dialog.ShowModal();
-
+
if (ret == wxID_CANCEL)
return false;
-
+
if (ret == wxID_YES)
{
if (!Save())
return false;
}
}
-
+
return true;
}
m_text->GetSelection(& selFrom, & selTo);
event.Enable( selFrom != selTo );
}
-#endif
+#endif
break;
default:
break;
void MyFrame::OnCloseWindow( wxCloseEvent& WXUNUSED(event) )
{
// Save changes?
- if (!Discard()) return;
-
+ if (!Discard()) return;
+
// Add current to history
if (!m_filename.empty())
AddToHistory( m_filename );
- // Write .ini file
+ // Write .ini file
wxConfig *conf = (wxConfig*) wxConfig::Get();
-
+
int max = HISTORY_ENTRIES;
if (m_history.GetCount() < (size_t)max)
max = m_history.GetCount();
-
+
conf->Write( _T("/History/Count"), max );
-
+
for (int i = 0; i < max; i++)
{
wxString tmp;
tmp.Printf( _T("/History/File%d"), (int)i );
-
+
conf->Write( tmp, m_history[(size_t)i] );
}
-
+
// Flush and delete config
delete wxConfig::Set( NULL );
IMPLEMENT_APP(MyApp)
-MyApp::MyApp()
-{
-}
-
bool MyApp::OnInit()
{
SetVendorName(_T("Free world"));
SetAppName(_T("wxEdit"));
-
+
MyFrame *frame = new MyFrame( NULL, wxID_ANY, _T("wxEdit"), wxPoint(20,20), wxSize(500,340) );
frame->Show( true );
-
+
return true;
}
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE );
-
+
private:
void CreateMyMenuBar();
-
+
private:
wxTextCtrl *m_text;
wxString m_filename;
wxArrayString m_history;
-
+
private:
void OnAbout( wxCommandEvent &event );
void OnNew( wxCommandEvent &event );
void OnSave( wxCommandEvent &event );
void OnSaveAs( wxCommandEvent &event );
void OnQuit( wxCommandEvent &event );
-
+
void OnCopy( wxCommandEvent &event );
void OnCut( wxCommandEvent &event );
void OnPaste( wxCommandEvent &event );
void OnDelete( wxCommandEvent &event );
-
+
void OnLastFiles( wxCommandEvent &event );
-
+
void MakeHistory();
void AddToHistory( const wxString &fname );
-
+
bool Save();
bool Discard();
-
+
void OnUpdateUI( wxUpdateUIEvent &event );
void OnCloseWindow( wxCloseEvent &event );
-
+
private:
DECLARE_EVENT_TABLE()
};
class MyApp: public wxApp
{
public:
- MyApp();
-
+ MyApp(){};
+
virtual bool OnInit();
virtual int OnExit();
};
IMPLEMENT_APP(MyApp)
-// Testing of ressources
-MyApp::MyApp()
-{
-}
-
bool MyApp::OnInit(void)
{
// Create the main frame window
class MyApp: public wxApp
{
public:
- MyApp(void) ;
+ MyApp(void){};
bool OnInit(void);
};
}
-TestGLCanvas::~TestGLCanvas()
-{
-}
-
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
// This is a dummy, to avoid an endless succession of paint messages.
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = _T("TestGLCanvas"), int *gl_attrib = NULL);
- ~TestGLCanvas();
+ ~TestGLCanvas(){};
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
// when using the direct evaluation in the return statement
wxInt32 first = read_char(f) ;
wxInt32 second = read_char(f) ;
-
+
return (first<<8) | second ;
}
do {
c = read_char(f);
if (cnt < LW_MAX_NAME_LEN)
- s[cnt] = c;
+ s[cnt] = (char)c;
else
s[LW_MAX_NAME_LEN-1] = 0;
cnt++;
static void read_pols(FILE *f, int nbytes, lwObject *lwo)
{
int guess_cnt = lwo->face_cnt;
-
+
while (nbytes > 0) {
lwFace *face;
int i;
/* allocate space for points */
face->index = (int*) calloc(sizeof(int)*face->index_cnt,1);
-
+
/* read points in */
for (i=0; i<face->index_cnt; i++) {
face->index[i] = read_short(f);
nbytes -= 2;
}
-
+
/* read surface material */
face->material = read_short(f);
nbytes -= 2;
-
+
/* skip over detail polygons */
if (face->material < 0) {
int det_cnt;
// Name: ownerdrw.cpp
// Purpose: Owner-draw sample, for Windows
// Author: Vadim Zeitlin
-// Modified by:
+// Modified by:
// Created: 13.11.97
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
public:
// ctor & dtor
OwnerDrawnFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h);
- ~OwnerDrawnFrame();
+ ~OwnerDrawnFrame(){};
// notifications
void OnQuit (wxCommandEvent& event);
wxMenuItem *pAboutItem;
};
-enum
+enum
{
- Menu_Quit = 1,
+ Menu_Quit = 1,
Menu_First = 100,
- Menu_Test1, Menu_Test2, Menu_Test3,
- Menu_Bitmap, Menu_Bitmap2,
+ Menu_Test1, Menu_Test2, Menu_Test3,
+ Menu_Bitmap, Menu_Bitmap2,
Menu_Submenu, Menu_Sub1, Menu_Sub2, Menu_Sub3,
Menu_Toggle, Menu_About,
Control_First = 1000,
EVT_MENU(Menu_Quit, OwnerDrawnFrame::OnQuit)
EVT_LISTBOX(Control_Listbox, OwnerDrawnFrame::OnListboxSelect)
EVT_CHECKLISTBOX(Control_Listbox, OwnerDrawnFrame::OnCheckboxToggle)
- EVT_COMMAND(Control_Listbox, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
+ EVT_COMMAND(Control_Listbox, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
OwnerDrawnFrame::OnListboxDblClick)
END_EVENT_TABLE()
file_menu->Append(pItem);
file_menu->AppendSeparator();
- pItem = new wxMenuItem(file_menu, Menu_Toggle, _T("&Disable/Enable\tCtrl+D"),
+ pItem = new wxMenuItem(file_menu, Menu_Toggle, _T("&Disable/Enable\tCtrl+D"),
_T("enables/disables the About-Item"), wxITEM_NORMAL);
pItem->SetFont(*wxNORMAL_FONT);
file_menu->Append(pItem);
// Of course Ctrl+RatherLongAccel will not work in this example:
- pAboutItem = new wxMenuItem(file_menu, Menu_About, _T("&About\tCtrl+RatherLongAccel"),
+ pAboutItem = new wxMenuItem(file_menu, Menu_About, _T("&About\tCtrl+RatherLongAccel"),
_T("display program information"), wxITEM_NORMAL);
pAboutItem->SetBitmap(bmpInfo);
pAboutItem->SetDisabledBitmap(bmpInfo_mono);
wxPanel *pPanel = new wxPanel(this);
// check list box
- static const wxChar* aszChoices[] = { _T("Hello"), _T("world"), _T("and"),
+ static const wxChar* aszChoices[] = { _T("Hello"), _T("world"), _T("and"),
_T("goodbye"), _T("cruel"), _T("world"),
_T("-------"), _T("owner-drawn"), _T("listbox") };
// normal (but owner-drawn) listbox
static const wxChar* aszColors[] = { _T("Red"), _T("Blue"), _T("Pink"),
- _T("Green"), _T("Yellow"),
+ _T("Green"), _T("Yellow"),
_T("Black"), _T("Violet") };
astrChoices = new wxString[WXSIZEOF(aszColors)];
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
- struct { unsigned int r, g, b; } aColors[] =
+ struct { unsigned char r, g, b; } aColors[] =
{
{255,0,0}, {0,0,255}, {255,128,192},
- {0,255,0}, {255,255,128},
+ {0,255,0}, {255,255,128},
{0,0,0}, {128,0,255}
};
for ( ui = 0; ui < WXSIZEOF(aszColors); ui++ )
{
pListBox->GetItem(ui)->SetTextColour(wxColor(aColors[ui].r,
- aColors[ui].g,
+ aColors[ui].g,
aColors[ui].b));
// yellow on white is horrible...
if ( ui == 4 )
Show(true);
}
-OwnerDrawnFrame::~OwnerDrawnFrame()
-{
-}
-
void OwnerDrawnFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
IMPLEMENT_APP(MyApp)
-MyApp::MyApp()
-{
-}
-
bool MyApp::OnInit(void)
{
wxImage::AddHandler(new wxPNGHandler);
wxT("png"), wxT("PNG files (*.png)|*.png") );
if (f == _T("")) return;
-
+
wxBitmap *backstore = new wxBitmap( 150, 150 );
-
+
wxMemoryDC memDC;
memDC.SelectObject( *backstore );
memDC.Clear();
memDC.DrawLine( 0, 0, 0, 10 );
memDC.SetTextForeground( *wxWHITE );
memDC.DrawText( _T("This is a memory dc."), 10, 10 );
-
+
memDC.SelectObject( wxNullBitmap );
-
+
backstore->SaveFile( f, wxBITMAP_TYPE_PNG, (wxPalette*)NULL );
-
+
delete backstore;
}
{
}
-MyCanvas::~MyCanvas(void)
-{
-}
-
// Define the repainting behaviour
void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{
class MyApp: public wxApp
{
public:
- MyApp(void) ;
+ MyApp(void){};
bool OnInit(void);
};
{
public:
MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size);
- ~MyCanvas(void) ;
+ ~MyCanvas(void){};
void OnPaint(wxPaintEvent& event);
DECLARE_EVENT_TABLE()
// Writes a header on a page. Margin units are in millimetres.
bool WritePageHeader(wxPrintout *printout, wxDC *dc, wxChar *text, float mmToLogical);
-MyApp::MyApp()
-{
-}
-
// The `main program' equivalent, creating the windows and returning the
// main frame
bool MyApp::OnInit(void)
SetBackgroundColour(* wxWHITE);
}
-MyCanvas::~MyCanvas(void)
-{
-}
-
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
class MyApp: public wxApp
{
public:
- MyApp() ;
+ MyApp(){};
bool OnInit();
int OnExit();
{
public:
MyCanvas(wxFrame *frame, const wxPoint& pos, const wxSize& size, long style = wxRETAINED);
- ~MyCanvas(void) ;
+ ~MyCanvas(void){};
virtual void OnDraw(wxDC& dc);
void OnEvent(wxMouseEvent& event);
llist->IncNumLines();
}
-wxLayoutLine::~wxLayoutLine()
-{
- // kbList cleans itself
-}
-
wxPoint
wxLayoutLine::RecalculatePosition(wxLayoutList *llist)
{
wxASSERT(offset);
wxLayoutObjectList::iterator
i,
- found = NULLIT;
+ found(NULL),
+ nulled(NULL);
CoordType x = 0, len;
/* We search through the objects. As we don't like returning the
object that the cursor is behind, we just remember such an
object in "found" so we can return it if there is really no
further object following it. */
- for(i = m_ObjectList.begin(); i != NULLIT; i++)
+ for(i = m_ObjectList.begin(); i != nulled; i++)
{
len = (**i).GetLength();
if( x <= xpos && xpos <= x + len )
llist->ApplyStyle(GetStyleInfo(), dc);
- wxLayoutObjectList::iterator i;
+ wxLayoutObjectList::iterator i, nulled(NULL);
CoordType x = 0, cx = 0, width;
- for(i = m_ObjectList.begin(); i != NULLIT; i++)
+ for(i = m_ObjectList.begin(); i != nulled; i++)
{
wxLayoutObject *obj = *i;
if ( obj->GetType() == WXLO_TYPE_CMD )
CoordType offset;
wxLOiterator i = FindObject(xpos, &offset);
- if(i == NULLIT)
+ wxLayoutObjectList::iterator nulled(NULL);
+ if(i == nulled)
{
if(xpos == 0 ) // aha, empty line!
{
CoordType offset;
wxLOiterator i = FindObject(xpos, &offset);
- if(i != NULLIT && (**i).GetType() == WXLO_TYPE_TEXT)
+ wxLayoutObjectList::iterator nulled(NULL);
+ if(i != nulled && (**i).GetType() == WXLO_TYPE_TEXT)
{
wxLayoutObjectText *tobj = (wxLayoutObjectText *) *i;
tobj->GetText().insert(offset, text);
wxASSERT(npos >= 0);
MarkDirty(xpos);
wxLOiterator i = FindObject(xpos, &offset);
+ wxLayoutObjectList::iterator nulled(NULL);
while(npos > 0)
{
- if(i == NULLIT) return npos;
+ if(i == nulled) return npos;
// now delete from that object:
if((**i).GetType() != WXLO_TYPE_TEXT)
{
MarkDirty(xpos);
wxLOiterator i = FindObject(xpos, &offset);
-
+ wxLayoutObjectList::iterator nulled(NULL);
for(;;)
{
- if(i == NULLIT) return false;
+ if(i == nulled) return false;
if((**i).GetType() != WXLO_TYPE_TEXT)
{
// This should only happen when at end of line, behind a non-text
wxLayoutList *llist,
const wxPoint & offset) const
{
- wxLayoutObjectList::iterator i;
+ wxLayoutObjectList::iterator i, nulled(NULL);
wxPoint pos = offset;
pos = pos + GetPosition();
else
llist->EndHighlighting(dc);
- for(i = m_ObjectList.begin(); i != NULLIT; i++)
+ for(i = m_ObjectList.begin(); i != nulled; i++)
{
if(highlight == -1) // partially highlight line
{
int cx,
bool WXUNUSED(suppressSIupdate))
{
- wxLayoutObjectList::iterator i;
+ wxLayoutObjectList::iterator i, nulled(NULL);
// when a line becomes dirty, we redraw it from the place where it was
// changed till the end of line (because the following wxLayoutObjects are
}
m_StyleInfo = llist->GetStyleInfo(); // save current style
- for(i = m_ObjectList.begin(); i != NULLIT; i++)
+ for(i = m_ObjectList.begin(); i != nulled; i++)
{
wxLayoutObject *obj = *i;
obj->Layout(dc, llist);
CoordType offset;
wxLOiterator i = FindObject(xpos, &offset);
- if(i == NULLIT)
+ wxLayoutObjectList::iterator nulled(NULL);
+ if(i == nulled)
// must be at the end of the line then
return new wxLayoutLine(this, llist);
// split this line:
bool
wxLayoutLine::Wrap(CoordType wrapmargin, wxLayoutList *llist)
{
+ wxLayoutObjectList::iterator nulled(NULL);
if(GetLength() < wrapmargin)
return false; // nothing to do
// find the object which covers the wrapmargin:
CoordType offset;
wxLOiterator i = FindObject(wrapmargin, &offset);
- wxCHECK_MSG( i != NULLIT, false,
+ wxCHECK_MSG( i != nulled, false,
wxT("Cannot find object covering wrapmargin."));
// from this object on, the rest of the line must be copied to the
// next one:
- wxLOiterator copyObject = NULLIT;
+ wxLOiterator copyObject = nulled;
// if we split a text-object, we must pre-pend some text to the
// next line later on, remember it here:
wxString prependText = _T("");
bool foundSpace = false;
do
{
-// while(i != NULLIT && (**i).GetType() != WXLO_TYPE_TEXT)
+// while(i != nulled && (**i).GetType() != WXLO_TYPE_TEXT)
// i--;
// try to find a suitable place to split the object:
wxLayoutObjectText *tobj = (wxLayoutObjectText *)*i;
if( this == llist->GetCursorLine() && xpos >= breakpos )
{
for(wxLOiterator j = m_ObjectList.begin();
- j != NULLIT && j != i; j++)
+ j != nulled && j != i; j++)
objectCursorPos += (**j).GetLength();
}
// now we know where to break it:
wxASSERT(m_Next);
// We need to move this and all following objects to the next
// line. Starting from the end of line, to keep the order right.
- if(copyObject != NULLIT)
+ if(copyObject != nulled)
{
wxLOiterator j;
for(j = m_ObjectList.tail(); j != copyObject; j--)
{
CoordType offset;
wxLOiterator i = FindObject(column, &offset);
- if(i == NULLIT) return -1; // cannot wrap
+ wxLayoutObjectList::iterator nulled(NULL);
+ if(i == nulled) return -1; // cannot wrap
// go backwards through the list and look for space in text objects
do
column -= (**i).GetLength();
i--;
}
- if( i != NULLIT)
+ if( i != nulled)
offset = (**i).GetLength();
- }while(i != NULLIT);
+ }while(i != nulled);
/* If we reached the begin of the list and have more than one
object, that one is longer than the margin, so break behind
it. */
CoordType pos = 0;
i = m_ObjectList.begin();
- while(i != NULLIT && (**i).GetType() != WXLO_TYPE_TEXT)
+ while(i != nulled && (**i).GetType() != WXLO_TYPE_TEXT)
{
pos += (**i).GetLength();
i++;
}
- if(i == NULLIT) return -1; //why should this happen?
+ if(i == nulled) return -1; //why should this happen?
// now we are behind the one long text object and need to find the
// first space in it
void
wxLayoutLine::Debug() const
{
+ wxLayoutObjectList::iterator nulled(NULL);
wxPoint pos = GetPosition();
WXLO_DEBUG((wxT("Line %ld, Pos (%ld,%ld), Height %ld, BL %ld, Font: %d"),
(long int) GetLineNumber(),
(long int) GetHeight(),
(long int) m_BaseLine,
(int) m_StyleInfo.family));
- if(m_ObjectList.begin() != NULLIT)
+ if(m_ObjectList.begin() != nulled)
{
WXLO_DEBUG(((**m_ObjectList.begin()).DebugDump().c_str()));
}
CoordType from,
CoordType to)
{
+ wxLayoutObjectList::iterator nulled(NULL);
CoordType firstOffset, lastOffset;
if(to == -1) to = GetLength();
wxLOiterator last = FindObject(to, &lastOffset);
// Common special case: only one object
- if( first != NULLIT && last != NULLIT && *first == *last )
+ if( first != nulled && last != nulled && *first == *last )
{
if( (**first).GetType() == WXLO_TYPE_TEXT )
{
bool
wxLayoutList::MoveCursorWord(int n, bool untilNext)
{
+ wxLayoutObjectList::iterator nulled(NULL);
wxCHECK_MSG( m_CursorLine, false, wxT("no current line") );
wxCHECK_MSG( n == -1 || n == +1, false, wxT("not implemented yet") );
n != 0;
n > 0 ? i++ : i-- )
{
- if ( i == NULLIT )
+ if ( i == nulled )
{
if ( n > 0 )
{
i = lineCur->GetLastObject();
}
- if ( i == NULLIT )
+ if ( i == nulled )
{
// moved to the end/beginning of text
return false;
bool
wxLayoutList::Insert(wxLayoutList *llist)
{
+ wxLayoutObjectList::iterator nulled(NULL);
wxASSERT(llist);
bool rc = true;
)
{
for(wxLOiterator i = line->GetFirstObject();
- i != NULLIT;
+ i != nulled;
i++)
rc |= Insert(*i);
LineBreak();
wxLayoutList::FindObjectScreen(wxDC &dc, wxPoint const pos,
wxPoint *cursorPos, bool *found)
{
+ wxLayoutObjectList::iterator nulled(NULL);
// First, find the right line:
wxLayoutLine
*line = m_FirstLine,
if ( found )
*found = didFind && foundinline;
- return (i == NULLIT) ? NULL : *i;
+ return (i == nulled) ? NULL : *i;
}
// layout is called in ScaleDC() when we have a DC
}
-wxLayoutPrintout::~wxLayoutPrintout()
-{
-}
-
float
wxLayoutPrintout::ScaleDC(wxDC *dc)
{
/// Define a list type of wxLayoutObject pointers.
KBLIST_DEFINE(wxLayoutObjectList, wxLayoutObject);
-/// An illegal iterator to save typing.
-#define NULLIT (wxLayoutObjectList::iterator(NULL))
-
/// The iterator type.
typedef wxLayoutObjectList::iterator wxLOiterator;
@param xpos the column number
@param offset where to store the difference between xpos and
the object's head
- @return iterator to the object or NULLIT
+ @return iterator to the object or iterator to NULL
*/
wxLayoutObjectList::iterator FindObject(CoordType xpos, CoordType
*offset) const ;
@param xpos the screen x coordinate
@param offset where to store the difference between xpos and
the object's head
- @return iterator to the object or NULLIT
+ @return iterator to the object or iterator to NULL
*/
wxLayoutObjectList::iterator FindObjectScreen(wxDC &dc,
wxLayoutList *llist,
private:
/// Destructor is private. Use DeleteLine() to remove it.
- ~wxLayoutLine();
+ ~wxLayoutLine(){};
/**@name Functions to let the lines synchronise with each other. */
//@{
_T("wxLayout Printout"));
/// Destructor.
- ~wxLayoutPrintout();
+ ~wxLayoutPrintout(){};
/** Function which prints the n-th page.
@param page the page number to print
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
int mode, int flags)
{
+ wxLayoutObjectList::iterator nulled(NULL);
wxASSERT(status);
wxLayoutExportObject * exp;
- if(status->m_iterator == NULLIT) // end of line
+ if(status->m_iterator == nulled) // end of line
{
if(!status->m_line || status->m_line->GetNextLine() == NULL)
// reached end of list
}
exp = new wxLayoutExportObject();
wxLayoutObjectType type;
- if(status->m_iterator != NULLIT)
+ if(status->m_iterator != nulled)
{
type = (** status->m_iterator).GetType();
if( mode == WXLO_EXPORT_AS_OBJECTS || ! WXLO_IS_TEXT(type)) // simple case
}
}
else
- { // iterator == NULLIT
+ { // iterator == nulled
if(mode == WXLO_EXPORT_AS_OBJECTS)
{
exp->type = WXLO_EXPORT_EMPTYLINE;
// text must be concatenated
for(;;)
{
- while(status->m_iterator == NULLIT)
+ while(status->m_iterator == nulled)
{
if(mode & WXLO_EXPORT_AS_HTML)
*str += _T("<br>");
public:
MyCanvas() {}
MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size );
- ~MyCanvas();
+ ~MyCanvas(){};
void OnPaint( wxPaintEvent &event );
void OnQueryPosition( wxCommandEvent &event );
void OnAddButton( wxCommandEvent &event );
SetCursor( wxCursor( wxCURSOR_IBEAM ) );
}
-MyCanvas::~MyCanvas()
-{
-}
-
void MyCanvas::OnMouseDown( wxMouseEvent &event )
{
if (event.LeftDown())
class MyScrolledWindow: public wxScrolledWindow
{
public:
- MyScrolledWindow() {}
+ MyScrolledWindow(){};
MyScrolledWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size );
- ~MyScrolledWindow();
+ ~MyScrolledWindow(){};
void OnPaint( wxPaintEvent &event );
private:
class MyCanvas: public wxPanel
{
public:
- MyCanvas() {}
+ MyCanvas(){};
MyCanvas( wxScrolledWindow *parent, MyTopLabels *top, MyRightLabels *right,
wxWindowID id, const wxPoint &pos, const wxSize &size );
- ~MyCanvas();
+ ~MyCanvas(){};
void OnPaint( wxPaintEvent &event );
void ScrollWindow( int dx, int dy, const wxRect *rect );
SetSizer( mainsizer );
}
-MyScrolledWindow::~MyScrolledWindow()
-{
-}
-
void MyScrolledWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
wxPaintDC dc( this );
SetCursor( wxCursor( wxCURSOR_IBEAM ) );
}
-MyCanvas::~MyCanvas()
-{
-}
-
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
wxPaintDC dc( this );
# pragma hdrstop
#endif
-// for all others, include the necessary headers
+// for all others, include the necessary headers
#ifndef WX_PRECOMP
# include "wx/wx.h"
#endif
// // update waitmore if needed.
// }
// bool success = client->IsConnected();
- //
+ //
// And that's all :-)
m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n"));
m_text->AppendText(_("Failed ! Unable to connect\n"));
wxMessageBox(_("Can't connect to the specified host"), _("Alert !"));
}
-
+
UpdateStatusBar();
}
m_sock->SetFlags(wxSOCKET_WAITALL);
buf1 = _("Test string (less than 256 chars!)");
- len = (wxStrlen(buf1) + 1) * sizeof(wxChar);
+ len = (unsigned char)((wxStrlen(buf1) + 1) * sizeof(wxChar));
buf2 = new wxChar[wxStrlen(buf1) + 1];
m_text->AppendText(_("Sending a test buffer to the server ..."));
m_text->AppendText(_("Comparing the two buffers ..."));
if (memcmp(msg1, msg2, len) != 0)
{
- m_text->AppendText(_("failed!\n"));
+ m_text->AppendText(_("failed!\n"));
m_text->AppendText(_("Test 2 failed !\n"));
}
else
{
public:
MyFrame();
- virtual ~MyFrame();
+ virtual ~MyFrame(){};
// Menu commands
void SplitHorizontal(wxCommandEvent& event);
{
public:
MyCanvas(wxWindow* parent, bool mirror);
- virtual ~MyCanvas();
+ virtual ~MyCanvas(){};
virtual void OnDraw(wxDC& dc);
#endif // wxUSE_STATUSBAR
}
-MyFrame::~MyFrame()
-{
-}
-
// menu command handlers
void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) )
m_mirror = mirror;
}
-MyCanvas::~MyCanvas()
-{
-}
-
void MyCanvas::OnDraw(wxDC& dcOrig)
{
wxMirrorDC dc(dcOrig, m_mirror);
{
public:
MyPanel(wxFrame *frame, int x, int y, int w, int h);
- virtual ~MyPanel()
- {
+ virtual ~MyPanel()
+ {
#if wxUSE_LOG
- delete wxLog::SetActiveTarget(m_logOld);
+ delete wxLog::SetActiveTarget(m_logOld);
#endif // wxUSE_LOG
}
if ( !m_panel->m_textrich->PageUp() )
wxLogMessage(_T("Already at the top"));
}
-
+
void OnGetLine(wxCommandEvent& WXUNUSED(event))
{
long nLine = wxGetNumberFromUser(wxT("Which line would you like to get?"),
wxT("Enter which line you would like to get"),
wxT("Get a line from the tabbed multiline text control") );
-
+
wxMessageBox(m_panel->m_tab->GetLineText(nLine));
}
long nLine = wxGetNumberFromUser(wxT("Which line would you like to get?"),
wxT("Enter which line you would like to get"),
wxT("Get length of a line from the tabbed multiline text control") );
-
- wxMessageBox(wxString::Format(wxT("Length of line %i is:%i"),
+
+ wxMessageBox(wxString::Format(wxT("Length of line %i is:%i"),
(int) nLine,
m_panel->m_tab->GetLineLength(nLine))
);
TEXT_LINE_UP,
TEXT_PAGE_DOWN,
TEXT_PAGE_UP,
-
+
TEXT_GET_LINE,
TEXT_GET_LINELENGTH,
-
+
TEXT_REMOVE,
TEXT_REPLACE,
TEXT_SELECT,
wxTextAttr attr;
attr.SetFont(font);
-
+
long start, end;
m_textCtrl->GetSelection(& start, & end);
m_textCtrl->SetStyle(start, end, attr);
data.SetChooseFull(true);
for (int i = 0; i < 16; i++)
{
- wxColour colour(i*16, i*16, i*16);
+ wxColour colour((unsigned char)(i*16), (unsigned char)(i*16), (unsigned char)(i*16));
data.SetCustomColour(i, colour);
}
wxTextAttr attr;
attr.SetTextColour(col);
-
+
long start, end;
m_textCtrl->GetSelection(& start, & end);
m_textCtrl->SetStyle(start, end, attr);
data.SetChooseFull(true);
for (int i = 0; i < 16; i++)
{
- wxColour colour(i*16, i*16, i*16);
+ wxColour colour((unsigned char)(i*16), (unsigned char)(i*16), (unsigned char)(i*16));
data.SetCustomColour(i, colour);
}
wxTextAttr attr;
attr.SetBackgroundColour(col);
-
+
long start, end;
m_textCtrl->GetSelection(& start, & end);
m_textCtrl->SetStyle(start, end, attr);
wxTextAttr attr;
attr.SetLeftIndent(indent);
-
+
long start, end;
m_textCtrl->GetSelection(& start, & end);
m_textCtrl->SetStyle(start, end, attr);
wxTextAttr attr;
attr.SetRightIndent(indent);
-
+
long start, end;
m_textCtrl->GetSelection(& start, & end);
m_textCtrl->SetStyle(start, end, attr);
{
public:
MyApp();
- virtual ~MyApp();
+ virtual ~MyApp(){};
virtual bool OnInit();
m_waitingUntilAllDone = false;
}
-MyApp::~MyApp()
-{
-}
-
// `Main program' equivalent, creating windows and returning main app frame
bool MyApp::OnInit()
{
void MyFrame::OnSize(wxSizeEvent& event)
{
- if ( m_treeCtrl
+ if ( m_treeCtrl
#if wxUSE_LOG
- && m_textCtrl
+ && m_textCtrl
#endif // wxUSE_LOG
)
{
#endif
}
-MyTreeCtrl::~MyTreeCtrl()
-{
-}
-
int MyTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
const wxTreeItemId& item2)
{
{
//attempt to guess where to show the menu
if (item.IsOk())
- {
+ {
//if an item was clicked, show menu to the right of it
wxRect rect;
GetBoundingRect(item, rect, true); //true = only the label
//event was generated by mouse, use supplied coords
pt = ScreenToClient(pt);
}
-
+
ShowMenu(item, pt);
}
MyTreeCtrl(wxWindow *parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style);
- virtual ~MyTreeCtrl();
+ virtual ~MyTreeCtrl(){};
void OnBeginDrag(wxTreeEvent& event);
void OnBeginRDrag(wxTreeEvent& event);
EVT_MENU(TYPES_MIME, MyApp::DoMIMEDemo)
END_EVENT_TABLE()
+wxString file_name = _T("test_wx.dat");
+wxString file_name2 = wxString(_T("test_wx2.dat"));
+
bool MyApp::OnInit()
{
// Create the main frame window
textCtrl.WriteText( _T("Writing to ofstream and wxFileOutputStream:\n") );
wxSTD ofstream std_file_output( "test_std.dat" );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
wxBufferedOutputStream buf_output( file_output );
wxTextOutputStream text_output( buf_output );
buf_output.Sync();
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
wxBufferedInputStream buf_input( file_input );
wxTextInputStream text_input( file_input );
textCtrl.WriteText( _T("Writing number 0 to 9 to buffered wxFileOutputStream:\n\n") );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
wxBufferedOutputStream buf_output( file_output );
for (ch = 0; ch < 10; ch++)
buf_output.Write( &ch, 1 );
buf_output.Sync();
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
for (ch2 = 0; ch2 < 10; ch2++)
{
file_input.Read( &ch, 1 );
textCtrl.WriteText( _T("Writing number 0 to 9 to buffered wxFileOutputStream, then\n") );
textCtrl.WriteText( _T("seeking back to #3 and writing 0:\n\n") );
- wxFileOutputStream file_output2( wxString(_T("test_wx2.dat")) );
+ wxFileOutputStream file_output2( file_name2 );
wxBufferedOutputStream buf_output2( file_output2 );
for (ch = 0; ch < 10; ch++)
buf_output2.Write( &ch, 1 );
buf_output2.Write( &ch, 1 );
buf_output2.Sync();
- wxFileInputStream file_input2( wxString(_T("test_wx2.dat")) );
+ wxFileInputStream file_input2( file_name2 );
for (ch2 = 0; ch2 < 10; ch2++)
{
file_input2.Read( &ch, 1 );
textCtrl.WriteText( _T("Reading number 0 to 9 from buffered wxFileInputStream, then\n") );
textCtrl.WriteText( _T("seeking back to #3 and reading the 0:\n\n") );
- wxFileInputStream file_input3( wxString(_T("test_wx2.dat")) );
+ wxFileInputStream file_input3( file_name2 );
wxBufferedInputStream buf_input3( file_input3 );
for (ch2 = 0; ch2 < 10; ch2++)
{
textCtrl.WriteText( _T("Writing number 0 to 9 to wxFileOutputStream:\n\n") );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
for (ch = 0; ch < 10; ch++)
file_output.Write( &ch, 1 );
textCtrl.WriteText( _T("Reading 0 to 10 to wxFileInputStream:\n\n") );
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
for (ch2 = 0; ch2 < 11; ch2++)
{
file_input.Read( &ch, 1 );
textCtrl.WriteText( _T("Reading 0 to 10 to wxFFileInputStream:\n\n") );
- wxFFileInputStream ffile_input( wxString(_T("test_wx.dat")) );
+ wxFFileInputStream ffile_input( file_name );
for (ch2 = 0; ch2 < 11; ch2++)
{
ffile_input.Read( &ch, 1 );
textCtrl.WriteText( _T("Reading 0 to 10 to buffered wxFFileInputStream:\n\n") );
- wxFFileInputStream ffile_input2( wxString(_T("test_wx.dat")) );
+ wxFFileInputStream ffile_input2( file_name );
wxBufferedInputStream buf_input( ffile_input2 );
for (ch2 = 0; ch2 < 11; ch2++)
{
// bigger than buffer
textCtrl.WriteText( _T("Writing 2000x 1 to wxFileOutputStream.\n\n") );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
for (int i = 0; i < 2000; i++)
{
char ch = 1;
textCtrl.WriteText( _T("Opening with a buffered wxFileInputStream:\n\n") );
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
wxBufferedInputStream buf_input( file_input );
textCtrl.WriteText( _T("wxBufferedInputStream.GetLastError() returns: ") );
textCtrl.WriteText( _T("Writing number 0 to 9 to wxFileOutputStream:\n\n") );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
for (ch = 0; ch < 10; ch++)
file_output.Write( &ch, 1 );
file_output.Sync();
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
ch = file_input.Peek();
str.Printf( wxT("First char peeked: %d\n"), (int) ch );
textCtrl.WriteText( _T("Writing number 0 to 9 to wxFileOutputStream...\n\n") );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
for (ch = 0; ch < 10; ch++)
file_output.Write( &ch, 1 );
textCtrl.WriteText( _T("Reading char from wxFileInputStream:\n\n") );
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
ch = file_input.GetC();
- size_t pos = file_input.TellI();
+ size_t pos = (size_t)file_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading another char from wxFileInputStream:\n\n") );
ch = file_input.GetC();
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading yet another char from wxFileInputStream:\n\n") );
ch = file_input.GetC();
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Now calling Ungetch( 5 ) from wxFileInputStream...\n\n") );
file_input.Ungetch( 5 );
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Now at position %d\n\n"), (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading char from wxFileInputStream:\n\n") );
ch = file_input.GetC();
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading another char from wxFileInputStream:\n\n") );
ch = file_input.GetC();
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Now calling Ungetch( 5 ) from wxFileInputStream again...\n\n") );
file_input.Ungetch( 5 );
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Now at position %d\n\n"), (int) pos );
textCtrl.WriteText( str );
file_input.SeekI( 3 );
ch = file_input.GetC();
- pos = file_input.TellI();
+ pos = (size_t)file_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
}
textCtrl.WriteText( _T("Writing number 0 to 9 to wxFileOutputStream...\n\n") );
- wxFileOutputStream file_output( wxString(_T("test_wx.dat")) );
+ wxFileOutputStream file_output( file_name );
for (ch = 0; ch < 10; ch++)
file_output.Write( &ch, 1 );
textCtrl.WriteText( _T("Reading char from wxBufferedInputStream via wxFileInputStream:\n\n") );
- wxFileInputStream file_input( wxString(_T("test_wx.dat")) );
+ wxFileInputStream file_input( file_name );
wxBufferedInputStream buf_input( file_input );
ch = buf_input.GetC();
- size_t pos = buf_input.TellI();
+ size_t pos = (size_t)buf_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading another char from wxBufferedInputStream:\n\n") );
ch = buf_input.GetC();
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading yet another char from wxBufferedInputStream:\n\n") );
ch = buf_input.GetC();
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Now calling Ungetch( 5 ) from wxBufferedInputStream...\n\n") );
buf_input.Ungetch( 5 );
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Now at position %d\n\n"), (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading char from wxBufferedInputStream:\n\n") );
ch = buf_input.GetC();
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Reading another char from wxBufferedInputStream:\n\n") );
ch = buf_input.GetC();
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
textCtrl.WriteText( _T("Now calling Ungetch( 5 ) from wxBufferedInputStream again...\n\n") );
buf_input.Ungetch( 5 );
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Now at position %d\n\n"), (int) pos );
textCtrl.WriteText( str );
buf_input.SeekI( 3 );
ch = buf_input.GetC();
- pos = buf_input.TellI();
+ pos = (size_t)buf_input.TellI();
str.Printf( wxT("Read char: %d. Now at position %d\n\n"), (int) ch, (int) pos );
textCtrl.WriteText( str );
}
}
-MyResizableListCtrl::~MyResizableListCtrl()
-{
-}
-
-
void MyResizableListCtrl::ContextSensitiveMenu( wxMouseEvent& event )
{
// Make an instance of a menu.
);
// Destuctor.
- ~MyResizableListCtrl();
+ ~MyResizableListCtrl(){};
protected:
wxXmlResource::Get()->LoadDialog(this, parent, wxT("derived_dialog"));
}
-// Destructor. (Empty, as I don't need anything special done when destructing).
-PreferencesDialog::~PreferencesDialog()
-{
-}
-
//-----------------------------------------------------------------------------
// Private members (including the event handlers)
//-----------------------------------------------------------------------------
PreferencesDialog( wxWindow* parent );
// Destructor.
- ~PreferencesDialog();
+ ~PreferencesDialog(){};
private: