// Original constructor that does not takes origin and extent. If you use this, // *DO* give origin/extent arguments to wxMakeMetafilePlaceable. wxMetafileDCImpl::wxMetafileDCImpl(wxDC *owner, const wxString& file) : wxMSWDCImpl(owner) { m_metaFile = NULL; m_minX = 10000; m_minY = 10000; m_maxX = -10000; m_maxY = -10000; // m_title = NULL; if (!file.IsNull() && wxFileExists(file)) wxRemoveFile(file); if (!file.IsNull() && (file != wxEmptyString)) m_hDC = (WXHDC) CreateMetaFile(file); else m_hDC = (WXHDC) CreateMetaFile(NULL); m_ok = (m_hDC != (WXHDC) 0) ; // Actual Windows mapping mode, for future reference. m_windowsMappingMode = wxMM_TEXT; SetMapMode(wxMM_TEXT); // NOTE: does not set HDC mapmode (this is correct) }
void wxError( const wxString &msg, const wxString &title ) { wxFprintf( stderr, _("Error ") ); if (!title.IsNull()) wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title) ); if (!msg.IsNull()) wxFprintf( stderr, wxT(": %s"), WXSTRINGCAST(msg) ); wxFprintf( stderr, wxT(".\n") ); }
void wxFatalError( const wxString &msg, const wxString &title ) { wxFprintf( stderr, _("Error ") ); if (!title.IsNull()) wxFprintf( stderr, wxT("%s "), WXSTRINGCAST(title) ); if (!msg.IsNull()) wxFprintf( stderr, wxT(": %s"), WXSTRINGCAST(msg) ); wxFprintf( stderr, wxT(".\n") ); exit(3); // the same exit code as for abort() }
void wxComboBox::SetValue( const wxString& value ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); GtkWidget *entry = GTK_COMBO(m_widget)->entry; wxString tmp; if (!value.IsNull()) tmp = value; gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) ); InvalidateBestSize(); }
void wxComboBox::Replace( long from, long to, const wxString& value ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); GtkWidget *entry = GTK_COMBO(m_widget)->entry; gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to ); if (value.IsNull()) return; gint pos = (gint)to; #if wxUSE_UNICODE wxCharBuffer buffer = wxConvUTF8.cWX2MB( value ); gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos ); #else gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos ); #endif }
void wxComboBox::SetValue( const wxString& value ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); GtkEntry *entry = NULL; #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); else #endif entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); wxString tmp; if (!value.IsNull()) tmp = value; gtk_entry_set_text( entry, wxGTK_CONV( tmp ) ); InvalidateBestSize(); }
bool wxDialog::Create( wxWindow* pParent , wxWindowID vId , const wxString& rsTitle , const wxPoint& rPos , const wxSize& rSize , long lStyle , const wxString& rsName ) { Init(); SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG); // // Save focus before doing anything which can potentially change it // m_pOldFocus = FindFocus(); // // All dialogs should really have this style // lStyle |= wxTAB_TRAVERSAL; if (!wxTopLevelWindow::Create( pParent ,vId ,rsTitle ,rPos ,rSize ,lStyle ,rsName )) return FALSE; SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); // // Must defer setting the title until after dialog is created and sized // if (!rsTitle.IsNull()) SetTitle(rsTitle); return TRUE; } // end of wxDialog::Create
wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname) { #ifndef HAVE_ESD_H m_snderror = wxSOUND_INVDEV; return; #else wxSoundFormatPcm pcm_default; // First, we make some basic test: is there ESD on this computer ? m_esd_ok = false; if (hostname.IsNull()) m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050, hostname.mb_str(), MY_ESD_NAME); else m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050, NULL, MY_ESD_NAME); if (m_fd_output == -1) { // Answer: no. We return with an error. m_snderror = wxSOUND_INVDEV; return; } // Close this unuseful stream. esd_close(m_fd_output); m_hostname = hostname; // Set the default audio format SetSoundFormat(pcm_default); // Initialize some variable m_snderror = wxSOUND_NOERROR; m_esd_stop = true; m_q_filled = true; m_esd_ok = true; m_fd_output= -1; m_fd_input = -1; #endif // defined HAVE_ESD_H }
void wxComboBox::Replace( long from, long to, const wxString& value ) { wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); GtkEntry *entry = NULL; #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); else #endif entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to ); if (value.IsNull()) return; gint pos = (gint)to; #if wxUSE_UNICODE wxCharBuffer buffer = wxConvUTF8.cWX2MB( value ); gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos ); #else gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos ); #endif }
bool wxMatrix2D::LoadFile( const wxString &filename, const wxArrayInt *cols ) { if (filename.IsNull()) return false; // valid separators for data // const char comma = 44; // comma const char tab = 9; // tab const char space = 32; // space // const char cr = 13; // carrage return wxFile loadfile; loadfile.Open( filename, wxFile::read ); if (!loadfile.IsOpened()) return false; m_file_comments.Clear(); // m_file_comments_positions.Clear(); wxFileInputStream filestream( loadfile ); wxTextInputStream textstream( filestream ); int sizeof_data = 4000; double *data = (double*)malloc(sizeof_data*sizeof(double)); if (data == (double*)NULL) return false; wxString line_str, num_str; int i, a, b, pos; int num_cols = 0; int num_rows = 0; int num_points = 0; int num_lines = 0; double point; bool fail = false; while ( !filestream.Eof() && !fail ) { ++num_lines; line_str = textstream.ReadLine(); if ( filestream.Eof() ) break; line_str.Trim(false); line_str.Trim(true); if (line_str.Left(1) == wxT("#")) { m_file_comments.Add( line_str ); //m_file_comments_positions.Add(num_lines); } else { ++num_rows; // do this once to figure out how many columns of data there is unless already given if ( num_cols < 1 ) { for (i = 0; i < 10000; ++i) { line_str.Trim(false); a = line_str.Find(space); b = line_str.Find(tab); if ( (a != -1) && (b != -1) ) pos = wxMin( a, b ); else if ( a != -1 ) pos = a; else pos = b; if ( pos != -1 ) num_str = line_str.Left( pos ); else num_str = line_str; if ( num_str.ToDouble(&point) ) { printf("i%d pts%d cols%d rows%d pos%d pt%lf \n", i, num_points, num_cols, num_rows, pos, point); fflush(stdout); //data[i] = point; ++num_cols; line_str = line_str.Right( line_str.Len() - num_str.Len() ); ++num_points; } else { i = 10000; break; } } } else { if ( num_points > sizeof_data - num_cols*2 ) { data = (double*)realloc( data, sizeof_data+1000 ); } for (i = 0; i < num_cols; ++i) { line_str.Trim(false); a = line_str.Find(space); b = line_str.Find(tab); if ( (a != -1) && (b != -1) ) pos = wxMin( a, b ); else if ( a != -1 ) pos = a; else pos = b; if ( pos != -1 ) num_str = line_str.Left( pos ); else num_str = line_str; if ( num_str.ToDouble(&point) ) { printf("i%d pts%d cols%d rows%d pos%d pt%lf \n", i, num_points, num_cols, num_rows, pos, point); fflush(stdout); //data[numpoints*numcolumns + i] = point; line_str = line_str.Right( line_str.Len() - num_str.Len() ); ++num_points; } else { // if not just a blank line then data is wrong if (i != 0) { fail = true; wxMessageBox(wxT("# for comments\n7 4\n33 25\n..."), wxT("Invalid data file format"), wxOK); } i = num_cols; break; } } } } } // not static data = (double*)realloc( data, (num_points+1)*sizeof(double) ); Create( num_cols, num_rows, data, false ); loadfile.Close(); return true; }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; PreCreation(); m_tempCallbackStruct = NULL; m_modified = false; m_processedDefault = false; Widget parentWidget = (Widget) parent->GetClientWidget(); Bool wantHorizScroll = (m_windowStyle & wxHSCROLL) != 0 ? True : False; // If we don't have horizontal scrollbars, we want word wrap. // OpenMotif 2.1 crashes if wantWordWrap is True in Japanese // locale (and probably other multibyte locales). The check might be // more precise #if wxCHECK_LESSTIF() || wxCHECK_MOTIF_VERSION( 2, 2 ) Bool wantWordWrap = wantHorizScroll == True ? False : True; #else Bool wantWordWrap = False; #endif if (m_windowStyle & wxTE_MULTILINE) { Arg args[8]; int count = 0; XtSetArg (args[count], XmNscrollHorizontal, wantHorizScroll); ++count; if( m_font.IsOk() ) XtSetArg (args[count], (String) wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ) ); ++count; XtSetArg (args[count], XmNwordWrap, wantWordWrap); ++count; XtSetArg (args[count], XmNvalue, (const char*)value.mb_str()); ++count; XtSetArg (args[count], XmNeditable, style & wxTE_READONLY ? False : True); ++count; XtSetArg (args[count], XmNeditMode, XmMULTI_LINE_EDIT ); ++count; m_mainWidget = (WXWidget) XmCreateScrolledText(parentWidget, name.char_str(), args, count); XtManageChild ((Widget) m_mainWidget); } else { m_mainWidget = (WXWidget)XtVaCreateManagedWidget ( name.mb_str(), xmTextWidgetClass, parentWidget, wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ), XmNvalue, (const char*)value.mb_str(), XmNeditable, (style & wxTE_READONLY) ? False : True, NULL ); #if 0 // TODO: Is this relevant? What does it do? int noCols = 2; if (!value.IsNull() && (value.length() > (unsigned int) noCols)) noCols = value.length(); XtVaSetValues((Widget) m_mainWidget, XmNcolumns, noCols, NULL); #endif } // remove border if asked for if ( style & wxNO_BORDER ) { XtVaSetValues((Widget)m_mainWidget, XmNshadowThickness, 0, NULL); } // install callbacks XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this); PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); return true; }
void AppendIfFilled(wxString &str, const wxString &delimiter, const wxString &what) { if (!what.IsNull()) str += delimiter + what; }
// This form is deprecated wxPrinterDC::wxPrinterDC( const wxString& rsDriverName , const wxString& rsDeviceName , const wxString& rsFile , bool bInteractive , int nOrientation ) { DEVOPENSTRUC vDevOpen = { (char*)rsDeviceName.c_str() ,(char*)rsDriverName.c_str() ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL ,NULL }; m_isInteractive = bInteractive; if (!rsFile.IsNull() && rsFile != wxT("")) m_printData.SetFilename(rsFile); /* Implement PM's version of this #if wxUSE_COMMON_DIALOGS if (interactive) { PRINTDLG pd; pd.lStructSize = sizeof( PRINTDLG ); pd.hwndOwner=(HWND) NULL; pd.hDevMode=(HANDLE)NULL; pd.hDevNames=(HANDLE)NULL; pd.Flags=PD_RETURNDC | PD_NOSELECTION | PD_NOPAGENUMS; pd.nFromPage=0; pd.nToPage=0; pd.nMinPage=0; pd.nMaxPage=0; pd.nCopies=1; pd.hInstance=(HINSTANCE)NULL; if ( PrintDlg( &pd ) != 0 ) { m_hDC = (WXHDC) pd.hDC; m_ok = TRUE; } else { m_ok = FALSE; return; } // m_dontDelete = TRUE; } else #endif */ if ((!rsDriverName.IsNull() && rsDriverName != wxT("")) && (!rsDeviceName.IsNull() && rsDeviceName != wxT("")) && (!rsFile.IsNull() && rsFile != wxT(""))) { m_hDC = (WXHDC) ::DevOpenDC( vHabmain ,OD_QUEUED ,"*" ,5L ,(PDEVOPENDATA)&vDevOpen ,NULLHANDLE ); m_ok = m_hDC ? TRUE: FALSE; } else { wxPrintData vPrintData; vPrintData.SetOrientation(nOrientation); m_hDC = wxGetPrinterDC(vPrintData); m_ok = m_hDC ? TRUE: FALSE; } if (m_hDC) { // int width = GetDeviceCaps(m_hDC, VERTRES); // int height = GetDeviceCaps(m_hDC, HORZRES); SetMapMode(wxMM_TEXT); } SetBrush(*wxBLACK_BRUSH); SetPen(*wxBLACK_PEN); } // end of wxPrinterDC::wxPrinterDC