- Timestamp:
- 09/25/01 15:44:19 (23 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r944 r945 8 8 people triing to commit changed files from such an archive to 9 9 the repository 10 11 * mmain/MBrowser.[cc,h]: 12 - reorganized code (constructor) 13 - reorganized deletion of gui objects 14 - fixed many, many memory leaks 10 15 11 16 -
trunk/MagicSoft/Mars/mmain/MBrowser.cc
r938 r945 50 50 }; 51 51 52 void MBrowser::CreateMenuBar() 53 { 54 // 55 // crate the menu bar 56 // 57 TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot()); 58 filemenu->AddEntry("Close", M_FILE_CLOSE); 59 //filemenu->Associate(this); 60 fList->Add(filemenu); 61 62 // 63 // the button messages are handled by main frame (this) 64 // 65 TGLayoutHints *laymenubar = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2); 66 TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0); 67 68 fList->Add(laymenubar); 69 fList->Add(laymenuitem); 70 71 TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame); 72 menubar->AddPopup("File", filemenu, laymenuitem); 73 AddFrame(menubar, laymenubar); 74 fList->Add(menubar); 75 } 76 77 void MBrowser::CreateUpperFrame(TGCompositeFrame *frametop) 78 { 79 80 // 81 // *********** Create Contents of frame top (upper part) ********** 82 // 83 fTop1 = new TGHorizontalFrame(frametop, 300, 100); 84 fTop2 = new TGHorizontalFrame(frametop, 300, 100); 85 fTop3 = new TGHorizontalFrame(frametop, 300, 100); 86 87 frametop->AddFrame(fTop1); 88 frametop->AddFrame(fTop2); 89 frametop->AddFrame(fTop3); 90 91 fList->Add(fTop1); 92 fList->Add(fTop2); 93 fList->Add(fTop3); 94 } 95 96 void MBrowser::CreateDirListMenu(TGCompositeFrame *frame) 97 { 98 // 99 // Create Dir-Listbox and buttons in first frame 100 // 101 fDir = new TGComboBox(frame, M_DIRBOX); 102 fDir->Resize(350, 20); 103 104 fPic1 = fClient->GetPicture("tb_uplevel.xpm"); 105 fPic2 = fClient->GetPicture("tb_list.xpm"); 106 fPic3 = fClient->GetPicture("tb_details.xpm"); 107 108 fCdup = new TGPictureButton(frame, fPic1, M_PBUTTON_CDIR_UP); 109 fListMode = new TGPictureButton(frame, fPic2, M_PBUTTON_LIST_MODE); 110 fDetail = new TGPictureButton(frame, fPic3, M_PBUTTON_DETAIL_MODE); 111 112 fCdup ->SetToolTipText("One Level up!"); 113 fListMode->SetToolTipText("List Mode"); 114 fDetail ->SetToolTipText("Details Mode"); 115 116 fListMode->SetState(kButtonUp); 117 fDetail ->SetState(kButtonEngaged); 118 119 fListMode->AllowStayDown(kTRUE); 120 fDetail ->AllowStayDown(kTRUE); 121 122 fDir ->Associate(this); 123 fCdup ->Associate(this); 124 fDetail ->Associate(this); 125 fListMode->Associate(this); 126 127 fList->Add(fDir); 128 fList->Add(fCdup); 129 fList->Add(fListMode); 130 fList->Add(fDetail); 131 132 // 133 // Layout Dir-Listbox and buttons 134 // 135 TGLayoutHints *laydir = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 5, 5, 5, 5); 136 TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5); 137 138 fList->Add(laydir); 139 fList->Add(laybut); 140 141 frame->AddFrame(fDir, laydir); 142 frame->AddFrame(fCdup, laybut); 143 frame->AddFrame(fListMode, laybut); 144 frame->AddFrame(fDetail, laybut); 145 } 146 147 void MBrowser::CreateDirListBox(TGCompositeFrame *frame) 148 { 149 // 150 // Create file viewer (browser) 151 // 152 fFileView = new TGListView(frame, 540, 380); 153 fList->Add(fFileView); 154 155 TGViewPort *port = fFileView->GetViewPort(); 156 port->SetBackgroundColor(fgWhitePixel); 157 158 fFileCont = new TGFileContainer(port, 100, 100, kVerticalFrame, fgWhitePixel); 159 fList->Add(fFileCont); 160 161 fFileView->SetContainer(fFileCont); 162 fFileView->SetViewMode(kLVDetails); 163 164 fFileCont->SetFilter("*"); 165 fFileCont->Associate(this); 166 fFileCont->Sort(kSortByName); 167 168 TGLayoutHints *layview = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5); 169 fList->Add(layview); 170 171 frame->AddFrame(fFileView, layview); 172 } 173 174 void MBrowser::CreateTab1(TGCompositeFrame *frame) 175 { 176 // 177 // Create three frames for the first tab 178 // 179 TGCompositeFrame *tab1 = new TGCompositeFrame(frame, 100, 100, kHorizontalFrame); 180 TGCompositeFrame *tab1a = new TGCompositeFrame(frame, 100, 100, kHorizontalFrame); 181 TGCompositeFrame *tab1b = new TGCompositeFrame(frame, 100, 100, kVerticalFrame); 182 183 TGLayoutHints *laytab1b = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5); 184 TGLayoutHints *laytab1 = new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5); 185 186 fList->Add(laytab1b); 187 fList->Add(laytab1); 188 189 frame->AddFrame(tab1a); 190 frame->AddFrame(tab1b, laytab1b); 191 frame->AddFrame(tab1, laytab1); 192 193 fList->Add(tab1); 194 fList->Add(tab1a); 195 fList->Add(tab1b); 196 197 CreateDirListMenu(tab1a); 198 CreateDirListBox(tab1b); 199 } 200 201 void MBrowser::CreateLowerFrame(TGCompositeFrame *framelow) 202 { 203 // 204 // *********** Create Contents of frame low (downer part) ********** 205 // 206 207 // 208 // ----- Create Object holding the Tabs ----- 209 // 210 TGTab *tabs = new TGTab(framelow, 400, 400); 211 fList->Add(tabs); 212 213 TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5); 214 fList->Add(laytabs); 215 216 framelow->AddFrame(tabs, laytabs); 217 218 // 219 // --- Create the first tab of the tabs --- 220 // 221 TGCompositeFrame *tf = tabs->AddTab("Input File"); 222 223 CreateTab1(tf); 224 } 52 225 53 226 MBrowser::MBrowser(const TGWindow *main, const TGWindow *p, … … 56 229 main?main:gClient->GetRoot(), w, h) 57 230 { 58 59 //60 // Main window to controll the october test61 //62 63 // set non-gui members to starting values64 65 231 fInputFile[0] = '\0'; 66 232 67 // 68 // First create the MenuBar. 69 // 70 71 // Layout objects for menue. 72 73 fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2 ) ; 74 fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft , 0, 4, 0, 0 ) ; 75 76 // crate the menu bar 77 78 fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ; 79 fFileMenu->AddEntry ("Close", M_FILE_CLOSE ) ; 80 fFileMenu->Associate(this) ; 81 82 // the button messages are handled by main frame (this) 83 84 fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ; 85 fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ; 86 AddFrame(fMenuBar, fLayMenuBar ) ; 87 88 // 89 // Create the top window with a lot of buttons 90 // 91 fFrameTop = new TGCompositeFrame (this, 300,100, kVerticalFrame ) ; 92 93 fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 94 fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 95 fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 96 97 fFrameTop->AddFrame (fTop1, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) ); 98 fFrameTop->AddFrame (fTop2, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) ); 99 fFrameTop->AddFrame (fTop3, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) ); 100 AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop ) ) ; 101 102 // 103 // Create the low window with a tabs in it 104 // 105 fFrameLow = new TGCompositeFrame (this, 300,100, kHorizontalFrame ) ; 106 107 fLayTab = new TGLayoutHints ( kLHintsExpandX , 5, 5, 5, 5 ) ; 108 109 // create the first tab 110 111 fTab = new TGTab ( fFrameLow, 400, 400 ) ; 112 113 TGCompositeFrame *tf = fTab->AddTab("Input File") ; 114 115 fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 116 fTabF1a = new TGCompositeFrame(tf, 100, 100, kHorizontalFrame); 117 fTabF1b = new TGCompositeFrame(tf, 100, 100, kVerticalFrame); 118 119 tf->AddFrame(fTabF1a, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 120 tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ; 121 122 fDir = new TGComboBox(fTabF1a, M_DIRBOX); 123 fDir->Resize(350, 20) ; 124 fDir->Associate(this); 125 126 fPicCdup = fClient->GetPicture("tb_uplevel.xpm"); 127 fPicList = fClient->GetPicture("tb_list.xpm"); 128 fPicDetail = fClient->GetPicture("tb_details.xpm") ; 129 130 fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ; 131 fCdup->SetToolTipText("One Level up!") ; 132 fCdup->Associate(this) ; 133 134 fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE); 135 fListMode->SetToolTipText("List Mode") ; 136 fListMode->Associate(this); 137 fListMode->SetState(kButtonUp); 138 fListMode->AllowStayDown(kTRUE); 139 140 fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ; 141 fDetail->SetToolTipText("Details Mode") ; 142 fDetail->Associate(this) ; 143 fDetail->SetState(kButtonEngaged) ; 144 fDetail->AllowStayDown(kTRUE) ; 145 146 fTabF1a->AddFrame(fDir, new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 5, 5, 5, 5)) ; 147 fTabF1a->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5)); 148 fTabF1a->AddFrame(fListMode, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5)); 149 fTabF1a->AddFrame(fDetail, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5)); 150 151 fFileView = new TGListView(fTabF1b, 540, 380 ) ; 152 fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100, 153 kVerticalFrame, fgWhitePixel) ; 154 155 fFileCont->Associate(this) ; 156 fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ; 157 fFileView->SetContainer(fFileCont) ; 158 fFileCont->SetFilter("*") ; 159 // fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ; 160 fFileView->SetViewMode(kLVDetails); 161 fFileCont->Sort(kSortByName) ; 162 163 fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ) ; 164 165 tf->AddFrame(fTabF1, fLayTab) ; 166 167 fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ); 168 169 AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ; 170 233 fList = new TList; 234 fList->SetOwner(); 235 236 CreateMenuBar(); 237 238 // 239 // ---- Create the top window with a lot of buttons ---- 240 // 241 TGCompositeFrame *frametop = new TGCompositeFrame(this, 300, 100, kVerticalFrame); 242 fList->Add(frametop); 243 AddFrame(frametop); 244 245 // 246 // ---- Create the low window with a tabs in it ---- 247 // 248 TGLayoutHints *layframelow = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY); 249 fList->Add(layframelow); 250 251 TGCompositeFrame *framelow = new TGCompositeFrame(this, 300, 100, kHorizontalFrame); 252 fList->Add(framelow); 253 254 AddFrame(framelow, layframelow); 255 256 CreateUpperFrame(frametop); 257 CreateLowerFrame(framelow); 258 259 // 260 // Map the window, set up the layout, etc. 261 // 171 262 ChangeDir(); 172 // 173 // Map the window, set up the layout, etc. 174 // 175 176 SetWMSizeHints(400, 350, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame 263 SetWMSizeHints(400, 350, 1000, 1000, 10, 10); // set the smallest and biggest size of the Main frame 177 264 } 178 265 … … 183 270 MBrowser::~MBrowser() 184 271 { 185 //delete fPicCdup, fPicList, fPicDetail; 186 delete fLayTab; 187 delete fLayMenuBar; 188 delete fLayMenuItem; 189 delete fFileView; 190 delete fFileCont; 191 delete fCdup; 192 delete fListMode; 193 delete fDetail; 194 delete fDir ; 195 delete fTabF1b; 196 delete fTabF1a; 197 delete fTabF1; 198 delete fTop3; 199 delete fTop2; 200 delete fTop1; 201 delete fTab; 202 delete fFrameTop; 203 delete fFrameLow; 204 delete fFileMenu; 205 delete fMenuBar; 206 272 fClient->FreePicture(fPic1); 273 fClient->FreePicture(fPic2); 274 fClient->FreePicture(fPic3); 275 276 delete fList; 207 277 } 208 209 278 210 279 // ====================================================================== … … 218 287 // window menu item is selected. 219 288 220 delete this ;289 delete this; 221 290 } 222 291 … … 293 362 294 363 case M_PBUTTON_LIST_MODE: 295 fFileView->SetViewMode(kLVList) ;364 fFileView->SetViewMode(kLVList); 296 365 fDetail->SetState(kButtonUp) ; 297 366 return kTRUE; 298 367 299 368 case M_PBUTTON_DETAIL_MODE: 300 fFileView->SetViewMode(kLVDetails) 301 fListMode->SetState(kButtonUp) 369 fFileView->SetViewMode(kLVDetails); 370 fListMode->SetState(kButtonUp); 302 371 return kTRUE; 303 372 } … … 321 390 322 391 case kC_CONTAINER: 323 switch (GET_SUBMSG(msg)) { 392 switch (GET_SUBMSG(msg)) 393 { 324 394 325 395 // case kCT_ITEMCLICK: -
trunk/MagicSoft/Mars/mmain/MBrowser.h
r938 r945 19 19 class TGFileContainer; 20 20 class TGListView; 21 class TList; 21 22 22 23 class MBrowser : public TGTransientFrame … … 28 29 // 29 30 30 // some member not connected with Gui31 32 // the things for the menu bar33 34 TGMenuBar *fMenuBar ;35 TGPopupMenu *fFileMenu ;36 37 //38 // divide the Window in two different parts39 //40 TGCompositeFrame *fFrameTop; // top part of the main window41 TGCompositeFrame *fFrameLow; // low part of the main window42 TGTab *fTab; // different tabs in the low window43 44 31 // 45 32 // the things in the file selector 46 33 // 47 TGCompositeFrame *fTabF1; // first tab of low part48 TGCompositeFrame *fTabF1a; // subpart of the file selector in low window49 TGCompositeFrame *fTabF1b; // subpart of the file selector in low window50 34 TGComboBox *fDir; 35 51 36 TGPictureButton *fCdup; 52 37 TGPictureButton *fListMode; 53 38 TGPictureButton *fDetail; 39 54 40 TGFileContainer *fFileCont; 55 41 TGListView *fFileView; 56 42 57 // Layout hints for different uses58 43 59 TGLayoutHints *fLayMenuBar; 60 TGLayoutHints *fLayMenuItem; 61 TGLayoutHints *fLayTab; 44 TList *fList; 62 45 63 46 // some icons and pictures often used 64 47 65 const TGPicture *fPicCdup; 66 const TGPicture *fPicList; 67 const TGPicture *fPicDetail; 48 const TGPicture *fPic1; 49 const TGPicture *fPic2; 50 const TGPicture *fPic3; 51 52 void CreateMenuBar(); 53 void CreateUpperFrame(TGCompositeFrame *frameup); 54 void CreateLowerFrame(TGCompositeFrame *framelow); 55 void CreateTab1(TGCompositeFrame *frame); 56 void CreateDirListMenu(TGCompositeFrame *frame); 57 void CreateDirListBox(TGCompositeFrame *frame); 68 58 69 59 protected:
Note:
See TracChangeset
for help on using the changeset viewer.