Changeset 719 for trunk/MagicSoft/Mars
- Timestamp:
- 04/04/01 11:36:55 (24 years ago)
- Location:
- trunk/MagicSoft/Mars/mmain
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mmain/MBrowser.cc
r714 r719 8 8 #include <TGMsgBox.h> // TGMsgBox 9 9 #include <TGListBox.h> // TGListBox 10 #include <TGComboBox.h> // TGComboBox 10 11 #include <TGFSContainer.h> // TGFileContainer 11 12 12 // FIXME: Move to MAGIC.h 13 #define S_ISDIR(m) ((m)&0170000 == 0040000) 13 #include <sys/stat.h> // S_ISDIR 14 14 15 15 #include <iostream.h> … … 19 19 M_PBUTTON_CDIR_UP = 0x1001, 20 20 M_PBUTTON_LIST_MODE = 0x1002, 21 M_PBUTTON_DETAIL_MODE = 0x1003 21 M_PBUTTON_DETAIL_MODE = 0x1003, 22 M_DIRBOX = 0x1004 22 23 }; 23 24 … … 64 65 65 66 fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 67 fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 68 fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ; 69 66 70 fFrameTop->AddFrame (fTop1, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) ); 67 68 fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;69 71 fFrameTop->AddFrame (fTop2, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) ); 70 71 fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;72 72 fFrameTop->AddFrame (fTop3, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) ); 73 74 73 AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop ) ) ; 75 74 … … 83 82 // create the first tab 84 83 85 fTab = new TGTab ( fFrameLow, 400, 400 ) ; 86 87 TGCompositeFrame *tf = fTab->AddTab("Input File") ; 88 89 fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 90 // tf->AddFrame(fTabF1, fLayTab ) ; 91 92 fTabF1a = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 93 tf->AddFrame(fTabF1a, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 94 95 fTabF1b = new TGCompositeFrame (tf, 100, 100, kVerticalFrame) ; 96 // tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ; 97 tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ; 98 99 fDir = new TGListBox(fTabF1a, -1) ; 100 fDir->Resize(350,20) ; 101 char temp[100] ; 102 // sprintf ( temp, "%s", START_DIRECTORY ) ; 103 sprintf ( temp, "%s", gSystem->WorkingDirectory() ) ; 104 fDir->AddEntry(temp, 1) ; 105 fTabF1a->AddFrame( fDir, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 106 107 fPicCdup = fClient->GetPicture("tb_uplevel.xpm") ; 108 fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ; 109 fCdup->SetToolTipText("One Level up!") ; 110 fCdup->Associate(this) ; 111 fTabF1a->AddFrame (fCdup, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 112 113 fPicList = fClient->GetPicture("tb_list.xpm") ; 114 fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE ) ; 115 fListMode->SetToolTipText("List Mode") ; 116 fListMode->Associate(this) ; 117 fListMode->SetState(kButtonUp) ; 118 fListMode->AllowStayDown(kTRUE) ; 119 fListMode->AllowStayDown(kTRUE) ; fTabF1a->AddFrame (fListMode, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 120 121 fPicDetail = fClient->GetPicture("tb_details.xpm") ; 122 fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ; 123 fDetail->SetToolTipText("Details Mode") ; 124 fDetail->Associate(this) ; 125 fDetail->SetState(kButtonEngaged) ; 126 fDetail->AllowStayDown(kTRUE) ; 127 fTabF1a->AddFrame (fDetail, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 5, 5) ) ; 128 129 fFileView = new TGListView(fTabF1b, 540, 380 ) ; 130 fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100, 131 kVerticalFrame, fgWhitePixel) ; 132 133 fFileCont->Associate(this) ; 134 fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ; 135 fFileView->SetContainer(fFileCont) ; 136 fFileCont->SetFilter("*") ; 137 // fFileCont->ChangeDirectory(START_DIRECTORY) ; 138 fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ; 139 fFileView->SetViewMode(kLVDetails); 140 fFileCont->Sort(kSortByName) ; 141 142 fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ) ; 143 144 tf->AddFrame(fTabF1, fLayTab) ; 145 146 fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ); 147 148 AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ; 149 150 // 151 // Map the window, set up the layout, etc. 152 // 153 154 SetWMSizeHints(400, 350, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame 155 } 84 fTab = new TGTab ( fFrameLow, 400, 400 ) ; 85 86 TGCompositeFrame *tf = fTab->AddTab("Input File") ; 87 88 fTabF1 = new TGCompositeFrame (tf, 100, 100, kHorizontalFrame) ; 89 fTabF1a = new TGCompositeFrame(tf, 100, 100, kHorizontalFrame); 90 fTabF1b = new TGCompositeFrame(tf, 100, 100, kVerticalFrame); 91 92 tf->AddFrame(fTabF1a, new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 5 ) ) ; 93 tf->AddFrame(fTabF1b, new TGLayoutHints ( kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5 ) ) ; 94 95 fDir = new TGComboBox(fTabF1a, M_DIRBOX); 96 fDir->Resize(350, 20) ; 97 fDir->Associate(this); 98 99 fPicCdup = fClient->GetPicture("tb_uplevel.xpm"); 100 fPicList = fClient->GetPicture("tb_list.xpm"); 101 fPicDetail = fClient->GetPicture("tb_details.xpm") ; 102 103 fCdup = new TGPictureButton(fTabF1a, fPicCdup, M_PBUTTON_CDIR_UP ) ; 104 fCdup->SetToolTipText("One Level up!") ; 105 fCdup->Associate(this) ; 106 107 fListMode = new TGPictureButton(fTabF1a, fPicList, M_PBUTTON_LIST_MODE); 108 fListMode->SetToolTipText("List Mode") ; 109 fListMode->Associate(this); 110 fListMode->SetState(kButtonUp); 111 fListMode->AllowStayDown(kTRUE); 112 113 fDetail = new TGPictureButton(fTabF1a, fPicDetail, M_PBUTTON_DETAIL_MODE ) ; 114 fDetail->SetToolTipText("Details Mode") ; 115 fDetail->Associate(this) ; 116 fDetail->SetState(kButtonEngaged) ; 117 fDetail->AllowStayDown(kTRUE) ; 118 119 fTabF1a->AddFrame(fDir, new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 5, 5, 5, 5)) ; 120 fTabF1a->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5)); 121 fTabF1a->AddFrame(fListMode, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5)); 122 fTabF1a->AddFrame(fDetail, new TGLayoutHints(kLHintsLeft|kLHintsTop, 5, 5, 5, 5)); 123 124 fFileView = new TGListView(fTabF1b, 540, 380 ) ; 125 fFileCont = new TGFileContainer(fFileView->GetViewPort(), 100, 100, 126 kVerticalFrame, fgWhitePixel) ; 127 128 fFileCont->Associate(this) ; 129 fFileView->GetViewPort()->SetBackgroundColor(fgWhitePixel) ; 130 fFileView->SetContainer(fFileCont) ; 131 fFileCont->SetFilter("*") ; 132 // fFileCont->ChangeDirectory(gSystem->WorkingDirectory()) ; 133 fFileView->SetViewMode(kLVDetails); 134 fFileCont->Sort(kSortByName) ; 135 136 fTabF1b->AddFrame(fFileView, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ) ; 137 138 tf->AddFrame(fTabF1, fLayTab) ; 139 140 fFrameLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) ); 141 142 AddFrame(fFrameLow, new TGLayoutHints (kLHintsExpandX|kLHintsExpandY) ) ; 143 144 ChangeDir(); 145 // 146 // Map the window, set up the layout, etc. 147 // 148 149 SetWMSizeHints(400, 350, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame 150 } 156 151 157 152 … … 236 231 } 237 232 233 void MBrowser::ChangeDir(const char *txt) 234 { 235 fFileCont->ChangeDirectory(txt?txt:gSystem->WorkingDirectory()); 236 237 const char *dir = fFileCont->GetDirectory(); 238 // const UInt_t num = fDir->GetSelected()+1; 239 240 // 241 // FIXME: This is a big workaround! 242 // 243 fDir->InsertEntry(dir, -1/*num*/, -1); 244 fDir->Select(-1/*num*/); 245 } 246 238 247 Bool_t MBrowser::ProcessMessage(Long_t msg, Long_t parm1, Long_t) 239 248 { … … 253 262 // goto the parent directory 254 263 // 255 gSystem->ChangeDirectory("..") ; 256 fDir->RemoveEntry(1) ; 257 { 258 const char *dir = gSystem->WorkingDirectory(); 259 260 fDir->AddEntry(dir, 1); 261 fDir->MapSubwindows(); 262 fDir->Layout(); 263 264 fFileCont->ChangeDirectory(dir); 265 fFileCont->DisplayDirectory(); 266 } 264 ChangeDir(".."); 267 265 return kTRUE; 268 266 … … 279 277 return kTRUE; 280 278 279 case kCM_COMBOBOX: 280 // 281 // FIXME: Don't add the new entry to the list! 282 // But to do this we need the number of entries in the list. 283 // 284 if (parm1 == M_DIRBOX) 285 ChangeDir(((TGTextLBEntry*)fDir->GetSelectedEntry())->GetText()->GetString()); 286 return kTRUE; 287 281 288 case kCM_MENU: 282 283 289 if (parm1==M_FILE_CLOSE) 284 290 CloseWindow(); … … 312 318 313 319 const char *str = item->GetItemName()->GetString(); 314 const char *dir = gSystem->WorkingDirectory(); 315 316 if (S_ISDIR(item->GetType())) // file is directory 320 321 // 322 // if the user choose a directory 323 // change to this directory 324 // 325 if (S_ISDIR(item->GetType())) 317 326 { 318 // 319 // goto directory 320 // 321 fFileCont->ChangeDirectory(str); 322 gSystem->ChangeDirectory(str); 323 324 fDir->RemoveEntry(1); 325 fDir->AddEntry(dir, 1); 326 fDir->MapSubwindows(); 327 fDir->Layout(); 327 ChangeDir(str); 328 328 return kTRUE; 329 329 } … … 335 335 const char *extension=strrchr(str, '.'); 336 336 337 338 337 if (!extension) 339 338 return kTRUE; 339 340 const char *dir = fFileCont->GetDirectory(); 340 341 341 342 if (!strcasecmp(extension, ".ps")) // postscript file -
trunk/MagicSoft/Mars/mmain/MBrowser.h
r714 r719 13 13 class TGPopupMenu; 14 14 class TGTab; 15 class TGComboBox; 15 16 class TGTextButton; 16 17 class TGListBox; … … 47 48 TGCompositeFrame *fTabF1a; // subpart of the file selector in low window 48 49 TGCompositeFrame *fTabF1b; // subpart of the file selector in low window 49 TG ListBox*fDir;50 TGComboBox *fDir; 50 51 TGPictureButton *fCdup; 51 52 TGPictureButton *fListMode; … … 73 74 void DisplInfo(const char *txt); 74 75 76 void ChangeDir(const char *txt=NULL); 77 75 78 TGHorizontalFrame *fTop1; 76 79 TGHorizontalFrame *fTop2;
Note:
See TracChangeset
for help on using the changeset viewer.