Changeset 945 for trunk


Ignore:
Timestamp:
09/25/01 15:44:19 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r944 r945  
    88       people triing to commit changed files from such an archive to
    99       the repository
     10       
     11   * mmain/MBrowser.[cc,h]:
     12     - reorganized code (constructor)
     13     - reorganized deletion of gui objects
     14     - fixed many, many memory leaks
    1015
    1116
  • trunk/MagicSoft/Mars/mmain/MBrowser.cc

    r938 r945  
    5050};
    5151
     52void 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
     77void 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
     96void 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
     147void 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
     174void 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
     201void 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}
    52225
    53226MBrowser::MBrowser(const TGWindow *main, const TGWindow *p,
     
    56229                   main?main:gClient->GetRoot(), w, h)
    57230{
    58 
    59     //
    60     //    Main window to controll the october test
    61     //
    62 
    63     //    set non-gui members to starting values
    64 
    65231    fInputFile[0] = '\0';
    66232
    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    //
    171262    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
    177264}
    178265
     
    183270MBrowser::~MBrowser()
    184271{
    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;
    207277}
    208 
    209278
    210279// ======================================================================
     
    218287   // window menu item is selected.
    219288
    220   delete this ;
     289    delete this;
    221290}
    222291
     
    293362           
    294363            case M_PBUTTON_LIST_MODE:
    295               fFileView->SetViewMode(kLVList) ;
     364              fFileView->SetViewMode(kLVList);
    296365              fDetail->SetState(kButtonUp) ;
    297366              return kTRUE;
    298367             
    299368          case M_PBUTTON_DETAIL_MODE:
    300               fFileView->SetViewMode(kLVDetails) ;
    301               fListMode->SetState(kButtonUp) ;
     369              fFileView->SetViewMode(kLVDetails);
     370              fListMode->SetState(kButtonUp);
    302371              return kTRUE;
    303372          }
     
    321390     
    322391  case kC_CONTAINER:
    323       switch (GET_SUBMSG(msg)) {
     392      switch (GET_SUBMSG(msg))
     393      {
    324394
    325395          //      case kCT_ITEMCLICK:
  • trunk/MagicSoft/Mars/mmain/MBrowser.h

    r938 r945  
    1919class TGFileContainer;
    2020class TGListView;
     21class TList;
    2122
    2223class MBrowser : public TGTransientFrame
     
    2829    //
    2930
    30     //   some member not connected with Gui
    31 
    32     //  the things for the menu bar
    33 
    34     TGMenuBar         *fMenuBar ;
    35     TGPopupMenu       *fFileMenu ;
    36 
    37     //
    38     //   divide the Window in two different parts
    39     //
    40     TGCompositeFrame  *fFrameTop;   // top part of the main window
    41     TGCompositeFrame  *fFrameLow;   // low part of the main window
    42     TGTab             *fTab;        // different tabs in the low window
    43 
    4431    //
    4532    //   the things in the file selector
    4633    //
    47     TGCompositeFrame  *fTabF1;     // first tab of low part
    48     TGCompositeFrame  *fTabF1a;    // subpart of the file selector in low window
    49     TGCompositeFrame  *fTabF1b;    // subpart of the file selector in low window
    5034    TGComboBox        *fDir;
     35
    5136    TGPictureButton   *fCdup;
    5237    TGPictureButton   *fListMode;
    5338    TGPictureButton   *fDetail;
     39
    5440    TGFileContainer   *fFileCont;
    5541    TGListView        *fFileView;
    5642
    57     //     Layout hints for different uses
    5843
    59     TGLayoutHints     *fLayMenuBar;
    60     TGLayoutHints     *fLayMenuItem;
    61     TGLayoutHints     *fLayTab;
     44    TList             *fList;
    6245
    6346    //     some icons and pictures often used
    6447
    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);
    6858
    6959protected:
Note: See TracChangeset for help on using the changeset viewer.