Logo ROOT   6.12/07
Reference Guide
TGFontDialog.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id: bcc7b53cab203466d39a6f17445d822d6fc19610 $
2 // Author: Bertrand Bellenot + Fons Rademakers + Valeriy Onuchin 23/04/03
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 /**************************************************************************
12 
13  This source is based on Xclass95, a Win95-looking GUI toolkit.
14  Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15 
16  Xclass95 is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Library General Public
18  License as published by the Free Software Foundation; either
19  version 2 of the License, or (at your option) any later version.
20 
21 **************************************************************************/
22 
23 #include "TGFontDialog.h"
24 #include "TString.h"
25 #include "TError.h"
26 #include "TGColorSelect.h"
27 #include "TGButton.h"
28 #include "TGLabel.h"
29 #include "TGListBox.h"
30 #include "TGComboBox.h"
31 #include <stdlib.h>
32 
33 
34 
36  kFDLG_OK = 1,
38 
43 
45 };
46 
47 static const char *gFDLG_DEFAULTSAMPLE = "AaBbCcYyZz 1234567890";
48 
49 
50 static const char *gFontSizes[] = {
51  "8", "9", "10", "11", "12", "13", "14", "16",
52  "18", "20", "22", "24", "26", "28", "30", "32",
53  "34", "36", "48", "72", 0
54 };
55 
56 static const char *gFontStyles[] = {
57  "Normal", "Bold", "Italic", "Bold Italic", 0
58 };
59 
61 
62 
63 static const char *gAlignTypes[] = {
64  "top left", "top center", "top right",
65  "middle left", "middle center", "middle right",
66  "bottom left", "bottom center", "bottom right",
67  0
68 };
69 
70 static const Int_t gAlignValues[] = {
80  0
81 };
82 
83 /*
84 static const char *gFontList[] = {
85  "Arial",
86  "Comic Sans MS",
87  "Courier New",
88  "Georgia",
89  "Impact",
90  "Monotype",
91  "Symbol",
92  "Times New Roman",
93  "Trebuchet MS",
94  "Verdana",
95  "Webdings",
96  "Wingdings",
97  0,
98 };
99 
100 static const char *gFontList2[] = {
101  "FreeSans",
102  "FreeSerif",
103  "FreeMono",
104  "OpenSymbol",
105  0
106 };
107 */
108 
109 //_____________________________________________________________________________
110 //
111 // TGFontDialog
112 //
113 // Font selection dialog, allowing to select one in the list of available fonts
114 // in the system.
115 //_____________________________________________________________________________
116 
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Create font dialog. When closed via OK button fontProp is set to
121 /// the newly selected font. If closed via Cancel button or WM close box
122 /// fontProp->fName == "".
123 
125  FontProp_t *fontProp, const TString &sample,
126  char **fontList, Bool_t wait) :
127  TGTransientFrame(p, t, 100, 100), fFontNames(0), fFontSizes(0), fFontStyles(0),
128  fTextAligns(0), fColorSelect(0), fFontProp(0), fItalic(0), fBold(0), fSize(0),
129  fTextAlign(0), fTextColor(0), fNumberOfFonts(0)
130 {
131  TGLabel *lbl;
132  TGHorizontalFrame *hf, *hf2;
133  TGVerticalFrame *vf;
134  Int_t i, w;
135  UInt_t width = 0, height = 0;
136 
137  fSampleTextGC = 0;
138  fLabelFont = 0;
139  fSample = 0;
140  fHitOK = kFALSE;
141  fWaitFor = wait;
142  fInitFont = 0;
143  fInitColor = 0;
144  fInitAlign = 0;
145 
146  if (!fontProp) {
147  Error("TGFontDialog", "fontProp argument may not be 0");
148  return;
149  }
151 
153  TGLayoutHints *lh2 = new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 0, 2, 2);
154 
155  fFontProp = fontProp;
156  if (fontProp->fName == "") {
157  fName = fontList ? fontList[0] : "Arial";
158  fItalic = kFALSE;
159  fBold = kFALSE;
160  fSize = 12;
161  fTextAlign = gAlignValues[6]; //kTextBottom | kTextLeft
163  } else {
164  fName = fontProp->fName;
165  fItalic = fontProp->fItalic;
166  fBold = fontProp->fBold;
167  fSize = fontProp->fSize;
168  fTextAlign = fontProp->fAlign;
169  fTextColor = fontProp->fColor;
170  }
171 
172  hf = new TGHorizontalFrame(this, 10, 10);
173  AddFrame(hf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
174 
175  //--------------------- font names listbox
176 
177  vf = new TGVerticalFrame(hf, 10, 10);
178 
179  lbl = new TGLabel(vf, new TGString("Font:"));
180  vf->AddFrame(lbl, lh2);
181 
184 
185  if (gVirtualX->InheritsFrom("TGX11") || gVirtualX->InheritsFrom("TGCocoa")) {
186  fFontNames->Connect("Selected(char*)", "TGFontDialog", this, "UpdateStyleSize(char*)");
187  }
188 
189  fFontNames->Associate(this);
191 
193  0, 10, 2, 2));
194 
195  //--------------------- font styles listbox
196 
197  vf = new TGVerticalFrame(hf, 10, 10);
198 
199  lbl = new TGLabel(vf, new TGString("Style:"));
200  vf->AddFrame(lbl, lh2);
201 
204  fFontStyles->Associate(this);
205  vf->AddFrame(fFontStyles, lh1);
206 
208  0, 10, 2, 2));
209 
210  //--------------------- font sizes listbox
211 
212  vf = new TGVerticalFrame(hf, 10, 10);
213 
214  lbl = new TGLabel(vf, new TGString("Size:"));
215  vf->AddFrame(lbl, lh2);
216 
219  fFontSizes->Associate(this);
220  vf->AddFrame(fFontSizes, lh1);
221 
223  0, 0, 2, 2));
224 
225  //--------------------- Text align and color
226 
227  vf = new TGVerticalFrame(hf, 10, 10);
228 
229  lbl = new TGLabel(vf, new TGString("Text Align :"));
230  vf->AddFrame(lbl, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
231 
233  fTextAligns->Associate(this);
235  kLHintsExpandX, 5, 5, 0, 5));
236 
237  fTextAligns->Resize(110, 20);
238 
239  vf->Layout();
240  vf->Resize(vf->GetDefaultSize());
241 
242  w = hf->GetDefaultWidth();
243 
244  hf2 = new TGHorizontalFrame(vf, 10, 10);
245  vf->AddFrame(hf2, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 5));
246 
247  lbl = new TGLabel(hf2, new TGString("Text Color"));
248  hf2->AddFrame(lbl, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5, 5, 20, 5));
249 
251  fColorSelect->Associate(this);
252 
254 
255  vf->Resize(vf->GetDefaultSize());
256 
258  10, 0, lbl->GetDefaultHeight()+6, 0));
259 
260  //--------------------- initialize controls
261 
263 
264  Int_t cnt = 0;
265  Bool_t own = kFALSE;
266 
267  if (!fontList) {
268  fontList = gVirtualX->ListFonts("-*-*-*-*", 10000, cnt);
269  own = kTRUE;
270  }
271 
272  Build(fontList, cnt);
273 
274  for (i = 0; gAlignTypes[i] != 0; ++i) {
276  }
277 
278  for (i = 0; gAlignValues[i] != 0; ++i) {
279  if (gAlignValues[i] == fTextAlign) {
280  fTextAligns->Select(i);
281  }
282  }
283 
284  TGLBEntry *entry = fTextAligns->FindEntry("bottom center");
285  if (entry)
286  fTextAligns->Resize(entry->GetWidth() + 20, entry->GetHeight() > 20 ?
287  entry->GetHeight() : 20);
288 
289  vf->Layout();
290  vf->Resize(vf->GetDefaultSize());
291 
292  //--------------------- sample box
293 
294  hf = new TGHorizontalFrame(this, 10, 10);
295  AddFrame(hf, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 5, 5, 5));
296 
297  TGGroupFrame *gf = new TGGroupFrame(hf, new TGString("Sample"));
298  hf->AddFrame(gf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3));
299 
300  TGCompositeFrame *cf = new TGCompositeFrame(gf, 200, 100, kSunkenFrame);
303  1, 1, 3, 1));
304 
305  if (sample == "")
307  else
308  fSampleText = sample;
309 
310  for (i = 0; gFontSizes[i] != 0; ++i) {
311  if (fSize == atoi(gFontSizes[i])) {
312  fFontSizes->Select(i);
313  break;
314  }
315  }
316 
317  if ((fBold == kFALSE) && (fItalic == kFALSE))
318  fFontStyles->Select(0);
319  if ((fBold == kTRUE) && (fItalic == kFALSE))
320  fFontStyles->Select(1);
321  if ((fBold == kFALSE) && (fItalic == kTRUE))
322  fFontStyles->Select(2);
323  if ((fBold == kTRUE) && (fItalic == kTRUE))
324  fFontStyles->Select(3);
325 
326  GetFontName(); //sets fLName and other data members
327 
328  GCValues_t gcval;
329  gcval.fMask = kGCForeground | kGCFont;
330  gcval.fForeground = fTextColor;
331  gcval.fFont = fLabelFont->GetFontHandle();
332  fSampleTextGC = fClient->GetGC(&gcval, kTRUE);
333  fSample = new TGLabel(cf, fSampleText); //, (*fSampleTextGC)(), (*fLabelFont)());
337  1, 1, 1, 1));
338  cf->Layout();
339  if (own) gVirtualX->FreeFontNames(fontList);
340 
341  gf->Resize(w, 80);
342 
343  //--------------------- OK and Cancel buttons
344 
345  vf = new TGVerticalFrame(hf, 10, 10, kFixedWidth);
346 
347  TGTextButton *ok = new TGTextButton(vf, new TGHotString("&OK"), kFDLG_OK);
348  ok->Associate(this);
349  vf->AddFrame(ok, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 20, 5));
350 
351  TGTextButton *cancel = new TGTextButton(vf, new TGHotString("&Cancel"), kFDLG_CANCEL);
352  cancel->Associate(this);
353  vf->AddFrame(cancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
354 
355  vf->Resize(cancel->GetDefaultWidth()+70, vf->GetDefaultHeight());
356 
357  hf->AddFrame(vf, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
359 
363 
366  fFontSizes->Layout();
367  fFontNames->Layout();
368 
369  SetWindowName("Font Selection");
370  SetIconName("Font Selection");
371  SetClassHints("ROOT", "FontDialog");
372 
378 
379  //---- set minimum size to the dialog box
380  width = GetDefaultWidth();
381  height = GetDefaultHeight();
382  MapSubwindows();
383  Resize(width, height);
384 
385  //---- position the dialog relative to the parent's window
386  CenterOnParent();
387 
388  // set minimum size
389  SetWMSize(width, height);
390  SetWMSizeHints(width, height, 10000, 10000, 0, 0);
391 
392  if (fWaitFor) {
393  MapWindow();
394  fClient->WaitForUnmap(this);
395  DeleteWindow();
396  }
397 }
398 
399 ////////////////////////////////////////////////////////////////////////////////
400 /// Delete all widgets.
401 
403 {
404  //fClient->FreeFont(fLabelFont);
406 }
407 
408 ////////////////////////////////////////////////////////////////////////////////
409 /// Called when window is closed via window manager.
410 
412 {
413  if (fWaitFor) {
414  UnmapWindow();
415  return;
416  }
417 
418  if (!fHitOK) {
419  fFontProp->fName = "";
420 
421  if (fInitFont) {
423  FontSelected((char*)fInitFont->GetName());
424  }
425  if (fInitColor) {
428  }
429 
430  if (fInitAlign) {
433  }
434  }
435  fFontNames->Select(0);
436  fFontStyles->Select(0);
437  fFontSizes->Select(0);
438 
439  // don't call DeleteWindow() here since that will cause access
440  // to the deleted dialog in the WaitFor() method (see ctor)
441  UnmapWindow();
442 }
443 
444 ////////////////////////////////////////////////////////////////////////////////
445 /// Handle dialog events.
446 
448 {
449  switch (GET_MSG(msg)) {
450  case kC_COMMAND:
451  switch (GET_SUBMSG(msg)) {
452  case kCM_BUTTON:
453  switch (parm1) {
454 
455  case kFDLG_OK:
456  fHitOK = kTRUE;
457  fFontProp->fName = fName;
459  fFontProp->fBold = fBold;
460  fFontProp->fSize = fSize;
463  CloseWindow();
464  break;
465  case kFDLG_CANCEL:
466  fHitOK = kFALSE;
467  CloseWindow();
468  break;
469  }
470  break;
471 
472  case kCM_LISTBOX:
473  GetFontName();
474  break;
475 
476  case kCM_COMBOBOX:
477  GetFontName();
478  break;
479 
480  default:
481  break;
482  }
483  break;
484 
485  case kC_COLORSEL:
486  switch (GET_SUBMSG(msg)) {
487 
488  case kCOL_SELCHANGED:
489  {
490  if (parm2 != (Int_t)fTextColor) {
491  fTextColor = parm2;
492  GetFontName();
493  }
494  }
495  break;
496 
497  default:
498  break;
499  }
500  break;
501 
502  default:
503  break;
504  }
505  return kTRUE;
506 }
507 
508 ////////////////////////////////////////////////////////////////////////////////
509 /// Build font dialog.
510 
512 {
513  TString family;
514  TString font;
515 
516  Int_t i;
517  fNumberOfFonts = 1;
518  Int_t n1, n2;
519 
520  for (i = 0; i < cnt; i++) {
521  font = fontList[i];
522  n1 = font.Index("-", 1);
523  n2 = font.Index("-", n1+1);
524  family = font(n1+1, n2-n1-1);
525 
526  if ((family.Length() == 0) || (family.BeginsWith("@"))) {
527  continue;
528  }
529 
530  if (!fFontNames->FindEntry(family.Data())) {
531  fFontNames->AddEntry(family.Data(), fNumberOfFonts++);
532  }
533  }
534 
536 
538 
539  if (le) {
540  fFontNames->Select(le->EntryId());
541  }
542 
544 
545  return kTRUE;
546 }
547 
548 ////////////////////////////////////////////////////////////////////////////////
549 /// Build font style and size list boxes
550 
551 void TGFontDialog::UpdateStyleSize(const char *family)
552 {
553  if (!family) {
554  return;
555  }
556 
557  TString font = family;
558  Bool_t styles[4] = { kFALSE, kFALSE, kFALSE, kFALSE };
559  Int_t cnt = 0;
560  Int_t i = 0;
561 
562  TString fname;
563  char **fontList = 0;
564 
565  fname = TString::Format("-*-%s-*-*", family);
566  fontList = gVirtualX->ListFonts(fname.Data(), 1000, cnt);
567 
568  fFontSizes->RemoveEntries(0, 1000);
569  fFontSizes->Layout();
570 
571  fFontStyles->RemoveEntries(0, 100);
572  fFontStyles->Layout();
573 
574  if (!cnt || !fontList) {
575  return;
576  }
577 
578  TString style1;
579  TString style2;
580  TString sz;
581  TString name;
582  Int_t n1, n2;
583  Bool_t x11 = gVirtualX->InheritsFrom("TGX11");
584  Bool_t all_sizes = !x11;
585  Bool_t all_styles = !x11;
586 
587  //
588  if (gVirtualX->InheritsFrom("TGCocoa")) {
589  all_sizes = kTRUE;
590  all_styles = kFALSE;
591  }
592 
593  int szn = 0;
594 
595  fFontSizes->AddEntry("12", szn++);
596 
597  for (i = 0; i < cnt; i++) {
598  name = fontList[i];
599  n1 = name.Index(family);
600 
601  if (n1 == kNPOS) {
602  break;
603  }
604  n1 += font.Length() + 1;
605  n2 = name.Index("-", n1);
606  if (n2 == kNPOS) {
607  break;
608  }
609 
610  style1 = name(n1, n2 - n1);
611 
612  n1 = n2 + 1;
613  n2 = name.Index("-", n1);
614  if (n2 == kNPOS) {
615  break;
616  }
617  style2 = name(n1, n2 - n1);
618 
619  if ((style1 == "normal") || (style1 == "medium")) {
620  if (style2 == "r") {
621  styles[0] = kTRUE;
622  gFontStylesReal[0] = style1 + "-" + style2;
623  } else if (style2 == "i") {
624  styles[2] = kTRUE;
625  gFontStylesReal[2] = style1 + "-" + style2;
626  } else if (style2 == "o") {
627  styles[2] = kTRUE;
628  gFontStylesReal[2] = style1 + "-" + style2;
629  }
630  } else if (style1 == "bold") {
631  if (style2 == "r") {
632  styles[1] = kTRUE;
633  gFontStylesReal[1] = style1 + "-" + style2;
634  } else if (style2 == "i") {
635  styles[3] = kTRUE;
636  gFontStylesReal[3] = style1 + "-" + style2;
637  } else if (style2 == "o") {
638  styles[3] = kTRUE;
639  gFontStylesReal[3] = style1 + "-" + style2;
640  }
641  } else if (style1 == "(null)") {
642  styles[0] = kTRUE;
643  gFontStylesReal[0] = "normal-r";
644  styles[1] = kTRUE;
645  gFontStylesReal[1] = "bold-r";
646  styles[2] = kTRUE;
647  gFontStylesReal[2] = "normal-i";
648  styles[3] = kTRUE;
649  gFontStylesReal[3] = "bold-i";
650  }
651 
652  n1++;
653  n2 = name.Index("-", n1);
654  n1 = n2 + 1;
655  n2 = name.Index("-", n1);
656  n1 = n2 + 1;
657 
658  if (n2 != kNPOS) {
659  n1 = n2 + 2;
660  n2 = name.Index("-", n1);
661  sz = name(n1, n2 - n1);
662  if (!sz.IsDigit()) {
663  continue;
664  }
665 
666  all_sizes = (sz == "0") && !x11;
667  if (!all_sizes) {
668  sz.Strip();
669  if (sz.Length() == 1) {
670  sz = " " + sz;
671  }
672  if (!fFontSizes->FindEntry(sz.Data())) {
673  fFontSizes->AddEntry(sz.Data(), szn++);
674  }
675  }
676  }
677  }
678  gVirtualX->FreeFontNames(fontList);
679 
680  Bool_t nostyles = kTRUE;
681  for (i = 0; gFontStyles[i] != 0; ++i) {
682  if (all_styles || styles[i]) {
683  nostyles = kFALSE;
685  }
686  }
687 
688  if (nostyles && x11) {
690  fBold = kFALSE;
691  fItalic = kFALSE;
692  }
693 
694  if (!fBold) {
695  if (!fItalic) {
696  fFontStyles->Select(0);
697  } else {
698  fFontStyles->Select(2);
699  }
700  } else {
701  if (!fItalic) {
702  fFontStyles->Select(1);
703  } else {
704  fFontStyles->Select(3);
705  }
706  }
707 
708 // if (nostyles) {
709 // fFontNames->RemoveEntry(fFontNames->FindEntry(family)->EntryId());
710 // }
711 
713  fFontStyles->Layout();
714 //
715 
716  sz = TString::Format("%d", fSize);
717  if (sz.Length() == 1) {
718  sz = " " + sz;
719  }
720 
721  for (i = 0; gFontSizes[i] != 0; ++i) {
722  if (all_sizes && !fFontSizes->FindEntry(gFontSizes[i])) {
723  fFontSizes->AddEntry(new TGString(gFontSizes[i]), i);
724  }
725  if (sz == gFontSizes[i]) {
726  fFontSizes->Select(i);
727  }
728  }
729 
732  fFontSizes->Layout();
733 }
734 
735 ////////////////////////////////////////////////////////////////////////////////
736 /// Sets fLName and other data members.
737 
739 {
740  TGTextLBEntry *e;
741  const char *size, *name;
742  Int_t sel;
743  Int_t sav = gErrorIgnoreLevel;
745 
746  TString oldName = fName;
748 
749  if (!e) {
750  fFontNames->Select(1);
752  }
753  name = e ? e->GetText()->GetString() : "";
754  fName = name;
755 
757  size = e ? e->GetText()->GetString() : "0";
758  fSize = atoi(size);
759 
760  sel = fFontStyles->GetSelected();
761  if (sel < 0) sel = 0;
762 
763  switch(sel) {
764  case 0:
765  fItalic = kFALSE;
766  fBold = kFALSE;
767  break;
768  case 1:
769  fItalic = kFALSE;
770  fBold = kTRUE;
771  break;
772  case 2:
773  fItalic = kTRUE;
774  fBold = kFALSE;
775  break;
776  case 3:
777  fItalic = kTRUE;
778  fBold = kTRUE;
779  break;
780  default:
781  fItalic = kFALSE;
782  fBold = kFALSE;
783  break;
784  }
785 
786  const char *rgstry = "*";
787 
788  if ((fName == "Symbol") || (fName == "Webdings") || (fName == "Wingdings")) {
789  rgstry = "microsoft";
790  }
791 
792  TString oldFont = fLName;
793  fLName = TString::Format("-*-%s-%s-*-*-%s-*-*-*-*-*-%s-*", name,
794  gFontStylesReal[sel].Data(), size, rgstry);
795 
796  if (oldFont != fLName) {
797  if (fLabelFont) {
798  //fClient->FreeFont(fLabelFont);
800 
801  if (!fLabelFont) {
802  fLabelFont = fClient->GetFont("fixed");
803  }
804  } else {
805  fLabelFont = fClient->GetFont("fixed");
806  }
807 
808  if (!fLabelFont) {
809  // should not happen
810  fLName = oldFont;
811  }
812  else if (fSample) {
814  }
815  }
816 
817  Int_t oldAlign = fTextAlign;
818 
819  Int_t idx = fTextAligns->GetSelected();
820  fTextAlign = gAlignValues[idx >= 0 ? idx : 6];
821 
822  if (fSample) {
823  if (fTextAlign != oldAlign) {
826  }
830  }
831  FontSelected((char*)fLName.Data());
832  fClient->NeedRedraw(this);
833  gErrorIgnoreLevel = sav;
834 }
835 
836 ////////////////////////////////////////////////////////////////////////////////
837 /// Set font
838 
840 {
841  if (!font) {
842  return;
843  }
844  TString name = font->GetName();
845 
846  if (name.Index("-", 1) == kNPOS) {
847  return;
848  }
849 
850  if (fSample) {
851  fLabelFont = font;
853  }
854  fInitFont = font;
855 
856  TString style1;
857  TString style2;
858  TString sz;
859 
860  TString family;
861  Int_t n1, n2;
862 
863  n1 = name.Index("-", 1);
864  n2 = name.Index("-", n1 + 1);
865  n1++;
866  family = name(n1, n2 - n1);
867 
869 
870  if (le) {
871  fFontNames->Select(le->EntryId());
872  }
873 
874  n1 = n2 + 1;
875  n2 = name.Index("-", n1);
876 
877  style1 = name(n1, n2 - n1);
878 
879  n1 = n2 + 1;
880  n2 = name.Index("-", n1);
881  if (n2 == kNPOS) {
882  return;
883  }
884  style2 = name(n1, n2 - n1);
885 
886  if ((style1 == "normal") || (style1 == "medium")) {
887  if (style2 == "r") {
888  fFontStyles->Select(0);
889  } else if (style2 == "i") {
890  fFontStyles->Select(2);
891  } else if (style2 == "o") {
892  fFontStyles->Select(2);
893  }
894  } else if (style1 == "bold") {
895  if (style2 == "r") {
896  fFontStyles->Select(1);
897  } else if (style2 == "i") {
898  fFontStyles->Select(3);
899  } else if (style2 == "o") {
900  fFontStyles->Select(3);
901  }
902  }
903  n1++;
904  n2 = name.Index("-", n1);
905  n1 = n2 + 1;
906  n2 = name.Index("-", n1);
907  n1 = n2 + 1;
908  n2 = name.Index("-", n1);
909  n1 = n2 + 1;
910  if (n2 != kNPOS) {
911  n1 = n2 + 1;
912  n2 = name.Index("-", n1);
913  sz = name(n1, n2 - n1);
914 
915  le = (TGTextLBEntry*)fFontSizes->FindEntry(sz.Data());
916  if (le) {
917  fFontSizes->Select(le->EntryId());
918  }
919  }
920 }
921 
922 ////////////////////////////////////////////////////////////////////////////////
923 /// Set color
924 
926 {
927  if (fSample) {
928  fTextColor = color;
930  }
931  fColorSelect->SetColor(color, kFALSE);
933  fInitColor = color;
934 }
935 
936 ////////////////////////////////////////////////////////////////////////////////
937 /// Set align
938 
940 {
941  if (fSample) {
942  fTextAlign = align;
944  }
945 
946  for (int i = 0; gAlignValues[i] != 0; ++i) {
947  if (gAlignValues[i] == align) {
948  fTextAligns->Select(i);
949  }
950  }
951  fInitAlign = align;
953 }
954 
955 ////////////////////////////////////////////////////////////////////////////////
956 /// Enable/disable align combobox
957 
959 {
960  fTextAligns->SetEnabled(on);
961 }
EFontDialog
static const char * gFontStyles[]
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual void SetFont(TGFont *font)
Set font.
virtual ~TGFontDialog()
Delete all widgets.
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
TGLabel * fSample
Definition: TGFontDialog.h:53
Pixel_t fInitColor
Definition: TGFontDialog.h:63
virtual void AddEntry(TGString *s, Int_t id)
Add entry with specified string and id to listbox.
Definition: TGListBox.cxx:1211
TGListBox * fFontStyles
Definition: TGFontDialog.h:51
R__EXTERN Int_t gErrorIgnoreLevel
Definition: TError.h:105
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGListBox.cxx:1643
static const char * gFDLG_DEFAULTSAMPLE
FontH_t fFont
Definition: GuiTypes.h:241
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition: TGFrame.cxx:1913
virtual void CloseWindow()
Called when window is closed via window manager.
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:359
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
static TString gFontStylesReal[4]
UInt_t GetHeight() const
Definition: TGFrame.h:272
void SetColor(Pixel_t color, Bool_t emit=kTRUE)
Set color.
virtual void UpdateStyleSize(const char *family)
Build font style and size list boxes.
Bool_t fItalic
Definition: TGFontDialog.h:58
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
Bool_t fWaitFor
Definition: TGFontDialog.h:71
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:373
virtual void EnableAlign(Bool_t on=kTRUE)
Enable/disable align combobox.
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:321
UInt_t GetWidth() const
Definition: TGFrame.h:271
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition: TGFrame.cxx:1759
TGFontDialog(const TGWindow *parent=0, const TGWindow *t=0, FontProp_t *fontProp=0, const TString &sample="", char **fontList=0, Bool_t wait=kTRUE)
Create font dialog.
void WaitForUnmap(TGWindow *w)
Wait for window to be unmapped.
Definition: TGClient.cxx:734
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
Remove a range of entries defined by from_ID and to_ID.
Definition: TGListBox.cxx:1361
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
TString fName
Definition: TGFontDialog.h:55
virtual void ColorSelected(Pixel_t c)
Definition: TGFontDialog.h:94
TGComboBox * fTextAligns
Definition: TGFontDialog.h:52
Bool_t fHitOK
Definition: TGFontDialog.h:69
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2365
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGFont * fInitFont
Definition: TGFontDialog.h:65
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition: TGFrame.cxx:1862
Bool_t Build(char **fontList, Int_t cnt)
Build font dialog.
const Int_t kFatal
Definition: TError.h:42
ULong_t fForeground
Definition: GuiTypes.h:226
const Mask_t kGCFont
Definition: GuiTypes.h:299
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:443
TGCompositeFrame(const TGCompositeFrame &)
TGGC * fSampleTextGC
Definition: TGFontDialog.h:67
virtual TGLBEntry * FindEntry(const char *s) const
Find entry by name.
Definition: TGComboBox.cxx:414
TGFont * fLabelFont
Definition: TGFontDialog.h:68
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
Bool_t fBold
Definition: TGFontDialog.h:59
void FreeGC(const TGGC *gc)
Free a graphics context.
Definition: TGClient.cxx:326
virtual void SortByName(Bool_t ascend=kTRUE)
Sort entries by name.
Definition: TGListBox.cxx:1513
FontProp_t * fFontProp
Definition: TGFontDialog.h:57
virtual TGLBEntry * Select(Int_t id, Bool_t sel=kTRUE)
Definition: TGListBox.h:352
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGListBox.h:356
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:867
Pixel_t fTextColor
Definition: TGFontDialog.h:62
virtual void FontSelected(char *font)
Definition: TGFontDialog.h:90
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:371
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
Int_t GET_SUBMSG(Long_t val)
Int_t EntryId() const
Definition: TGListBox.h:68
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:561
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Ssiz_t Length() const
Definition: TString.h:386
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1080
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:237
TGListBox * fFontNames
Definition: TGFontDialog.h:49
virtual void SetEnabled(Bool_t on=kTRUE)
Set state of combo box. If kTRUE=enabled, kFALSE=disabled.
Definition: TGComboBox.cxx:631
#define gVirtualX
Definition: TVirtualX.h:350
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get graphics context from the gc pool.
Definition: TGClient.cxx:318
Int_t GET_MSG(Long_t val)
const char * GetString() const
Definition: TGString.h:40
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void SetColor(Pixel_t color)
Set color.
long Long_t
Definition: RtypesCore.h:50
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:238
TGListBox * fFontSizes
Definition: TGFontDialog.h:50
#define ClassImp(name)
Definition: Rtypes.h:359
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1004
const TGString * GetText() const
Definition: TGListBox.h:115
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
virtual void AlignSelected(Int_t a)
Definition: TGFontDialog.h:92
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
TString fSampleText
Definition: TGFontDialog.h:66
Definition: TGFont.h:149
static const char * gFontSizes[]
static const char * gAlignTypes[]
virtual void SetPosition(Int_t pos)=0
void GetFontName()
Sets fLName and other data members.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
const Mask_t kGCForeground
Definition: GuiTypes.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
TString fLName
Definition: TGFontDialog.h:56
virtual TGScrollBar * GetScrollBar() const
Definition: TGListBox.h:337
virtual void Layout()
Layout the listbox components.
Definition: TGListBox.cxx:1460
virtual void UnmapWindow()
Definition: TGFrame.h:253
Mask_t fMask
Definition: GuiTypes.h:250
virtual Int_t GetSelected() const
Definition: TGComboBox.h:134
virtual Int_t GetSelected() const
Return id of selected listbox item.
Definition: TGListBox.cxx:1523
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:393
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle dialog events.
static const Int_t gAlignValues[]
virtual void MapWindow()
Definition: TGFrame.h:251
TGClient * fClient
Definition: TGObject.h:37
Int_t fInitAlign
Definition: TGFontDialog.h:64
TGColorSelect * fColorSelect
Definition: TGFontDialog.h:54
void SetWMSize(UInt_t w, UInt_t h)
Give the window manager a window size hint.
Definition: TGFrame.cxx:1849
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition: TString.cxx:1817
Int_t fNumberOfFonts
Definition: TGFontDialog.h:70
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
Int_t fTextAlign
Definition: TGFontDialog.h:61
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition: TGFrame.cxx:1824
virtual void SetAlign(Int_t align)
Set align.
const Bool_t kTRUE
Definition: RtypesCore.h:87
static Pixel_t GetBlackPixel()
Get black pixel value.
Definition: TGFrame.cxx:704
char name[80]
Definition: TGX11.cxx:109
const char * cnt
Definition: TXMLSetup.cxx:74
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition: TGClient.cxx:346
const char * Data() const
Definition: TString.h:345
FontH_t GetFontHandle() const
Definition: TGFont.h:192