Hi Bill,
try this small app. Save as canvas.cxx and compile using:
g++ `root-config --cflags --glibs` -o canvas canvas.cxx
//-------------------------------------------------------------
#include <TApplication.h>
#include <TGButton.h>
#include <TRootEmbeddedCanvas.h>
int main()
{
// Create application environment
TApplication app("test", 0, 0);
// Create main frame
TGMainFrame mf(gClient->GetRoot(), 100, 100);
// Create embedded canvas and add to main frame, centered in x and y and
// with 30 pixel margins all around
TRootEmbeddedCanvas *c = new TRootEmbeddedCanvas("Canvas", &mf, 600, 400);
mf.AddFrame(c, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
30, 30, 30, 30));
// Create button and add to main frame, centered in x and with 30
// pixel margin at bottom, when button is clicked terminate program
TGButton *b = new TGTextButton(&mf, "Quit");
b->SetCommand("gApplication->Terminate()");
mf.AddFrame(b,new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 30));
// Set main frame name, map sub windows (button), initialize layout
// algorithm via Resize() and map main frame
mf.SetWindowName("Test");
mf.MapSubwindows();
mf.Resize(mf.GetDefaultSize());
mf.MapWindow();
// enter application event loop
app.Run();
return 0;
}
//--------------------------------------------------
Cheers, Fons.
On Friday 04 January 2002 18:31, William Hanlon wrote:
> Hi,
>
> Thanks for your suggestions, but perhaps I should been more
> specific. When I said using the ROOT gui classes I meant the TG*
> classes (e.g. TGMainFrame, TGCanvas, etc) in a standalone program. I
> have been using $ROOTSYS/test/guitest.cxx and $ROOTSYS/guiviewer.cxx
> mainly as examples to follow. Both are good, but have many buttons and
> other widgets stuck in them. I would like to start with the most basic
> program that just has a drawable canvas (no other widgets) to get my
> feet wet. After that I think I could piece together how to add more
> widgets using the examples listed above.
>
> Thanks,
> Bill
--
Org: CERN, European Laboratory for Particle Physics.
Mail: 1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7679480
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET