Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGedMarkerSelect.cxx
Go to the documentation of this file.
1// @(#)root/ged:$Id$
2// Author: Marek Biskup, Ilka Antcheva 22/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
13
14/** \class TGedMarkerSelect
15 \ingroup ged
16
17The TGedMarkerSelect widget is a button showing selected marker
18and a little down arrow. When clicked on the arrow the
19TGedMarkerPopup pops up.
20
21Selecting a marker in this widget will generate the event:
22kC_MARKERSEL, kMAR_SELCHANGED, widget id, style.
23
24and the signal:
25MarkerSelected(Style_t marker)
26
27*/
28
29/** \class TGedMarkerPopup
30 \ingroup ged
31
32The TGedMarkerPopup is a popup containing buttons to
33select marker style.
34
35*/
36
37#include "TGedMarkerSelect.h"
38#include "TGPicture.h"
39#include "TGButton.h"
40#include "TVirtualX.h"
41
42#include <iostream>
43
44
46 const char* fFilename; // xpm file name
47 const char* fName; // type number for tooltip
48 Int_t fNumber; // marker type number
49};
50
52
53 {"marker1.xpm", "1", 1},
54 {"marker6.xpm", "6", 6},
55 {"marker7.xpm", "7", 7},
56 {"marker2.xpm", "2", 2},
57 {"marker3.xpm", "3", 3},
58 {"marker4.xpm", "4", 4},
59 {"marker5.xpm", "5", 5},
60 {"marker20.xpm", "20", 20},
61 {"marker21.xpm", "21", 21},
62 {"marker22.xpm", "22", 22},
63 {"marker23.xpm", "23", 23},
64 {"marker24.xpm", "24", 24},
65 {"marker25.xpm", "25", 25},
66 {"marker26.xpm", "26", 26},
67 {"marker27.xpm", "27", 27},
68 {"marker28.xpm", "28", 28},
69 {"marker29.xpm", "29", 29},
70 {"marker30.xpm", "30", 30},
71 {0, 0, 0},
72};
73
75{
76 for (Int_t i = 0; gMarkers[i].fFilename != 0; i++) {
77 if (gMarkers[i].fNumber == number)
78 return &gMarkers[i];
79 }
80 return 0;
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Create marker popup window.
85
88 GetDefaultFrameBackground())
89{
90 TGButton *b;
92
94 gClient->GetColorByName("white", white); // white background
96
97 SetLayoutManager(new TGTileLayout(this, 1));
98
99 for (int i = 0; gMarkers[i].fFilename != 0; i++) {
100 AddFrame(b = new TGPictureButton(this, gMarkers[i].fFilename,
102 new TGLayoutHints(kLHintsLeft, 14, 14, 14, 14));
103 b->SetToolTipText(gMarkers[i].fName);
104 }
105
106 Resize(65, 94);
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Destructor.
112
114{
116 TIter next(GetList());
117 while ((el = (TGFrameElement *)next())) {
118 if (el->fFrame->InheritsFrom(TGPictureButton::Class()))
119 fClient->FreePicture(((TGPictureButton *)el->fFrame)->GetPicture());
120 }
121 Cleanup();
122}
123
124////////////////////////////////////////////////////////////////////////////////
125/// Process messages generated by the marker popup window.
126
128{
131 EndPopup();
132 }
133
134 if (parm2) {
135 // no warning
136 }
137
138 return kTRUE;
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Create and show marker popup window.
143
145 : TGedSelect(p, id)
146{
147 fPicture = 0;
148 SetPopup(new TGedMarkerPopup(gClient->GetDefaultRoot(), this, markerStyle));
150
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Process messages according to the user input.
155
167
168////////////////////////////////////////////////////////////////////////////////
169/// Draw selected marker type as current one.
170
172{
174
175 Int_t x, y;
176 UInt_t w, h;
177
178 if (IsEnabled()) {
179 // pattern rectangle
180
181 x = fBorderWidth + 2;
182 y = fBorderWidth + 2; // 1;
183 h = fHeight - (fBorderWidth * 2) - 4; // -3; // 14
184 w = h;
185 if (fState == kButtonDown) {
186 ++x; ++y;
187 }
188 gVirtualX->DrawRectangle(fId, GetShadowGC()(), x, y, w - 1, h - 1);
189
190 if (fPicture != 0) fPicture->Draw(fId, fDrawGC->GetGC(), x + 1, y + 1);
191 } else { // sunken rectangle
192 x = fBorderWidth + 2;
193 y = fBorderWidth + 2; // 1;
194 w = 42;
195 h = fHeight - (fBorderWidth * 2) - 4; // 3;
197 }
198}
199
200////////////////////////////////////////////////////////////////////////////////
201/// Set marker.
202
204{
206 gClient->NeedRedraw(this);
207
208 if (fPicture) {
209 gClient->FreePicture(fPicture);
210 fPicture = 0;
211 }
212
214
215 if (md) fPicture = gClient->GetPicture(md->fFilename);
216
218}
219
220////////////////////////////////////////////////////////////////////////////////
221/// Save the pattern select widget as a C++ statement(s) on output stream out
222
223void TGedMarkerSelect::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
224{
225 out <<" TGedMarkerSelect *";
226 out << GetName() << " = new TGedMarkerSelect(" << fParent->GetName()
227 << "," << fMarkerStyle << "," << WidgetId() << ");" << std::endl;
228}
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
@ kOwnBackground
Definition GuiTypes.h:391
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define b(i)
Definition RSha256.hxx:100
#define h(i)
Definition RSha256.hxx:106
short Style_t
Style number (short)
Definition RtypesCore.h:96
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kButtonDown
Definition TGButton.h:54
#define gClient
Definition TGClient.h:157
@ kLHintsLeft
Definition TGLayout.h:24
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t SetMarkerStyle
static MarkerDescription_t * GetMarkerByNumber(Int_t number)
static MarkerDescription_t gMarkers[]
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kC_MARKERSEL
@ kC_COMMAND
@ kCM_BUTTON
@ kMAR_SELCHANGED
Int_t GET_SUBMSG(Long_t val)
A button abstract base class.
Definition TGButton.h:68
static const TGGC & GetDefaultGC()
Return default graphics context.
Definition TGButton.cxx:464
EButtonState fState
button state
Definition TGButton.h:75
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:992
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:959
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual void Draw3dRectangle(UInt_t type, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw 3D rectangle on the frame border.
Definition TGFrame.cxx:349
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:304
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
GContext_t GetGC() const
Definition TGGC.h:41
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
Yield an action as soon as it is clicked.
Definition TGButton.h:228
static TClass * Class()
This is a layout manager for the TGListView widget.
Definition TGLayout.h:303
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
Bool_t IsEnabled() const
Definition TGWidget.h:69
Int_t WidgetId() const
Definition TGWidget.h:68
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
TString fName
name of the window used in SavePrimitive()
Definition TGWindow.h:30
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
The TGedMarkerPopup is a popup containing buttons to select marker style.
TGedMarkerPopup(const TGWindow *p, const TGWindow *m, Style_t markerStyle)
Create marker popup window.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages generated by the marker popup window.
~TGedMarkerPopup() override
Destructor.
void SetMarkerStyle(Style_t pattern)
Set marker.
Style_t fMarkerStyle
marker style
void SavePrimitive(std::ostream &out, Option_t *="") override
Save the pattern select widget as a C++ statement(s) on output stream out.
void DoRedraw() override
Draw selected marker type as current one.
const TGPicture * fPicture
image used for popup window
virtual void MarkerSelected(Style_t marker=0)
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process messages according to the user input.
TGedMarkerSelect(const TGWindow *p, Style_t markerStyle, Int_t id)
Create and show marker popup window.
is a popup window.
void EndPopup()
Ungrab pointer and unmap popup window.
const TGWindow * fMsgWindow
is button that shows popup window when clicked.
void DoRedraw() override
Draw separator and arrow.
virtual void SetPopup(TGedPopup *p)
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TMarker m
Definition textangle.C:8