void wxWebPreferences::SetStringPref(const wxString& name, const wxString& value)
{
    ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch();
    if (prefs.empty())
        return;

    prefs->SetCharPref((const char*)name.mbc_str(), (const char*)value.mbc_str());
}
Example #2
0
void remove_tabela_pessoa(wxString nome) {
  sprintf(comando,"DELETE FROM pessoa WHERE nome='%s'", (const char*)nome.mbc_str() );
 /* // Para diagnóstico
  printf("\n%s", (const char*)nome.mbc_str());
  printf("\n%s", (const char*)telefone.mbc_str());
  printf("\n%s", comando);
*/
  if (mysql_query(&conexao, comando) == 0 )
    printf("\nRemoveu com sucesso");
  else
    printf("\nErro ao Remover %s\n", (const char*)nome.mbc_str() );
}
Example #3
0
wxDiff::wxDiff(wxString filename1, wxString filename2)
              : m_filename1(filename1), m_filename2(filename2)
{
    typedef std::string elem;
    typedef pair<elem, elemInfo> sesElem;
    ifstream Aifs(filename1.mbc_str());
    ifstream Bifs(filename2.mbc_str());
    elem buf;
    vector<elem> ALines, BLines;

    while(getline(Aifs, buf))
    {
        ALines.push_back(buf);
    }
    while(getline(Bifs, buf))
    {
        BLines.push_back(buf);
    }

    Diff<elem, vector<elem> > diff(ALines, BLines);
    diff.onHuge();
    diff.compose();

    uniHunk< sesElem > hunk;

    diff.composeUnifiedHunks();
    std::ostringstream help;
    diff.printUnifiedFormat();
    diff.printUnifiedFormat(help);

    m_diff = wxString(help.str().c_str(), wxConvUTF8);

    vector<wxArrayString> diffs;
    wxStringTokenizer tkz(m_diff, wxT("\n"));
    wxArrayString currdiff;
    while(tkz.HasMoreTokens())
    {
        wxString token = tkz.GetNextToken();
        if(token.StartsWith(_T("@@")) &&
           token.EndsWith(_T("@@")) &&
           !currdiff.IsEmpty())
        {
            diffs.push_back(currdiff);
            currdiff.clear();
        }
        currdiff.Add(token);
    }
    if(!currdiff.IsEmpty())
        diffs.push_back(currdiff);

    ParseDiff(diffs);
}
Example #4
0
void wxTextCtrl::DoSetValue( const wxString &value, int flags )
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    if ( !(flags & SetValue_SendEvent) )
    {
        // do not generate events
        IgnoreNextTextUpdate();
    }

    if (m_windowStyle & wxTE_MULTILINE)
    {
        gint len = gtk_text_get_length( GTK_TEXT(m_text) );
        gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
        len = 0;
        gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.length(), &len );
    }
    else
    {
        gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV( value ) );
    }

    // GRG, Jun/2000: Changed this after a lot of discussion in
    //   the lists. wxWidgets 2.2 will have a set of flags to
    //   customize this behaviour.
    SetInsertionPoint(0);

    m_modified = false;
}
Example #5
0
void wxDataFormat::SetId( const wxString& id )
{
    PrepareFormats();
    m_type = wxDF_PRIVATE;
    m_format = XInternAtom( wxGlobalDisplay(),
                            id.mbc_str(), False );
}
Example #6
0
 bool CUserList::deleteUser( const wxString& user )
 {
     char *zErrMsg = 0;
     CUserItem *pUser = getUser( user );
     if ( NULL == pUser ) return false;
     
     // Internal users can't be deleted
     if ( pUser->getUserID() <= 0 ) return false;
     
     // Check if database is open
    if ( NULL == gpobj->m_db_vscp_daemon ) {
        gpobj->logMsg( _("Failed to read VSCP settings database - not open." ) );
        return false;
    }
    
    gpobj->m_db_vscp_configMutex.Lock();
     
    char *sql = sqlite3_mprintf( VSCPDB_USER_DELETE_USERNAME,
                                    (const char *)user.mbc_str() );
    if ( SQLITE_OK != sqlite3_exec( gpobj->m_db_vscp_daemon, sql, NULL, NULL, &zErrMsg ) ) {
        sqlite3_free( sql );
        gpobj->logMsg( wxString::Format( _("Delete user: Unable to delete user in db. [%s] Err=%s\n"), sql, zErrMsg ) );
        gpobj->m_db_vscp_configMutex.Unlock();
        return false;
    }
        
    gpobj->m_db_vscp_configMutex.Unlock(); 
    sqlite3_free( sql );
    
    // Remove also from internal table
    m_userhashmap.erase( user );
    
    return true;
 }
