Author Topic: is it posible to convert a wxs file into a xrc?  (Read 6728 times)

Offline wobien

  • Multiple posting newcomer
  • *
  • Posts: 69
is it posible to convert a wxs file into a xrc?
« on: January 11, 2008, 03:22:50 pm »
Hi,
If I start a new wxWidgets project with wxSmith my main window is created in a wxs file without an xrc.
Is it possible to convert this wxs file into a xrc file?
Comparing them in a texteditor shows that they are very similar, but not quite the same.

mikeroku

  • Guest
Re: is it posible to convert a wxs file into a xrc?
« Reply #1 on: February 04, 2008, 08:12:53 pm »
I would also recommend to have XRC main dialog in new app wizard.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: is it posible to convert a wxs file into a xrc?
« Reply #2 on: February 05, 2008, 08:13:28 pm »
XRC option in wizard will have to wait for a while - nobody asked for it before so I thought it's not really necessary.

Quick workaround for wizard is to create project, remove main resource (available under right-click menu on resource browser) and add new resource using XRC. New resource may be set to main (the one that starts up) in wxSmith->Project options menu.

Automatic switching content from wxs to xrc may introduce some small problems. You can try the following:
* Backup project files (I didn't test this method well so it may lead to data loss)
* Copy content of wxs file to desired xrc one
* Edit created xrc file and change name of main node from <wxsmith> to <resource> (remember to rename closing tag at the end of file too)
* Open .cbp file in some text editor (remember to close it in C::B first), find entry related to the resource (it will be inside <wxsmith> node and add attribute called xrc with name of created xrc file like here:
 <wxDialog wxs="wxsmith/Testdialog.wxs" src="TestMain.cpp" hdr="TestMain.h" name="TestDialog" language="CPP" xrc="Testdialog.xrc" />,
name relative to project path.
* Now open project in C::B and open converted resource - while opening wxSmith should update xrc file to follow xrc standard.

I'm planning to add conversion on demand one day (just by few clicks) but it ontroduces few problems - not everything can be done when using xrc file so it may cut some stuff.

Regards
   BYO


Offline aPlatypus

  • Single posting newcomer
  • *
  • Posts: 3
Re: is it posible to convert a wxs file into a xrc?
« Reply #3 on: March 26, 2008, 01:10:48 pm »
Hello ...

I am interested in the XRC question myself.  I was looking at the 'complicated' recipe to convert.  How different are the files?  It occurs to me, that an XSLT filter is called for.  After all that is what XSLT is built to do :wink:

It seems to me that a simple little script might do the job anyway (without XSLT).  Is the wxSmilth layout documented some place?

I've got another question, why not use an XRC based schema?   I would 'see' two way to accomplish that.  To embed the XRC as embedded XML in a wxSmith layout.  Or, to keep two files.  One  the XRC and the other a 'wxSmith helper' file.

I hope I'm not over simplifying this.  Something to think about, I think.

Cheers,
          Will.

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: is it posible to convert a wxs file into a xrc?
« Reply #4 on: March 26, 2008, 10:11:07 pm »
I am interested in the XRC question myself.  I was looking at the 'complicated' recipe to convert.  How different are the files?  It occurs to me, that an XSLT filter is called for.  After all that is what XSLT is built to do :wink:

Generraly wxs file (when used for resource without separate xrc file) only use different name of root node and adds few extra properties / nodes. Simple text editor should be enough ;)

Quote
I've got another question, why not use an XRC based schema?   I would 'see' two way to accomplish that.  To embed the XRC as embedded XML in a wxSmith layout.  Or, to keep two files.  One  the XRC and the other a 'wxSmith helper' file.

You can create wxSmith resources which does use xrc files, in such case wxs file does keep only those extra informations that are not covered inside xrc files and xrc should have valid resource structure.

But XRC files have some limitations which have to be taken into consideration - for example you can not put wxTimer object inside it. That's why wxSmith have to add few limitations to be compatible with XRC.

Regards
   BYO

Offline aPlatypus

  • Single posting newcomer
  • *
  • Posts: 3
Re: is it posible to convert a wxs file into a xrc?
« Reply #5 on: May 01, 2008, 02:47:39 pm »
Hi Byo

Hope all is well.  Thanks for your response.  I appreciate that the xwSmith layout is similar to XRC.

Quote
used for resource without separate xrc file) only use different name of root node and adds few extra properties / nodes. Simple text editor should be enough

