Changeset 7827 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 07/31/06 12:48:48 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r7826 r7827 339 339 sizemenu->AddEntry("Fit to 1400x1050", kSize1400); 340 340 sizemenu->AddEntry("Fit to 1600x1200", kSize1600); 341 sizemenu->AddEntry("Fit to &Desktop", kSizeOptimum); 341 342 sizemenu->Associate(this); 342 343 … … 672 673 // always by deleting the corresponding object. 673 674 // 675 // You can give either width or height. (Set the value not given to -1) 676 // The other value is calculated accordingly. If width and height are 677 // given height is ignored. If width=height=0 an optimum size from 678 // the desktop size is calculated. 679 // 674 680 // Update time default: 10s 675 681 // 676 MStatusDisplay::MStatusDisplay( Long_t t)682 MStatusDisplay::MStatusDisplay(Int_t w, Int_t h, Long_t t) 677 683 : TGMainFrame(NULL, 1, 1), fName("MStatusDisplay"), fLog(&gLog), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0) 678 684 { … … 714 720 // In newer root versions gClient!=NULL in batch mode! 715 721 if (!gClient || !gClient->GetRoot() || gROOT->IsBatch()) // BATCH MODE 722 { 723 Resize(644, 484); 716 724 return; 725 } 717 726 718 727 AddMenuBar(); … … 725 734 // set the smallest and biggest size of the Main frame 726 735 // and move it to its appearance position 727 SetWMSizeHints(572, 480, 2048, 1536, 1, 1); 728 MoveResize(rand()%100+572, rand()%100+480, 572, 480); 736 SetWMSizeHints(566, 476, 2048, 1536, 1, 1); 737 MoveResize(rand()%100+566, rand()%100+476, 566, 476); 738 if (h>0) 739 SetDisplayHeight(h); 740 if (w>0) 741 SetDisplayWidth(w); 742 if (w==0 && h==0) 743 SetOptimumSize(); 729 744 730 745 // … … 997 1012 if (gROOT->IsBatch()) 998 1013 { 999 TCanvas *c = new TCanvas(name, name); 1014 // 4 = 2*default border width of a canvas 1015 const UInt_t cw = GetWidth(); 1016 const UInt_t ch = 2*cw/3 + 25; // 25: Menu, etc 1017 1018 TCanvas *c = new TCanvas(name, name, -cw, ch); 1000 1019 fBatch->Add(c); 1001 1020 return *c; … … 1617 1636 return kTRUE; 1618 1637 1619 case kSize640: 1620 Resize(572, 480);1638 case kSize640: 1639 SetDisplaySize(640, 480); 1621 1640 return kTRUE; 1622 1641 case kSize768: 1623 Resize(714, 576);1642 SetDisplaySize(768, 576); 1624 1643 return kTRUE; 1625 1644 case kSize800: 1626 Resize(750, 600);1645 SetDisplaySize(800, 600); 1627 1646 return kTRUE; 1628 1647 case kSize960: 1629 Resize(900, 700);1648 SetDisplaySize(960, 720); 1630 1649 return kTRUE; 1631 1650 case kSize1024: 1632 Resize(1000, 768);1651 SetDisplaySize(1024, 768); 1633 1652 return kTRUE; 1634 1653 case kSize1152: 1635 Resize(1147, 864);1654 SetDisplaySize(1152, 864); 1636 1655 return kTRUE; 1637 1656 case kSize1280: 1638 Resize(1321, 980);1657 SetDisplaySize(1280, 1024); 1639 1658 return kTRUE; 1640 1659 case kSize1400: 1641 Resize(1426, 1050);1660 SetDisplaySize(1400, 1050); 1642 1661 return kTRUE; 1643 1662 case kSize1600: 1644 Resize(1550, 1400); 1663 SetDisplaySize(1600, 1200); 1664 return kTRUE; 1665 case kSizeOptimum: 1666 SetOptimumSize(); 1645 1667 return kTRUE; 1646 1668 … … 2940 2962 } 2941 2963 2964 // -------------------------------------------------------------------------- 2965 // 2966 // Change width of display. The height is calculated accordingly. 2967 // 2968 void MStatusDisplay::SetDisplayWidth(UInt_t dw) 2969 { 2970 if (gROOT->IsBatch()) 2971 { 2972 SetCanvasWidth(dw); 2973 return; 2974 } 2975 2976 // 4 == 2*default border with of canvas 2977 dw -= 4; 2978 2979 // Difference between canvas size and display size 2980 const UInt_t cw = GetWidth() -fTab->GetWidth(); 2981 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 2982 2983 const UInt_t dh = TMath::Nint((dw - cw)/1.5 + ch); 2984 2985 Resize(dw, dh); // Set display size 2986 } 2987 2988 // -------------------------------------------------------------------------- 2989 // 2990 // Change height of display. The width is calculated accordingly. 2991 // 2992 void MStatusDisplay::SetDisplayHeight(UInt_t dh) 2993 { 2994 if (gROOT->IsBatch()) 2995 { 2996 SetCanvasHeight(dh); 2997 return; 2998 } 2999 3000 // 4 == 2*default border with of canvas 3001 dh -= 4; 3002 3003 // Difference between canvas size and display size 3004 const UInt_t cw = GetWidth() -fTab->GetWidth(); 3005 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 3006 3007 const UInt_t dw = TMath::Nint((dh - ch)*1.5 + cw); 3008 3009 Resize(dw, dh); // Set display size 3010 } 3011 3012 // -------------------------------------------------------------------------- 3013 // 3014 // Change width of canvas. The height is calculated accordingly. 3015 // 3016 void MStatusDisplay::SetCanvasWidth(UInt_t w) 3017 { 3018 // 4 == 2*default border with of canvas 3019 w += 4; 3020 3021 if (gROOT->IsBatch()) 3022 { 3023 Resize(w, 3*w/2); 3024 return; 3025 } 3026 3027 // Difference between canvas size and display size 3028 const UInt_t cw = GetWidth() -fTab->GetWidth(); 3029 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 3030 3031 const UInt_t h = TMath::Nint(w/1.5 + ch); 3032 3033 Resize(w + cw, h); // Set display size 3034 } 3035 3036 // -------------------------------------------------------------------------- 3037 // 3038 // Change height of canvas. The width is calculated accordingly. 3039 // 3040 void MStatusDisplay::SetCanvasHeight(UInt_t h) 3041 { 3042 // 4 == 2*default border with of canvas 3043 h += 4; 3044 3045 if (gROOT->IsBatch()) 3046 { 3047 Resize(2*h/3, h); 3048 return; 3049 } 3050 3051 // Difference between canvas size and display size 3052 const UInt_t cw = GetWidth() -fTab->GetWidth(); 3053 const UInt_t ch = GetHeight()-fTab->GetHeight()+fTab->GetTabHeight(); 3054 3055 // 4 == 2*default border with of canvas 3056 const UInt_t dw = TMath::Nint((h+4)*1.5 + cw); 3057 3058 Resize(dw, h + ch); // Set display size 3059 } 3060 3061 // -------------------------------------------------------------------------- 3062 // 3063 // Calculate width and height of the display such that it fits into the 3064 // defined box. 3065 // 3066 void MStatusDisplay::SetDisplaySize(UInt_t w, UInt_t h) 3067 { 3068 if (gROOT->IsBatch()) 3069 return; 3070 3071 SetDisplayHeight(h); 3072 3073 if (GetWidth()>w) 3074 SetDisplayWidth(w); 3075 } 3076 3077 // -------------------------------------------------------------------------- 3078 // 3079 // Calculate an optimum size for the display from the desktop size 3080 // 3081 void MStatusDisplay::SetOptimumSize() 3082 { 3083 if (gROOT->IsBatch()) 3084 return; 3085 3086 const UInt_t w = TMath::Nint(0.95*gClient->GetDisplayWidth()); 3087 const UInt_t h = TMath::Nint(0.95*gClient->GetDisplayHeight()); 3088 3089 SetDisplaySize(w, h); 3090 } 3091 3092 2942 3093 Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt) 2943 3094 { … … 2951 3102 UInt_t h = evt->fHeight; 2952 3103 2953 const Bool_t wchanged = w!=GetWidth() ;2954 const Bool_t hchanged = h!=GetHeight() ;3104 const Bool_t wchanged = w!=GetWidth()-fTab->GetWidth(); 3105 const Bool_t hchanged = h!=GetHeight()-fTab->GetHeight(); 2955 3106 2956 3107 if (!wchanged && !hchanged) -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r7825 r7827 59 59 // kSize 60 60 kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152, 61 kSize1280, kSize1400, kSize1600, 61 kSize1280, kSize1400, kSize1600, kSizeOptimum, 62 62 // kLog 63 63 kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend, … … 157 157 158 158 public: 159 MStatusDisplay( Long_t t=1000);159 MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000); 160 160 virtual ~MStatusDisplay(); 161 161 … … 246 246 Bool_t SaveLogAsPS(const char *name) const; 247 247 248 // Size options 249 void SetCanvasWidth(UInt_t w); 250 void SetCanvasHeight(UInt_t h); 251 252 void SetDisplayWidth(UInt_t w); 253 void SetDisplayHeight(UInt_t h); 254 255 void SetOptimumSize(); 256 void SetDisplaySize(UInt_t w, UInt_t h); 257 248 258 Int_t SaveAs(Int_t num=-1); 249 259 Int_t Open(TString fname, const char *name="MStatusDisplay");
Note:
See TracChangeset
for help on using the changeset viewer.