Exemple #1
0
void TExpenser::drawStatisticsMonthTab() {

    fStatisticsTab = fTab->AddTab("Statistics (Month)");
    fStatisticsTab -> SetLayoutManager(new TGHorizontalLayout(fStatisticsTab));

    TRootEmbeddedCanvas * fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fStatisticsTab, CANVAS_WIDTH, CANVAS_HEIGHT);
    fStatisticsTab -> AddFrame(fEcanvas, new TGLayoutHints(kLHintsCenterX, 10,10,10,1));
    fCanvas = fEcanvas->GetCanvas();
    fCategoriesHistogram = new TH1F("fCategoriesHistogram", "Expenses for each category for a given month", NCATEGORIES, 0, NCATEGORIES);
    fCategoriesHistogram -> SetStats(0);

    TGVerticalFrame *vframe = new TGVerticalFrame(fStatisticsTab, 60, 40);
    fStatisticsTab -> AddFrame(vframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));

    // month selector
    fStatisticsMonth = new TGComboBox(vframe);
    for (unsigned i = 0; i < 12; i++) {
        fStatisticsMonth->AddEntry(MONTHS[i], i+1);
    }
    fStatisticsMonth->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    TDatime time;
    fStatisticsMonth->Select(time.GetMonth());
    vframe->AddFrame(fStatisticsMonth, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // year selector
    fStatisticsYear = new TGComboBox(vframe);
    for (unsigned i = FIRST_YEAR; i <= LAST_YEAR; i++) {
        fStatisticsYear->AddEntry(toStr(i), i+1-FIRST_YEAR);
    }
    fStatisticsYear->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    fStatisticsYear->Select(time.GetYear()-FIRST_YEAR+1);
    vframe->AddFrame(fStatisticsYear, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // update-button
    TGTextButton * update_button = new TGTextButton(vframe,"&Apply");
    update_button -> SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    update_button -> Connect("Clicked()", "TExpenser", this, "calculate_monthly()");
    vframe -> AddFrame(update_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    // monthly sum
    TColor *color = gROOT->GetColor(kBlue);
    TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-22-*-*-*-*-*-*-*");
    fTotalMonthlyExpenses = new TGLabel(vframe, "");
    vframe->AddFrame(fTotalMonthlyExpenses, new TGLayoutHints(kLHintsNormal, 5, 5, 3, 4));
    fTotalMonthlyExpenses->SetTextColor(color);
    fTotalMonthlyExpenses -> SetTextFont(font);

    calculate_monthly();
}
Exemple #2
0
void TExpenser::drawStatisticsYearTab() {

    fStatisticsYearTab = fTab->AddTab("Statistics (Year)");
    fStatisticsYearTab -> SetLayoutManager(new TGHorizontalLayout(fStatisticsYearTab));

    TRootEmbeddedCanvas * StatisticsYearCanvas = new TRootEmbeddedCanvas("StatisticsYearCanvas",fStatisticsYearTab, CANVAS_WIDTH, CANVAS_HEIGHT);
    fStatisticsYearTab -> AddFrame(StatisticsYearCanvas, new TGLayoutHints(kLHintsCenterX, 10,10,10,1));
    fCanvasYear = StatisticsYearCanvas->GetCanvas();
    fMonthsHistogram = new TH1F("fMonthsHistogram", "Expenses for each month for a given category", 12, 0, 12);
    fMonthsHistogram -> SetStats(0);

    TGVerticalFrame *vframe = new TGVerticalFrame(fStatisticsYearTab, 60, 40);
    fStatisticsYearTab -> AddFrame(vframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));

    //  selector
    fStatisticsCategory = new TGComboBox(vframe);
    for (unsigned i = 0; i < NCATEGORIES; i++) {
        fStatisticsCategory->AddEntry(CATEGORIES[i], i+1);
    }
    fStatisticsCategory -> AddEntry("All Categories", NCATEGORIES+1);
    fStatisticsCategory->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    fStatisticsCategory->Select(1);
    vframe->AddFrame(fStatisticsCategory, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // year selector
    TDatime time;
    fStatisticsYear2 = new TGComboBox(vframe);
    for (unsigned i = FIRST_YEAR; i <= LAST_YEAR; i++) {
        fStatisticsYear2->AddEntry(toStr(i), i+1-FIRST_YEAR);
    }
    fStatisticsYear2->Resize(DROPDOWN_MENU_WIDTH, DROPDOWN_MENU_HEIGHT);
    fStatisticsYear2->Select(time.GetYear()-FIRST_YEAR+1);
    vframe->AddFrame(fStatisticsYear2, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // update-button
    TGTextButton * update_button = new TGTextButton(vframe,"&Update");
    update_button -> Connect("Clicked()", "TExpenser", this, "calculate_yearly()");
    vframe -> AddFrame(update_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    calculate_yearly();
}
Exemple #3
0
KVFileDialog::KVFileDialog(const TGWindow *p, const TGWindow *main,
                           EKVFileDialogMode dlg_type, TGFileInfo *file_info) :
   TGTransientFrame(p, main, 10, 10, kVerticalFrame)
{
   // Create a file selection dialog. Depending on the dlg_type it can be
   // used for opening or saving a file or selecting a directory.

   fDlgMode=dlg_type;
   SetCleanup(kDeepCleanup);
   Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()");
   DontCallClose();

   int i;

   if (!p && !main) {
      MakeZombie();
      return;
   }
   if (!file_info) {
      Error("KVFileDialog", "file_info argument not set");
      fFileInfo = &gInfo;
      if (fFileInfo->fIniDir) {
         delete [] fFileInfo->fIniDir;
         fFileInfo->fIniDir = 0;
      }
      if (fFileInfo->fFilename) {
         delete [] fFileInfo->fFilename;
         fFileInfo->fFilename = 0;
      }
      fFileInfo->fFileTypeIdx = 0;
   } else
      fFileInfo = file_info;

   if (!fFileInfo->fFileTypes)
      fFileInfo->fFileTypes = gDefTypes;

   if (!fFileInfo->fIniDir)
      fFileInfo->fIniDir = StrDup(".");

   TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10);
   
   //--- top toolbar elements
   TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave)
                                                  ? "S&ave in:" : "&Look in:"));
   fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB);
   fTreeLB->Associate(this);

   fPcdup = fClient->GetPicture("tb_uplevel.xpm");
   fPnewf = fClient->GetPicture("tb_newfolder.xpm");
   fPlist = fClient->GetPicture("tb_list.xpm");
   fPdetails = fClient->GetPicture("tb_details.xpm");

   if (!(fPcdup && fPnewf && fPlist && fPdetails))
      Error("KVFileDialog", "missing toolbar pixmap(s).\n");

   fCdup    = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP);
   fNewf    = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER);
   fList    = new TGPictureButton(fHtop, fPlist, kIDF_LIST);
   fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS);

   fCdup->SetStyle(gClient->GetStyle());
   fNewf->SetStyle(gClient->GetStyle());
   fList->SetStyle(gClient->GetStyle());
   fDetails->SetStyle(gClient->GetStyle());

   fCdup->SetToolTipText("Up One Level");
   fNewf->SetToolTipText("Create New Folder");
   fList->SetToolTipText("List");
   fDetails->SetToolTipText("Details");

   fCdup->Associate(this);
   fNewf->Associate(this);
   fList->Associate(this);
   fDetails->Associate(this);

   fList->AllowStayDown(kTRUE);
   fDetails->AllowStayDown(kTRUE);

   fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());

   fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2));
   fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
   fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2));

   if (dlg_type == kKVFDSave) {
      fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB);
      fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected");
   } else {
      fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB);
      fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed");
      fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)");
   }
   fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
   fCheckB->SetOn(fFileInfo->fMultipleSelection);
   AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));

   //--- file view

   fFv = new TGListView(this, 400, 161);

   fFc = new TGFileContainer(fFv->GetViewPort(),
                             10, 10, kHorizontalFrame, fgWhitePixel);
   fFc->Associate(this);

   fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
   fFv->SetContainer(fFc);
   fFv->SetViewMode(kLVList);
   fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time

   TGTextButton** buttons = fFv->GetHeaderButtons();
   if (buttons) {
      buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)");
      buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)");
      buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)");
      buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)");
      buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)");
      buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)");
   }

   fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]);
   fFc->Sort(kSortByName);
   fFc->ChangeDirectory(fFileInfo->fIniDir);
   fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
   fTreeLB->Update(fFc->GetDirectory());

   fList->SetState(kButtonEngaged);

   AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1));

   if (dlg_type == kKVFDOpen) {
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)");
      fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()");
   }
   
   //--- file name and types

   TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10);

   TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10);

   TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:"));
   fTbfname = new TGTextBuffer(1034);
   fName = new TGTextEntry(fHfname, fTbfname);
   fName->Resize(230, fName->GetDefaultHeight());
   fName->Associate(this);

   fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10);

   TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:"));
   fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB);
   fTypes->Associate(this);
   fTypes->Resize(230, fName->GetDefaultHeight());

   TString s;
   for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
      s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]);
      fTypes->AddEntry(s.Data(), i);
   }
   fTypes->Select(fFileInfo->fFileTypeIdx);

   // Show all items in combobox without scrollbar
   //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize();
   //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight);

   if (fFileInfo->fFilename && fFileInfo->fFilename[0])
      fTbfname->AddText(0, fFileInfo->fFilename);
   else
      fTbfname->Clear();

   fTypes->GetListBox()->Resize(230, 120);
   fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
   fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));

   fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX));

   //--- Open/Save and Cancel buttons

   TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);

   fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave)
                                                 ? "&Save" : "&Open"), kIDF_OK);
   fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL);

   fOk->Associate(this);
   fCancel->Associate(this);

   fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
   fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));

   UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20;
   fVbf->Resize(width + 20, fVbf->GetDefaultHeight());

   fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));

   AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
   SetEditDisabled(kEditDisable);

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   Resize(size);

   //---- position relative to the parent's window

   CenterOnParent();

   //---- make the message box non-resizable

   SetWMSize(size.fWidth, size.fHeight);
   SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1);

   const char *wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type==kKVFDOpen) ? "Open" : "Choose directory...");
   SetWindowName(wname);
   SetIconName(wname);
   SetClassHints("FileDialog", "FileDialog");

   SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
                              kMWMDecorMinimize | kMWMDecorMenu,
               kMWMFuncAll |  kMWMFuncResize    | kMWMFuncMaximize |
                              kMWMFuncMinimize,
               kMWMInputModeless);

   MapWindow();
   fFc->DisplayDirectory();
   fClient->WaitFor(this);
}
Exemple #4
0
void TExpenser::drawExpensesTab() {

    fExpensesTab = fTab->AddTab("Expenses");
    fExpensesTab -> SetLayoutManager(new TGHorizontalLayout(fExpensesTab));

    // Create the table
    createExpensesTableInterface();
    fTable = new TGTable(fExpensesTab, 999, fTableInterface, NROWSTABLE, fTableInterface->GetNColumns());
    fExpensesTab -> AddFrame(fTable, new TGLayoutHints(kLHintsCenterY,2,2,2,2));

    // create a frame holding all widgets on the right of the table
    TGVerticalFrame *hframe = new TGVerticalFrame(fExpensesTab, 500, 40);
    fExpensesTab -> AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));

    // --------- New expense group --------- //
    TGGroupFrame *frame_new_expense = new TGGroupFrame(hframe, "New expense");
    frame_new_expense->SetTitlePos(TGGroupFrame::kLeft);
    frame_new_expense->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1"); // when font too large, collides with group content....
    // frame_new_expense->SetTextColor(kBlue); // doesn't work unfortunately
    hframe->AddFrame(frame_new_expense, new TGLayoutHints(kLHintsExpandX));

    // expense amount entry field
    fAmountEntry = new TGNumberEntryField(frame_new_expense, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEAAnyNumber);
    frame_new_expense->AddFrame(fAmountEntry, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    // date entry field
    TDatime time;
    fDateEntry = new TGNumberEntry(frame_new_expense, time.GetDate(), 10, -1, TGNumberFormat::kNESDayMYear, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 20090101., 20200101);
    frame_new_expense->AddFrame(fDateEntry, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    // withdrawn or not
    fWithdrawn = new TGComboBox(frame_new_expense,30);
    fWithdrawn->AddEntry("Not Withdrawn", 1);
    fWithdrawn->AddEntry("Withdrawn", 2);
    fWithdrawn->Select(1);
    fWithdrawn->Resize(150, 20);
    frame_new_expense->AddFrame(fWithdrawn, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // category selector
    fCategoryBox = new TGComboBox(frame_new_expense,100);
    for (unsigned i = 0; i < NCATEGORIES; i++) {
        fCategoryBox->AddEntry(CATEGORIES[i], i+1);
    }
    fCategoryBox->Resize(150, 20);
    fCategoryBox->Select(1);
    frame_new_expense->AddFrame(fCategoryBox, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // description field
    fDescription = new TGTextEntry(frame_new_expense, "");
    fDescription -> SetToolTipText("Description");
    fDescription -> Resize(200, fDescription->GetDefaultHeight());
    frame_new_expense -> AddFrame(fDescription, new TGLayoutHints(kLHintsLeft, 5,5,5,5));

    // add-button
    TGTextButton * add_button = new TGTextButton(frame_new_expense,"&Add Expense");
    add_button -> Connect("Clicked()", "TExpenser", this, "add()");
    add_button  ->  SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    frame_new_expense -> AddFrame(add_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    // --------- Withdrawing group --------- //
    TGGroupFrame *frame_withdrawn = new TGGroupFrame(hframe, "Withdrawing");
    frame_withdrawn->SetTitlePos(TGGroupFrame::kLeft);
    frame_withdrawn->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1"); // when font too large, collides with group content....
    hframe->AddFrame(frame_withdrawn, new TGLayoutHints(kLHintsExpandX));

    // withdrawn id entry field and withdrawn button
    TGHorizontalFrame *hframe1 = new TGHorizontalFrame(frame_withdrawn, 500, 40);
    frame_withdrawn -> AddFrame(hframe1,new TGLayoutHints(kLHintsLeft,5,5,3,4));
    fWithdrawnIdEntry = new TGNumberEntryField(hframe1, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber);
    hframe1->AddFrame(fWithdrawnIdEntry, new TGLayoutHints(kLHintsLeft|kLHintsExpandY,5,5,3,4));
    TGTextButton * withdrawn_button = new TGTextButton(hframe1,"&Withdrawn");
    withdrawn_button ->  SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    hframe1->AddFrame(withdrawn_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));
    withdrawn_button -> Connect("Clicked()", "TExpenser", this, "set_withdrawn()");

    // commit-button
    TGTextButton * commit_button = new TGTextButton(hframe,"&Commit");
    commit_button -> Connect("Clicked()", "TExpenser", this, "commit()");
    commit_button -> SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    hframe -> AddFrame(commit_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    // --------- Filter group --------- //
    TGGroupFrame *frame_filter = new TGGroupFrame(hframe, "Filter");
    frame_filter->SetTitlePos(TGGroupFrame::kLeft);
    frame_filter->SetTextFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1"); // when font too large, collides with group content....
    hframe->AddFrame(frame_filter, new TGLayoutHints(kLHintsExpandX));

    // filter category selector
    fFilterCategoryBox = new TGComboBox(frame_filter, 100);
    fFilterCategoryBox->AddEntry("Select Category", 1);
    for (unsigned i = 1; i < NCATEGORIES+1; i++) {
        fFilterCategoryBox->AddEntry(CATEGORIES[i], i+1);
    }
    fFilterCategoryBox->Resize(150, 20);
    fFilterCategoryBox->Select(1);
    frame_filter->AddFrame(fFilterCategoryBox, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // month selector
    fFilterMonthBox = new TGComboBox(frame_filter);
    fFilterMonthBox -> AddEntry("Select Month", 1);
    for (unsigned i = 0; i < 12; i++) {
        fFilterMonthBox->AddEntry(MONTHS[i], i+2);
    }
    fFilterMonthBox->Select(1);
    fFilterMonthBox->Resize(150, 20);
    frame_filter->AddFrame(fFilterMonthBox, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // year selector
    fFilterYearBox = new TGComboBox(frame_filter);
    fFilterYearBox -> AddEntry("Select Year", 1);
    for (unsigned i = FIRST_YEAR; i <= LAST_YEAR; i++) {
        fFilterYearBox->AddEntry(toStr(i), i+2-FIRST_YEAR);
    }
    fFilterYearBox->Resize(100, 20);
    fFilterYearBox->Select(1);
    frame_filter->AddFrame(fFilterYearBox, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // withdrawn/not withdrawn selector
    fFilterWithdrawnBox = new TGComboBox(frame_filter);
    fFilterWithdrawnBox -> AddEntry("Select Withdrawn", 1);
    fFilterWithdrawnBox->AddEntry("Withdrawn", 2);
    fFilterWithdrawnBox->AddEntry("Not Withdrawn", 3);
    fFilterWithdrawnBox->Resize(100, 20);
    fFilterWithdrawnBox->Select(1);
    frame_filter->AddFrame(fFilterWithdrawnBox, new TGLayoutHints(kLHintsLeft,5,10,5,5));

    // description filtering - text field
    fFilterDescriptionEntry = new TGTextEntry(frame_filter, "");
    fFilterDescriptionEntry -> SetToolTipText("Filter Description");
    fFilterDescriptionEntry -> Resize(200, fFilterDescriptionEntry->GetDefaultHeight());
    frame_filter -> AddFrame(fFilterDescriptionEntry, new TGLayoutHints(kLHintsLeft, 5,5,5,5));

    TGHorizontalFrame *hframe2 = new TGHorizontalFrame(frame_filter, 500, 40);
    frame_filter -> AddFrame(hframe2,new TGLayoutHints(kLHintsLeft,5,5,3,4));

    TGTextButton * filter_button = new TGTextButton(hframe2,"&Filter");
    filter_button -> Connect("Clicked()", "TExpenser", this, "filter_expense_table()");
    filter_button -> SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    hframe2 -> AddFrame(filter_button, new TGLayoutHints(kLHintsLeft,5,5,3,4));

    TGTextButton * undo_filter_button = new TGTextButton(hframe2,"&Undo Filters");
    undo_filter_button -> Connect("Clicked()", "TExpenser", this, "undo_filters_expense_table()");
    undo_filter_button -> SetFont("-*-times-bold-r-*-*-28-*-*-*-*-*-*-*");
    hframe2 -> AddFrame(undo_filter_button, new TGLayoutHints(kLHintsLeft,15,5,3,4));
}
Exemple #5
0
//______________________________________________________________________________
Bool_t ArgusWindow::Start()
{
   // Start Argus Window
   fWatchAll.Start(false);
   ROMEPrint::Debug("ArgusWindow::Start()\n");

   // Create status bar
   Int_t parts[2] = {70, 30};
   fStatusBar = new TGStatusBar(this, 50, 10, kHorizontalFrame);
   fStatusBar->SetParts(parts, sizeof(parts) / sizeof(Int_t));
   fProgress = new TGHProgressBar(fStatusBar->GetBarPart(1), TGProgressBar::kStandard, 20);
   fProgress->SetPosition(0);
   fStatusBar->GetBarPart(1)->AddFrame(fProgress, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 10, 10));
   if (fStatusBarSwitch) {
      this->AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 0, 0, 2, 0));
   }

   // Create horizontal frame which holds menu bar
   TGHorizontalFrame *hMenuFrame = new TGHorizontalFrame(this, 0, 0);
   AddFrame(hMenuFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
   {
      // Create menubar
      fMenuBar = new TGMenuBar(hMenuFrame, 1, 1, kHorizontalFrame);
      hMenuFrame->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
      {
         // Create popup menu
         fMenuFile = new TGPopupMenu(fClient->GetRoot());
         fMenuFile->Associate(this);
         fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));

         if (fTabWindow) {
            fMenuFile->AddEntry("New Window", M_FILE_NEW_WINDOW);
            if (gROME->GetNumberOfNetFolders()>0) {
               TGPopupMenu *fMenuNetFolder = new TGPopupMenu(fClient->GetRoot());
               if (AddMenuNetFolder(fMenuNetFolder)) {
                  fMenuFile->AddPopup("&Connect NetFolder", fMenuNetFolder);
                  fMenuNetFolder->Associate(this);
               }
            }
//            fMenuFile->AddEntry("Start C&ontroller", M_FILE_CONTROLLER);
            fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
         } else {
            fMenuFile->AddEntry("C&lose", M_FILE_EXIT);
         }
      }
   }

   {
      // separator
      TGHorizontal3DLine *hline = new TGHorizontal3DLine(this);
      AddFrame(hline, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX));
   }

   // Horizontal frame which holds the main canvas
   TGHorizontalFrame *hFrame = new TGHorizontalFrame(this);
   AddFrame(hFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY));

   // Vertical frame which holds the info frame and listtree
   TGVerticalFrame *vFrame = new TGVerticalFrame(hFrame);
   hFrame->AddFrame(vFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 1));
   {

      // now analyzer controller is dockable
      if (fTabWindow && !gROME->IsStandAloneARGUS()) {
         fController = new ArgusAnalyzerController(vFrame, -1, fControllerNetFolder);
         fController->Associate(this);
         vFrame->AddFrame(fController, new TGLayoutHints (kLHintsTop | kLHintsLeft));
      }

      if (!gROME->IsStandAloneARGUS()) {
         // run#
         TGHorizontalFrame *runFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(runFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fRunLabel   = new TGLabel(runFrame, "Run : ");
         fRunLabel->SetTextJustify(kTextLeft | kTextCenterY);
         runFrame->AddFrame(fRunLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fRunNumber   = new TGLabel(runFrame, "0");
         fRunNumber->SetTextJustify(kTextRight | kTextCenterY);
         runFrame->AddFrame(fRunNumber, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));

         // evnet#
         TGHorizontalFrame *eventFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(eventFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fEventLabel   = new TGLabel(eventFrame, "Event : ");
         fEventLabel->SetTextJustify(kTextLeft | kTextCenterY);
         eventFrame->AddFrame(fEventLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fEventNumber   = new TGLabel(eventFrame, "0");
         fEventNumber->SetTextJustify(kTextLeft | kTextCenterY);
         eventFrame->AddFrame(fEventNumber, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));

         // Year/Mon/Day
         TGHorizontalFrame *YearMonDayFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(YearMonDayFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fYearMonDayLabel = new TGLabel(YearMonDayFrame, "Date : ");
         fYearMonDayLabel->SetTextJustify(kTextLeft | kTextCenterY);
         YearMonDayFrame->AddFrame(fYearMonDayLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fYearMonDay = new TGLabel(YearMonDayFrame, "1970-Jan-01");
         fYearMonDay->SetTextJustify(kTextLeft | kTextCenterY);
         YearMonDayFrame->AddFrame(fYearMonDay, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));

         // Hour/Min/Sec
         TGHorizontalFrame *HourMinSecFrame = new TGHorizontalFrame(vFrame);
         vFrame->AddFrame(HourMinSecFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 15, 10, 2, 2));

         TGLabel *fHourMinSecLabel = new TGLabel(HourMinSecFrame, "Time : ");
         fHourMinSecLabel->SetTextJustify(kTextLeft | kTextCenterY);
         HourMinSecFrame->AddFrame(fHourMinSecLabel, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));

         fHourMinSec = new TGLabel(HourMinSecFrame, "00:00:00");
         fHourMinSec->SetTextJustify(kTextLeft | kTextCenterY);
         HourMinSecFrame->AddFrame(fHourMinSec, new TGLayoutHints(kLHintsRight, 5, 0, 0, 0));
      }

      // Vertical frame which holds users info frame
      fUserInfoFrame = new TGVerticalFrame(vFrame);
      vFrame->AddFrame(fUserInfoFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0));

//         fControllerDock = new TGDockableFrame(vFrame, 0, kVerticalFrame);
//         vFrame->AddFrame(fControllerDock, new TGLayoutHints(kLHintsTop | kLHintsLeft));
//         fControllerDock->EnableUndock(kTRUE);
//         fControllerDock->EnableHide(kTRUE);
//         fControllerDock->Associate(this);

      if (fListTreeView && fTabWindow) {
         // Create ListTree
         TGCanvas *canvas = new TGCanvas(vFrame, 120, 400);
         vFrame->AddFrame(canvas, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY));
         fListTree = new TGListTree(canvas, kHorizontalFrame);
         fListTree->Connect("Clicked(TGListTreeItem*,Int_t)", "ArgusWindow", this, "OnClick(TGListTreeItem*,Int_t)");
         fListTree->Connect("DoubleClicked(TGListTreeItem*,Int_t)", "ArgusWindow", this, "OnDoubleClick(TGListTreeItem*,Int_t)");
         fListTree->Associate(this);
      }

      // Create the main frame
      const UInt_t width  = static_cast<UInt_t>(640 * GetWindowScale());
      const UInt_t height = static_cast<UInt_t>(480 * GetWindowScale());
      if (!fListTreeView && fTabWindow) {
         fTab = new TGTab(hFrame, width, height);
         fTab->Associate(this);
         hFrame->AddFrame(fTab, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
      } else {
         fMainFrame = new ROMECompositeFrame(hFrame, width, height);
         hFrame->AddFrame(fMainFrame, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY));
      }
   }

   ROMEPrint::Debug("Creating Tabs\n");
   CheckActiveFlags();
   if (!CreateTabs()) {
      fWatchAll.Stop();
      return kFALSE;
   }
   ROMEPrint::Debug("Tabs Created\n");

   MapSubwindows();

   TGDimension size = GetDefaultSize();

   ArgusTab   *tab;
   Int_t       lastTabIndex = -1;
   Int_t       iTab;
   const Int_t nTabs = fTabObjects->GetEntriesFast();
   if (fListTreeView) {
      ArgusTab   *lastTab = 0;
      TGDimension framesize(0,0);

      // first, hide all the tabs
      for (iTab = 0; iTab < nTabs; iTab++) {
         tab = GetTabObjectAt(iTab);
         fMainFrame->HideFrame(tab);
      }

      // show all the tabs one by one to get the maximum window size
      size = GetDefaultSize();
      for (iTab = nTabs-1; iTab >=0; iTab--) {
         tab = GetTabObjectAt(iTab);
         if (tab->IsSwitch() && fNumberOfChildren[iTab]<=0) {
            fMainFrame->HideFrame(lastTab);
            fMainFrame->ShowFrame(tab);

            framesize = GetDefaultSize();
            if (size.fWidth < framesize.fWidth) {
               size.fWidth = framesize.fWidth;
            }
            if (size.fHeight < framesize.fHeight) {
               size.fHeight = framesize.fHeight;
            }

            if (fTabWindow) { // we don't have listtrees for sub-windows
               fListTree->HighlightItem(fListTreeItem[iTab]);
            }
            lastTab = tab;
            lastTabIndex = iTab;
         }
      }
   } else {
      for (iTab = nTabs-1; iTab >=0; iTab--) {
         tab = GetTabObjectAt(iTab);
         if (tab->IsSwitch() && fNumberOfChildren[iTab]<=0) {
            fCurrentTabID = tab->GetID();
            lastTabIndex = iTab;
         }
      }
   }

   Resize(size);
   fInitialWidth  = size.fWidth;
   fInitialHeight = size.fHeight;

   // Adjust size of the sub window so that the main frame has the
   // same size as the parent's. This is not done if the parent window
   // is tab-view, because the size of the main frame is not trivial.
   if (!fTabWindow) {
      if (gROME->GetWindow()->IsListTreeView()) {
         TGDimension size1 = gROME->GetWindow()->GetInitialSize();
         TGDimension size3 = gROME->GetWindow()->GetUserInfoFrame()->GetSize();
         TGDimension size4 = GetUserInfoFrame()->GetSize();

         // Height shall be the same as the parent, but width might be
         // different because of different width of info frame.
         Resize(size1.fWidth - size3.fWidth + size4.fWidth, size1.fHeight);
      }
   }

   gSystem->Sleep(500);
   MapWindow();

   while (!IsMapped()) {
      gSystem->Sleep(20);
   }

   if (!gROME->IsStandAloneARGUS()) {
      // hide run# and event# if argus controller is shown/docked
      if (fController && (!fController->IsHidden() || !fController->IsUndocked())) {
         ((TGCompositeFrame*)(fRunNumber->GetParent()->GetParent()))->HideFrame((TGFrame*)(fRunNumber->GetParent()));
         ((TGCompositeFrame*)(fEventNumber->GetParent()->GetParent()))->HideFrame((TGFrame*)(fEventNumber->GetParent()));
      }
   }

   TriggerTabSelected(lastTabIndex);

   gSystem->Sleep(500);

   ROMEPrint::Debug("End of ArgusWindow::Start()\n");
   fWatchAll.Stop();
   return kTRUE;
}
Exemple #6
0
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
  TGMainFrame(p, w, h)
{
   // Create horizontal splitter
   TGVerticalFrame *fVf = new TGVerticalFrame(this, 10, 10);

   TGHorizontalFrame *fH1 = new TGHorizontalFrame(fVf, 10, 50, kFixedHeight);
   TGHorizontalFrame *fH2 = new TGHorizontalFrame(fVf, 10, 10);
   TGCompositeFrame *fFtop = new TGCompositeFrame(fH1, 10, 10, kSunkenFrame);
   TGCompositeFrame *fFbottom = new TGCompositeFrame(fH2, 10, 10, kSunkenFrame);

   TGLabel *fLtop = new TGLabel(fFtop, "Top Frame");
   TGLabel *fLbottom = new TGLabel(fFbottom, "Bottom Frame");

   fFtop->AddFrame(fLtop, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                            3, 0, 0, 0));
   fFbottom->AddFrame(fLbottom, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                                  3, 0, 0, 0));

   fH1->AddFrame(fFtop, new TGLayoutHints(kLHintsTop | kLHintsExpandY | 
                                          kLHintsExpandX, 0, 0, 1, 2));
   fH2->AddFrame(fFbottom, new TGLayoutHints(kLHintsTop | kLHintsExpandY | 
                                             kLHintsExpandX, 0, 0, 1, 2));

   fH1->Resize(fFtop->GetDefaultWidth(), fH1->GetDefaultHeight()+20);
   fH2->Resize(fFbottom->GetDefaultWidth(), fH2->GetDefaultHeight()+20);
   fVf->AddFrame(fH1, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   TGHSplitter *hsplitter = new TGHSplitter(fVf,2,2);
   hsplitter->SetFrame(fH1, kTRUE);
   fVf->AddFrame(hsplitter, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   fVf->AddFrame(fH2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));   
   
   // button frame
   TGVerticalFrame *hframe = new TGVerticalFrame(this, 10, 10);
   TGCompositeFrame *cframe2 = new TGCompositeFrame(hframe, 170, 50, 
                                             kHorizontalFrame | kFixedWidth);
   TGTextButton *save = new TGTextButton(cframe2, "&Save");
   cframe2->AddFrame(save, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             3, 2, 2, 2));
   save->Connect("Clicked()", "MyMainFrame", this, "DoSave()");
   save->SetToolTipText("Click on the button to save the application as C++ macro");
   
   TGTextButton *exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");
   cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             2, 0, 2, 2));
   hframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
   
   AddFrame(fVf, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY));
   AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
   
   // What to clean up in dtor
   SetCleanup(kDeepCleanup);
     
   // Set a name to the main frame   
   SetWindowName("Horizontal Splitter");
   SetWMSizeHints(300, 250, 600, 600, 0, 0);
   MapSubwindows();
   Resize(GetDefaultSize());
   MapWindow();
}