The reason to use a XSLT is to make transformations automatic, to wxSmith and from wxSmith to XRC and the paired-down-wxSmith layout makes it for a fully automated step possible.  It is a philosophical point(??) never repeat yourself.  In my history, the most tedious of repetitive exercises involve text editors -- At that time I throw and awk script at the opportunity.

XSLT is the Naughty (00-s) answer for we remaining frustrated awk fans.

Having looked at the wxSmith layout and made the conversion to XRC a few times now, why don't you just use the XRC by default anyway!  That would make for a cleaner design.  As if the wxSmith encapsulated the XRC.  At them moment it looks as if we have a bit of a hybrid.

Surely that kind, DRY (don't repeat yourself), approach has to be easier on maintaining the plug-in.  It is a minor thing really.  My unspeakable history reminds me that it is just the small things in design that have the potential to be annoying in the long-run.  *grin*

Aloha,
          Will


Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: is it posible to convert a wxs file into a xrc?
« Reply #6 on: May 04, 2008, 10:20:11 pm »
Having looked at the wxSmith layout and made the conversion to XRC a few times now, why don't you just use the XRC by default anyway!  That would make for a cleaner design.  As if the wxSmith encapsulated the XRC.  At them moment it looks as if we have a bit of a hybrid.

XRC file adds some limits into designer - for example such items like timers are not available because XRC can not handle them. It also don't define some extra properties - for example with XRC you can't define items inside wxTreeCtrl and I planned this functionality. So currently wxSmith works like this: by default it don't use XRC file because it adds limitations, but if you have to use it for some reason you can always do so.

Regards
   BYO

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: is it posible to convert a wxs file into a xrc?
« Reply #7 on: May 05, 2008, 08:00:51 pm »
Byo: How about making derivative classes that do the initialization like you want it?

From http://lists.wxwidgets.org/pipermail/wx-users/2002-September/024391.html :

Quote
> one major thing i fight with is usually that it seems to allowe
> only the common classes like wxTreeCtrl and stuff.

Fortunately for you, this is not true anymore :) The syntax is quite
simple:
Code: [Select]
   <object class="wxTreeCtrl" subclass="MyTreeCtrl">
       ...
   </object>
MyTreeCtrl must be registered in wx's RTTI system:
   class MyTreeCtrl: public wxTreeCtrl
   {
      DECLARE_DYNAMIC_CLASS(MyTreeCtrl)
   }
   ...
   IMPLEMENT_DYNAMIC_CLASS(MyTreeCtrl, wxTreeCtrl)

HTH,
Vaclav

I imagine that if you also define xrc handlers for objects like wxTimer, maybe that could do the trick :)

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: is it posible to convert a wxs file into a xrc?
« Reply #8 on: May 05, 2008, 08:21:56 pm »
Byo: How about making derivative classes that do the initialization like you want it?

From http://lists.wxwidgets.org/pipermail/wx-users/2002-September/024391.html :

That may require some extra libraries to be included in project using wxSmith. I quess that it would be better just to add some extra customizing code right after xrc file is loaded. But that won't be simple solution ;).

Quote
I imagine that if you also define xrc handlers for objects like wxTimer, maybe that could do the trick :)

It won't help much, I can only get items accessible through wxWindow::FindWindow. So the only solution I see now is to create some fake invisible component that contains timer - but that adds some overhead.

Regards
   BYO

Offline xawari

  • Multiple posting newcomer
  • *
  • Posts: 36
  • programming, usability ctrl
    • welcome to reality
Re: is it posible to convert a wxs file into a xrc?
« Reply #9 on: December 14, 2010, 05:04:25 pm »
Sorry for bringing up such an old topic, but I really want to ask.

I too want and option to use XRC by default in a New App wizard. But still there's nothing done after two years and I wonder if it's still planned to be done?
(I'm really tired of deleting and re-creating dialogs and frames every time :) )


PS: using XML comments for additional data storing is not an option? (MSVC does this all the time)
┌──────────────────────────────────────────────────────╖
in another thousand years we'll be machines or gods█
╘══════════════════════════════════════════════════════╝