adding arbitrarily many widgets after creation of the main window



Hi,
I am new to gtkmm and use gtkmm2.4 under SuSE9.2. 
My aim is to write a program with ACID Pro
functionality for Linux. 
Like Acid, it contains windows that each describe a
Track's meta 
data (in the left half) and present the time periods
for which it 
is to be looped in a DrawingArea to the right. 
Whenever I load a new track from a MIDI file, I need
an additional window 
with details on the track and a DrawingArea. 
I have created the DrawingArea and meta data Widget by
subclassing and they 
load and behave properly when I load
on etrack during the initialisation of my main window.
However, when I want to add a track after
initialisation, I cant get it to work.

Here is what what I have done (assuming using
namespace Gtk;):
AcidWindow is the Main Window for the application. 
TrackWindow is the Frame that holds the meta data for
a track. 
MyArea is derived from DrawingArea and
displays the time intervals for which the
corresponding track gets looped.
The complete info on each track is in a Alignment, via
	        /TrackWindow
Alignment--HBox	
                \MyArea
Each Alignment consecutively gets stored in a VBox.
Leaving aside member functions and varaibles not
needed at the moment, 
the declaration of an AcidWindow becomes: 
class AcidWindow : public Gtk::Window{
public:
  AcidWindow();
  virtual ~AcidWindow();
  protected:  
  void  AcidWindow::AddTrackToDisplay(snd_score::Part
part,std::string filename,int idx);
  Gtk::VBox vbox;
  MyArea track_display;  
  TrackWindow track_window;  
  Gtk::HBox track_info_and_display;  
  Gtk::Alignment align;
};

  To display one Track when the AcidWindow is created,
I use the following code(which works):  
 
track_info_and_display.pack_start(track_window,Gtk::PACK_SHRINK,1);
  track_info_and_display.pack_start(track_display);
  float xalign=0.0;  
  float yalign=0.0;  
  float xscale=1.0;  
  float yscale=0.0;  
  align.add(track_info_and_display);  
  align.set(xalign,yalign,xscale,yscale);  
  vbox.pack_start(align,Gtk::PACK_SHRINK);
 I noticed that as soon as one of
track_display,track_window,track_info_and_display,
align is not declared as member of AcidWindow but
 simply instantiated when needed in AcidWindws
constructor, the align widget does not get displayed
when I run the program. I concluded that in order to
 have arbitrarily many Widgets of each MyArea,
TrackWindow, HBox, Alignment, they need to be members
of AcidWindow.
 Now the only way I saw to have arbitrarily many
Widgets of a given type be members of AcidWindow is to
declare a container of them.
 So I tried to add values to the vectors, like
 std::vector<MyArea> track_displays;
track_displays.push_back(MyArea());
 The compiler said the copy constructor of a Widget is
private/protected, which means this approach doesnt
work.
 But it appears that some container is needed in order
to have many Widgets of
 the same type as members of AcidWindow.
 Similarly, I got stuck working with Box_Helpers:

 Gtk::Box_Helpers::BoxList& list=vbox.children();
 MyArea help();
 children.push_back(Gtk::Box_Helpers::Element(help));
 
 help is not recognized by the compiler as a Widget
and therefore does not get added to the BoxList (even
though MyArea is subclassed from DrawingArea).

I feel I am using the wrong way to achieve my
objective. There must be a way of choice to add 
multiple tracks after my main window has been
instantiated. Can someone give advice?
 
 Thanks in advance,
 Michael Geis


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]