Skip to content
Snippets Groups Projects
Commit 059c422f authored by Bertrand Bellenot's avatar Bertrand Bellenot
Browse files

Cleanup (remove duplicates <code></code>)

git-svn-id: http://root.cern.ch/svn/root/trunk@39574 27541ba8-7e3a-0410-8455-c3a389f83636
parent 59debed5
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,7 @@ void example() {
}
</programlisting>
<para>The <emphasis role="bold"><code>TGMainFrame </code></emphasis>class defines a top level window that interacts with the system window manager. Its method <code>CloseWindow()</code> is invoked when Alt+F4 are pressed or a window manager close/exit command is used. To terminate the application when this happens you need to override the <code>CloseWindow()</code> method and call <code>gApplication-&gt;Terminate</code><code>(0)</code>. </para>
<para>The <emphasis role="bold"><code>TGMainFrame </code></emphasis>class defines a top level window that interacts with the system window manager. Its method <code>CloseWindow()</code> is invoked when Alt+F4 are pressed or a window manager close/exit command is used. To terminate the application when this happens you need to override the <code>CloseWindow()</code> method and call <code>gApplication-&gt;Terminate(0)</code>. </para>
<para>The main frame can be considered as a container where all widgets of the application are organized with respect to their parent-child relationship. After the main frame we create <code>fEcanvas</code> – an object of class <emphasis role="bold"><code>TRootEmbeddedCanvas</code></emphasis>. It is a quite complex widget and we will explain it in detail later. For the moment keep in mind only its main purpose – to create a <emphasis role="bold"><code>TCanvas</code></emphasis> – the ROOT basic whiteboard for drawing and editing different graphical objects. </para>
<programlisting language="c++">fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,200,200);
......@@ -179,7 +179,7 @@ TGTextButton *exit = new TGTextButton(hframe,"&amp;Exit",
hframe -&gt;AddFrame(exit,new TGLayoutHints(kLHintsCenterX,5,5,3,4));
</programlisting>
<para>They are created as objects of the <emphasis role="bold"><code>TGTextButton</code></emphasis> class that represent the command buttons with a text label. When you click on a command button it performs the action shown on its label. These buttons are well known as “push buttons” or just “buttons”. The parent address <code>hframe</code> is passed as first parameter. The second one defines the button label and normally indicates the action to be taken when the button is clicked. It is possible to define a hot key for the button at that point using the hot string for its label. A hot string is a string with a “hot” character underlined. This character we call the button hot key. It shows the assigned keyboard mnemonic for the button choice. Following our example, this means that you can use <code>Alt+D</code> to click on Draw button and <code>Alt+E</code> to click on Exit. There is a possibility to specify a command string as third parameter of the button constructor. We use it to assign the command <code>gApplication-&gt;Terminate</code><code>(0)</code>. The application will be terminated when you click on the Exit button. </para>
<para>They are created as objects of the <emphasis role="bold"><code>TGTextButton</code></emphasis> class that represent the command buttons with a text label. When you click on a command button it performs the action shown on its label. These buttons are well known as “push buttons” or just “buttons”. The parent address <code>hframe</code> is passed as first parameter. The second one defines the button label and normally indicates the action to be taken when the button is clicked. It is possible to define a hot key for the button at that point using the hot string for its label. A hot string is a string with a “hot” character underlined. This character we call the button hot key. It shows the assigned keyboard mnemonic for the button choice. Following our example, this means that you can use <code>Alt+D</code> to click on Draw button and <code>Alt+E</code> to click on Exit. There is a possibility to specify a command string as third parameter of the button constructor. We use it to assign the command <code>gApplication-&gt;Terminate(0)</code>. The application will be terminated when you click on the Exit button. </para>
<para>We call again <code>AddFrame()</code> to add the buttons to their parent widget giving layout hints for each of them. This time we would like to have centered buttons with an amount of 5 pixels on the left, 5 on the right, 3 on the top and 4 on the bottom. You can feel already that the same steps are repeated three times: to create a new widget with passing a parent address as a parameter, to define layout hints for it and to add it in the parent list. The next line is something new:</para>
<programlisting language="c++">draw-&gt;Connect("Clicked()","MyMainFrame",this,"DoDraw()");
......@@ -345,7 +345,7 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h)
<title>Widgets Overview</title>
<para>The word widget is a contraction of windows and gadget. Almost all GUI elements are widgets. A button is a widget, a menu item is a widget, a scrollbar is a widget, and a complete dialog box is a widget too. Some widgets may have sub widgets. For example, a dialog box can contain buttons, text fields, a combo-box, etc. </para>
<para>On the screen widgets look like rectangular areas with special behaviors. In terms of the object-oriented programming we can define a widget in ROOT as an object of a class deriving from <emphasis role="bold"><code>TGObject</code></emphasis>. </para>
<para>This section presents all currently supported widgets in ROOT and their most useful methods. All of them can be considered as building blocks for an application, and most of them can be found in dialogs. Provided snippets of the code will give you practical guidelines where and how to use certain widgets. The macro <code>$ROOTSYS/tutorials/</code><code>gui/</code><code>guitest.C</code> contains the complete source code.</para>
<para>This section presents all currently supported widgets in ROOT and their most useful methods. All of them can be considered as building blocks for an application, and most of them can be found in dialogs. Provided snippets of the code will give you practical guidelines where and how to use certain widgets. The macro <code>$ROOTSYS/tutorials/gui/guitest.C</code> contains the complete source code.</para>
<figure><title>Widgets created by ROOT GUI classes</title>
<para>
......@@ -363,7 +363,7 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h)
<sect2>
<title>TGWidget</title>
<para>The widgets base class <emphasis role="bold"><code>TGWidget</code></emphasis> is typically used as a mix-in class via multiple inheritances. Its properties are available for all deriving widgets: <emphasis role="bold"><code>TGButton</code></emphasis>, <emphasis role="bold"><code>TGComboBox</code></emphasis>, <emphasis role="bold"><code>TGTab</code></emphasis>, <emphasis role="bold"><code>TGColorPalette</code></emphasis>, <emphasis role="bold"><code>TGColorPick</code></emphasis>, <emphasis role="bold"><code>TGDoubleSlider</code></emphasis>, <emphasis role="bold"><code>TGListTree</code></emphasis>, <emphasis role="bold"><code>TGNumberEntry</code></emphasis>, <emphasis role="bold"><code>TGScrollBar</code></emphasis>, <emphasis role="bold"><code>TGShutterItem</code></emphasis>, <emphasis role="bold"><code>TGTextEntry</code></emphasis>, <emphasis role="bold"><code>TGSlider</code></emphasis>, <emphasis role="bold"><code>TGListBox</code></emphasis>, <emphasis role="bold"><code>TGView.</code></emphasis> </para>
<para>This class has four data members keeping information about the widget id – important for event processing, the window which handles the widget’s events, the widget status flags and the assigned command (if there is any). The general properties of <emphasis role="bold"><code>TGWidget</code></emphasis> are specified by <code>SetFlags</code><code>(Int_t flags)</code> and <code>ClearFlags</code><code>(Int_t flags)</code> methods. The status flags are: <code>kWidgetWantFocus</code>, <code>kWidgetHasFocus</code>, and <code>kWidgetIsEnabled</code>. The method <code>Associate(const TGWindow* w)</code> – sets the window which handles the widget events. <code>SetCommand(const char* command)</code> – sets the command to be executed. The command string can be gathering via <code>GetCommand()</code> method. For example, the third parameter in <emphasis role="bold"><code>TGTextButton</code></emphasis> constructor can be omitted and set later in your program, i.e. instead of:</para>
<para>This class has four data members keeping information about the widget id – important for event processing, the window which handles the widget’s events, the widget status flags and the assigned command (if there is any). The general properties of <emphasis role="bold"><code>TGWidget</code></emphasis> are specified by <code>SetFlags(Int_t flags)</code> and <code>ClearFlags(Int_t flags)</code> methods. The status flags are: <code>kWidgetWantFocus</code>, <code>kWidgetHasFocus</code>, and <code>kWidgetIsEnabled</code>. The method <code>Associate(const TGWindow* w)</code> – sets the window which handles the widget events. <code>SetCommand(const char* command)</code> – sets the command to be executed. The command string can be gathering via <code>GetCommand()</code> method. For example, the third parameter in <emphasis role="bold"><code>TGTextButton</code></emphasis> constructor can be omitted and set later in your program, i.e. instead of:</para>
<programlisting language="c++">TGTextButton *exit = new TGTextButton(hframe,"&amp;Exit",
"gApplication-&gt;Terminate()");
......@@ -375,7 +375,7 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h)
exit-&gt;SetCommand("gApplication-&gt;Terminate()");
</programlisting>
<para>The method <code>IsEnabled()</code> – returns <code>kTRUE</code> if the widget has flag <code>kWidgetIsEnabled</code> and it accepts user events. This method is very important for creating a good user interface because it allows you to disable or enable a widget depending on the situation of your application. As a standard all disabled widgets are displayed “grayed out”. <code>HasFocus</code><code>()</code> – returns <code>kTRUE</code> if the widget has the input focus (i.e. flag <code>kWidgetHasFocus</code> is set). Remember that only one item in a complex widget as a dialog can have the value of <code>HasFocus()</code> sets as true. <code>WantFocus</code><code>()</code> – returns <code>kTRUE</code> if the flag <code>kWidgetWantFocus</code> is set.</para>
<para>The method <code>IsEnabled()</code> – returns <code>kTRUE</code> if the widget has flag <code>kWidgetIsEnabled</code> and it accepts user events. This method is very important for creating a good user interface because it allows you to disable or enable a widget depending on the situation of your application. As a standard all disabled widgets are displayed “grayed out”. <code>HasFocus()</code> – returns <code>kTRUE</code> if the widget has the input focus (i.e. flag <code>kWidgetHasFocus</code> is set). Remember that only one item in a complex widget as a dialog can have the value of <code>HasFocus()</code> sets as true. <code>WantFocus()</code> – returns <code>kTRUE</code> if the flag <code>kWidgetWantFocus</code> is set.</para>
</sect2>
<sect2>
......@@ -390,11 +390,11 @@ exit-&gt;SetCommand("gApplication-&gt;Terminate()");
<title>Frames</title>
<para>Most of the frame classes are mainly created for arranging widgets in a window. The class <emphasis role="bold"><code>TGFrame</code></emphasis> is a subclass of <emphasis role="bold"><code>TGWindow</code></emphasis> providing additional window characteristics and overriding some methods of <emphasis role="bold"><code>TGWindow</code></emphasis>. It is a base class for the simple widgets as buttons, labels, etc. Its only purpose is to draw a frame around widgets that do not have a frame of their own. The main groups of <emphasis role="bold"><code>TGFrame</code></emphasis> member functions are: </para>
<itemizedlist>
<listitem><para>Window’s functions: <code>DoRedraw</code><code>()</code>, <code>DeleteWindow</code><code>()</code>, <code>Activate</code><code>()</code>, etc.</para></listitem>
<listitem><para>Geometry functions: <code>Move</code><code>()</code>, <code>Resize</code><code>()</code>, <code>SetSize</code><code>()</code>, etc.</para></listitem>
<listitem><para>Graphics handlers: <code>ChangeBackground</code><code>()</code>, <code>ChangeOptions</code><code>()</code>, etc.</para></listitem>
<listitem><para>Mouse and keyboard functions: <code>HandleButton</code><code>()</code>, <code>HandleFocusChange</code><code>()</code>, <code>HandleKey</code><code>()</code>, <code>HandleMotion</code><code>()</code>, etc.</para></listitem>
<listitem><para>Event handlers: <code>HandleEvent</code><code>()</code>, <code>ProcessEvent</code><code>()</code>, <code>GetSender</code><code>()</code>, <code>SendMessage</code><code>()</code>,<code> ProcessMessage</code><code>()</code>, <code>GetLastClick</code><code>()</code>, etc.</para></listitem>
<listitem><para>Window’s functions: <code>DoRedraw()</code>, <code>DeleteWindow()</code>, <code>Activate()</code>, etc.</para></listitem>
<listitem><para>Geometry functions: <code>Move()</code>, <code>Resize()</code>, <code>SetSize()</code>, etc.</para></listitem>
<listitem><para>Graphics handlers: <code>ChangeBackground()</code>, <code>ChangeOptions()</code>, etc.</para></listitem>
<listitem><para>Mouse and keyboard functions: <code>HandleButton()</code>, <code>HandleFocusChange()</code>, <code>HandleKey()</code>, <code>HandleMotion()</code>, etc.</para></listitem>
<listitem><para>Event handlers: <code>HandleEvent()</code>, <code>ProcessEvent()</code>, <code>GetSender()</code>, <code>SendMessage()</code>,<code> ProcessMessage()</code>, <code>GetLastClick()</code>, etc.</para></listitem>
</itemizedlist>
<figure><title>The GUI classes hierarchy</title>
......@@ -588,7 +588,7 @@ ULong_t back = GetDefaultBackground());
kHorizontalFrame);
</programlisting>
<para>The class <emphasis role="bold"><code>TGCompositeFrame</code></emphasis> is the base class of all composite widgets as a menu bar, a list box, a combo box, etc. It subclasses <emphasis role="bold"><code>TGFrame</code></emphasis> and has in addition a layout manager and a list of child frames/widgets. There are two steps to do the design using a composite frame widget. First you put all widgets you need within this frame and assign them desired properties using <code>AddFrame(),</code> then you lay them out by the <code>Layout</code><code>()</code> method according to the assigned layout manager. The method <code>AddFrame()</code> creates an instance of <emphasis role="bold"><code>TGFrameElement</code></emphasis> class for every child widget of a composite frame. This class has three public data members: the child pointer, its layout hints, and a status variable showing if the child is visible or hidden. If no hints are specified, the default layout hints are used. Because the layout is very important part of any design we include a special section about layout management and layout hints. </para>
<para>The class <emphasis role="bold"><code>TGCompositeFrame</code></emphasis> is the base class of all composite widgets as a menu bar, a list box, a combo box, etc. It subclasses <emphasis role="bold"><code>TGFrame</code></emphasis> and has in addition a layout manager and a list of child frames/widgets. There are two steps to do the design using a composite frame widget. First you put all widgets you need within this frame and assign them desired properties using <code>AddFrame(),</code> then you lay them out by the <code>Layout()</code> method according to the assigned layout manager. The method <code>AddFrame()</code> creates an instance of <emphasis role="bold"><code>TGFrameElement</code></emphasis> class for every child widget of a composite frame. This class has three public data members: the child pointer, its layout hints, and a status variable showing if the child is visible or hidden. If no hints are specified, the default layout hints are used. Because the layout is very important part of any design we include a special section about layout management and layout hints. </para>
<para>You can set a layout manager for the composite frame via:</para>
<programlisting language="c++">compFrame-&gt;SetLayoutManager(TGLayoutManager *l);
......@@ -600,7 +600,7 @@ ULong_t back = GetDefaultBackground());
<programlisting language="c++">compFrame-&gt;RemoveFrame(TGFrame *f);
</programlisting>
<para>You can hide or show a child frame of a composite frame using the methods: <code>HideFrame</code><code>(TGFrame *f)</code> or <code>ShowFrame</code><code>(TGFrame *f).</code> You should call, for example <code>HideFrame(TGFrame *f),</code> only after the frames have been laid out and the sub windows of the composite frame have been mapped via method <code>MapSubwindows(),</code> i.e.</para>
<para>You can hide or show a child frame of a composite frame using the methods: <code>HideFrame(TGFrame *f)</code> or <code>ShowFrame(TGFrame *f).</code> You should call, for example <code>HideFrame(TGFrame *f),</code> only after the frames have been laid out and the sub windows of the composite frame have been mapped via method <code>MapSubwindows(),</code> i.e.</para>
<programlisting language="c++">frame-&gt;AddFrame(hFrame1,fLayout1);
frame-&gt;AddFrame(hFrame2,fLayout2);
......@@ -610,10 +610,10 @@ frame-&gt;HideFrame(hFrame2); <emphasis role="italic">// hides fram
frame-&gt;MapWindow(); <emphasis role="italic">// maps main frame</emphasis>
</programlisting>
<para>The state information about a child frame can be obtained from the methods <code>GetState</code><code>(TGframe *f)</code>, <code>IsArranged(TGFrame *f)</code>, and <code>IsVisible</code><code>(TGFrame *f)</code>. </para>
<para>The method <code>Cleanup</code><code>()</code> deletes all objects of the composite frame added via <code>AddFrame()</code>. All <emphasis role="bold"><code>TGFrameElement</code></emphasis> objects (frames and layout hints) must be unique, i.e. cannot be shared.</para>
<para>The state information about a child frame can be obtained from the methods <code>GetState(TGframe *f)</code>, <code>IsArranged(TGFrame *f)</code>, and <code>IsVisible(TGFrame *f)</code>. </para>
<para>The method <code>Cleanup()</code> deletes all objects of the composite frame added via <code>AddFrame()</code>. All <emphasis role="bold"><code>TGFrameElement</code></emphasis> objects (frames and layout hints) must be unique, i.e. cannot be shared.</para>
<para>We already mentioned that <emphasis role="bold"><code>TGMainFrame</code></emphasis> class defines top level windows interacting with the system window manager. It handles applications with a menu bar, toolbar, text entry fields and other widgets surrounding a central area (e.g. a canvas widget). It lays out a set of related widgets and provides the typical application main window behavior. As you can see from the Figure above, it inherits from <emphasis role="bold"><code>TGCompositeFrame</code></emphasis> and is inherited by <emphasis role="bold"><code>TGTransientFrame</code></emphasis> and several ROOT interface classes: <emphasis role="bold"><code>TViewerX3D</code></emphasis>,<emphasis role="bold"><code> TRootBrowser</code></emphasis>, <emphasis role="bold"><code>TRootCanvas</code></emphasis>, <emphasis role="bold"><code>TRootControlBar</code></emphasis>, <emphasis role="bold"><code>TTreeViewer.</code></emphasis></para>
<para>To fix the size of a top level window you have to use the method <emphasis role="bold"><code>TGMainFrame</code></emphasis><code>::SetWMSize</code><code>().</code> This call tells the Window Manager that it should not resize the window. The option <code>kFixedSize</code> works only for embedded frames like <emphasis role="bold"><code>TGCompositeFrame</code></emphasis> and derived classes (in combination with layout hints). </para>
<para>To fix the size of a top level window you have to use the method <emphasis role="bold"><code>TGMainFrame</code></emphasis><code>::SetWMSize().</code> This call tells the Window Manager that it should not resize the window. The option <code>kFixedSize</code> works only for embedded frames like <emphasis role="bold"><code>TGCompositeFrame</code></emphasis> and derived classes (in combination with layout hints). </para>
<para>The <emphasis role="bold"><code>TGVerticalFrame</code></emphasis> and <emphasis role="bold"><code>TGHorizontalFrame</code></emphasis> are composite frames that lay out their child frames in vertical or horizontal way in the same order as they were added and according to their hints preferences.</para>
<para>The <emphasis role="bold"><code>TGTransientFrame</code></emphasis> class defines transient windows that typically are used for dialogs. They extend and complete an interaction within a limited context. Always transient frames are displayed from another window or another dialog. They may appear because of a command button being activated or a menu item being selected. They may also present automatically when an additional input and the user attention are required by a certain condition. </para>
<para>The <emphasis role="bold"><code>TGGroupFrame</code></emphasis> class presents a very convenient frame which surrounds visually a group of logically connected widgets: radio buttons, related check boxes, two or more functionally related controls. </para>
......@@ -781,7 +781,7 @@ groupFrame-&gt;SetTitlePos(TGGroupFrame::kLeft);
<para>
<inlinemediaobject><imageobject><imagedata fileref="pictures/0200020B.jpg" width="307.25pt" depth="208.55pt"/></imageobject></inlinemediaobject>
</para>
<para>The signals/slot communication mechanism is an advanced object communication concept; it largely replaces the concept of callback functions to handle actions in GUI’s. Signals and slots are just like any object-oriented methods implemented in C++. The objects are the instances of classes that don’t know anything about each other. They interact and allow method calls of other object’s methods. The idea is simple: any object can send out (emit) a signal in certain situations saying that something happened. This is all it does to communicate and it does not know whether anything is interested in this information. On the other side there might be an object waiting for that signal and ready to react to it. This object disposes of special instruments to listen to the sent out signals. To have a communication we need a message transmission between the objects. In this simple example we use signals and slots. The code of the method <emphasis role="bold"><code>TGButton</code></emphasis><code>::Clicked</code><code>()</code> is:</para>
<para>The signals/slot communication mechanism is an advanced object communication concept; it largely replaces the concept of callback functions to handle actions in GUI’s. Signals and slots are just like any object-oriented methods implemented in C++. The objects are the instances of classes that don’t know anything about each other. They interact and allow method calls of other object’s methods. The idea is simple: any object can send out (emit) a signal in certain situations saying that something happened. This is all it does to communicate and it does not know whether anything is interested in this information. On the other side there might be an object waiting for that signal and ready to react to it. This object disposes of special instruments to listen to the sent out signals. To have a communication we need a message transmission between the objects. In this simple example we use signals and slots. The code of the method <emphasis role="bold"><code>TGButton</code></emphasis><code>::Clicked()</code> is:</para>
<programlisting language="c++">virtual void Clicked() { Emit("Clicked()"); } <emphasis role="italic">// *SIGNAL*</emphasis>
</programlisting>
......@@ -815,7 +815,7 @@ MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) {
<para>
<inlinemediaobject><imageobject><imagedata fileref="pictures/0200020C.jpg" width="207.95pt" depth="135.3pt"/></imageobject></inlinemediaobject>
</para>
<para>To benefit from this mechanism your classes must inherit from <emphasis role="bold"><code>TQObject</code></emphasis> or otherwise the class definition must start with <code>RQ_OBJECT</code><code>(“ClassName”) </code>macro. This macro allows the signals/slots communication mechanism to be applied between compiled and interpreted classes in an interactive ROOT session without having the class derive from <emphasis role="bold"><code>TQObject</code></emphasis>. Every signal method declaration is followed by a comment <code>“*SIGNAL*”.</code> Only instances of a class that defines a signal or instances of its subclasses can emit the signal. The ROOT implementation of a popular example presenting signals and slots is the next. Let’s have a minimal class declaration:</para>
<para>To benefit from this mechanism your classes must inherit from <emphasis role="bold"><code>TQObject</code></emphasis> or otherwise the class definition must start with <code>RQ_OBJECT(“ClassName”) </code>macro. This macro allows the signals/slots communication mechanism to be applied between compiled and interpreted classes in an interactive ROOT session without having the class derive from <emphasis role="bold"><code>TQObject</code></emphasis>. Every signal method declaration is followed by a comment <code>“*SIGNAL*”.</code> Only instances of a class that defines a signal or instances of its subclasses can emit the signal. The ROOT implementation of a popular example presenting signals and slots is the next. Let’s have a minimal class declaration:</para>
<programlisting language="c++">class MyClass {
private:
......@@ -850,7 +850,7 @@ public:
}
</programlisting>
<para>The line <code>Emit("SetValue(Int_t)",v)</code> activates the signal <code>SetValue(Int_t)</code> with argument v. You can use any of the methods <emphasis role="bold"><code>TQObject</code></emphasis><code>::Emit</code><code>(“full_method_name”,arguments)</code> to emit a signal. We create two instances of <code>MyClass</code> and connect them together: </para>
<para>The line <code>Emit("SetValue(Int_t)",v)</code> activates the signal <code>SetValue(Int_t)</code> with argument v. You can use any of the methods <emphasis role="bold"><code>TQObject</code></emphasis><code>::Emit(“full_method_name”,arguments)</code> to emit a signal. We create two instances of <code>MyClass</code> and connect them together: </para>
<programlisting language="c++">MyClass *objA = new MyClass();
MyClass *objB = new MyClass();
......@@ -862,7 +862,7 @@ objB-&gt;GetValue(); <emphasis role="italic">// the value is 79</emphas
<para>By calling the method <code>objA-&gt;Connect()</code>, <code>objA</code> connects its signal "<code>SetValue(Int_t)</code>" to the "<code>MyClass::SetValue(Int_t)</code>" method (slot) of <code>objB</code>. Next, when you call <code>objA-&gt;SetValue(79) </code>object <code>objA </code>emits a signal which <code>objB </code>receives and <code>objB-&gt;SetValue(79) </code>is invoked.</para>
<para>It is executed immediately, just like a normal function call. <code>objB</code> will emit the same signal in turn, but nobody is interested in this signal, since no slot has been connected to it. Signals are currently implemented for all ROOT GUI classes, event handlers (<emphasis role="bold"><code>TFileHandler</code></emphasis>, <emphasis role="bold"><code>TSignalHandler</code></emphasis>, etc.), timers (<emphasis role="bold"><code>TTimer)</code></emphasis> and pads (<emphasis role="bold"><code>TPad</code></emphasis>, <emphasis role="bold"><code>TCanvas</code></emphasis>, etc.). To find all defined signals you just do: <code>grep ‘*SIGNAL*’ $ROOTSYS/include/*.h</code></para>
<para>As a programmer you build the sender-receiver part of object connections using the <emphasis role="bold"><code>TQObject</code></emphasis><code>::Connect</code><code>()</code> method. You can connect one signal to many different slots. The slots will be activated in order they were connected to the signal. You can change this order using the methods <code>LowPriority</code><code>()</code> and <code>HightPriority</code><code>()</code> of <emphasis role="bold"><code>TQObject</code></emphasis>. Also, many signals can be connected to one slot of a particular object or a slot can be connected to a signal for all objects of a specific class. It is even possible to connect a signal directly to another signal – this will emit the second signal immediately after the first one is emitted. </para>
<para>As a programmer you build the sender-receiver part of object connections using the <emphasis role="bold"><code>TQObject</code></emphasis><code>::Connect()</code> method. You can connect one signal to many different slots. The slots will be activated in order they were connected to the signal. You can change this order using the methods <code>LowPriority()</code> and <code>HightPriority()</code> of <emphasis role="bold"><code>TQObject</code></emphasis>. Also, many signals can be connected to one slot of a particular object or a slot can be connected to a signal for all objects of a specific class. It is even possible to connect a signal directly to another signal – this will emit the second signal immediately after the first one is emitted. </para>
<para>All signals and slots are normal class methods and can take any number of arguments of any type. The common methods of <emphasis role="bold"><code>TQObject</code></emphasis> that activate a signal with any number and type of parameters are:</para>
<programlisting language="c++">Emit(signal_name,param);
......@@ -923,7 +923,7 @@ Connect(myButton, "Pressed()","TH1",hist, "Draw(="LEGO")");
</programlisting>
<para>As you see the parameter’s value is preceded by the equation symbol (=). </para>
<para>You have the possibility to destroy a signal/slot connection by using <code>Disconnect</code><code>()</code> methods. There are three ways to do this: </para>
<para>You have the possibility to destroy a signal/slot connection by using <code>Disconnect()</code> methods. There are three ways to do this: </para>
<para>1/ to destroy all connections to an object’s signals;</para>
<para>2/ to destroy all connections to a particular object’s signal; 3/ to detach an object from a specific receiver:</para>
......@@ -934,8 +934,8 @@ Disconnect(myObgect,0,myReceiver,0); <emphasis role="italic">// case 3</emp
<para>Three parameters of these methods could be replaced by 0. The meaning in these cases would be “any signal”, “any receiving object”, “any slot of the receiving object”, i.e. 0 is used as a wildcard. The sender parameter cannot be 0, because you can disconnect signals from one given object. If the signal parameter is 0, the receiver and the slot are disconnected from any signal. Giving the name of the signal you disconnect this signal. </para>
<para>In addition to all Qt features the ROOT version of signals/slots gives you the possibility to connect slots to a class. The slots will be executed every time the specified signal is emitted by any object of this class. A slot can have default arguments and it can be either a class method or stand-alone function (compiled or interpreted).</para>
<para>The method <emphasis role="bold"><code>TQObject</code></emphasis><code>::HasConnection</code><code>(signale_name)</code> checks if there is an object connected to this signal and returns true if it is the case.</para>
<para>Using <emphasis role="bold"><code>TQObject</code></emphasis><code>::NumberOfConnections</code><code>()</code>, <emphasis role="bold"><code>TQObject</code></emphasis><code>::NumberOfSignals</code><code>()</code> you can check how many signals or connections has the object.</para>
<para>The method <emphasis role="bold"><code>TQObject</code></emphasis><code>::HasConnection(signale_name)</code> checks if there is an object connected to this signal and returns true if it is the case.</para>
<para>Using <emphasis role="bold"><code>TQObject</code></emphasis><code>::NumberOfConnections()</code>, <emphasis role="bold"><code>TQObject</code></emphasis><code>::NumberOfSignals()</code> you can check how many signals or connections has the object.</para>
<para>The rules for using signals/slots mechanism in a standalone executable program do not differ from what was described previously. Let’s remind that</para>
<itemizedlist>
<listitem><para>a slot can be any class method with a generated CINT dictionary</para></listitem>
......@@ -1225,7 +1225,7 @@ fMenuBar-&gt;AddPopup("&amp;Help", fMenuHelp, fMBHelpLayout);
</programlisting>
<para>Using the method <emphasis role="bold"><code>TGMenuBar</code></emphasis><code>::AddPopup</code> we add three <emphasis role="bold"><code>TGPopupMenu</code></emphasis> objects to the menu bar <code>fMenuBar</code>. The first parameter is a hot string used by <emphasis role="bold"><code>TGMenuTitle</code></emphasis> object. When you add a popup menu to the menu bar, a <emphasis role="bold"><code>TGMenuTitle</code></emphasis> object is created by the menu bar. It is the name of the popup menu. A menu title should have a one-word name that reflects the purpose of all items within the corresponding popup menu. It should also have a defined character as its unique access key. The second parameter is the popup menu we would like to add. The third one is an object of <emphasis role="bold"><code>TGLayoutHints</code></emphasis> type that defines how the menu title will be laid out in the menu bar. In our example the <emphasis role="italic"><code>File</code></emphasis> and <code>Test</code> menus will be laid out to the left of the menu bar with 4 pixels distance in between, the <code>Help</code> menu – will be laid out to the right. </para>
<para>The menu classes provide a very flexible menu system: you can enable, disable, add or remove menu items dynamically. The method <code>HideEntry</code><code>(menuID)</code> hides the menu entry (the entry will not be shown in the popup menu). To enable a hidden entry you should call <code>EnableEntry</code><code>(menuID)</code> method. By default all entries are enabled. The method <code>DisableEntry</code><code>(menuID)</code> helps you to disable a menu entry – it will appear in sunken relieve. The <code>DeleteEntry</code><code>(menuID)</code> method will delete the specified entry from the menu. </para>
<para>The menu classes provide a very flexible menu system: you can enable, disable, add or remove menu items dynamically. The method <code>HideEntry(menuID)</code> hides the menu entry (the entry will not be shown in the popup menu). To enable a hidden entry you should call <code>EnableEntry(menuID)</code> method. By default all entries are enabled. The method <code>DisableEntry(menuID)</code> helps you to disable a menu entry – it will appear in sunken relieve. The <code>DeleteEntry(menuID)</code> method will delete the specified entry from the menu. </para>
<para>A few words about the menu design. A menu should be kept consistent and simple. All related items need to be in a popup menu. The cascade menus should be used judiciously. Try to limit them to one, maximum two levels. </para>
<para>There are some rules for naming the menu objects:</para>
<itemizedlist>
......@@ -1337,7 +1337,7 @@ parent-&gt;AddFrame(fListBox,new TGLayoutHints(kLHintsTop|kLHintsLeft,
5, 5, 5, 5));
</programlisting>
<para>We create the list box widget passing the parent window pointer and giving an ID number. Next we add entries with specified string and ID to the list box. Before adding the list box to its parent widget, it should be resized via <code>Resize</code><code>(width, height)</code> method. The list box width and height are in pixels. The default entry layout hints are <code>kLHintsExpandX | kLHintsTop</code>. If you want to add entries using different ones, call the method: </para>
<para>We create the list box widget passing the parent window pointer and giving an ID number. Next we add entries with specified string and ID to the list box. Before adding the list box to its parent widget, it should be resized via <code>Resize(width, height)</code> method. The list box width and height are in pixels. The default entry layout hints are <code>kLHintsExpandX | kLHintsTop</code>. If you want to add entries using different ones, call the method: </para>
<programlisting language="c++">TGListBox::AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints);
</programlisting>
......@@ -1496,7 +1496,7 @@ parent-&gt;AddFrame(icon,new TGLayoutHints(kLHintsLeft|kLHintsBottom,
<para>The <emphasis role="bold"><code>TGPicture</code></emphasis> objects are cached by <emphasis role="bold"><code>TGClient</code></emphasis> in order to keep the resource usage low and to improve the efficiency of the client-server windowing systems. <emphasis role="bold"><code>TGClient</code></emphasis> will check whether a pixmap with the same name was already loaded before to register a new picture object. If it finds it, it will return a pointer to the existing object. Also, it will increase the usage counter for the object. </para>
<para>All <emphasis role="bold"><code>TGPicture</code></emphasis> objects are managed by the class <emphasis role="bold"><code>TGPicturePool</code></emphasis>. <emphasis role="bold"><code>TGClient</code></emphasis> creates an object of this type upon initialization. Normally your application program does not deal directly with this class because all manipulations go through <emphasis role="bold"><code>TGClient</code></emphasis> class. </para>
<para>Once you have finished with using of the <emphasis role="bold"><code>TGPicture</code></emphasis> object, you should call the method <emphasis role="bold"><code>TGClient</code></emphasis><code>::FreePicture</code><code>(const TGPicture *pic)</code> to free it. The usage counter of the picture object will be decreased and when it reaches zero – the <emphasis role="bold"><code>TGPicture</code></emphasis> object will be deleted.</para>
<para>Once you have finished with using of the <emphasis role="bold"><code>TGPicture</code></emphasis> object, you should call the method <emphasis role="bold"><code>TGClient</code></emphasis><code>::FreePicture(const TGPicture *pic)</code> to free it. The usage counter of the picture object will be decreased and when it reaches zero – the <emphasis role="bold"><code>TGPicture</code></emphasis> object will be deleted.</para>
</sect2>
<sect2>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment