Author Topic: Bricscad and wxWidgets  (Read 11474 times)

0 Members and 1 Guest are viewing this topic.

pkohut

  • Bull Frog
  • Posts: 427
Re: Bricscad and wxWidgets
« Reply #30 on: August 31, 2010, 04:58:34 AM »
There are a number of ways to instance controls in WxWidgets. The docs and most online tutorials show a method which uses event tables and EVT_-macros, very much like we do in MFC. However, there is a newer, more capable method using Connect(...), which is "dynamic event routing",  http://wiki.wxwidgets.org/Example_Of_Using_Connect_For_Events. If you use wxWidgets 2.9 or above you can switch to using wxEvtHandler::Bind instead of Connect (http://wiki.wxwidgets.org/Events  see: Using Connect)

In the first link, "Example of Using Connect for Events", put a dozen or so controls on the form and the code will get unwieldy. So I would suggest looking at wxFormBuilder (a GUI builder), and the code it will generate for you automatically (very nice).

Basically it will create a base class, with all the initialization code generated (you don't touch this code ***), and you derive from the base to implement any special behaviors or overrides. If later a control needs to be added or removed, just load the "*.fbp" file into wxFormBuilder, make the change and save. The newly generated base class files will overwrite the older ones.

*** Like with must GUI builders and code generators, you hit a wall and they can't do something out of the box. For me I wanted some of the new wxAux controls, and resorted to editing the base class by hand to get the new functionality. Once edited that way all future edits must be done by hand as well, otherwise regenerating the base class would mean losing code.  So, up front I try and get wxFormBuild to do as much work as possible before applying hand edits, afterward changes are mostly easy one or two off changes.  Now, having sat back to write this post and reflect, I should just write another layer of inheritance to initialize any controls that wxFormBuilder can't handle, and let it handle the base class for all the others.  (Full wxAux support is available in upcoming wxFormbuilder 3.2)

The latest WxFormBuilder 3.1 links are at http://wxformbuilder.org/?page_id=27.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: Bricscad and wxWidgets
« Reply #31 on: August 31, 2010, 07:52:14 AM »
I will have to take a look at wxFormBuilder, any tips on persisting dialog data?

pkohut

  • Bull Frog
  • Posts: 427
Re: Bricscad and wxWidgets
« Reply #32 on: August 31, 2010, 08:18:37 AM »
I will have to take a look at wxFormBuilder, any tips on persisting dialog data?

Not off the top, but I think it might be built into the framework.

pkohut

  • Bull Frog
  • Posts: 427
Re: Bricscad and wxWidgets
« Reply #33 on: August 31, 2010, 10:13:24 AM »
I will have to take a look at wxFormBuilder, any tips on persisting dialog data?

Not off the top, but I think it might be built into the framework.

I think I misunderstood your question. If not here's the link
http://docs.wxwidgets.org/trunk/overview_persistence.html

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: Bricscad and wxWidgets
« Reply #34 on: August 31, 2010, 11:13:16 AM »
That's it! you're awesome!  8-)

jgr

  • Guest
Re: Bricscad and wxWidgets
« Reply #35 on: September 01, 2010, 11:02:35 PM »
wxWidgets can be used by .Net (PInvoke) to create a dockable window in Bricscad?
I've looked at wxnet.sourceforge.net but i do not understand nothing.

Thanks.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: Bricscad and wxWidgets
« Reply #36 on: September 01, 2010, 11:22:17 PM »
I have never tried, I think that would be pretty hard.

pkohut

  • Bull Frog
  • Posts: 427
Re: Bricscad and wxWidgets
« Reply #37 on: September 02, 2010, 02:34:31 AM »
Daniel,

The document below has a simple example of Model-View which handles printing, clipboard, undo/redo. Sections 4 and 5. This is done without using the doc/view framework provided in wxWidgets. So perfect for the type of UI's we may write for Autocad.

http://biolpc22.york.ac.uk/pub/docs/tutorials/MartinBernreuther/wxIntro.pdf

The available document/view framework is explained at
http://docs.wxwidgets.org/2.6/wx_docviewoverview.html