Author Topic: wxSmith, error adding ColourDialog to second frame  (Read 6832 times)

Offline Skywise

  • Single posting newcomer
  • *
  • Posts: 9
wxSmith, error adding ColourDialog to second frame
« on: July 06, 2014, 02:00:24 am »
First off, I'm new to the forum and this is my first post. So if I'm in the wrong place, please just let me know the right forum. I did read the "new users" and "read this" sticky's.

BTW, the link on http://forums.codeblocks.org/index.php/topic,1427.0.html to the berliOS page is no good. It goes to the main page, and searching for anything to do with Code Blocks or wxSmith turns up zero results. Not sure if it's me or some other problem. I was trying to see if my issue has been filed as a bug already.

Being a new member, some background. I'm new to both C++, Code::Blocks, and wxWidgets, having started with them about 6 months ago. I've been a hobbyist programmer since the 80's, but have mostly played with variants of Basic. Most recently I spent a bit over a decade using something called XBasic, which is pretty obscure but quite powerful and fast. I've made Windows GUI programs and even dabbled with OpenGL with it. But it's so obscure it's not keeping up with the times and no one is really maintaining it anymore. My skills are leaving XBasic behind. I also have a background in electronics and currently play with the Parallax Propeller microcontroller. In fact, the program I'm currently writing is an interface to control a Propeller based project via USB.

I must say, I REALLY REALLY REALLY like Code Blocks. It's made learning C++ and wxWidgets quite enjoyable. There's so much support out there for both that until now I have been able to google for every question or stupid programmer mistake and get moving again. I'm wishing I had switched a long time ago.

I am using CB 13.12 and wxWidgets 3.0.0 as a static build (yes, this noob managed to compile it successfully!  ;D )

OK. On to my problem. I'm thinking it's a wxSmith problem as I'm using it to generate the GUI and it appears it may not be generating proper code. But I'm not good enough yet to figure out where the error is.

I have a program that has a main window and second window. On the second window I was using a ColourPickerCtrl button successfully. But there's things about the control I don't like, so I thought I'd try making my own by simply calling up a ColourDialog from a button event. But I am getting errors on building (detailed below) for the new frame after nothing more than adding the ColourDialog.

I am able to reduce the problem to utter simplicity:

> start a new wxWidgets project
> add a new frame (wxSmith -> add wxFrame)
> add wxColourDialog to the new frame (via wxSmith, Dialogs tab)
> compile

That's it. No other code necessary. Having the dialog on the main window works just fine. So it's something to do with adding it to a new frame. At the very least, the wxFileDialog works OK on the second window as my program already has that. So that tells me the problem may be specific to the colour dialog.

Thanks for any help.

Brian

The error log:

Code
||=== Build: Debug in ColourDialogTest (compiler: GNU GCC Compiler) ===|
my cpp\LEDART002stuff\FTDIComms\ColourDialogTest\NewFrame.h|21|error: 'wxColourDialog' does not name a type|
my cpp\LEDART002stuff\FTDIComms\ColourDialogTest\NewFrame.cpp||In constructor 'NewFrame::NewFrame(wxWindow*, wxWindowID, const wxPoint&, const wxSize&)':|
my cpp\LEDART002stuff\FTDIComms\ColourDialogTest\NewFrame.cpp|27|error: 'ColourDialog1' was not declared in this scope|
my cpp\LEDART002stuff\FTDIComms\ColourDialogTest\NewFrame.cpp|27|error: expected type-specifier before 'wxColourDialog'|
my cpp\LEDART002stuff\FTDIComms\ColourDialogTest\NewFrame.cpp|27|error: expected ';' before 'wxColourDialog'|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 8 second(s)) ===|


Here is the generated new frame's header:

Code
#ifndef NEWFRAME_H
#define NEWFRAME_H

#ifndef WX_PRECOMP
//(*HeadersPCH(NewFrame)
#include <wx/colordlg.h>
#include <wx/frame.h>
//*)
#endif
//(*Headers(NewFrame)
//*)

class NewFrame: public wxFrame
{
public:

NewFrame(wxWindow* parent,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize);
virtual ~NewFrame();

//(*Declarations(NewFrame)
wxColourDialog* ColourDialog1;    //******* ERROR ON THIS LINE *******//
//*)

protected:

//(*Identifiers(NewFrame)
//*)

private:

//(*Handlers(NewFrame)
//*)

DECLARE_EVENT_TABLE()
};

#endif

and the generated cpp code:
Code
#include "wx_pch.h"
#include "NewFrame.h"

#ifndef WX_PRECOMP
//(*InternalHeadersPCH(NewFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)
#endif
//(*InternalHeaders(NewFrame)
//*)

//(*IdInit(NewFrame)
//*)

BEGIN_EVENT_TABLE(NewFrame,wxFrame)
//(*EventTable(NewFrame)
//*)
END_EVENT_TABLE()

NewFrame::NewFrame(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(NewFrame)
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
SetClientSize(wxDefaultSize);
Move(wxDefaultPosition);
ColourDialog1 = new wxColourDialog(this);    //******* ADDITION ERRORS HERE *******//
//*)
}

NewFrame::~NewFrame()
{
//(*Destroy(NewFrame)
//*)
}


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: wxSmith, error adding ColourDialog to second frame
« Reply #1 on: July 06, 2014, 02:29:38 am »
What happens if you comment #ifndef WX_PRECOMP and the #endif below it?
Are you sure you've not disabled the colour dialog in the settings of wxWidgets during build?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Online stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: wxSmith, error adding ColourDialog to second frame
« Reply #2 on: July 06, 2014, 02:33:14 am »
Possible work around of missing header that wxSmith seems to think is in wxprec.h; but, it is NOT in wxWidgets 3.0.
Edit3: Not in wx.h in wx 2.8.12 either.

I added the line #include <wx/colordlg.h> to wx_pch.h; not sure where the problem exists.
Tim S.

Edit2: I am a wxSmith beginner; but, almost master at using PCH correctly under MinGW GCC.

Code
/***************************************************************
 * Name:      wx_pch.h
 * Purpose:   Header to create Pre-Compiled Header (PCH)
 * Author:     ()
 * Created:   2014-07-05
 * Copyright:  ()
 * License:  
 **************************************************************/

#ifndef WX_PCH_H_INCLUDED
#define WX_PCH_H_INCLUDED

// basic wxWidgets headers
#include <wx/wxprec.h>

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#ifdef WX_PRECOMP
    // put here all your rarely-changing header files
    #include <wx/colordlg.h>
#endif // WX_PRECOMP

#endif // WX_PCH_H_INCLUDED
« Last Edit: July 06, 2014, 02:38:37 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Skywise

  • Single posting newcomer
  • *
  • Posts: 9
Re: wxSmith, error adding ColourDialog to second frame
« Reply #3 on: July 06, 2014, 02:55:21 am »
Are you sure you've not disabled the colour dialog in the settings of wxWidgets during build?

But then I'd not be able to use the dialog at all, right? And I can in other circumstances.

What happens if you comment #ifndef WX_PRECOMP and the #endif below it?

That seems to work at first try. I'll test more to be sure there aren't other issues. I take it what's happening is the #if is causing the
include of colordlg.h to not happen.

Brian
« Last Edit: July 06, 2014, 03:02:24 am by Skywise »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: wxSmith, error adding ColourDialog to second frame
« Reply #4 on: July 06, 2014, 12:33:46 pm »
Then probably what Tim is saying about wx_pch is correct.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]