GREAT MOD EXTENSION ADDED!

Forum announcements are posted here. New cool features, scheduled backups and maintenance, you name it.
Post Reply
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

GREAT MOD EXTENSION ADDED!

Post by Jorg » Tue Nov 23, 2004 7:07 pm

I am very proud to announce that upCASE has changed the forum in such a way that every bbcode code tag will now be replaced by [ syntax="wxwidgets" ] .. Yes you have read it correctly, we have a very own wxWidgets C++ syntax now!!!!

The greatest thing about this code is that it has clickable links to the wxWidgets help for all classes it recognises... just like we wanted from day #1.... consider the following source as example, and ... happy posting!

Special thanks go to upCODE for his patience and effort in this matter. This is a great extension to the board!

Code: Select all

/////////////////////////////////////////////////////////////////////////////
// Name:        minimal.cpp
// Purpose:     Minimal wxWidgets sample
// Author:      Julian Smart
// Modified by:
// Created:     04/01/98
// RCS-ID:      $Id: minimal.cpp,v 1.66 2004/05/25 11:18:01 JS Exp $
// Copyright:   (c) Julian Smart
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

// ============================================================================
// declarations
// ============================================================================

// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------

// the application icon (under Windows and OS/2 it is in resources and even
// though we could still include the XPM here it would be unused)
#if !defined(__WXMSW__) && !defined(__WXPM__)
    #include "../sample.xpm"
#endif

// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------

// Define a new application type, each program should derive a class from wxApp
class MyApp : public wxApp
{
public:
    // override base class virtuals
    // ----------------------------

    // this one is called on application startup and is a good place for the app
    // initialization (doing it here and not in the ctor allows to have an error
    // return: if OnInit() returns false, the application terminates)
    virtual bool OnInit();
};

// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
    // ctor(s)
    MyFrame(const wxString& title);

    // event handlers (these functions should _not_ be virtual)
    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);

private:
    // any class wishing to process wxWidgets events must use this macro
    DECLARE_EVENT_TABLE()
};

// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------

// IDs for the controls and the menu commands
enum
{
    // menu items
    Minimal_Quit = wxID_EXIT,

    // it is important for the id corresponding to the "About" command to have
    // this standard value as otherwise it won't be handled properly under Mac
    // (where it is special and put into the "Apple" menu)
    Minimal_About = wxID_ABOUT
};

// ----------------------------------------------------------------------------
// event tables and other macros for wxWidgets
// ----------------------------------------------------------------------------

// the event tables connect the wxWidgets events with the functions (event
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(Minimal_Quit,  MyFrame::OnQuit)
    EVT_MENU(Minimal_About, MyFrame::OnAbout)
END_EVENT_TABLE()

// Create a new application object: this macro will allow wxWidgets to create
// the application object during program execution (it's better than using a
// static object for many reasons) and also implements the accessor function
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
// not wxApp)
IMPLEMENT_APP(MyApp)

// ============================================================================
// implementation
// ============================================================================

// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------

// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
    // create the main application window
    MyFrame *frame = new MyFrame(_T("Minimal wxWidgets App"));

    // and show it (the frames, unlike simple controls, are not shown when
    // created initially)
    frame->Show(true);

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned false here, the
    // application would exit immediately.
    return true;
}

// ----------------------------------------------------------------------------
// main frame
// ----------------------------------------------------------------------------

// frame constructor
MyFrame::MyFrame(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title)
{
    // set the frame icon
    SetIcon(wxICON(sample));

#if wxUSE_MENUS
    // create a menu bar
    wxMenu *menuFile = new wxMenu;

    // the "About" item should be in the help menu
    wxMenu *helpMenu = new wxMenu;
    helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));

    menuFile->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));

    // now append the freshly created menu to the menu bar...
    wxMenuBar *menuBar = new wxMenuBar();
    menuBar->Append(menuFile, _T("&File"));
    menuBar->Append(helpMenu, _T("&Help"));

    // ... and attach this menu bar to the frame
    SetMenuBar(menuBar);
#endif // wxUSE_MENUS

#if wxUSE_STATUSBAR
    // create a status bar just for fun (by default with 1 pane only)
    CreateStatusBar(2);
    SetStatusText(_T("Welcome to wxWidgets!"));
#endif // wxUSE_STATUSBAR
}


// event handlers

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    // true is to force the frame to close
    Close(true);
}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxString msg;
    msg.Printf( _T("This is the About dialog of the minimal sample.\n")
                _T("Welcome to %s"), wxVERSION_STRING);

    wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this);
}
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

User avatar
tierra
Site Admin
Site Admin
Posts: 1343
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post by tierra » Tue Nov 23, 2004 10:42 pm

Doh! Needs some mod to work with C syntax highlighting next ;)

Looks like it needs a bit more work on wx detection as well. Notice wxCommandEvent isn't linked, wxString isn't linked in one place, I think either stuff in comments isn't linked at all, or there's something to the effect of why wxString isn't linked in code. Hashing up links for general wx functions and macros from this page would be nice as well:
http://www.wxwidgets.org/manuals/2.5.3/ ... abetically

Checking scope and linking member functions would be awesome, but that's going a little far now ;)

metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Post by metalogic » Wed Nov 24, 2004 12:59 am

Looks like it needs a bit more work on wx detection
Let's not get ahead of ourselves here. Before we start pointing out flaws and asking for more, let's just take a moment to appreciate what Jorg and upCASE are doing.

When you do something out of your own time and effort all you get in return is appreciation. Let's not deny Jorg and upCASE this little repayment. Even that's not enough.

Jorg and upCASE: Thank you very much for spending time in improving the wx community experience.

I repeat:
THANK YOU!

- Santiago

(Edited to add due kudos to upCASE as well :))
Last edited by metalogic on Wed Nov 24, 2004 8:48 am, edited 1 time in total.

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Nov 24, 2004 8:13 am

Thanks metalogic, but most of the credit goes to upCASE he put a lot of effort in making this wxwidgets syntax highlight module, I only merged it..
:mrgreen:

As it is not perfect (maybe), I already think it is a great improvement. If there are issues, please use the bugtracker on http://solidsteel.nl/bugs and select wxForum as your project. In there you can put all your requests and wishes..

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Wed Nov 24, 2004 8:40 am

Hi!
Taling about bugs: I don't see the syntax highlighting.
It's all black and white with the links in blue, but not my fancy colour scheme :D

Did you include the css?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Nov 24, 2004 8:43 am

Hi upCASE, try to fuily refresh the browser by Ctrl-key + Refresh-button. I had the same thing, but I was sure it worked because at home I got the correct result.. here it looks great, all highlighting is in it's place..

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Wed Nov 24, 2004 8:46 am

Hi!
Yup, there it is :D

Glad that it worked! Hope you all like it.

About the function list: I had a look at it and I'll see what I can do. Also member functions using "-> " don't get highlighted.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

User avatar
ABX
Can't get richer than this
Can't get richer than this
Posts: 810
Joined: Mon Sep 06, 2004 1:43 pm
Location: Poznan, Poland
Contact:

Re: GREAT MOD EXTENSION ADDED!

Post by ABX » Wed Nov 24, 2004 8:46 am

Jorg wrote:I am very proud to announce that upCASE has changed the forum in such a way that every bbcode code tag will now be replaced by [ syntax="wxwidgets" ] .. Yes you have read it correctly, we have a very own wxWidgets C++ syntax now!!!!
Good work!

I wonder if it would be also interesting to put it into wx-announce or wx-users list with link to this thread so people outside forum could be informed about advantages of using this way of communication.

ABX

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Nov 24, 2004 9:35 am

Yes I could, but I don't want to give the impression I am stealing away people from the list again, by announching the forum. What do you think ???

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

User avatar
ABX
Can't get richer than this
Can't get richer than this
Posts: 810
Joined: Mon Sep 06, 2004 1:43 pm
Location: Poznan, Poland
Contact:

Post by ABX » Wed Nov 24, 2004 10:22 am

Jorg wrote:Yes I could, but I don't want to give the impression I am stealing away people from the list again, by announching the forum. What do you think ???
I think you can in the same message write a reminder that people should not post simultanously in both places because forums and mailing lists share large group of readers :-)

ABX

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Wed Nov 24, 2004 3:08 pm

Hi!
Notice wxCommandEvent isn't linked, wxString isn't linked in one place, I think either stuff in comments isn't linked at all, or there's something to the effect of why wxString isn't linked in code.
The problem is that the parser can't choose if a & means "address" or reference. It's just a symbol. "wxCommandEvent&" doesn't get parsed correctly, because the parser thinks it's a string with a symbol. I'll add support for references in a minute.
I'll check if I can do that :D
Checking scope and linking member functions would be awesome, but that's going a little far now
This may take a while, because it would imply hacking the parser engine. I'd be glad if member functions referenced by pointer would get parsed correctly. So far wxString.Printf() will work while wxString::Format() or wxString->Format() won't.

I'll add more to the highlighter once I have some time (maybe this weekend) and get my internet access back at home :D
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

eros
I live to help wx-kind
I live to help wx-kind
Posts: 162
Joined: Mon Sep 06, 2004 1:40 am
Location: Argentina

Post by eros » Wed Nov 24, 2004 6:23 pm

Its looking really good so far. Good work :)
...

Avi
Super wx Problem Solver
Super wx Problem Solver
Posts: 398
Joined: Mon Aug 30, 2004 9:27 pm
Location: Tel-Aviv, Israel

Post by Avi » Wed Nov 24, 2004 6:49 pm

Simply admirable. Amazing job!

User avatar
tierra
Site Admin
Site Admin
Posts: 1343
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

Post by tierra » Wed Nov 24, 2004 8:10 pm

upCASE wrote:
Checking scope and linking member functions would be awesome, but that's going a little far now
This may take a while, because it would imply hacking the parser engine. I'd be glad if member functions referenced by pointer would get parsed correctly. So far wxString.Printf() will work while wxString::Format() or wxString->Format() won't.

I'll add more to the highlighter once I have some time (maybe this weekend) and get my internet access back at home :D
No problem, take your time. Excellent work upCASE! I was just kinda joking about linking in member functions, that's a lot of work you don't really need to do. But I guess if you find an easy way to do it, go for it.

Post Reply