JG ROOT Tools libraries  version 5.0 - august 2014
RGBaseRequester.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file RGBaseRequester.hh
3  *
4  * Include file for class RGBaseRequester
5  */
6 //======================================================================
7 
8 #ifndef RG_BASE_REQUESTER_HH
9 #define RG_BASE_REQUESTER_HH
10 
11 #include <iostream>
12 #include <fstream>
13 #include <iomanip>
14 #include <string>
15 
16 using namespace std ;
17 
18 #include <TGFrame.h>
19 #include <TGLabel.h>
20 #include <TGButton.h>
21 
22 #include "RBaseFunctions.hh"
23 #include "RDico.hh"
24 
25 ///! Base requesters otptions.
27 {
28  // format de la zone de widgets additionnels
29  rgReqVerticalFrame = 0x00000000, // vertical layout (default)
30  rgReqHorizontalFrame = 0x00000001, // horizontal vertical
31  rgReqFrameType = 0x00000001, // layout options bits
32  rgReqNoExpandX = 0x00000002, // X expansion option
33  rgReqNoExpandY = 0x00000004, // Y expansion option
34 
35  // position des boutons de requête
36  rgReqButtonsBottom = 0x00000000, // buttons under the request (default)
37  rgReqButtonsRight = 0x00000040, // buttons on the right side (centered)
38  rgReqButtonsRightTop = 0x00000140, // buttons on the right side (up)
39  rgReqButtonsRightBottom = 0x00000240, // buttons on the right side (down)
40  rgReqButtonsLeft = 0x000000C0, // buttons on the left side (centered)
41  rgReqButtonsLeftTop = 0x000001C0, // buttons on the left side (up)
42  rgReqButtonsLeftBottom = 0x000002C0, // buttons on the left side (down)
43  rgReqButtonsSideTop = 0x00000100, // side buttons up
44  rgReqButtonsSideBottom = 0x00000200, // side buttons down
45  rgReqButtonsSide = 0x00000300, // side buttons options
46  rgReqButtonsPosition = 0x000003C0, // buttons position options bits
47 
48  // autres options
49  rgReqNoWait = 0x00001000 // do not wait for request to complete
50 };
51 
52 //======================================================================
53 /*! class RGBaseRequester
54  *
55  * Base class to define requests that expect a result from button click.
56  *
57  * When the request is executed, the result is stored in \b result variable.
58  * The values correspond to button numbers, starting at 1, except the
59  * last one that is 0, like the window close button.
60  *
61  * Buttons are defined in a single character string, each button text
62  * separated from others with '|' character.
63  * When a button is selected, the request is closed, except if the button
64  * text ends with '*', or if a slot is called that calls the CancelClose()
65  * function.
66  *
67  * Base requester options:
68  * - format for addtionnal widgets frame
69  * - \b rgReqVerticalFrame
70  * - \b rgReqHorizontalFrame
71  * - \b rgReqFrameType
72  * - \b rgReqNoExpandX
73  * - \b rgReqNoExpandY
74  *
75  * - position of request buttons
76  * - \b rgReqButtonsBottom
77  * - \b rgReqButtonsRight
78  * - \b rgReqButtonsRightTop
79  * - \b rgReqButtonsRightBottom
80  * - \b rgReqButtonsLeft
81  * - \b rgReqButtonsLeftTop
82  * - \b rgReqButtonsLeftBottom
83  * - \b rgReqButtonsSideTop
84  * - \b rgReqButtonsSideBottom
85  * - \b rgReqButtonsSide
86  * - \b rgReqButtonsPosition
87  *
88  * - other options
89  * - \b rgReqNoWait
90  */
91 class RGBaseRequester : public TGTransientFrame
92 {
93  //------------------------------------------------------------
94  /*! \object_doc{RGBaseRequester} */
95  GObject(RGBaseRequester);
96  //------------------------------------------------------------
97 
98  protected:
99 
100  static UInt_t max_width; ///< Maximum request width
101  static UInt_t max_height; ///< Maximum request height
102 
103 #ifndef __MAKECINT__
104  int * result_adr; ///< Request resul pointer
105 #endif
106 
107  string req_title; ///< Request title
108 #ifndef __MAKECINT__
109  const char * req_buttons; ///< Buttons texts
110 #endif
111  UInt_t options; ///< Request options
112 
113  ULong_t req_button_layout; ///< Buttons layout
114 
115  TGCompositeFrame * w_widget_frame; ///< Frame for widgets
116  TGCompositeFrame * w_buttons_frame; ///< Frame for buttons
117 
118  TList buttons_list; ///< List of created buttons
119 
120  Bool_t cancel_close; ///< Check for close cancellation
121 
122 
123  //------------------------------------------------------------
124  // Constructors / affectation / destructor
125  public:
126  // Constructor with return value
127  RGBaseRequester ( const TGWindow * parent,
128  const TGWindow * main,
129  int & result,
130  const char * title,
131  const char * buttons = rDico.brq_ok_cancel.c_str(),
132  const ULong_t opts = 0,
133  const bool auto_start = true );
134 
135  // Constructor without return value (for derived classes)
136  RGBaseRequester ( const TGWindow * parent,
137  const TGWindow * main,
138  const char * title,
139  const char * buttons = rDico.brq_ok_cancel.c_str(),
140  const ULong_t opts = 0,
141  const bool auto_start = false );
142 
143  protected:
144  RGBaseRequester ( const RGBaseRequester & req );
145 
146  public:
147  virtual ~RGBaseRequester();
148 
149  //------------------------------------------------------------
150  protected:
151  // setting base widgets
152  virtual void Construct ( );
153 
154  public:
155  // request mapping
156  virtual void MapRequester ( );
157 
158  // request execution
159  virtual void Request ( );
160 
161  // access to requester widgets pointers
162  virtual TGCompositeFrame * GetFrame ( ) const;
163  virtual TGHorizontalFrame * GetHFrame ( ) const;
164  virtual TGVerticalFrame * GetVFrame ( ) const;
165 
166  // adding widgets
167  virtual void AddFrame (TGFrame *f, TGLayoutHints *l = 0);
168 
169  virtual void CloseFromButton ( );
170  virtual void CancelClose ( const Bool_t b = kTRUE );
171 
172  // Signals
173  virtual void ReqButtonClicked ( Int_t n ); // *SIGNAL*
174 
175  // Slots
176  virtual void ProcessedEvent ( Event_t * event );
177 
178  // buttons slots
179  virtual void Button ( Int_t n );
180  virtual void Quit ( );
181 
182  //------------------------------------------------------------
183  /*! For ROOT dictionary.*/
184  ClassDef(RGBaseRequester,0);
185 };
186 
187 //----------------------------------------------------------------------
188 // Inline functions
189 #include "icc/RGBaseRequester.icc"
190 
191 //======================================================================
192 #endif
193 
Definition: RGBaseRequester.hh:91
TGCompositeFrame * w_buttons_frame
Frame for buttons.
Definition: RGBaseRequester.hh:116
Bool_t cancel_close
Check for close cancellation.
Definition: RGBaseRequester.hh:120
int * result_adr
Request resul pointer.
Definition: RGBaseRequester.hh:104
UInt_t options
Request options.
Definition: RGBaseRequester.hh:111
string brq_ok_cancel
Button texts.
Definition: RDico.hh:189
const char * req_buttons
Buttons texts.
Definition: RGBaseRequester.hh:109
RGRequestOptions
! Base requesters otptions.
Definition: RGBaseRequester.hh:26
static UInt_t max_height
Maximum request height.
Definition: RGBaseRequester.hh:101
static UInt_t max_width
Maximum request width.
Definition: RGBaseRequester.hh:100
TList buttons_list
List of created buttons.
Definition: RGBaseRequester.hh:118
RDico & rDico
! Unique instance of the dictionary class
Definition: RDico.cpp:12
TGCompositeFrame * w_widget_frame
Frame for widgets.
Definition: RGBaseRequester.hh:115
ULong_t req_button_layout
Buttons layout.
Definition: RGBaseRequester.hh:113
string req_title
Request title.
Definition: RGBaseRequester.hh:107