38 ClassImp(TGedMarkerSelect);
39 ClassImp(TGedMarkerPopup);
41 struct MarkerDescription_t {
42 const char* fFilename;
47 static MarkerDescription_t gMarkers[] = {
49 {
"marker1.xpm",
"1", 1},
50 {
"marker6.xpm",
"6", 6},
51 {
"marker7.xpm",
"7", 7},
52 {
"marker2.xpm",
"2", 2},
53 {
"marker3.xpm",
"3", 3},
54 {
"marker4.xpm",
"4", 4},
55 {
"marker5.xpm",
"5", 5},
56 {
"marker20.xpm",
"20", 20},
57 {
"marker21.xpm",
"21", 21},
58 {
"marker22.xpm",
"22", 22},
59 {
"marker23.xpm",
"23", 23},
60 {
"marker24.xpm",
"24", 24},
61 {
"marker25.xpm",
"25", 25},
62 {
"marker26.xpm",
"26", 26},
63 {
"marker27.xpm",
"27", 27},
64 {
"marker28.xpm",
"28", 28},
65 {
"marker29.xpm",
"29", 29},
66 {
"marker30.xpm",
"30", 30},
70 static MarkerDescription_t* GetMarkerByNumber(Int_t number)
72 for (Int_t i = 0; gMarkers[i].fFilename != 0; i++) {
73 if (gMarkers[i].fNumber == number)
82 TGedMarkerPopup::TGedMarkerPopup(
const TGWindow *p,
const TGWindow *m, Style_t markerStyle)
83 : TGedPopup(p, m, 30, 30, kDoubleBorder | kRaisedFrame | kOwnBackground,
84 GetDefaultFrameBackground())
87 fCurrentStyle = markerStyle;
90 gClient->GetColorByName(
"white", white);
91 SetBackgroundColor(white);
93 SetLayoutManager(
new TGTileLayout(
this, 1));
95 for (
int i = 0; gMarkers[i].fFilename != 0; i++) {
96 AddFrame(b =
new TGPictureButton(
this, gMarkers[i].fFilename,
97 gMarkers[i].fNumber, TGButton::GetDefaultGC()(), kSunkenFrame),
98 new TGLayoutHints(kLHintsLeft, 14, 14, 14, 14));
99 b->SetToolTipText(gMarkers[i].fName);
109 TGedMarkerPopup::~TGedMarkerPopup()
112 TIter next(GetList());
113 while ((el = (TGFrameElement *)next())) {
114 if (el->fFrame->InheritsFrom(TGPictureButton::Class()))
115 fClient->FreePicture(((TGPictureButton *)el->fFrame)->GetPicture());
123 Bool_t TGedMarkerPopup::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
125 if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON) {
126 SendMessage(fMsgWindow, MK_MSG(kC_MARKERSEL, kMAR_SELCHANGED), 0, parm1);
140 TGedMarkerSelect::TGedMarkerSelect(
const TGWindow *p, Style_t markerStyle, Int_t
id)
144 SetPopup(
new TGedMarkerPopup(gClient->GetDefaultRoot(),
this, markerStyle));
145 SetMarkerStyle(markerStyle);
152 Bool_t TGedMarkerSelect::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
154 if (GET_MSG(msg) == kC_MARKERSEL && GET_SUBMSG(msg) == kMAR_SELCHANGED) {
155 SetMarkerStyle(parm2);
156 parm1 = (Long_t)fWidgetId;
157 SendMessage(fMsgWindow, MK_MSG(kC_MARKERSEL, kMAR_SELCHANGED),
167 void TGedMarkerSelect::DoRedraw()
169 TGedSelect::DoRedraw();
177 x = fBorderWidth + 2;
178 y = fBorderWidth + 2;
179 h = fHeight - (fBorderWidth * 2) - 4;
181 if (fState == kButtonDown) {
184 gVirtualX->DrawRectangle(fId, GetShadowGC()(), x, y, w - 1, h - 1);
186 if (fPicture != 0) fPicture->Draw(fId, fDrawGC->GetGC(), x + 1, y + 1);
188 x = fBorderWidth + 2;
189 y = fBorderWidth + 2;
191 h = fHeight - (fBorderWidth * 2) - 4;
192 Draw3dRectangle(kSunkenFrame, x, y, w, h);
199 void TGedMarkerSelect::SetMarkerStyle(Style_t markerStyle)
201 fMarkerStyle = markerStyle;
202 gClient->NeedRedraw(
this);
205 gClient->FreePicture(fPicture);
209 MarkerDescription_t *md = GetMarkerByNumber(fMarkerStyle);
211 if (md) fPicture = gClient->GetPicture(md->fFilename);
213 MarkerSelected(fMarkerStyle);
219 void TGedMarkerSelect::SavePrimitive(std::ostream &out, Option_t * )
221 out <<
" TGedMarkerSelect *";
222 out << GetName() <<
" = new TGedMarkerSelect(" << fParent->GetName()
223 <<
"," << fMarkerStyle <<
"," << WidgetId() <<
");" << std::endl;