00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "TGedMarkerSelect.h"
00033 #include "TGPicture.h"
00034 #include "TGToolTip.h"
00035 #include "TGButton.h"
00036 #include "Riostream.h"
00037
00038 ClassImp(TGedMarkerSelect)
00039 ClassImp(TGedMarkerPopup)
00040
00041 struct MarkerDescription_t {
00042 const char* fFilename;
00043 const char* fName;
00044 Int_t fNumber;
00045 };
00046
00047 static MarkerDescription_t gMarkers[] = {
00048
00049 {"marker1.xpm", "1", 1},
00050 {"marker6.xpm", "6", 6},
00051 {"marker7.xpm", "7", 7},
00052 {"marker2.xpm", "2", 2},
00053 {"marker3.xpm", "3", 3},
00054 {"marker4.xpm", "4", 4},
00055 {"marker5.xpm", "5", 5},
00056 {"marker20.xpm", "20", 20},
00057 {"marker21.xpm", "21", 21},
00058 {"marker22.xpm", "22", 22},
00059 {"marker23.xpm", "23", 23},
00060 {"marker24.xpm", "24", 24},
00061 {"marker25.xpm", "25", 25},
00062 {"marker26.xpm", "26", 26},
00063 {"marker27.xpm", "27", 27},
00064 {"marker28.xpm", "28", 28},
00065 {"marker29.xpm", "29", 29},
00066 {"marker30.xpm", "30", 30},
00067 {0, 0, 0},
00068 };
00069
00070 static MarkerDescription_t* GetMarkerByNumber(Int_t number)
00071 {
00072 for (Int_t i = 0; gMarkers[i].fFilename != 0; i++) {
00073 if (gMarkers[i].fNumber == number)
00074 return &gMarkers[i];
00075 }
00076 return 0;
00077 }
00078
00079
00080 TGedMarkerPopup::TGedMarkerPopup(const TGWindow *p, const TGWindow *m, Style_t markerStyle)
00081 : TGedPopup(p, m, 30, 30, kDoubleBorder | kRaisedFrame | kOwnBackground,
00082 GetDefaultFrameBackground())
00083 {
00084
00085
00086 TGButton *b;
00087 fCurrentStyle = markerStyle;
00088
00089 Pixel_t white;
00090 gClient->GetColorByName("white", white);
00091 SetBackgroundColor(white);
00092
00093 SetLayoutManager(new TGTileLayout(this, 1));
00094
00095 for (int i = 0; gMarkers[i].fFilename != 0; i++) {
00096 AddFrame(b = new TGPictureButton(this, gMarkers[i].fFilename,
00097 gMarkers[i].fNumber, TGButton::GetDefaultGC()(), kSunkenFrame),
00098 new TGLayoutHints(kLHintsLeft, 14, 14, 14, 14));
00099 b->SetToolTipText(gMarkers[i].fName);
00100 }
00101
00102 Resize(65, 94);
00103 MapSubwindows();
00104 }
00105
00106
00107 TGedMarkerPopup::~TGedMarkerPopup()
00108 {
00109
00110
00111 TGFrameElement *el;
00112 TIter next(GetList());
00113 while ((el = (TGFrameElement *)next())) {
00114 if (el->fFrame->InheritsFrom(TGPictureButton::Class()))
00115 fClient->FreePicture(((TGPictureButton *)el->fFrame)->GetPicture());
00116 }
00117 Cleanup();
00118 }
00119
00120
00121 Bool_t TGedMarkerPopup::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
00122 {
00123
00124
00125 if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON) {
00126 SendMessage(fMsgWindow, MK_MSG(kC_MARKERSEL, kMAR_SELCHANGED), 0, parm1);
00127 EndPopup();
00128 }
00129
00130 if (parm2) {
00131
00132 }
00133
00134 return kTRUE;
00135 }
00136
00137
00138 TGedMarkerSelect::TGedMarkerSelect(const TGWindow *p, Style_t markerStyle, Int_t id)
00139 : TGedSelect(p, id)
00140 {
00141
00142
00143 fPicture = 0;
00144 SetPopup(new TGedMarkerPopup(gClient->GetDefaultRoot(), this, markerStyle));
00145 SetMarkerStyle(markerStyle);
00146
00147 }
00148
00149
00150 Bool_t TGedMarkerSelect::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
00151 {
00152
00153
00154 if (GET_MSG(msg) == kC_MARKERSEL && GET_SUBMSG(msg) == kMAR_SELCHANGED) {
00155 SetMarkerStyle(parm2);
00156 parm1 = (Long_t)fWidgetId;
00157 SendMessage(fMsgWindow, MK_MSG(kC_MARKERSEL, kMAR_SELCHANGED),
00158 parm1, parm2);
00159 }
00160
00161 return kTRUE;
00162 }
00163
00164
00165 void TGedMarkerSelect::DoRedraw()
00166 {
00167
00168
00169 TGedSelect::DoRedraw();
00170
00171 Int_t x, y;
00172 UInt_t w, h;
00173
00174 if (IsEnabled()) {
00175
00176
00177 x = fBorderWidth + 2;
00178 y = fBorderWidth + 2;
00179 h = fHeight - (fBorderWidth * 2) - 4;
00180 w = h;
00181 if (fState == kButtonDown) {
00182 ++x; ++y;
00183 }
00184 gVirtualX->DrawRectangle(fId, GetShadowGC()(), x, y, w - 1, h - 1);
00185
00186 if (fPicture != 0) fPicture->Draw(fId, fDrawGC->GetGC(), x + 1, y + 1);
00187 } else {
00188 x = fBorderWidth + 2;
00189 y = fBorderWidth + 2;
00190 w = 42;
00191 h = fHeight - (fBorderWidth * 2) - 4;
00192 Draw3dRectangle(kSunkenFrame, x, y, w, h);
00193 }
00194 }
00195
00196
00197 void TGedMarkerSelect::SetMarkerStyle(Style_t markerStyle)
00198 {
00199
00200
00201 fMarkerStyle = markerStyle;
00202 gClient->NeedRedraw(this);
00203
00204 if (fPicture) {
00205 gClient->FreePicture(fPicture);
00206 fPicture = 0;
00207 }
00208
00209 MarkerDescription_t *md = GetMarkerByNumber(fMarkerStyle);
00210
00211 if (md) fPicture = gClient->GetPicture(md->fFilename);
00212
00213 MarkerSelected(fMarkerStyle);
00214 }
00215
00216
00217 void TGedMarkerSelect::SavePrimitive(ostream &out, Option_t * )
00218 {
00219
00220
00221 out <<" TGedMarkerSelect *";
00222 out << GetName() << " = new TGedMarkerSelect(" << fParent->GetName()
00223 << "," << fMarkerStyle << "," << WidgetId() << ");" << endl;
00224 }