test-Remove.cxx File Reference

#include <Midad/Gui/GuiMainWindow.h>
#include <Midad/Gui/GuiBox.h>
#include <Midad/Gui/GuiLabel.h>
#include <Midad/Gui/GuiTextEntry.h>
#include <Midad/Gui/GuiTable.h>
#include <Midad/Gui/GuiButton.h>
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <TROOT.h>
#include <TApplication.h>
#include <sigc++/signal.h>
#include <sigc++/bind.h>
#include <sigc++/object_slot.h>

Go to the source code of this file.

Functions

void remove_it (GuiBox *box, GuiTextEntry *gte, GuiTextButton *but[])
void show_it (GuiBox *box, GuiTextEntry *gte, GuiTextButton *but[])
void hide_it (GuiBox *box, GuiTextEntry *gte, GuiTextButton *but[])
void add_it (GuiBox *box, GuiTextEntry *gte, GuiTextButton *but[])
int main (int argc, char *argv[])

Variables

static const char * numbers []

Function Documentation

void add_it ( GuiBox box,
GuiTextEntry gte,
GuiTextButton but[] 
)

Definition at line 66 of file test-Remove.cxx.

References GuiCompositeFrameBase::Add(), GuiBase::GetMainWindow(), numbers, and GuiCompositeFrameBase::Show().

Referenced by main().

00067 {
00068     int i = atoi(gte->GetText());
00069     if (i < 0 || i > 9) {
00070         cerr << "Number " << i << " not in [0-9]\n";
00071         return;
00072     }
00073 
00074     if (but[i]) {
00075         cerr << "Button " << numbers[i] << " already exists\n";
00076         return;
00077     }
00078 
00079     cerr << "Adding " << numbers[i] << endl;
00080 
00081     but[i] = manage(new GuiTextButton(*box,numbers[i]));
00082     box->Add(*but[i]);
00083     box->Show(*but[i]);
00084     box->GetMainWindow()->Layout();
00085 }

void hide_it ( GuiBox box,
GuiTextEntry gte,
GuiTextButton but[] 
)

Definition at line 56 of file test-Remove.cxx.

References GuiBase::GetMainWindow(), and GuiCompositeFrameBase::Hide().

Referenced by main().

00057 {
00058     int i = atoi(gte->GetText());
00059 
00060     if (!but[i]) return;
00061     cerr << "Hiding " << i << endl;
00062 
00063     box->Hide(*but[i]);
00064     box->GetMainWindow()->Layout();
00065 }

int main ( int  argc,
char *  argv[] 
)

Definition at line 87 of file test-Remove.cxx.

References GuiTextEntry::activated, GuiCompositeFrameBase::Add(), add_it(), GuiMainWindow::ConnectClose(), hide_it(), numbers, remove_it(), show_it(), and GuiMainWindow::ShowAll().

00088 {
00089     TApplication theApp("App", &argc, argv);
00090 
00091     GuiMainWindow* mw = manage(new GuiMainWindow(100,100));
00092 
00093     GuiBox* box = manage(new GuiBox(*mw, kVerticalFrame));
00094     mw->Add(*box);
00095 
00096     GuiTextButton* buts[10];
00097     GuiTextEntry* gte;
00098     GuiLabel* lab;
00099 
00100     lab = manage(new GuiLabel(*box,"Number to remove"));
00101     box->Add(*lab);
00102     gte = manage(new GuiTextEntry(*box));
00103     box->Add(*gte);
00104     gte->activated.connect(bind(bind(bind(slot(remove_it),buts),gte),box));
00105 
00106 
00107     lab = manage(new GuiLabel(*box,"Number to hide"));
00108     box->Add(*lab);
00109     gte = manage(new GuiTextEntry(*box));
00110     box->Add(*gte);
00111     gte->activated.connect(bind(bind(bind(slot(hide_it),buts),gte),box));
00112 
00113     lab = manage(new GuiLabel(*box,"Number to show"));
00114     box->Add(*lab);
00115     gte = manage(new GuiTextEntry(*box));
00116     box->Add(*gte);
00117     gte->activated.connect(bind(bind(bind(slot(show_it),buts),gte),box));
00118 
00119     lab = manage(new GuiLabel(*box,"Number to add (0-9)"));
00120     box->Add(*lab);
00121     gte = manage(new GuiTextEntry(*box));
00122     box->Add(*gte);
00123     gte->activated.connect(bind(bind(bind(slot(add_it),buts),gte),box));
00124 
00125 
00126     for (int i=0; numbers[i]; ++i) {
00127         buts[i] = manage(new GuiTextButton(*box,numbers[i]));
00128         box->Add(*buts[i]);
00129     }
00130 
00131 
00132 
00133     mw->ShowAll();
00134     mw->ConnectClose(true);
00135     mw->Resize(mw->GetDefaultWidth(),mw->GetDefaultHeight());
00136 
00137     theApp.Run();
00138 
00139     return 0;
00140 } // end of main()

void remove_it ( GuiBox box,
GuiTextEntry gte,
GuiTextButton but[] 
)

Definition at line 34 of file test-Remove.cxx.

References GuiBase::GetMainWindow(), and GuiCompositeFrameBase::Remove().

Referenced by main().

00035 {
00036     int i = atoi(gte->GetText());
00037 
00038     if (!but[i]) return;
00039 
00040     cerr << "Removing " << i << endl;
00041 
00042     box->Remove(*but[i]);
00043     but[i] = 0;
00044     box->GetMainWindow()->Layout();
00045 }

void show_it ( GuiBox box,
GuiTextEntry gte,
GuiTextButton but[] 
)

Definition at line 46 of file test-Remove.cxx.

References GuiBase::GetMainWindow(), and GuiCompositeFrameBase::Show().

Referenced by main().

00047 {
00048     int i = atoi(gte->GetText());
00049 
00050     if (!but[i]) return;
00051     cerr << "Showing " << i << endl;
00052 
00053     box->Show(*but[i]);
00054     box->GetMainWindow()->Layout();
00055 }


Variable Documentation

const char* numbers[] [static]
Initial value:
 {
    "zero",
    "one",
    "two",
    "three",
    "four",
    "five",
    "six",
    "seven",
    "eight",
    "nine",
    0
}

Definition at line 20 of file test-Remove.cxx.

Referenced by add_it(), and main().


Generated on 8 Jul 2019 for loon by  doxygen 1.6.1