Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGedPatternSelect.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Marek Biskup, Ilka Antcheva 24/07/03
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, 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 #ifndef ROOT_TGedPatternSelect
13 #define ROOT_TGedPatternSelect
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TGedPatternFrame, TGedPatternSelector, TGedPatternPopup //
18 // and TGedPatternColor. //
19 // //
20 // The TGedPatternFrame is a small frame with border showing a //
21 // specific pattern (fill style). //
22 // //
23 // The TGedPatternSelector is a composite frame with TGedPatternFrames //
24 // of all diferent styles //
25 // //
26 // The TGedPattern is a popup containing a TGPatternSelector. //
27 // //
28 // The TGedPatternSelect widget is a button with pattern area with //
29 // a little down arrow. When clicked on the arrow the //
30 // TGedPatternPopup pops up. //
31 // //
32 // Selecting a pattern in this widget will generate the event: //
33 // kC_PATTERNSEL, kPAT_SELCHANGED, widget id, style. //
34 // //
35 // and the signal: //
36 // PatternSelected(Style_t pattern) //
37 // //
38 // TGedSelect is button that shows popup window when clicked. //
39 // TGedPopup is a popup window. //
40 // //
41 //////////////////////////////////////////////////////////////////////////
42 
43 #include "TGButton.h"
44 #include "TGToolTip.h"
45 
46 
47 class TGedPopup : public TGCompositeFrame {
48 
49 protected:
50  const TGWindow *fMsgWindow;
51 
52 public:
53  TGedPopup(const TGWindow* p, const TGWindow *m, UInt_t w, UInt_t h,
54  UInt_t options = 0, Pixel_t back = GetDefaultFrameBackground());
55  virtual ~TGedPopup() { }
56 
57  virtual Bool_t HandleButton(Event_t *event);
58  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
59  void PlacePopup(Int_t x, Int_t y, UInt_t w, UInt_t h);
60  void EndPopup();
61 
62  ClassDef(TGedPopup,0) //popup window
63 };
64 
65 class TGedPatternFrame : public TGFrame {
66 
67 protected:
68  const TGWindow *fMsgWindow;
69  Bool_t fActive;
70  Style_t fPattern;
71  static TGGC *fgGC;
72  TGToolTip *fTip; // tool tip associated with a button
73  char fTipText[7];
74 
75  virtual void DoRedraw();
76 
77 public:
78  TGedPatternFrame(const TGWindow *p, Style_t pattern, Int_t width = 40,
79  Int_t height = 20);
80  virtual ~TGedPatternFrame() { delete fTip; }
81 
82  virtual Bool_t HandleButton(Event_t *event);
83  virtual Bool_t HandleCrossing(Event_t *event);
84  virtual void DrawBorder();
85 
86  void SetActive(Bool_t in) { fActive = in; gClient->NeedRedraw(this); }
87  Style_t GetPattern() const { return fPattern; }
88  static void SetFillStyle(TGGC* gc, Style_t fstyle); //set fill style for given GC
89 
90  ClassDef(TGedPatternFrame,0) //pattern frame
91 };
92 
93 class TGedPatternSelector : public TGCompositeFrame {
94 
95 protected:
96  Int_t fActive;
97  const TGWindow *fMsgWindow;
98  TGedPatternFrame *fCe[27];
99 
100 public:
101  TGedPatternSelector(const TGWindow *p);
102  virtual ~TGedPatternSelector();
103 
104  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
105  void SetActive(Int_t newat);
106  Int_t GetActive() const { return fActive; }
107 
108  ClassDef(TGedPatternSelector,0) //select pattern frame
109 };
110 
111 class TGedPatternPopup : public TGedPopup {
112 
113 protected:
114  Style_t fCurrentPattern;
115 
116 public:
117  TGedPatternPopup(const TGWindow *p, const TGWindow *m, Style_t pattern);
118  virtual ~TGedPatternPopup();
119 
120  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
121 
122  ClassDef(TGedPatternPopup,0) // Color selector popup
123 };
124 
125 class TGedSelect : public TGCheckButton {
126 
127 protected:
128  TGGC *fDrawGC;
129  TGedPopup *fPopup;
130 
131  virtual void DoRedraw();
132  void DrawTriangle(GContext_t gc, Int_t x, Int_t y);
133 
134 public:
135  TGedSelect(const TGWindow *p, Int_t id);
136  virtual ~TGedSelect();
137 
138  virtual Bool_t HandleButton(Event_t *event);
139 
140  virtual void Enable();
141  virtual void Disable();
142  virtual void SetPopup(TGedPopup* p) { fPopup = p; } // popup will be deleted in destructor.
143 
144  ClassDef(TGedSelect,0) //selection check-button
145 };
146 
147 class TGedPatternSelect : public TGedSelect {
148 
149 protected:
150  Style_t fPattern;
151 
152  virtual void DoRedraw();
153 
154 public:
155  TGedPatternSelect(const TGWindow *p, Style_t pattern, Int_t id);
156  virtual ~TGedPatternSelect() {}
157 
158  void SetPattern(Style_t pattern, Bool_t emit=kTRUE);
159  Style_t GetPattern() const { return fPattern; }
160  virtual TGDimension GetDefaultSize() const { return TGDimension(55, 21); }
161  virtual void PatternSelected(Style_t pattern = 0)
162  { Emit("PatternSelected(Style_t)", pattern ? pattern : GetPattern()); } // *SIGNAL*
163  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
164  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
165 
166  ClassDef(TGedPatternSelect,0) //pattern selection check-button
167 };
168 
169 #endif