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
46
48 const char* fFilename; // xpm file name
49 const char* fName; // type number for tooltip
50 Int_t fNumber; // marker type number
51};
52
54
55 {"marker1.xpm", "1", 1},
56 {"marker6.xpm", "6", 6},
57 {"marker7.xpm", "7", 7},
58 {"marker2.xpm", "2", 2},
59 {"marker3.xpm", "3", 3},
60 {"marker4.xpm", "4", 4},
61 {"marker5.xpm", "5", 5},
62 {"marker20.xpm", "20", 20},
63 {"marker21.xpm", "21", 21},
64 {"marker22.xpm", "22", 22},
65 {"marker23.xpm", "23", 23},
66 {"marker24.xpm", "24", 24},
67 {"marker25.xpm", "25", 25},
68 {"marker26.xpm", "26", 26},
69 {"marker27.xpm", "27", 27},
70 {"marker28.xpm", "28", 28},
71 {"marker29.xpm", "29", 29},
72 {"marker30.xpm", "30", 30},
73 {0, 0, 0},
74};
75
77{
78 for (Int_t i = 0; gMarkers[i].fFilename != 0; i++) {
79 if (gMarkers[i].fNumber == number)
80 return &gMarkers[i];
81 }
82 return 0;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Create marker popup window.
87
90 GetDefaultFrameBackground())
91{
92 TGButton *b;
93 fCurrentStyle = markerStyle;
94
95 Pixel_t white;
96 gClient->GetColorByName("white", white); // white background
97 SetBackgroundColor(white);
98
99 SetLayoutManager(new TGTileLayout(this, 1));
100
101 for (int i = 0; gMarkers[i].fFilename != 0; i++) {
102 AddFrame(b = new TGPictureButton(this, gMarkers[i].fFilename,
104 new TGLayoutHints(kLHintsLeft, 14, 14, 14, 14));
105 b->SetToolTipText(gMarkers[i].fName);
106 }
107
108 Resize(65, 94);
110}
111
112////////////////////////////////////////////////////////////////////////////////
113/// Destructor.
114
116{
117 TGFrameElement *el;
118 TIter next(GetList());
119 while ((el = (TGFrameElement *)next())) {
121 fClient->FreePicture(((TGPictureButton *)el->fFrame)->GetPicture());
122 }
123 Cleanup();
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Process messages generated by the marker popup window.
128
130{
131 if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON) {
133 EndPopup();
134 }
135
136 if (parm2) {
137 // no warning
138 }
139
140 return kTRUE;
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// Create and show marker popup window.
145
147 : TGedSelect(p, id)
148{
149 fPicture = 0;
150 SetPopup(new TGedMarkerPopup(gClient->GetDefaultRoot(), this, markerStyle));
151 SetMarkerStyle(markerStyle);
152
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Process messages according to the user input.
157
159{
160 if (GET_MSG(msg) == kC_MARKERSEL && GET_SUBMSG(msg) == kMAR_SELCHANGED) {
161 SetMarkerStyle(parm2);
162 parm1 = (Longptr_t)fWidgetId;
164 parm1, parm2);
165 }
166
167 return kTRUE;
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Draw selected marker type as current one.
172
174{
176
177 Int_t x, y;
178 UInt_t w, h;
179
180 if (IsEnabled()) {
181 // pattern rectangle
182
183 x = fBorderWidth + 2;
184 y = fBorderWidth + 2; // 1;
185 h = fHeight - (fBorderWidth * 2) - 4; // -3; // 14
186 w = h;
187 if (fState == kButtonDown) {
188 ++x; ++y;
189 }
190 gVirtualX->DrawRectangle(fId, GetShadowGC()(), x, y, w - 1, h - 1);
191
192 if (fPicture != 0) fPicture->Draw(fId, fDrawGC->GetGC(), x + 1, y + 1);
193 } else { // sunken rectangle
194 x = fBorderWidth + 2;
195 y = fBorderWidth + 2; // 1;
196 w = 42;
197 h = fHeight - (fBorderWidth * 2) - 4; // 3;
199 }
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Set marker.
204
206{
207 fMarkerStyle = markerStyle;
208 gClient->NeedRedraw(this);
209
210 if (fPicture) {
211 gClient->FreePicture(fPicture);
212 fPicture = 0;
213 }
214
216
217 if (md) fPicture = gClient->GetPicture(md->fFilename);
218
220}
221
222////////////////////////////////////////////////////////////////////////////////
223/// Save the pattern select widget as a C++ statement(s) on output stream out
224
225void TGedMarkerSelect::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
226{
227 out <<" TGedMarkerSelect *";
228 out << GetName() << " = new TGedMarkerSelect(" << fParent->GetName()
229 << "," << fMarkerStyle << "," << WidgetId() << ");" << std::endl;
230}
@ 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
Definition RtypesCore.h:89
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
@ 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 TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t SetMarkerStyle
static MarkerDescription_t * GetMarkerByNumber(Int_t number)
static MarkerDescription_t gMarkers[]
#define gVirtualX
Definition TVirtualX.h:338
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:470
EButtonState fState
button state
Definition TGButton.h:75
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:308
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:1000
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
TGFrame * fFrame
Definition TGLayout.h:112
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
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:357
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:312
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
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()
void Draw(Option_t *="") override
Default Draw method for all objects.
Definition TGPicture.h:46
Pixmap_t GetPicture() const
Definition TGPicture.h:54
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:336
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.
The TGedMarkerSelect widget is a button showing selected marker and a little down arrow.
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)
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TMarker m
Definition textangle.C:8