- Windows 3.1,Windows 95/98,Windows NT
- 带有
Motif/Lesstif 的大多数 UNIX 版本
- 带有 GTK+ 的大多数 UNIX 版本
- Mac
- wxInt32(32 位有符号整数)
- wxInt16(16 位有符号整数)
- wxInt8(8 位有符号整数)
- wxUint32(32 位无符号整数)
- wxUint16 =
wxWord(16 位无符号整数)
- wxUint8 = wxByte(8 位无符号整数)
- wxINTxx_SWAP_ON_BE()
- wxUINTxx_SWAP_ON_BE()
- wxINTxx_SWAP_ON_LE()
- wxUINTxx_SWAP_ON_LE()
- wxINTxx_SWAP_ALWAYS()
- wxUINTxx_SWAP_ALWAYS()
wxInt32 old_var
= 0xF
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_p_w_picpath = new wxImage( bitmap );
// Have some fun
if ( p_p_w_picpath->Ok() ){
if (
p_p_w_picpath->GetHeight() > 50 && p_p_w_picpath->GetWidth() > 50 ){
unsigned
char red = p_p_w_picpath->GetRed( 50, 50
);
unsigned
char green = p_p_w_picpath->GetGreen( 50, 50 );
unsigned
char blue = p_p_w_picpath->GetBlue( 50,
50 );
// Secure
but might be slow
p_p_w_picpath->SetRGB( 50, 50, red, green, blue );
// If you
want fast action use a pointer...
unsigned
char* data = p_p_w_picpath->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
}
|
- 您可以参阅本文在
developerWorks 全球站点上的 英文原文.
- 仔细查看 wxWindows 主页
- 阅读有关 Sourceforge 上的 wxWindows信息
- wxStudio 是创建免费、跨平台集成开发环境的研究计划
- wxDesigner 有 Windows 和 UNIX 版可用
- wxPROs 是 wxWindows 和 wxPython 的专业人员资源组织