MIDAS
Loading...
Searching...
No Matches
TGTextDialog Class Reference
Inheritance diagram for TGTextDialog:
Collaboration diagram for TGTextDialog:

Public Member Functions

 TGTextDialog (const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, char *label, char *ret_str, UInt_t options=kVerticalFrame)
 
virtual ~TGTextDialog ()
 
virtual void CloseWindow ()
 
virtual Bool_t ProcessMessage (Long_t msg, Long_t parm1, Long_t parm2)
 

Protected Attributes

TGCompositeFramefF1
 
TGCompositeFramefF2
 
TGButtonfOkButton
 
TGButtonfCancelButton
 
TGLayoutHintsfL1
 
TGLayoutHintsfL5
 
TGLayoutHintsfL6
 
TGLayoutHintsfL21
 
TGTextEntryfText
 
TGTextBufferfBLabel
 
TGLabelfLabel
 
charfRetStr
 

Detailed Description

Definition at line 37 of file rmidas.c.

Constructor & Destructor Documentation

◆ TGTextDialog()

TGTextDialog::TGTextDialog ( const TGWindow p,
const TGWindow main,
UInt_t  w,
UInt_t  h,
char label,
char ret_str,
UInt_t  options = kVerticalFrame 
)

Definition at line 64 of file rmidas.c.

66 :TGTransientFrame(p, main, w, h, options)
67{
68/* Create a dialog to enter a single line text entry */
69
71
73
74 fF1 = new TGCompositeFrame(this, 60, 20, kVerticalFrame | kFixedWidth);
75 fF2 = new TGCompositeFrame(this, 60, 20, kHorizontalFrame);
76
77 fOkButton = new TGTextButton(fF1, new TGHotString("&Ok"), 1);
78 fCancelButton = new TGTextButton(fF1, new TGHotString("&Cancel"), 2);
79 fF1->Resize(fOkButton->GetDefaultWidth() + 40, GetDefaultHeight());
80
81 fOkButton->Associate(this);
82 fCancelButton->Associate(this);
83
84 fL1 = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0);
85 fL21 = new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 5, 10, 0);
86
87 fF1->AddFrame(fOkButton, fL1);
88 fF1->AddFrame(fCancelButton, fL1);
90
91 fLabel = new TGLabel(fF2, new TGHotString(label));
92
93 fBLabel = new TGTextBuffer(50);
94 if (fRetStr[0])
95 fBLabel->AddText(0, fRetStr);
96 else
97 fOkButton->SetState(kButtonDisabled);
98
100 fText->Associate(this);
101 fText->Resize(220, fText->GetDefaultHeight());
102 fText->SelectAll();
103
104 fL5 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 5, 0, 0);
105 fL6 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 2, 0, 0);
106
107 fF2->AddFrame(fLabel, fL5);
108 fF2->AddFrame(fText, fL5);
109 AddFrame(fF2, fL1);
110
113
114 // position relative to the parent's window
115 Int_t ax, ay;
116 if (main) {
118 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
119 (Int_t) (((TGFrame *) main)->GetWidth() -
120 fWidth) >> 1,
121 (Int_t) (((TGFrame *) main)->GetHeight() -
122 fHeight) >> 1, ax, ay, wdum);
123 } else {
125 gVirtualX->GetWindowSize(fClient->GetRoot()->GetId(), ax, ay, root_w, root_h);
126 ax = (root_w - fWidth) >> 1;
127 ay = (root_h - fHeight) >> 1;
128 }
129
130 Move(ax, ay);
132
133 SetWindowName("Enter Text");
134
137
138 MapWindow();
139 fClient->WaitFor(this);
140}
TGButton * fCancelButton
Definition rmidas.c:42
TGCompositeFrame * fF2
Definition rmidas.c:40
TGCompositeFrame * fF1
Definition rmidas.c:40
TGLayoutHints * fL6
Definition rmidas.c:43
TGLabel * fLabel
Definition rmidas.c:46
TGLayoutHints * fL21
Definition rmidas.c:43
TGTextBuffer * fBLabel
Definition rmidas.c:45
TGLayoutHints * fL1
Definition rmidas.c:43
char * fRetStr
Definition rmidas.c:47
TGLayoutHints * fL5
Definition rmidas.c:43
TGButton * fOkButton
Definition rmidas.c:41
TGTextEntry * fText
Definition rmidas.c:44
int main()
Definition hwtest.cxx:23
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~TGTextDialog()

TGTextDialog::~TGTextDialog ( )
virtual

Definition at line 144 of file rmidas.c.

145{
146 // Clean up text dialog
147
148 delete fCancelButton;
149 delete fOkButton;
150 delete fText;
151 delete fLabel;
152 delete fF1;
153 delete fF2;
154 delete fL1;
155 delete fL5;
156 delete fL6;
157 delete fL21;
158}

Member Function Documentation

◆ CloseWindow()

void TGTextDialog::CloseWindow ( )
virtual

Definition at line 162 of file rmidas.c.

163{
164 // Close the dialog. On close the dialog will be deleted and cannot be
165 // re-used.
166
167 DeleteWindow();
168}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMessage()

Bool_t TGTextDialog::ProcessMessage ( Long_t  msg,
Long_t  parm1,
Long_t  parm2 
)
virtual

Definition at line 170 of file rmidas.c.

171{
172 const char *string;
173
174 switch (GET_MSG(msg)) {
175 case kC_COMMAND:
176 switch (GET_SUBMSG(msg)) {
177 case kCM_BUTTON:
178 switch (parm1) {
179 case 1:
180 if (fRetStr)
181 strcpy(fRetStr, fBLabel->GetString());
182 CloseWindow();
183 break;
184 case 2:
185 fRetStr[0] = 0;
186 CloseWindow();
187 break;
188 }
189 break;
190
191 default:
192 break;
193 }
194 break;
195
196 case kC_TEXTENTRY:
197 switch (GET_SUBMSG(msg)) {
198 case kTE_TEXTCHANGED:
199 string = fBLabel->GetString();
200 if (strlen(string) == 0)
201 fOkButton->SetState(kButtonDisabled);
202 else
203 fOkButton->SetState(kButtonUp);
204 break;
205 case kTE_ENTER:
206 if (fRetStr)
207 strcpy(fRetStr, fBLabel->GetString());
208 CloseWindow();
209 break;
210 default:
211 break;
212 }
213 break;
214
215 default:
216 break;
217 }
218
219 return kTRUE;
220}
virtual void CloseWindow()
Definition rmidas.c:162
Here is the call graph for this function:

Member Data Documentation

◆ fBLabel

TGTextBuffer* TGTextDialog::fBLabel
protected

Definition at line 45 of file rmidas.c.

◆ fCancelButton

TGButton* TGTextDialog::fCancelButton
protected

Definition at line 42 of file rmidas.c.

◆ fF1

TGCompositeFrame* TGTextDialog::fF1
protected

Definition at line 40 of file rmidas.c.

◆ fF2

TGCompositeFrame * TGTextDialog::fF2
protected

Definition at line 40 of file rmidas.c.

◆ fL1

TGLayoutHints* TGTextDialog::fL1
protected

Definition at line 43 of file rmidas.c.

◆ fL21

TGLayoutHints * TGTextDialog::fL21
protected

Definition at line 43 of file rmidas.c.

◆ fL5

TGLayoutHints * TGTextDialog::fL5
protected

Definition at line 43 of file rmidas.c.

◆ fL6

TGLayoutHints * TGTextDialog::fL6
protected

Definition at line 43 of file rmidas.c.

◆ fLabel

TGLabel* TGTextDialog::fLabel
protected

Definition at line 46 of file rmidas.c.

◆ fOkButton

TGButton* TGTextDialog::fOkButton
protected

Definition at line 41 of file rmidas.c.

◆ fRetStr

char* TGTextDialog::fRetStr
protected

Definition at line 47 of file rmidas.c.

◆ fText

TGTextEntry* TGTextDialog::fText
protected

Definition at line 44 of file rmidas.c.


The documentation for this class was generated from the following file: