Changeset 719 for trunk/MagicSoft


Ignore:
Timestamp:
04/04/01 11:36:55 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mmain
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mmain/MBrowser.cc

    r714 r719  
    88#include <TGMsgBox.h>       // TGMsgBox
    99#include <TGListBox.h>      // TGListBox
     10#include <TGComboBox.h>     // TGComboBox
    1011#include <TGFSContainer.h>  // TGFileContainer
    1112
    12 // FIXME: Move to MAGIC.h
    13 #define S_ISDIR(m) ((m)&0170000 == 0040000)
     13#include <sys/stat.h>       // S_ISDIR
    1414
    1515#include <iostream.h>
     
    1919    M_PBUTTON_CDIR_UP     = 0x1001,
    2020    M_PBUTTON_LIST_MODE   = 0x1002,
    21     M_PBUTTON_DETAIL_MODE = 0x1003
     21    M_PBUTTON_DETAIL_MODE = 0x1003,
     22    M_DIRBOX              = 0x1004
    2223};
    2324
     
    6465
    6566    fTop1 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
     67    fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
     68    fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
     69
    6670    fFrameTop->AddFrame (fTop1, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
    67 
    68     fTop2 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
    6971    fFrameTop->AddFrame (fTop2, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
    70 
    71     fTop3 = new TGHorizontalFrame (fFrameTop, 300, 100 ) ;
    7272    fFrameTop->AddFrame (fTop3, new TGLayoutHints(kLHintsCenterX, 10, 10, 5, 5) );
    73 
    7473    AddFrame(fFrameTop, new TGLayoutHints (kLHintsTop ) ) ;
    7574
     
    8382    //    create the first tab
    8483
    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}
    156151
    157152
     
    236231}
    237232
     233void 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
    238247Bool_t MBrowser::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
    239248{     
     
    253262              //  goto the parent directory
    254263              //
    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("..");
    267265              return kTRUE;
    268266           
     
    279277          return kTRUE;
    280278
     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
    281288        case kCM_MENU:
    282 
    283289          if (parm1==M_FILE_CLOSE)
    284290              CloseWindow();
     
    312318
    313319          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()))
    317326          {
    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);
    328328              return kTRUE;
    329329          }
     
    335335          const char *extension=strrchr(str, '.');
    336336
    337 
    338337          if (!extension)
    339338              return kTRUE;
     339
     340          const char *dir = fFileCont->GetDirectory();
    340341
    341342          if (!strcasecmp(extension, ".ps")) // postscript file
  • trunk/MagicSoft/Mars/mmain/MBrowser.h

    r714 r719  
    1313class TGPopupMenu;
    1414class TGTab;
     15class TGComboBox;
    1516class TGTextButton;
    1617class TGListBox;
     
    4748    TGCompositeFrame  *fTabF1a;    // subpart of the file selector in low window
    4849    TGCompositeFrame  *fTabF1b;    // subpart of the file selector in low window
    49     TGListBox         *fDir;
     50    TGComboBox        *fDir;
    5051    TGPictureButton   *fCdup;
    5152    TGPictureButton   *fListMode;
     
    7374    void DisplInfo(const char *txt);
    7475
     76    void ChangeDir(const char *txt=NULL);
     77
    7578    TGHorizontalFrame *fTop1;
    7679    TGHorizontalFrame *fTop2;
Note: See TracChangeset for help on using the changeset viewer.