Search found 122 matches

by Deluge
Sun Jun 20, 2010 1:17 am
Forum: C++ Development
Topic: Class with Optional Argument in Constructor
Replies: 1
Views: 490

Ok, figured it out. I set the default argument in the header file:

gnrcabt.h

Code: Select all

class GenericAbout : public wxDialog
{
  public:
    GenericAbout(wxWindow* parent, wxWindowID id, const wxString& title=_T("Default Title"));
};
by Deluge
Sun Jun 20, 2010 12:54 am
Forum: C++ Development
Topic: Class with Optional Argument in Constructor
Replies: 1
Views: 490

Class with Optional Argument in Constructor

I'm trying to create a custom wxDialog with an optional third argument (title). I thought that the correct way to do this was to use "=" to create a default value for the argument. Here is a portion of my code: gnrcabt.h class GenericAbout : public wxDialog { public: GenericAbout(wxWindow*...
by Deluge
Wed Jun 16, 2010 12:14 am
Forum: C++ Development
Topic: Segfault when Closing wxDialog - Gtk
Replies: 4
Views: 959

Thanks
by Deluge
Tue Jun 15, 2010 1:12 am
Forum: C++ Development
Topic: Segfault when Closing wxDialog - Gtk
Replies: 4
Views: 959

Okay, so I need to create the dialog in the constructor then all I do in the class method is "ShowModal()"? Edit: It seems to be working. Is this the correct way to do it? Create the dialog in the constructor: // Help Dialog help = new wxDialog(this, -1, _T("Help"), wxDefaultPosi...
by Deluge
Tue Jun 15, 2010 12:46 am
Forum: C++ Development
Topic: Segfault when Closing wxDialog - Gtk
Replies: 4
Views: 959

Segfault when Closing wxDialog - Gtk

This is the class method that creates and shows a dialog. I don't get any errors on Windows, but on Linux with Gtk the app crashes when I close the dialog. It has something to do with the child widgets and box sizers. If I remove the widgets or sizers there is no segfault. void MainWindow::OnHelp(wx...
by Deluge
Sat May 29, 2010 2:58 am
Forum: C++ Development
Topic: cout & printf won't work with wxWidgets
Replies: 2
Views: 1094

cout & printf won't work with wxWidgets

I think it may have something to do with the way I compiled wxWidgets, but I cannot use cout or printf in a wx app on Windows XP. I have no problems with it in Linux. #include <wx/wx.h> #include <stdio.h> using namespace std; class MainWindow : public wxFrame { public: MainWindow(const wxString&...
by Deluge
Wed May 26, 2010 10:40 pm
Forum: C++ Development
Topic: wxToolBar->SetToolSeparation Doesn't Work
Replies: 3
Views: 1286

I think that "CreateToolBar()" is an automated way of placing a toolbar, and if I used "new wxToolBar()" I would have to place the tool bar on its parent myself.

wxGtk-2.8.10, Ubuntu 10.04 Lucid, Compilation... compiler? g++.
by Deluge
Wed May 26, 2010 10:36 pm
Forum: C++ Development
Topic: Can't Add Widgets to wxDialog
Replies: 4
Views: 2399

Thank you both very much. I am still learning about the heap and stack.
by Deluge
Wed May 26, 2010 9:11 pm
Forum: C++ Development
Topic: Can't Add Widgets to wxDialog
Replies: 4
Views: 2399

Can't Add Widgets to wxDialog

I've always been able to add widgets to a custom dialog with wxPython, but I am having trouble doing it with wxWidgets in C++. According to Zetcode I should be able to do it. Here is the member function that contains my dialog: void MainWindow::OnHelp(wxMenuEvent& event) { wxDialog help(this, -1...
by Deluge
Wed May 26, 2010 1:21 pm
Forum: C++ Development
Topic: Playing a Sound from a Thread
Replies: 1
Views: 881

http://ubuntuforums.org/showthread.php?p=9362621 Got figured out what I wanted to do: #include <wx/wx.h> #include <wx/sound.h> #include <pthread.h> #include <iostream> using namespace std; const int ID_NULL = wxNewId(); const int ID_DOG = wxNewId(); const int ID_CAT = wxNewId(); class MainWindow : ...
by Deluge
Wed May 26, 2010 12:35 pm
Forum: C++ Development
Topic: Playing a Sound from a Thread
Replies: 1
Views: 881

Playing a Sound from a Thread

I am trying to press a button to play a wxSound and send an event to the main thread when the sound is finished playing. Is it okay to create and play a wxSound from a secondary thread? Be aware that in wxWidgets you *must not* touch any gui elements from secondary threads. Is the wxSound in my code...
by Deluge
Tue May 25, 2010 9:56 pm
Forum: C++ Development
Topic: Using Threads (pthreads) Within a Class
Replies: 14
Views: 4325

Thanks, that works.
by Deluge
Tue May 25, 2010 9:40 pm
Forum: C++ Development
Topic: wxToolBar->SetToolSeparation Doesn't Work
Replies: 3
Views: 1286

wxToolBar->SetToolSeparation Doesn't Work

I'm on Ubuntu Linux using wxGtk and I can't resize the separators on my toolbar: // Tool Bar wxBitmap ico_exit(wxImage(_T("pic/exit.png"))); wxBitmap ico_abc(wxImage(_T("pic/abc.png"))); wxBitmap ico_anim(wxImage(_T("pic/animals.png"))); wxBitmap ico_food(wxImage(_T(&qu...
by Deluge
Tue May 25, 2010 9:26 pm
Forum: C++ Development
Topic: Using Threads (pthreads) Within a Class
Replies: 14
Views: 4325

My mistake, i shouldn't have called it "id", it's a little ambiguous here. I meant "event type", the id usually refers to the id of the object (e.g. clicked button etc), which you don't have in this case. So you should use a custom event type and wxID_ANY as id. Connect(ID_NULL,...
by Deluge
Tue May 25, 2010 5:41 pm
Forum: C++ Development
Topic: Using Threads (pthreads) Within a Class
Replies: 14
Views: 4325

Like this? const int ID_NULL = wxNewId(); Connect(ID_NULL, 0, wxCommandEventHandler(MainWindow::EnableButton), 0, this); void *MainWindow::StartThread(void *arg) { wxEvtHandler *obj = wxDynamicCast(arg, wxEvtHandler); if (obj) { wxSleep(3); // Give the thread a few seconds to finish cout << "Th...