Example #7
0
void wxWebPreferences::SetIntPref(const wxString& name, int value)
{
    ns_smartptr<nsIPref> prefs = nsGetPrefService();
    if (prefs.empty())
        return;
        
    prefs->SetIntPref((const char*)name.mbc_str(), value);
}
void wxWebPreferences::SetBoolPref(const wxString& name, bool value)
{
    ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch();
    if (prefs.empty())
        return;

    prefs->SetBoolPref((const char*)name.mbc_str(), value ? PR_TRUE : PR_FALSE);
}
Example #9
0
ns_smartptr<nsILocalFile> nsNewLocalFile(const wxString& filename)
{
    nsresult res = 0;
    ns_smartptr<nsILocalFile> ret;
    
    res = NS_NewNativeLocalFile(nsDependentCString((const char*)filename.mbc_str()), TRUE, &ret.p);
    
    if (NS_FAILED(res))
        ret.clear();
    
    return ret;
}
Example #10
0
// Static implementation
void PgStatement::ExecuteTemporary
  (
  Postgres * pg,
  const wxString& sQuery,
  const ArrayRecord& raParameters,
  PGresult ** ppgr
  )
  {
  PgParameters pgp(raParameters);
  int * pnParamFormats = pgp.GetParamFormats();

  PGresult * pgr = NULL;
  try
    {
    pgr = PQexecParams
      (
      pg->conn,
      sQuery.mbc_str(),
      pgp.GetParamCount(),
      pgp.GetParamTypes(),
      pgp.GetParamValues(),
      pgp.GetParamLengths(),
      pnParamFormats,
      0
      );
    }
  catch(...)
    {
    char * szPgError = PQerrorMessage(pg->conn);

    throw wx::Exception(wxT("PgStatement::ExecuteTemporary() Query caused exception: %s."), wxString::FromAscii(szPgError));
    }

  ExecStatusType exs = PQresultStatus(pgr);
  if(exs == PGRES_FATAL_ERROR)
    {
    char * szPgError = PQerrorMessage(pg->conn);

    throw wx::Exception(wxT("PgStatement::ExecuteTemporary() Query execution failed: %s."), wxString::FromAscii(szPgError));
    }

  if(ppgr == NULL)
    {
    if(pgr != NULL)
      {
      PQclear(pgr);
      pgr = NULL;
      }
    }
  else
    *ppgr = pgr;
  }
Example #11
0
bool wxWebPreferences::GetBoolPref(const wxString& name)
{
    ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch();
    wxASSERT(!prefs.empty());
    if (prefs.empty())
        return false;
        
    PRBool val;
    if (NS_FAILED(prefs->GetBoolPref((const char*)name.mbc_str(), &val)))
        return false;
        
    return (val == PR_TRUE ? true : false);
}
Example #12
0
ns_smartptr<nsIURI> nsNewURI(const wxString& spec)
{
    ns_smartptr<nsIURI> res;
    
    ns_smartptr<nsIIOService> io_service = nsGetIOService();
    if (io_service.empty())
        return res;
    
    std::string cstr_spec = (const char*)spec.mbc_str();
    
    io_service->NewURI(nsDependentCString(cstr_spec.c_str()), nsnull, nsnull, &res.p);
    
    return res;
}
Example #13
0
int wxWebPreferences::GetIntPref(const wxString& name)
{
    ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch();
    wxASSERT(!prefs.empty());
    if (prefs.empty())
        return 0;
    
    int val = 0;
    
    if (NS_FAILED(prefs->GetIntPref((const char*)name.mbc_str(), &val)))
        return 0;
        
    return val;
}
Example #14
0
void wxTextCtrl::Replace( long from, long to, const wxString &value )
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    Remove( from, to );

    if (!value.empty())
    {
        gint pos = (gint)from;
#if wxUSE_UNICODE
        wxWX2MBbuf buf = value.mbc_str();
        gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos );
#else
        gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &pos );
