File indexing completed on 2025-01-18 10:12:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGMdiDecorFrame
0013 #define ROOT_TGMdiDecorFrame
0014
0015
0016 #include "TGFrame.h"
0017 #include "TGMenu.h"
0018 #include "TGButton.h"
0019 #include "TGIcon.h"
0020 #include "TGLabel.h"
0021 #include "TGFont.h"
0022 #include "TGMdiMainFrame.h"
0023 #include "TGMdiFrame.h"
0024
0025
0026
0027 enum EMdiResizerPlacement {
0028 kMdiResizerTop = 1,
0029 kMdiResizerBottom = 2,
0030 kMdiResizerLeft = 4,
0031 kMdiResizerRight = 8
0032 };
0033
0034
0035 class TGMdiMainFrame;
0036 class TGMdiDecorFrame;
0037 class TGMdiFrame;
0038 class TGMdiTitleBar;
0039 class TGMdiTitleIcon;
0040 class TGMdiButtons;
0041
0042
0043
0044
0045 class TGMdiWinResizer : public TGFrame, public TGWidget {
0046
0047 friend class TGMdiMainFrame;
0048
0049 protected:
0050 const TGWindow *fMdiWin;
0051 Int_t fWinX, fWinY, fWinW, fWinH;
0052 Int_t fOldX, fOldY, fOldW, fOldH;
0053 Int_t fNewX, fNewY, fNewW, fNewH;
0054 Int_t fMinW, fMinH;
0055 Int_t fMdiOptions;
0056 Int_t fPos;
0057 Int_t fX0, fY0;
0058 Bool_t fLeftButPressed, fRightButPressed, fMidButPressed;
0059
0060 const TGGC *fBoxGC;
0061 Int_t fLineW;
0062
0063 void MoveResizeIt();
0064 void DrawBox(Int_t x, Int_t y, UInt_t width, UInt_t height);
0065
0066 public:
0067 TGMdiWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos,
0068 const TGGC *boxGC, Int_t linew,
0069 Int_t mdioptions = kMdiDefaultResizeMode,
0070 Int_t w = 1, Int_t h = 1, UInt_t options = kOwnBackground);
0071
0072 Bool_t HandleButton(Event_t *event) override;
0073 void DrawBorder() override {}
0074
0075 void SetResizeMode(Int_t mode) { fMdiOptions = mode; }
0076 void SetMinSize(Int_t w = 50, Int_t h = 20) { fMinW = w; fMinH = h; }
0077
0078 ClassDefOverride(TGMdiWinResizer, 0)
0079 };
0080
0081
0082 class TGMdiVerticalWinResizer : public TGMdiWinResizer {
0083
0084 public:
0085 TGMdiVerticalWinResizer(const TGWindow *p, const TGWindow *mdiwin,
0086 Int_t pos, const TGGC *boxGC, Int_t linew,
0087 Int_t mdioptions = kMdiDefaultResizeMode,
0088 Int_t w = 4, Int_t h = 5);
0089
0090 Bool_t HandleMotion(Event_t *event) override;
0091 void DrawBorder() override;
0092
0093 ClassDefOverride(TGMdiVerticalWinResizer, 0)
0094 };
0095
0096
0097 class TGMdiHorizontalWinResizer : public TGMdiWinResizer {
0098
0099 public:
0100 TGMdiHorizontalWinResizer(const TGWindow *p, const TGWindow *mdiwin,
0101 Int_t pos, const TGGC *boxGC, Int_t linew,
0102 Int_t mdioptions = kMdiDefaultResizeMode,
0103 Int_t w = 5, Int_t h = 4);
0104
0105 Bool_t HandleMotion(Event_t *event) override;
0106 void DrawBorder() override;
0107
0108 ClassDefOverride(TGMdiHorizontalWinResizer, 0)
0109 };
0110
0111
0112 class TGMdiCornerWinResizer : public TGMdiWinResizer {
0113
0114 public:
0115 TGMdiCornerWinResizer(const TGWindow *p, const TGWindow *mdiwin,
0116 Int_t pos, const TGGC *boxGC, Int_t linew,
0117 Int_t mdioptions = kMdiDefaultResizeMode,
0118 Int_t w = 20, Int_t h = 20);
0119
0120 Bool_t HandleMotion(Event_t *event) override;
0121 void DrawBorder() override;
0122
0123 ClassDefOverride(TGMdiCornerWinResizer, 0)
0124 };
0125
0126
0127
0128
0129 class TGMdiButtons : public TGCompositeFrame {
0130
0131 friend class TGMdiTitleBar;
0132
0133 protected:
0134 TGPictureButton *fButton[5];
0135 TGLayoutHints *fDefaultHint, *fCloseHint;
0136 const TGWindow *fMsgWindow;
0137
0138 public:
0139 TGMdiButtons(const TGWindow *p, const TGWindow *titlebar);
0140 ~TGMdiButtons() override;
0141
0142 TGPictureButton *GetButton(Int_t no) const { return fButton[no]; }
0143
0144 ClassDefOverride(TGMdiButtons, 0)
0145 };
0146
0147
0148
0149
0150 class TGMdiTitleIcon : public TGIcon {
0151
0152 friend class TGMdiFrame;
0153 friend class TGMdiTitleBar;
0154
0155 protected:
0156 const TGWindow *fMsgWindow;
0157 TGPopupMenu *fPopup;
0158
0159 void DoRedraw() override;
0160
0161 public:
0162 TGMdiTitleIcon(const TGWindow *p, const TGWindow *titlebar,
0163 const TGPicture *pic, Int_t w, Int_t h);
0164 ~TGMdiTitleIcon() override;
0165
0166 Bool_t HandleDoubleClick(Event_t *event) override;
0167 Bool_t HandleButton(Event_t *event) override;
0168 TGPopupMenu *GetPopup() const { return fPopup; }
0169
0170 ClassDefOverride(TGMdiTitleIcon, 0)
0171 };
0172
0173
0174
0175
0176 class TGMdiTitleBar : public TGCompositeFrame {
0177
0178 friend class TGMdiDecorFrame;
0179 friend class TGMdiMainFrame;
0180
0181 protected:
0182 const TGWindow *fMdiWin;
0183 TGMdiButtons *fButtons;
0184 TGMdiTitleIcon *fWinIcon;
0185 TGLabel *fWinName;
0186 TGCompositeFrame *fLFrame, *fMFrame,*fRFrame;
0187 TGLayoutHints *fLHint, *fLeftHint, *fMiddleHint, *fRightHint;
0188 Int_t fX0, fY0;
0189 Bool_t fLeftButPressed, fRightButPressed, fMidButPressed;
0190
0191 TGMdiTitleBar(const TGWindow *p, const TGWindow *mdiwin,
0192 const char *name = "Untitled");
0193 void LayoutButtons(UInt_t buttonmask, Bool_t isMinimized,
0194 Bool_t isMaximized);
0195
0196 void AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons);
0197 void RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons);
0198
0199 public:
0200 ~TGMdiTitleBar() override;
0201
0202 Bool_t HandleButton(Event_t *event) override;
0203 Bool_t HandleDoubleClick(Event_t *event) override;
0204 Bool_t HandleMotion(Event_t *event) override;
0205 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0206
0207 void SetTitleBarColors(UInt_t fore, UInt_t back, TGFont *f);
0208 TGMdiButtons *GetButtons() const { return fButtons; }
0209 TGMdiTitleIcon *GetWinIcon() const { return fWinIcon; }
0210 TGLabel *GetWinName() const { return fWinName; }
0211 Int_t GetX0() { return fX0; }
0212 Int_t GetY0() { return fY0; }
0213 Bool_t IsLeftButPressed() { return fLeftButPressed; }
0214 Bool_t IsRightButPressed() { return fRightButPressed; }
0215 Bool_t IsMidButPressed() { return fMidButPressed; }
0216
0217 void SetX0(Int_t x0) { fX0 = x0; }
0218 void SetY0(Int_t y0) { fY0 = y0; }
0219 void SetLeftButPressed(Bool_t press = kTRUE) { fLeftButPressed = press; }
0220 void SetRightButPressed(Bool_t press = kTRUE) { fRightButPressed= press; }
0221 void SetMidButPressed(Bool_t press = kTRUE) { fMidButPressed = press; }
0222
0223 ClassDefOverride(TGMdiTitleBar, 0)
0224 };
0225
0226
0227
0228
0229 class TGMdiDecorFrame : public TGCompositeFrame {
0230
0231 friend class TGMdiMainFrame;
0232
0233 protected:
0234 Int_t fPreResizeX, fPreResizeY;
0235 Int_t fPreResizeWidth, fPreResizeHeight;
0236 Int_t fMinimizedX, fMinimizedY;
0237 Bool_t fIsMinimized, fIsMaximized;
0238 Bool_t fMinimizedUserPlacement;
0239 Bool_t fIsCurrent;
0240
0241 TGMdiFrame *fFrame;
0242 TGMdiMainFrame *fMdiMainFrame;
0243
0244 TGMdiVerticalWinResizer *fUpperHR, *fLowerHR;
0245 TGMdiCornerWinResizer *fUpperLeftCR, *fLowerLeftCR;
0246 TGMdiCornerWinResizer *fUpperRightCR, *fLowerRightCR;
0247 TGMdiHorizontalWinResizer *fLeftVR, *fRightVR;
0248 TGLayoutHints *fLHint, *fExpandHint;
0249
0250 ULong_t fButtonMask;
0251 TGMdiTitleBar *fTitlebar;
0252
0253 public:
0254 enum {
0255
0256 kMdiBorderWidth = 5
0257 };
0258
0259 TGMdiDecorFrame(TGMdiMainFrame *main, TGMdiFrame *frame, Int_t w, Int_t h,
0260 const TGGC *boxGC, UInt_t options = 0,
0261 Pixel_t back = GetDefaultFrameBackground());
0262 ~TGMdiDecorFrame() override;
0263
0264 Bool_t HandleButton(Event_t *event) override;
0265 Bool_t HandleConfigureNotify(Event_t *event) override;
0266
0267 virtual Int_t CloseWindow() { return fFrame->CloseWindow(); }
0268 void Layout() override;
0269
0270 void Move(Int_t x, Int_t y) override;
0271 void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h) override;
0272
0273 void SetMdiButtons(ULong_t buttons);
0274 ULong_t GetMdiButtons() const { return fButtonMask; }
0275
0276 void SetResizeMode(Int_t mode = kMdiDefaultResizeMode);
0277
0278 void SetWindowName(const char *name) override;
0279 void SetWindowIcon(const TGPicture *pic);
0280 const char *GetWindowName() {
0281 return (const char *)fTitlebar->GetWinName()->GetText()->GetString();
0282 }
0283 const TGPicture *GetWindowIcon() { return fTitlebar->GetWinIcon()->GetPicture(); }
0284 Bool_t IsCurrent() const { return fIsCurrent; }
0285 Bool_t IsMinimized() const { return fIsMinimized; }
0286 Bool_t IsMaximized() const { return fIsMaximized; }
0287 Int_t GetPreResizeX() const { return fPreResizeX; }
0288 Int_t GetPreResizeY() const { return fPreResizeY; }
0289 Int_t GetPreResizeWidth() const { return fPreResizeWidth; }
0290 Int_t GetPreResizeHeight() const { return fPreResizeHeight; }
0291 Int_t GetMinimizedX() const { return fMinimizedX; }
0292 Int_t GetMinimizedY() const { return fMinimizedY; }
0293 Bool_t GetMinUserPlacement() const { return fMinimizedUserPlacement; }
0294
0295 void SetCurrent(Bool_t cur = kTRUE) {fIsCurrent = cur; }
0296 void SetDecorBorderWidth(Int_t bw);
0297 void SetPreResizeX(Int_t x) { fPreResizeX = x; }
0298 void SetPreResizeY(Int_t y) { fPreResizeY = y; }
0299 void SetPreResizeWidth(Int_t w) { fPreResizeWidth = w; }
0300 void SetPreResizeHeight(Int_t h) { fPreResizeHeight = h; }
0301 void SetMinimizedX(Int_t x) { fMinimizedX = x; }
0302 void SetMinimizedY(Int_t y) { fMinimizedY = y; }
0303 void Minimize(Bool_t min = kTRUE) { fIsMinimized = min; }
0304 void Maximize(Bool_t max = kTRUE) { fIsMaximized = max; }
0305 void SetMinUserPlacement(Bool_t place = kTRUE) { fMinimizedUserPlacement = place; }
0306
0307 TGMdiFrame *GetMdiFrame() const { return fFrame; }
0308 TGMdiTitleBar *GetTitleBar() const { return fTitlebar; }
0309
0310 TGMdiVerticalWinResizer *GetUpperHR() const { return fUpperHR; }
0311 TGMdiVerticalWinResizer *GetLowerHR() const { return fLowerHR; }
0312 TGMdiCornerWinResizer *GetUpperLeftCR() const { return fUpperLeftCR; }
0313 TGMdiCornerWinResizer *GetLowerLeftCR() const { return fLowerLeftCR; }
0314 TGMdiCornerWinResizer *GetUpperRightCR() const { return fUpperRightCR; }
0315 TGMdiCornerWinResizer *GetLowerRightCR() const { return fLowerRightCR; }
0316 TGMdiHorizontalWinResizer *GetLeftVR() const { return fLeftVR; }
0317 TGMdiHorizontalWinResizer *GetRightVR() const { return fRightVR; }
0318
0319 ClassDefOverride(TGMdiDecorFrame, 0)
0320 };
0321
0322 #endif