Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / no matching function for call to `wxTextAttr::wxTextAttr(

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. no matching function for call to `wxTextAttr::wxTextAttr(
#2526
Posted by: 2003-08-23 02:20:16
Hi,
i'm trying to create a new wxTextAttr but i only get the following errormessage :



no matching function for call to `wxTextAttr::wxTextAttr(



If i use wxTextAttr without attributes it works well (but don't realy makes sense ;-).

Here the full codeline :



mainTextAttr =  new wxTextAttr(wxColour(0,0,0),wxColour(255,255,255),mainTextFont);



(mainTextFont ist a wxFont object)...

What i'm doing wrong ? I'm using DevCpp 4.9.8.0 with the with it bundled MinGW compiler.
Message2. Re: no matching function for call to `wxTextAttr::wxTextAttr(
#2529
Posted by: guidance 2003-08-23 06:40:50
You may included "windows.h", try #include "wx/msw/winundef.h" after that.
Message3. Re: no matching function for call to `wxTextAttr::wxTextAttr(
#2531
Posted by: 2003-08-23 14:47:54
Sorry,
i din't use "windows.h" (so using winundef.h had no effect). What else can it be ? Here the whole source ... :




#include "wx/wx.h"


// Das Anwendungsicon (unter Windows und OS/2 ist es in den Resoursen)
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
    #include "mondrian.xpm"
#endif

wxChar *FILETYPES = _T("Text Dateien|*.txt|"
                       "Alle Dateien| *.*");

// Eine neue Anwendung namens "mainApp" von wxApp ableiten
class mainApp : public wxApp
{
  public:
    // Das Standart "OnInit()" mit einer virtuellen Funktion überschreiben
    virtual bool OnInit();
};

// Das Hauptframe definieren
class mainFrame : public wxFrame
{
  public:
    // ctor(s)
    mainFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
    long style = wxDEFAULT_FRAME_STYLE);

    // Eventhandler
    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
    void OnOpenFile(wxCommandEvent& event);   
   
    // Tectcontroll definieren
    wxTextCtrl *mainText;
    wxFont *mainTextFont;
    wxTextAttr *mainTextAttr;

  private:
    // Jede Klasse die ein wxWindows Event nutzen will braucht dieses Makro
    DECLARE_EVENT_TABLE()
   
    // Aktueller Dateiname
   wxString currentFilename;
   wxString currentDirectory;
};

// IDs für die Controlls und die Menü Commands
enum
  {
  // Menü items
  smartEdit_Quit = 1,
  smartEdit_Open = 2,

  // Es ist wichtig das "About" immer diese ID hat (wegen MAC)
  smartEdit_About = wxID_ABOUT
  };

// Die Eventtabelle verbindet wxWindows Events mit Funktionen
BEGIN_EVENT_TABLE(mainFrame, wxFrame)
    EVT_MENU(smartEdit_Quit,  mainFrame::OnQuit)
    EVT_MENU(smartEdit_Open, mainFrame::OnOpenFile)
    EVT_MENU(smartEdit_About, mainFrame::OnAbout)
END_EVENT_TABLE()

// Dieses Makro erlaubt wxWindows das Frame w?hrend der Anwendung zu erz?ugen
IMPLEMENT_APP(mainApp)

// Equivalent zur "main()" Funktion, das Programm startet hier
bool mainApp::OnInit()
  {
  // Erstelle das Anwendungsfenster
  mainFrame *frame = new mainFrame(_T("smartEdit"),
                                 wxPoint(50, 50), wxSize(450, 340));
                                
  // Zeige es an
  frame->Show(TRUE);

  // Durch das zurückgeben von "TRUE" best?tigen wir den ordnungsgem??en Start
  return TRUE;
  }

// Frame Konstruktor
mainFrame::mainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
         : wxFrame(NULL, -1, title, pos, size, style)
  {
  // Frameicon setzen
  SetIcon(wxICON(mondrian));

  #if wxUSE_MENUS
  // Menüleiste erstellen
  wxMenu *menuFile = new wxMenu;

  // Die Items werden den Menüpunkten hinzugefügt
  wxMenu *helpMenu = new wxMenu;
  helpMenu->Append(smartEdit_About, _T("&?ber...tF1"), _T("Zeigt den "?ber" Dialog"));
  menuFile->Append(smartEdit_Open, _T("?&ffnentCTRL+O"), _T("?ffnet eine Datei"));
  menuFile->Append(smartEdit_Quit, _T("B&eendentAlt+F4"), _T("Beendet das Programm"));

  // Nun wird das Menü der Menüleiste hinzugefügt
  wxMenuBar *menuBar = new wxMenuBar();
  menuBar->Append(menuFile, _T("&Datei"));
  menuBar->Append(helpMenu, _T("&Hilfe"));

  // ... und die Menüleiste dem Frame hinzugefügt
  SetMenuBar(menuBar);
  #endif // wxUSE_MENUS

  #if wxUSE_STATUSBAR
    // Eine Statusleiste erstellen
    CreateStatusBar(1);

  #endif // wxUSE_STATUSBAR
 
  // Textcontroll hinzufügen
  mainTextFont = new wxFont(14,wxSWISS,wxNORMAL,wxNORMAL,FALSE,"",wxFONTENCODING_SYSTEM);
  mainTextAttr =  new wxTextAttr(wxColour(0,0,0),wxColour(255,255,255),mainTextFont);
  mainText = (wxTextCtrl *) NULL;
  mainText = new wxTextCtrl(this, -1, wxString(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
  }
 
// Funktion zum ?ffnen einer Datei
void mainFrame::OnOpenFile(wxCommandEvent&)
  {
  wxFileDialog *openFileDialog = new wxFileDialog(this, "Datei ?ffnen", "", "", FILETYPES, wxOPEN, wxDefaultPosition);
 
  // Falls "OK" Datei in das Textfenster laden
  if(openFileDialog->ShowModal() == wxID_OK)
    {
    mainText->LoadFile(openFileDialog->GetPath());
    }
  }

// Funktion zum beenden des Programms
void mainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
  {
  // Schlie?t das Fenster
  Close(TRUE);
  }

// Funktion für den "?ber..." Knopf
void mainFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxString msg;
    msg.Printf( _T("smartEdit 0.01n"));

    wxMessageBox(msg, _T("?ber smartEdit"), wxOK | wxICON_INFORMATION, this);
}
Message4. Re: no matching function for call to `wxTextAttr::wxTextAttr(
#2532
Posted by: guidance 2003-08-23 16:00:28
According to the doc:

wxTextAttr(const wxColour& colText, const wxColour& colBack = wxNullColour, const wxFont& font = wxNullFont)

I think it should be:
mainTextFont = new wxFont(14, wxSWISS, wxNORMAL, wxNORMAL, FALSE, "", wxFONTENCODING_SYSTEM);
mainTextAttr =  new wxTextAttr(wxColour(0,0,0),wxColour(255,255,255), *mainTextFont);
Message5. Re: no matching function for call to `wxTextAttr::wxTextAttr(
#2538
Posted by: 2003-08-23 21:41:15
Thank, now it works !
Message6. Re: no matching function for call to `wxTextAttr::wxTextAttr(
#2540
Posted by: 2003-08-23 21:44:33
I didn't need thee whole wxTextAttr object, SetFont() was enought.
Message7. Re: no matching function for call to `wxTextAttr::wxTextAttr(
#2541
Posted by: guidance 2003-08-23 22:04:02
If you noticed the "candidate" prompt message from the compiler, you must can solve this problem by yourself.
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0