#endif // wxUSE_UNICODE
    }
}
Example #15
0
bool wxColour::FromString(const wxString& name)
{
    Display *dpy = wxGlobalDisplay();
    WXColormap colormap = wxTheApp->GetMainColormap( dpy );
    XColor xcol;
    if ( XParseColor( dpy, (Colormap)colormap, name.mbc_str(), &xcol ) )
    {
        UnRef();

        m_refData = new wxColourRefData;
        M_COLDATA->m_colormap = colormap;
        M_COLDATA->m_color = xcol;
        return true;
    }

    return wxColourBase::FromString(name);
}
Example #16
0
bool CUserItem::isUserInDB(const wxString& user, long *pid )  
{
    bool rv = false;
    char *zErrMsg = 0;
    sqlite3_stmt *ppStmt;
    
    // Database must be open
    if ( NULL == gpobj->m_db_vscp_daemon ) {
        gpobj->logMsg( _("isUserInDB: VSCP daemon database is not open.\n") );
        return false;
    }
    
    // Search username
    char *sql = sqlite3_mprintf( VSCPDB_USER_CHECK_USER,
                                    (const char *)user.mbc_str() );
    
    gpobj->m_db_vscp_configMutex.Lock();
    
    if ( SQLITE_OK != sqlite3_prepare( gpobj->m_db_vscp_daemon,
                                            sql,
                                            -1,
                                            &ppStmt,
                                            NULL ) ) {
        gpobj->logMsg( _("isUserInDB: Failed to read user database - prepare query.\n") );
        sqlite3_free( sql );
        gpobj->m_db_vscp_configMutex.Unlock();
        return false;
    }
    
    while ( SQLITE_ROW  == sqlite3_step( ppStmt ) ) {
        rv = true;
        if ( NULL != pid ) {
            *pid = sqlite3_column_int( ppStmt,VSCPDB_ORDINAL_USER_ID );
        }
    }
    
    sqlite3_free( sql );
    sqlite3_finalize( ppStmt );
    
    gpobj->m_db_vscp_configMutex.Unlock();
    
    return rv;
}
Example #17
0
wxString wxWebPreferences::GetStringPref(const wxString& name)
{
    wxString val;
    
    ns_smartptr<nsIPrefBranch> prefs = nsGetPrefBranch();
    wxASSERT(!prefs.empty());
    if (prefs.empty())
        return val;

    char* cstr = NULL;
    
    if (NS_FAILED(prefs->GetCharPref((const char*)name.mbc_str(), &cstr)))
        return val;
    
    if (cstr)
    {
        val = wxString::From8BitData(cstr);
        NS_Free(cstr);
    }
    
    return val;
}
Example #18
0
void wx2ns(const wxString& wxstr, nsEmbedCString& nsstr)
{
    nsstr.Assign(wxstr.mbc_str());
}
Example #19
0
bool wxTextCtrl::Create( wxWindow *parent,
                         wxWindowID id,
                         const wxString &value,
                         const wxPoint &pos,
                         const wxSize &size,
                         long style,
                         const wxValidator& validator,
                         const wxString &name )
{
    m_needParent = true;
    m_acceptsFocus = true;

    if (!PreCreation( parent, pos, size ) ||
            !CreateBase( parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG( wxT("wxTextCtrl creation failed") );
        return false;
    }


    m_vScrollbarVisible = false;

    bool multi_line = (style & wxTE_MULTILINE) != 0;

    if (multi_line)
    {
        // create our control ...
        m_text = gtk_text_new( NULL, NULL );

        // ... and put into the upper left hand corner of the table
        bool bHasHScrollbar = false;
        m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
        GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
        gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
                          (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
                          (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
                          0, 0);

        // always wrap words
        gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );

        // finally, put the vertical scrollbar in the upper right corner
        m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
        GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
        gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
                         GTK_FILL,
                         (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
                         0, 0);
    }
    else
    {
        // a single-line text control: no need for scrollbars
        m_widget =
            m_text = gtk_entry_new();
    }

    m_parent->DoAddChild( this );

    m_focusWidget = m_text;

    PostCreation(size);

    if (multi_line)
        gtk_widget_show(m_text);

    if (multi_line)
    {
        gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
                           (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );

        // only initialize gs_gtk_text_draw once, starting from the next the
        // klass::draw will already be wxgtk_text_draw
        if ( !gs_gtk_text_draw )
        {
            GtkDrawCallback&
            draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw;

            gs_gtk_text_draw = draw;

            draw = wxgtk_text_draw;
        }
    }

    if (!value.empty())
    {
#if !GTK_CHECK_VERSION(1, 2, 0)
        // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
        // gtk_editable_insert_text()
        gtk_widget_realize(m_text);
#endif // GTK 1.0

        gint tmp = 0;
#if wxUSE_UNICODE
        wxWX2MBbuf val = value.mbc_str();
        gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
#else
        gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.length(), &tmp );
#endif

        if (multi_line)
        {
            // Bring editable's cursor uptodate. Bug in GTK.
            SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
        }
    }

    if (style & wxTE_PASSWORD)
    {
        if (!multi_line)
            gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE );
    }

    if (style & wxTE_READONLY)
    {
        if (!multi_line)
            gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
    }
    else
    {
        if (multi_line)
            gtk_text_set_editable( GTK_TEXT(m_text), 1 );
    }

    // We want to be notified about text changes.
    gtk_signal_connect( GTK_OBJECT(m_text), "changed",
                        GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);

    m_cursor = wxCursor( wxCURSOR_IBEAM );

    wxTextAttr attrDef(GetForegroundColour(), GetBackgroundColour(), GetFont());
    SetDefaultStyle( attrDef );

    return true;
}
Example #20
0
bool wxRegExImpl::Compile(const wxString& expr, int flags)
{
    Reinit();

#ifdef WX_NO_REGEX_ADVANCED
#   define FLAVORS wxRE_BASIC
#else
#   define FLAVORS (wxRE_ADVANCED | wxRE_BASIC)
    wxASSERT_MSG( (flags & FLAVORS) != FLAVORS,
                  wxT("incompatible flags in wxRegEx::Compile") );
#endif
    wxASSERT_MSG( !(flags & ~(FLAVORS | wxRE_ICASE | wxRE_NOSUB | wxRE_NEWLINE)),
                  wxT("unrecognized flags in wxRegEx::Compile") );

    // translate our flags to regcomp() ones
    int flagsRE = 0;
    if ( !(flags & wxRE_BASIC) )
    {
#ifndef WX_NO_REGEX_ADVANCED
        if (flags & wxRE_ADVANCED)
            flagsRE |= REG_ADVANCED;
        else
#endif
            flagsRE |= REG_EXTENDED;
    }
    if ( flags & wxRE_ICASE )
        flagsRE |= REG_ICASE;
    if ( flags & wxRE_NOSUB )
        flagsRE |= REG_NOSUB;
    if ( flags & wxRE_NEWLINE )
        flagsRE |= REG_NEWLINE;

    // compile it
#ifdef WXREGEX_USING_BUILTIN
    bool conv = true;
    // FIXME-UTF8: use wc_str() after removing ANSI build
    int errorcode = wx_re_comp(&m_RegEx, expr.c_str(), expr.length(), flagsRE);
#else
    // FIXME-UTF8: this is potentially broken, we shouldn't even try it
    //             and should always use builtin regex library (or PCRE?)
    const wxWX2MBbuf conv = expr.mbc_str();
    int errorcode = conv ? regcomp(&m_RegEx, conv, flagsRE) : REG_BADPAT;
#endif

    if ( errorcode )
    {
        wxLogError(_("Invalid regular expression '%s': %s"),
                   expr.c_str(), GetErrorMsg(errorcode, !conv).c_str());

        m_isCompiled = false;
    }
    else // ok
    {
        // don't allocate the matches array now, but do it later if necessary
        if ( flags & wxRE_NOSUB )
        {
            // we don't need it at all
            m_nMatches = 0;
        }
        else
        {
            // we will alloc the array later (only if really needed) but count
            // the number of sub-expressions in the regex right now

            // there is always one for the whole expression
            m_nMatches = 1;

            // and some more for bracketed subexperessions
            for ( const wxChar *cptr = expr.c_str(); *cptr; cptr++ )
            {
                if ( *cptr == wxT('\\') )
                {
                    // in basic RE syntax groups are inside \(...\)
                    if ( *++cptr == wxT('(') && (flags & wxRE_BASIC) )
                    {
                        m_nMatches++;
                    }
                }
                else if ( *cptr == wxT('(') && !(flags & wxRE_BASIC) )
                {
                    // we know that the previous character is not an unquoted
                    // backslash because it would have been eaten above, so we
                    // have a bare '(' and this indicates a group start for the
                    // extended syntax. '(?' is used for extensions by perl-
                    // like REs (e.g. advanced), and is not valid for POSIX
                    // extended, so ignore them always.
                    if ( cptr[1] != wxT('?') )
                        m_nMatches++;
                }
            }
        }

        m_isCompiled = true;
    }

    return IsValid();
}
Example #21
0
void insere_tabela_pessoa(wxString nome, wxString telefone) {
  sprintf(comando,"INSERT INTO pessoa(nome, telefone) VALUES('%s', '%s')", (const char*)nome.mbc_str(), (const char*)telefone.mbc_str() );
 /* // Para diagnóstico
  printf("\n%s", (const char*)nome.mbc_str());
  printf("\n%s", (const char*)telefone.mbc_str());
  printf("\n%s", comando);
*/
  if (mysql_query(&conexao, comando) == 0 )
    printf("\nInseriu com sucesso");
  else
    printf("\nErro ao Inserir dados no DB\n");
}