[ROOT] extending TGFileDialog

From: David Faden (dfaden@iastate.edu)
Date: Fri Jul 06 2001 - 22:13:58 MEST


Hi,
   I've spent some time attempting to extend TGFileDialog to allow it to 
return the selected file type as well as the selected file name. I've 
tried to do this by overriding TGFileDialog's 
Bool_t ProcessMessage(Long_t,Long_t,Long_t). Later, when overriding
ProcessMessage didn't seem to be working, I tried doing my work in a 
custom destructor. However, though they both seem to be declared as 
virtual methods in TGFileDialog, neither my subclass's ProcessMessage nor 
its destructor seem to be being called.
   Below, I've included code that shows how I'm trying to extend 
TGFileDialog. I have a feeling I'm bumping against some area of C++ that 
I don't understand quite right, but I don't know enough to know what I 
don't know. I'd appreciate it very much if someone could point out the 
error in my code or point out to me code to successfully do what I want to do.
   Thank you.

David

---

class TTypeTGFileDialog : public TGFileDialog
{
public:
  TTypeTGFileDialog(const TGWindow* parentWindow,
		     const TGWindow* mainWindow,
		     EFileDialogMode dialogMode,
		     TGFileInfo* fileInfo) :
    TGFileDialog(parentWindow,
		 mainWindow,
		 dialogMode,
		 fileInfo),
    fSelectedFileType(0) {}
  TTypeTGFileDialog(const TGWindow* parentWindow,
		     EFileDialogMode dialogMode,
		     TGFileInfo* fileInfo,
		     char** selectedFileType) :
    TGFileDialog(parentWindow,
		 gClient->GetRoot(),
		 dialogMode,
		 fileInfo),
    fSelectedFileType(selectedFileType) {
    cerr << "Construction!" << endl;
}

  ~TTypeTGFileDialog() {
    cerr << "Destruction." << endl;
  }

  Bool_t ProcessMessage(Long_t message, Long_t param1, Long_t param2);

private:
  char** fSelectedFileType; //Holds selected file type.
};


Bool_t TTypeTGFileDialog::ProcessMessage(Long_t message,
					 Long_t param1,
					 Long_t param2)
  {

    cerr << "ProcessMessage" << endl;

    TGTextLBEntry* te =
      (TGTextLBEntry*) (fTypes->GetSelectedEntry());

    if (fFileInfo->fFileTypes && fSelectedFileType) {
      *fSelectedFileType = fFileInfo->fFileTypes[te->EntryId() + 1];
    }
    return TGFileDialog::ProcessMessage(message,param1,param2);
  }



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:51 MET