wxInt32 old_var = 0xF 1F 2F 3F 4;
wxInt32 new_var = wxINT32_SWAP_ALWAYS( old_var )
|
if ( wxBYTE_ORDER == wxLITTLE_ENDIAN ){
// Do stuff for little endian machine...
}else{
// Do stuff for big endian machine...
}
|
wxString old_report = "smithers_00.doc"
wxString new_report = "my_smithers.doc";
if ( wxCopyFile( old_report, "smithers_00.bak" ) == true ){
if ( wxRemoveFile( old_report ) == true ){
if ( wxRenameFile( new_report, old_report ) == false ){
// Doh!
}
}
}
|
wxPathList path_list;
// Add current working directory
path_list.Add( "." );
// Add one directory above current working directory
path_list.Add( ".." );
// Add directories from environment variable PATH to the list
path_list.AddEnvList( "PATH" );
wxString path = path_list.FindValidPath( "homer.bmp" );
|
wxHtmlWindow html_window = new wxHtmlWindow( this );
html_window->SetRelatedFrame( this, "HTML : %%s" );
html_window->SetRelatedStatusBar( 0 );
|
html_window->LoadPage( "burns.htm" );
|
html_window->SetPage( "<html><body>Hello, Monty!</body></html>" );
|
bool MyApp::OnInit()
{
wxImage::AddHandler( new wxPNGHandler );
// more ...
}
|
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "maggie.xpm"
#endif
// more ...
void MyApp::UseBitmap()
{
wxBitmap bitmap( wxBITMAP( maggie ));
// more ...
}
|
wxImage* p_image = new wxImage( bitmap );
// Have some fun
if ( p_image->Ok() ){
if ( p_image->GetHeight() > 50 && p_image->GetWidth() > 50 ){
unsigned char red = p_image->GetRed( 50, 50 );
unsigned char green = p_image->GetGreen( 50, 50 );
unsigned char blue = p_image->GetBlue( 50, 50 );
// Secure but might be slow
p_image->SetRGB( 50, 50, red, green, blue );
// If you want fast action use a pointer...
unsigned char* data = p_image->GetData();
// Manipulate the data...
}
}
|
#ifdef USE__UNICODE
wchar_t wide_char = L'h';
wchar_t const* wide_string = L"Hello, World!";
int length = wcslen( wide_string );
#else
char ansi_char = 'h';
char const* ansi_string = "Hello, World!";
int length = strlen( ansi_string );
#endif
|
wxChar wx_char = wxT( '*' );
wxString wx_string = wxT( "Hello, World!" );
int length = wx_string.Len();
|
// Start logging for Dump() call
wxDebugContext::SetCheckpoint();
wxString *thing = new wxString;
wxDate* date = new wxDate;
// non-object allocation
char *ordinaryNonObject = new char[1000];
// more ...
// Print number of object and non-object allocations
wxDebugContext::Dump();
// Print allocation statistics
wxDebugContext::PrintStatistics();
|
13:32:45: ----- Memory dump of memcheck at Tue Dec 26 13:32:45 2000 -----
13:32:45: ..\..\..\samples\memcheck\memcheck.cpp(88):
non-object data at $DD3DC0, size 4
13:32:45: ..\..\..\samples\memcheck\memcheck.cpp(89):
wxDate at $DD40D0, size 24
13:32:45: ..\..\..\samples\memcheck\memcheck.cpp(92):
non-object data at $DD4118, size 1000
|
13:32:45: ----- Memory statistics of memcheck at Tue Dec 26 13:32:45 2000 -----
13:32:45: 1 objects of class wxDate, total size 24
13:32:45: 5 objects of class nonobject, total size 4256
13:32:45:
13:32:45: Number of object items: 1
13:32:45: Number of non-object items: 5
13:32:45: Total allocated size: 4280
|
wxString s1 = "Hello, World!";
wxString s2 = "Hello";
if ( s1.IsEmpty() == false ){
s2.Empty();
s2 = s1.Left( 5 );
int pos = s1.Find( ',' );
s2 += s1.Mid( pos, 2 );
s2 += s1.Right( 6 );
}
|
class CButtonCtrl : public COleControl
{
// Implementation
protected:
LRESULT OnOcmCommand( WPARAM wParam, LPARAM lParam );
DECLARE_MESSAGE_MAP()
};
|
BEGIN_MESSAGE_MAP( CButtonCtrl, COleControl )
//{{AFX_MSG_MAP( CButtonCtrl )
ON_MESSAGE( OCM_COMMAND, OnOcmCommand )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
|
class MyButton : public wxButton
{
void OnButton( wxMouseEvent& event )
private:
DECLARE_EVENT_TABLE()
};
|
BEGIN_EVENT_TABLE( MyButton, wxButton )
EVT_BUTTON( -1, MyButton::OnButton )
END_EVENT_TABLE()
|
class A {
virtual void foo() {};
};
class B : public A {};
A* p_A = new B();
B* p_B = dynamic_cast( p_A );
|
B* p_B = wxDynamicCast( p_A, B );
|
wxString s1 = "Hello, World!";
wxString s2 = "Hello";
s2.erase();
for ( size_t i = 0; i < s1.length(); ++i )
s2 += s1[i];
if ( s1.compare( s2 ) == 0 ) {
// Strings are equal
}
|