WCToolbar_Bridge::WCToolbar_Bridge(WCMainFrame *frame, WCToolbar* toolbar, const std::string &title, const WCVector4 &position) : _frame(frame), _isVisible(false), _title(title), _core(toolbar), _platform(NULL) { //Create platform toolbar this->_platform = this->_frame->AddToolBar(wxConvertMB2WX(title.c_str())); //Make sure is not nil if (this->_platform == NULL) { CLOGGER_ERROR(WCLogManager::RootLogger(), "WCToolbar_Bridge::WCToolbar_Bridge - Not able to create platform toolbar"); } //Add the toolbar to wx this->_platform->Realize(); this->_frame->AuiManager()->AddPane(this->_platform, wxAuiPaneInfo().Name(wxConvertMB2WX(title.c_str())).Caption(wxConvertMB2WX(title.c_str())).ToolbarPane().Top().Left()); this->_frame->AuiManager()->GetPane(this->_platform).Show(); }
void WCToolbar_Bridge::AddButton(WCToolbarButton_Bridge *button) { //Create wx Button object with appropriate parameters wxString msg = wxConvertMB2WX(button->Message().c_str()); wxString tooltip = wxConvertMB2WX(button->Tooltip().c_str()); //m_type = type; wxString stdIcon = wxConvertMB2WX(button->StandardIcon().c_str()); wxString activeIcon = wxConvertMB2WX(button->ActiveIcon().c_str()); //Call to platform to add the toolbar button wxString imagePath = wxGetApp().GetExeFolder() + _T("/Resources/") + stdIcon + _T(".tiff"); wxToolBarToolBase* tool = this->_frame->AddToolBarTool(this->_platform, this->_nextToolID, msg, wxBitmap(imagePath, wxBITMAP_TYPE_TIF), tooltip); //Update the toolbar this->_platform->Realize(); this->_nextToolID++; }
bool wxGetFullHostName(wxChar *buf, int sz) { bool ok = wxGetHostNameInternal(buf, sz); if ( ok ) { if ( !wxStrchr(buf, wxT('.')) ) { struct hostent *host = gethostbyname(wxConvertWX2MB(buf)); if ( !host ) { wxLogSysError(_("Cannot get the official hostname")); ok = false; } else { // the canonical name wxStrncpy(buf, wxConvertMB2WX(host->h_name), sz); } } //else: it's already a FQDN (BSD behaves this way) } return ok; }
// class constructor Resound::MonitorNodeWidget::MonitorNodeWidget(wxWindow* parent, int id, ParameterAddress _addr) : Resound::ParameterAddressWidgetBase(parent,id,_addr) { SetWindowStyle(wxSIMPLE_BORDER | wxCLIP_CHILDREN); SetBackgroundColour(wxColour(30,100,150)); SetForegroundColour(wxColour(255,255,255)); wxSize size(45,45); SetSize(size); SetMinSize(size); SetMaxSize(size); // construct the sub objects and sizer wxBoxSizer *topSizer = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *leftSizer = new wxBoxSizer( wxVERTICAL ); SetToolTip(wxConvertMB2WX(addr.get_address().c_str())); //leftSizer->Add(new wxStaticText(this,MNW_LABEL,label, wxPoint(0,0),wxSize(40,18),wxALIGN_CENTRE),wxSizerFlags(0).Align(0).Border(wxALL,0)); //leftSizer->Add(new wxToggleButton(this,MNW_LOCKBUTTON,_("L"), wxPoint(0,0),wxSize(20,20)),wxSizerFlags(0).Center().Border(wxALL,0)); topSizer->Add(leftSizer); meter = new Resound::ParameterVUMeterWidget(this,MNW_METER,rand() % 128,0,128,_(RESOURCE_DIR "/image/smMeterOff.png"),_(RESOURCE_DIR "/image/smMeterOn.png")); meter->SetTarget(addr); topSizer->Add(meter,wxSizerFlags(0).Align(0).Border(wxALL,0)); //meter1 SetSizer(topSizer); //topSizer->SetSizeHints(this); // set size hints to honour minimum size topSizer->Layout(); }
// retrieve either the hostname or FQDN depending on platform (caller must // check whether it's one or the other, this is why this function is for // private use only) static bool wxGetHostNameInternal(wxChar *buf, int sz) { wxCHECK_MSG( buf, false, wxT("NULL pointer in wxGetHostNameInternal") ); *buf = wxT('\0'); // we're using uname() which is POSIX instead of less standard sysinfo() #if defined(HAVE_UNAME) struct utsname uts; bool ok = uname(&uts) != -1; if ( ok ) { wxStrncpy(buf, wxConvertMB2WX(uts.nodename), sz - 1); buf[sz] = wxT('\0'); } #elif defined(HAVE_GETHOSTNAME) bool ok = gethostname(buf, sz) != -1; #else // no uname, no gethostname wxFAIL_MSG(wxT("don't know host name for this machine")); bool ok = false; #endif // uname/gethostname if ( !ok ) { wxLogSysError(_("Cannot get the hostname")); } return ok; }
// Get user name e.g. Julian Smart bool wxGetUserName(wxChar *buf, int maxSize) { *buf = wxT('\0'); // buffer allocation MemHandle handle = MemHandleNew(maxSize-1); if( handle == NULL ) return false; // lock the buffer char *id = (char *)MemHandleLock(handle); if( id == NULL ) return false; // get user's name if( DlkGetSyncInfo(NULL, NULL, NULL, id, NULL, NULL) != errNone ) { MemPtrUnlock(id); return false; } wxStrncpy (buf, wxConvertMB2WX(id), maxSize - 1); // free the buffer MemPtrUnlock(id); return true; }
bool wxGetUserName(wxChar *buf, int sz) { struct passwd *who; *buf = wxT('\0'); if ((who = getpwuid (getuid ())) != NULL) { // pw_gecos field in struct passwd is not standard #ifdef HAVE_PW_GECOS char *comma = strchr(who->pw_gecos, ','); if (comma) *comma = '\0'; // cut off non-name comment fields wxStrncpy (buf, wxConvertMB2WX(who->pw_gecos), sz - 1); #else // !HAVE_PW_GECOS wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1); #endif // HAVE_PW_GECOS/!HAVE_PW_GECOS return true; } return false; }
void Logging::logFatalError( const char *szFormat, ... ) const { wxLog *pLogBak = wxLog::SetActiveTarget(m_pLogger); va_list marker; va_start( marker, szFormat ); wxVLogFatalError( wxConvertMB2WX(szFormat), marker ); va_end( marker ); wxLog::SetActiveTarget(pLogBak); }
bool wxGetUserId(wxChar *buf, int sz) { struct passwd *who; *buf = wxT('\0'); if ((who = getpwuid(getuid ())) != NULL) { wxStrncpy (buf, wxConvertMB2WX(who->pw_name), sz - 1); return true; } return false; }
void Logging::logTrace( const char *szFormat, ... ) const { wxLog *pLogBak = wxLog::SetActiveTarget(m_pLogger); va_list marker; va_start( marker, szFormat ); // wxVLogTrace( wxConvertMB2WX(szFormat), marker ); @todo FIXME modified interface in wx2.5 and superior. wxVLogDebug( wxConvertMB2WX(szFormat), marker ); va_end( marker ); wxLog::SetActiveTarget(pLogBak); }
int main(int argc, char* argv[]) { if (argc < 2) { wxFprintf(stderr, _T("Usage : ExpandXar <input file> <output file>\n")); return 1; } #if wxUSE_UNICODE wxChar **wxArgv = new wxChar *[argc + 1]; { int n; for (n = 0; n < argc; n++ ) { wxMB2WXbuf warg = wxConvertMB2WX(argv[n]); wxArgv[n] = wxStrdup(warg); } wxArgv[n] = NULL; } #else // !wxUSE_UNICODE #define wxArgv argv #endif // wxUSE_UNICODE/!wxUSE_UNICODE int RetVal = 0; if (!ProcessFile(wxArgv[1], wxArgv[2])) { RetVal = 1; } #if wxUSE_UNICODE { for ( int n = 0; n < argc; n++ ) free(wxArgv[n]); delete [] wxArgv; } #endif // wxUSE_UNICODE wxUnusedVar(argc); wxUnusedVar(argv); return RetVal; }
wxFrame* wxStEditApp::CreateHelpFrame(const wxString& caption, const char* text) { wxFrame *helpFrame = new wxFrame(NULL, wxID_ANY, caption, wxDefaultPosition, wxSize(600,400)); wxHtmlWindow *htmlWin = new wxHtmlWindow(helpFrame); if (htmlWin->SetPage(wxConvertMB2WX(text))) { helpFrame->Centre(); helpFrame->Show(); } else { htmlWin->SetPage(_("Unable to display help, sorry!")); } return helpFrame; }
int main (int argc, char **argv) { if (argc != 2) { std::cout << "Usage: " << argv[0] << " <xmlfile>" << std::endl; return 1; } else { std::cout << "Staring Parser..." << std::endl; } GVParseReport* pr = new GVParseReport (wxConvertMB2WX (argv[1])); // Test doesn't work anymore, perhaps write a work around later //pr->Parse(); delete pr; return 0; } /* End of main */
char *wxGetUserHome( const wxString &user ) #endif { struct passwd *who = (struct passwd *) NULL; if ( !user ) { wxChar *ptr; if ((ptr = wxGetenv(wxT("HOME"))) != NULL) { #if wxUSE_UNICODE wxWCharBuffer buffer( ptr ); return buffer; #else return ptr; #endif } if ((ptr = wxGetenv(wxT("USER"))) != NULL || (ptr = wxGetenv(wxT("LOGNAME"))) != NULL) { who = getpwnam(wxConvertWX2MB(ptr)); } // We now make sure the the user exists! if (who == NULL) { who = getpwuid(getuid()); } } else { who = getpwnam (user.mb_str()); } return wxConvertMB2WX(who ? who->pw_dir : 0); }
int main(int argc, char **argv) { #if wxUSE_UNICODE wxChar **wxArgv = new wxChar *[argc + 1]; { int n; for (n = 0; n < argc; n++ ) { wxMB2WXbuf warg = wxConvertMB2WX(argv[n]); wxArgv[n] = wxStrdup(warg); } wxArgv[n] = NULL; } #else // !wxUSE_UNICODE #define wxArgv argv #endif // wxUSE_UNICODE/!wxUSE_UNICODE wxInitializer initializer; if ( !initializer ) { fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.\n"); return -1; } wxString src; if (argc != 2) { fprintf(stderr, "version.h path not specified, aborting.\n"); return -1; } wxTextFile f(wxArgv[1]); wxString cur; if (!f.Open(wxConvLibc)) { fprintf(stderr, "Failed to open version.h \"%S\", aborting.\n", wxArgv[1]); return -1; } unsigned long verl[4] = { 0 }; for (cur = f.GetFirstLine(); !f.Eof(); cur = f.GetNextLine()) { fprintf(stdout, "processing \"%S\"\n", cur.c_str()); wxStringTokenizer tkz(cur, L"\t "); wxString ver; while (tkz.HasMoreTokens()) { if (tkz.GetNextToken() == L"PRODUCTVER") { fprintf(stdout, " PRODUCTVER spotted\n"); if (tkz.HasMoreTokens()) { ver = tkz.GetNextToken(); fprintf(stdout, " is %S\n", ver.c_str()); // parse ver // wxStringTokenizer tkzv(ver, L", "); if (tkzv.HasMoreTokens()) tkzv.GetNextToken().ToULong(&verl[0]); if (tkzv.HasMoreTokens()) tkzv.GetNextToken().ToULong(&verl[1]); if (tkzv.HasMoreTokens()) tkzv.GetNextToken().ToULong(&verl[2]); if (tkzv.HasMoreTokens()) tkzv.GetNextToken().ToULong(&verl[3]); fprintf(stdout, " deciphered: %d.%d.%d.%d\n", verl[0], verl[1], verl[2], verl[3]); } } } } if (verl[0] == 0 && verl[1] == 0 && verl[2] == 0 && verl[3] == 0) { ; } else { verl[3]++; f.Clear(); f.AddLine(L"#ifndef __VERSION_H__"); f.AddLine(L"#define __VERSION_H__"); f.AddLine(wxString::Format(L"#define FILEVER %d,%d,%d,%d", verl[0], verl[1], verl[2], verl[3])); f.AddLine(wxString::Format(L"#define PRODUCTVER %d,%d,%d,%d", verl[0], verl[1], verl[2], verl[3])); f.AddLine(wxString::Format(L"#define STRFILEVER \"%d, %d, %d, %d\\0\"", verl[0], verl[1], verl[2], verl[3])); f.AddLine(wxString::Format(L"#define STRPRODUCTVER \"%d, %d, %d, %d\\0\"", verl[0], verl[1], verl[2], verl[3])); f.AddLine(L"#endif"); f.Write(wxTextFileType_None, wxConvLibc); } }
int main(int argc, char* argv[]) { #if wxUSE_UNICODE // Set to the user's default locale for these conversions char* pOldLoc = setlocale(LC_CTYPE, ""); wxChar **wxArgv = new wxChar *[argc + 1]; { int n; for (n = 0; n < argc; n++ ) { wxMB2WXbuf warg = wxConvertMB2WX(argv[n]); wxArgv[n] = wxStrdup(warg); } wxArgv[n] = NULL; } // Set back to the old locale (should we be doing this?) setlocale(LC_CTYPE, pOldLoc); #else // !wxUSE_UNICODE #define wxArgv argv #endif // wxUSE_UNICODE/!wxUSE_UNICODE wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program"); wxInitializer initializer; if ( !initializer ) { fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.\n"); return -1; } // Default to OK exit value int RetVal = 0; static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, _T("v"), _T("verbose"), _T("be verbose") }, { wxCMD_LINE_SWITCH, _T("g"), _T("progress"), _T("give progress") }, { wxCMD_LINE_SWITCH, _T("p"), _T("prepareexport"), _T("prepare export") }, { wxCMD_LINE_SWITCH, _T("e"), _T("export"), _T("do export") }, { wxCMD_LINE_SWITCH, _T("c"), _T("canimport"), _T("can import") }, { wxCMD_LINE_SWITCH, _T("i"), _T("import"), _T("do import") }, { wxCMD_LINE_SWITCH, _T("z"), _T("compress"), _T("(de)compress (output) input file") }, { wxCMD_LINE_OPTION, _T("f"), _T("file"), _T("input/output file") }, { wxCMD_LINE_OPTION, _T("x"), _T("xmlfile"), _T("xml configuration file") }, #if SVGDEBUG { wxCMD_LINE_OPTION, _T("T"), _T("tracelevel"), _T("enable debug") }, #endif { wxCMD_LINE_NONE } }; wxCmdLineParser parser(cmdLineDesc, argc, wxArgv); switch ( parser.Parse() ) { case -1: wxLogMessage(_T("Help was given, terminating.")); break; case 0: // ShowCmdLine(parser); if (Run(parser)) RetVal = 0; else RetVal = 1; break; default: RetVal = 1; break; } #if wxUSE_UNICODE { for ( int n = 0; n < argc; n++ ) free(wxArgv[n]); delete [] wxArgv; } #endif // wxUSE_UNICODE wxUnusedVar(argc); wxUnusedVar(argv); // May need to use exit(RetVal) here if the OS ignores the return value from main return RetVal; }