List Info

Thread: Re-using components




Re-using components
country flaguser name
United States
2007-05-18 14:14:59

I'm new to DialogBlocks, and can't seem to figure out how to
accomplish this basic task.

I'm creating a Wizard, but I need to be able to re-use the same
panels in regular wx.Frames, too. The wizard is an initial setup
wizard, but the user should be able to revisit those settings from
within the app at a later date. I have always done this by creating a
wx.Panel that contained the controls for each step of the wizard, and
then adding those panels to the wizard pages. I can then also use
those panels in a Preferences dialog from within the app.

So in DialogBlocks I create a new Top-level Panel, and name it
LocalePanel. I add the controls that are needed to let the user set
up their locale preferences. I save that, and then create a new
Wizard with several pages. This is where I'm stuck: how do I add an
instance of LocalePanel to the first page of the wizard? Copy/Paste
doesn't seem to work, and if I add a Foreign Window and set that
window's class to LocalePanel, nothing displays - I get a blank area.

I'm running DialogBlocks v. 4.08 Unicode on Windows XP.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

__._,_.___
.

__,_._,___
Re: Re-using components
country flaguser name
United States
2007-05-19 01:50:34

>-- On Fri, 18 May 2007 15:14:59 -0400 Ed Leafe wrote --
> I'm new to DialogBlocks, and can't seem to figure out how to
> accomplish this basic task.
>
> I'm creating a Wizard, but I need to be able to re-use the same
>; panels in regular wx.Frames, too. The wizard is an initial setup
> wizard, but the user should be able to revisit those settings from
>; within the app at a later date. I have always done this by creating
> a wx.Panel that contained the controls for each step of the wizard,
> and then adding those panels to the wizard pages. I can then also
>; use those panels in a Preferences dialog from within the app.
>;
> So in DialogBlocks I create a new Top-level Panel, and name it
> LocalePanel. I add the controls that are needed to let the user set
> up their locale preferences. I save that, and then create a new
> Wizard with several pages. This is where I'm stuck: how do I add an
> instance of LocalePanel to the first page of the wizard? Copy/Paste
> doesn't seem to work, and if I add a Foreign Window and set that
>; window's class to LocalePanel, nothing displays - I get a blank
> area.
>
> I'm running DialogBlocks v. 4.08 Unicode on Windows XP.
>
>
> -- Ed Leafe
> -- http://leafe.com
> -- http://dabodev.com
>

You say what your platform is and the DialogBlocks version, but you don't
mention the wxWidgets version or your build system.;)

I'm using the same platform and DialogBlocks version with wxWidgets-2.8.3 and
Visual Studio 2005 (Express or Standard, doesn't matter).

One thing that's difficult to do is use a top level element as a child and have
it retain its values.

I've put together something that probably is a solution, but it's not so much
reusable as a centralized definition/implementation and a central location for
storing the values in variables. I used individual variables, but there's no
reason you couldn't use a wxArray of one type or another.

The goal, as I saw it, was to do as much in DB as possible leaving very little
hand coding. I think I did that. Here's the scenario.

Create a top level Null element (wxFrame, wxDialog, wxPanel, whatever). I used a
wxDialog. Within that dialog I created a wxPanel and subclassed it as
"DataPanel", I then specified not external implementation with separate files
for the subclass.

Then create the "real" top level elements. I have a wxFrame, MainFrame, a
wxWizard, TheWiz, and a wxDialog, DataDialog. TheWiz and DataDialog each have an
instance of DataPanel, this of course requires hand coding the include for
DataPanel, DataPanel.h. MainFrame creates an instance of TheWiz, theWiz, in its
Init(). The entered data is then placed in the variables (specified in DB in the
Variables tab) in MainFrame. Under File in the MainFrame menubar is an Update
Data menuitem. This creates an instance of DataDialog, theDlg, in its event
handler. theDlg is populated with the stored values from MainFrame and theDlg is
shown modal. On return, the variables in MainFrame are updated.

I'm attaching a zip of the .pjd and sources. If you're not using Visual Studio,
you'll need to make the necessary changes in Build>Configurations... .

HTH:

BTW, you could just as easily defined the DataPanel in either TheWiz or
DataDialog. I just put it in an unused top level element to keep it separated so
the implementation was clearer.

Also, if you're new to DB, you might like to check out the tutorials available
at wxMS_developers under Links.;)

thx,
Dave S.


"Before you judge a man, walk a mile in his shoes. After that who cares?... He's
a mile away and you've got his shoes!"

"In Scotland, there is no such thing as bad weather - only the wrong clothes."

"There are two seasons in Scotland - Winter and July.";

On receiving honorary Doctorate from University of Glasgow in 2001:

"I'm now a Doctor of Letters. Most of them Fs and Bs."


Personal quotes from Scotsman Musician/Comedian/Actor Billy Connolly


wxMS_developers · Development with wxWidgets on MSWindows
http://tech.groups.yahoo.com/group/wxMS_developers/

wxWidgets Code Exchange
http://www.wxCodex.net/

__._,_.___
.

__,_._,___
  
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )