Editor Class Reference

Collaboration diagram for Editor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Editor (const TGWindow *main, UInt_t w, UInt_t h)
virtual ~Editor ()
void LoadFile (const char *file)
void LoadBuffer (const char *buffer)
void AddBuffer (const char *buffer)
TGTextEdit * GetEditor () const
void SetTitle ()
void Popup ()
void CloseWindow ()
void DoOK ()
void DoOpen ()
void DoSave ()
void DoClose ()

Private Attributes

TGTransientFrame * fMain
TGTextEdit * fEdit
TGTextButton * fOK
TGLayoutHints * fL1
TGLayoutHints * fL2

Detailed Description

Definition at line 488 of file guitest.C.


Constructor & Destructor Documentation

Editor::Editor ( const TGWindow *  main,
UInt_t  w,
UInt_t  h 
)

Definition at line 2438 of file guitest.C.

02439 {
02440    // Create an editor in a dialog.
02441 
02442    fMain = new TGTransientFrame(gClient->GetRoot(), main, w, h);
02443    fMain->Connect("CloseWindow()", "Editor", this, "CloseWindow()");
02444    fMain->DontCallClose(); // to avoid double deletions.
02445 
02446    // use hierarchical cleaning
02447    fMain->SetCleanup(kDeepCleanup);
02448 
02449    fEdit = new TGTextEdit(fMain, w, h, kSunkenFrame | kDoubleBorder);
02450    fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
02451    fMain->AddFrame(fEdit, fL1);
02452    fEdit->Connect("Opened()", "Editor", this, "DoOpen()");
02453    fEdit->Connect("Saved()",  "Editor", this, "DoSave()");
02454    fEdit->Connect("Closed()", "Editor", this, "DoClose()");
02455 
02456    // set selected text colors
02457    Pixel_t pxl;
02458    gClient->GetColorByName("#3399ff", pxl);
02459    fEdit->SetSelectBack(pxl);
02460    fEdit->SetSelectFore(TGFrame::GetWhitePixel());
02461 
02462    fOK = new TGTextButton(fMain, "  &OK  ");
02463    fOK->Connect("Clicked()", "Editor", this, "DoOK()");
02464    fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
02465    fMain->AddFrame(fOK, fL2);
02466 
02467    SetTitle();
02468 
02469    fMain->MapSubwindows();
02470 
02471    fMain->Resize();
02472 
02473    // editor covers right half of parent window
02474    fMain->CenterOnParent(kTRUE, TGTransientFrame::kRight);
02475 }

Editor::~Editor (  )  [virtual]

Definition at line 2477 of file guitest.C.

02478 {
02479    // Delete editor dialog.
02480 
02481    fMain->DeleteWindow();  // deletes fMain
02482 }


Member Function Documentation

void Editor::LoadFile ( const char *  file  ) 

Definition at line 2515 of file guitest.C.

02516 {
02517    // Load a file in the editor.
02518 
02519    fEdit->LoadFile(file);
02520 }

void Editor::LoadBuffer ( const char *  buffer  ) 

Definition at line 2508 of file guitest.C.

Referenced by TestMainFrame::DoButton().

02509 {
02510    // Load a text buffer in the editor.
02511 
02512    fEdit->LoadBuffer(buffer);
02513 }

void Editor::AddBuffer ( const char *  buffer  ) 

Definition at line 2522 of file guitest.C.

Referenced by TestMainFrame::DoButton().

02523 {
02524    // Add text to the editor.
02525 
02526    TGText txt;
02527    txt.LoadBuffer(buffer);
02528    fEdit->AddText(&txt);
02529 }

TGTextEdit* Editor::GetEditor (  )  const [inline]

Definition at line 505 of file guitest.C.

Referenced by SetTitle().

00505 { return fEdit; }

void Editor::SetTitle (  ) 

Definition at line 2484 of file guitest.C.

Referenced by DoOpen(), DoSave(), and Editor().

02485 {
02486    // Set title in editor window.
02487 
02488    TGText *txt = GetEditor()->GetText();
02489    Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
02490 
02491    char title[256];
02492    if (untitled)
02493       sprintf(title, "ROOT Editor - Untitled");
02494    else
02495       sprintf(title, "ROOT Editor - %s", txt->GetFileName());
02496 
02497    fMain->SetWindowName(title);
02498    fMain->SetIconName(title);
02499 }

void Editor::Popup (  ) 

Definition at line 2501 of file guitest.C.

Referenced by TestMainFrame::DoButton().

02502 {
02503    // Show editor.
02504 
02505    fMain->MapWindow();
02506 }

void Editor::CloseWindow (  ) 

Definition at line 2531 of file guitest.C.

Referenced by DoClose(), and DoOK().

02532 {
02533    // Called when closed via window manager action.
02534 
02535    delete this;
02536 }

void Editor::DoOK (  ) 

Definition at line 2538 of file guitest.C.

02539 {
02540    // Handle ok button.
02541 
02542    CloseWindow();
02543 }

void Editor::DoOpen (  ) 

Definition at line 2545 of file guitest.C.

02546 {
02547    SetTitle();
02548 }

void Editor::DoSave (  ) 

Definition at line 2550 of file guitest.C.

02551 {
02552    SetTitle();
02553 }

void Editor::DoClose (  ) 

Definition at line 2555 of file guitest.C.

02556 {
02557    // Handle close button.
02558 
02559    CloseWindow();
02560 }


Member Data Documentation

TGTransientFrame* Editor::fMain [private]

Definition at line 491 of file guitest.C.

Referenced by Editor(), Popup(), SetTitle(), and ~Editor().

TGTextEdit* Editor::fEdit [private]

Definition at line 492 of file guitest.C.

Referenced by AddBuffer(), Editor(), GetEditor(), LoadBuffer(), and LoadFile().

TGTextButton* Editor::fOK [private]

Definition at line 493 of file guitest.C.

Referenced by Editor().

TGLayoutHints* Editor::fL1 [private]

Definition at line 494 of file guitest.C.

Referenced by Editor().

TGLayoutHints* Editor::fL2 [private]

Definition at line 495 of file guitest.C.

Referenced by Editor().


The documentation for this class was generated from the following file:
Generated on Mon Jan 7 13:18:16 2013 for MicromegasFramework by  doxygen 1.4.7