Dear Rooters The attached 2 simple codes are almost the same with each other except that the 1st one (i.e. o1.h, o1.c) define a 'MainFrame' and add the TGTab object 'SelectPC' inside the 'MainFrame', e.g. MainFrame=new TGCompositeFrame(this,100,100,kHorizontalFrame); SelectPC = new TGTab(MainFrame, 300,300); ..................... MainFrame->AddFrame(SelectPC,PCLayout); while the 2nd one(i.e. o2.c, o2.h) do the following: SelectPC = new TGTab(this,300,300); ..................... AddFrame(SelectPC,PCLayout); In the 2nd case, the keyword 'kCM_TAB' in implementation 'ProcessMessage' really works when click each tab with mouse, and give messages like "Tab unit 1 is activated". In the 1st case, it does not work. Could you tell me the reason ? W__W W__W / \ PHONE : 972 8 9343372 (o) 9471872 (h) / \ ( 0 _ 0) Fax : 972-8-946-6253 (0 _ 0 ) \_ V_/ E-mail: xiewei@ceres.weizmann.ac.il \_^ _/ / \ / \ =OOOo=======oOOO====================================OOOo=======oOOO====== #ifndef _mointer_ #define _mointer_ #include <stdlib.h> #include <TROOT.h> #include <TApplication.h> #include <TGXW.h> #include <TEnv.h> #include <TGListBox.h> #include <TGClient.h> #include <TGFrame.h> #include <TGIcon.h> #include <TGLabel.h> #include <TGButton.h> #include <TGTextEntry.h> #include <TGMsgBox.h> #include <TGMenu.h> #include <TGCanvas.h> #include <TGComboBox.h> #include <TGTab.h> #include <TGSlider.h> #include <TGFileDialog.h> #include <TRootEmbeddedCanvas.h> #include <TCanvas.h> #include <TH1.h> #include <TH2.h> #include <TRandom.h> #include <TSystem.h> #include <TPaveLabel.h> class Moniter : public TGMainFrame { private: TGCompositeFrame *MainFrame; TGTab *SelectPC; TGLayoutHints *PCLayout, *SubframeLayout, *MainFrameLayout, *SliderLayout,*StartLayout, *CancelLayout, *ButtonFrameLayout, *BufferLayout, *CanvasFrameLayout, *DefaultLayout; //-- Get data corresponding to each slow control quantity --- void Status(Int_t Id); //?????????? public: Moniter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kMainFrame | kVerticalFrame); ~Moniter(); void CloseWindow(); Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); Int_t DistancetoPrimitive(Int_t px, Int_t py); void ExecuteEvent(Int_t event, Int_t px, Int_t py); //--- deal with threshold buffer -------- void ReFillBuffer(Int_t param1); //-- Get Threshold Values for each task from Buffer ------- void GetBufferValue(); ClassDef(Moniter,0) }; #endif //---------------------------------------------------------- // Next ROOT version should solve following problems // Whe Tab is changed, range of slider, text of TGLabel, etc should // be changed correspondingly. Now, you have to set push puttons of // each task to get the value #include "oo.h" enum ETestCommandIdentifiers { M_FILE_OPEN, M_FILE_SAVE, M_FILE_SAVEAS, M_FILE_EXIT, M_TEST_DLG, M_TEST_MSGBOX, M_TEST_SLIDER, M_HELP_CONTENTS, M_HELP_SEARCH, M_HELP_ABOUT, M_CASCADE_1, M_CASCADE_2, M_CASCADE_3, LowEntryID, UpEntryID, VId2, HId2, LowSliderID, UpSliderID, VSId2, HSId2 }; Int_t mb_button_id[9] = { kMBYes, kMBNo, kMBOk, kMBApply, kMBRetry, kMBIgnore, kMBCancel, kMBClose, kMBDismiss }; EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion, kMBIconExclamation, kMBIconAsterisk }; const char *filetypes[] = { "All files", "*", "ROOT files", "*.root", "ROOT macros", "*.C", 0, 0 }; ClassImp(Moniter) Moniter::Moniter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) : TGMainFrame(p, w, h) { MainFrameLayout = new TGLayoutHints(kLHintsTop|kLHintsExpandX, 0,0,0,0); PCLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX |kLHintsExpandY,1,1,1,1); MainFrame=new TGCompositeFrame(this,100,100,kHorizontalFrame); SelectPC = new TGTab(MainFrame, 300,300); TGCompositeFrame *tf = SelectPC->AddTab("Gain"); tf = SelectPC->AddTab("HV&LV"); tf = SelectPC->AddTab("P&T"); tf = SelectPC->AddTab("Gas Flow"); //----- Add Main Frame ----------------- MainFrame->AddFrame(SelectPC,PCLayout); AddFrame(MainFrame, MainFrameLayout); //---- Map and Resize window or subwindows ---- SetWindowName("Pad Chamber Slow Control System"); MapSubwindows(); Resize(440,GetDefaultHeight()); MapWindow(); } //--------------------------------- Moniter::~Moniter() { delete MainFrame; delete PCLayout; delete MainFrameLayout; delete SelectPC; } //--------------------------------- void Moniter::ReFillBuffer(Int_t parm1) { } //---------------------------------- void Moniter::Status(Int_t param1) { } //--------------------------------- void Moniter::CloseWindow() { delete this; } //--------------------------------- Bool_t Moniter::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) { char buf[10]; switch (GET_MSG(msg)) { case kC_COMMAND: switch (GET_SUBMSG(msg)) { case kCM_TAB: printf("Tab item %ld activated\n", parm1); break; default: break; } default: break; } return kTRUE; } //--- mouse Control ------------- void Moniter::ExecuteEvent(Int_t event, Int_t px, Int_t py) { } //--- Serve for ExecuteEvent ------- Int_t Moniter::DistancetoPrimitive(Int_t px, Int_t py) { return 0; } //--- Convert buffer value to real threhold value ------- void Moniter::GetBufferValue() { } #ifndef _mointer_ #define _mointer_ #include <stdlib.h> #include <TROOT.h> #include <TApplication.h> #include <TGXW.h> #include <TEnv.h> #include <TGListBox.h> #include <TGClient.h> #include <TGFrame.h> #include <TGIcon.h> #include <TGLabel.h> #include <TGButton.h> #include <TGTextEntry.h> #include <TGMsgBox.h> #include <TGMenu.h> #include <TGCanvas.h> #include <TGComboBox.h> #include <TGTab.h> #include <TGSlider.h> #include <TGFileDialog.h> #include <TRootEmbeddedCanvas.h> #include <TCanvas.h> #include <TH1.h> #include <TH2.h> #include <TRandom.h> #include <TSystem.h> #include <TPaveLabel.h> class Moniter : public TGMainFrame { private: TGCompositeFrame *MainFrame; TGTab *SelectPC; TGLayoutHints *PCLayout, *SubframeLayout, *MainFrameLayout, *SliderLayout,*StartLayout, *CancelLayout, *ButtonFrameLayout, *BufferLayout, *CanvasFrameLayout, *DefaultLayout; //-- Get data corresponding to each slow control quantity --- void Status(Int_t Id); //?????????? public: Moniter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kMainFrame | kVerticalFrame); ~Moniter(); void CloseWindow(); Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); Int_t DistancetoPrimitive(Int_t px, Int_t py); void ExecuteEvent(Int_t event, Int_t px, Int_t py); //--- deal with threshold buffer -------- void ReFillBuffer(Int_t param1); //-- Get Threshold Values for each task from Buffer ------- void GetBufferValue(); ClassDef(Moniter,0) }; #endif //---------------------------------------------------------- // Next ROOT version should solve following problems // Whe Tab is changed, range of slider, text of TGLabel, etc should // be changed correspondingly. Now, you have to set push puttons of // each task to get the value #include "oo.h" enum ETestCommandIdentifiers { M_FILE_OPEN, M_FILE_SAVE, M_FILE_SAVEAS, M_FILE_EXIT, M_TEST_DLG, M_TEST_MSGBOX, M_TEST_SLIDER, M_HELP_CONTENTS, M_HELP_SEARCH, M_HELP_ABOUT, M_CASCADE_1, M_CASCADE_2, M_CASCADE_3, LowEntryID, UpEntryID, VId2, HId2, LowSliderID, UpSliderID, VSId2, HSId2 }; Int_t mb_button_id[9] = { kMBYes, kMBNo, kMBOk, kMBApply, kMBRetry, kMBIgnore, kMBCancel, kMBClose, kMBDismiss }; EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion, kMBIconExclamation, kMBIconAsterisk }; const char *filetypes[] = { "All files", "*", "ROOT files", "*.root", "ROOT macros", "*.C", 0, 0 }; ClassImp(Moniter) Moniter::Moniter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options) : TGMainFrame(p, w, h) { MainFrameLayout = new TGLayoutHints(kLHintsTop|kLHintsExpandX, 0,0,0,0); PCLayout = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX |kLHintsExpandY,1,1,1,1); // MainFrame=new TGCompositeFrame(this,100,100,kHorizontalFrame); //SelectPC = new TGTab(MainFrame, 300,300); SelectPC = new TGTab(this, 300,300); TGCompositeFrame *tf = SelectPC->AddTab("Gain"); tf = SelectPC->AddTab("HV&LV"); tf = SelectPC->AddTab("P&T"); tf = SelectPC->AddTab("Gas Flow"); //----- Add Main Frame ----------------- // AddFrame(MainFrame, MainFrameLayout); // MainFrame->AddFrame(SelectPC,PCLayout); AddFrame(SelectPC,PCLayout); //---- Map and Resize window or subwindows ---- SetWindowName("Pad Chamber Slow Control System"); MapSubwindows(); Resize(440,GetDefaultHeight()); MapWindow(); } //--------------------------------- Moniter::~Moniter() { delete MainFrame; delete PCLayout; delete MainFrameLayout; delete SelectPC; } //--------------------------------- void Moniter::ReFillBuffer(Int_t parm1) { } //---------------------------------- void Moniter::Status(Int_t param1) { } //--------------------------------- void Moniter::CloseWindow() { delete this; } //--------------------------------- Bool_t Moniter::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) { char buf[10]; switch (GET_MSG(msg)) { case kC_COMMAND: switch (GET_SUBMSG(msg)) { case kCM_TAB: printf("Tab item %ld activated\n", parm1); break; default: break; } default: break; } return kTRUE; } //--- mouse Control ------------- void Moniter::ExecuteEvent(Int_t event, Int_t px, Int_t py) { } //--- Serve for ExecuteEvent ------- Int_t Moniter::DistancetoPrimitive(Int_t px, Int_t py) { return 0; } //--- Convert buffer value to real threhold value ------- void Moniter::GetBufferValue() { }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:40 MET