@@ -238,21 +238,20 @@ void TBox::ExecuteEvent(Int_t event, Int_t px, Int_t py)
238238
239239 Bool_t isBox = !(InheritsFrom (" TPave" ) || InheritsFrom (" TWbox" ));
240240
241- const Int_t kMaxDiff = 7 ;
242- const Int_t kMinSize = 20 ;
241+ constexpr Int_t kMaxDiff = 7 ;
242+ constexpr Int_t kMinSize = 20 ;
243243
244244 static Int_t px1, px2, py1, py2, pxl, pyl, pxt, pyt, pxold, pyold;
245245 static Int_t px1p, px2p, py1p, py2p, pxlp, pylp, pxtp, pytp;
246246 static Double_t oldX1, oldY1, oldX2, oldY2;
247247 static Bool_t pA, pB, pC, pD, pTop, pL, pR, pBot, pINSIDE;
248248 Int_t wx, wy;
249249 auto parent = gPad ;
250- auto pp = parent->GetPainter ();
251- Bool_t opaque = gPad ->OpaqueMoving ();
252- Bool_t ropaque = gPad ->OpaqueResizing ();
250+ Bool_t opaque = parent->OpaqueMoving ();
251+ Bool_t ropaque = parent->OpaqueResizing ();
253252
254253 // convert to user coordinates and either paint ot set back
255- auto action = [parent,pp, isBox,this ](Bool_t paint, Int_t _x1, Int_t _y1, Int_t _x2, Int_t _y2) {
254+ auto action = [parent,isBox,this ](Bool_t paint, Int_t _x1, Int_t _y1, Int_t _x2, Int_t _y2) {
256255 auto x1 = parent->AbsPixeltoX (_x1);
257256 auto y1 = parent->AbsPixeltoY (_y1);
258257 auto x2 = parent->AbsPixeltoX (_x2);
@@ -268,6 +267,8 @@ void TBox::ExecuteEvent(Int_t event, Int_t px, Int_t py)
268267 }
269268 }
270269 if (paint) {
270+ auto pp = parent->GetPainter ();
271+ pp->SetAttLine ({GetFillColor () > 0 ? GetFillColor () : (Color_t) 1 , GetLineStyle (), 2 });
271272 pp->DrawBox (x1, y1, x2, y2, TVirtualPadPainter::kHollow );
272273 } else {
273274 SetX1 (x1);
@@ -296,27 +297,15 @@ void TBox::ExecuteEvent(Int_t event, Int_t px, Int_t py)
296297 oldY1 = fY1 ;
297298 oldX2 = fX2 ;
298299 oldY2 = fY2 ;
299- pp->SetAttLine ({GetFillColor () > 0 ? GetFillColor () : (Color_t) 1 , GetLineStyle (), 2 });
300300
301301 // No break !!!
302302
303303 case kMouseMotion :
304304
305- px1 = gPad ->XtoAbsPixel (GetX1 ());
306- py1 = gPad ->YtoAbsPixel (GetY1 ());
307- px2 = gPad ->XtoAbsPixel (GetX2 ());
308- py2 = gPad ->YtoAbsPixel (GetY2 ());
309-
310- if (isBox) {
311- if (gPad ->GetLogx ()) {
312- if (GetX1 () > 0 ) px1 = gPad ->XtoAbsPixel (TMath::Log10 (GetX1 ()));
313- if (GetX2 () > 0 ) px2 = gPad ->XtoAbsPixel (TMath::Log10 (GetX2 ()));
314- }
315- if (gPad ->GetLogy ()) {
316- if (GetY1 () > 0 ) py1 = gPad ->YtoAbsPixel (TMath::Log10 (GetY1 ()));
317- if (GetY2 () > 0 ) py2 = gPad ->YtoAbsPixel (TMath::Log10 (GetY2 ()));
318- }
319- }
305+ px1 = parent->XtoAbsPixel (isBox ? parent->XtoPad (GetX1 ()) : GetX1 ());
306+ py1 = parent->YtoAbsPixel (isBox ? parent->YtoPad (GetY1 ()) : GetY1 ());
307+ px2 = parent->XtoAbsPixel (isBox ? parent->XtoPad (GetX2 ()) : GetX2 ());
308+ py2 = parent->YtoAbsPixel (isBox ? parent->YtoPad (GetY2 ()) : GetY2 ());
320309
321310 if (px1 < px2) {
322311 pxl = px1;
@@ -355,64 +344,59 @@ void TBox::ExecuteEvent(Int_t event, Int_t px, Int_t py)
355344
356345 pA = pB = pC = pD = pTop = pL = pR = pBot = pINSIDE = kFALSE ;
357346
358- // case pA
347+ // case pA
359348 if (TMath::Abs (px - pxl) <= kMaxDiff && TMath::Abs (py - pyl) <= kMaxDiff ) {
360349 pxold = pxl; pyold = pyl; pA = kTRUE ;
361- gPad ->SetCursor (kTopLeft );
350+ parent ->SetCursor (kTopLeft );
362351 }
363- // case pB
352+ // case pB
364353 if (TMath::Abs (px - pxt) <= kMaxDiff && TMath::Abs (py - pyl) <= kMaxDiff ) {
365354 pxold = pxt; pyold = pyl; pB = kTRUE ;
366- gPad ->SetCursor (kTopRight );
355+ parent ->SetCursor (kTopRight );
367356 }
368- // case pC
357+ // case pC
369358 if (TMath::Abs (px - pxt) <= kMaxDiff && TMath::Abs (py - pyt) <= kMaxDiff ) {
370359 pxold = pxt; pyold = pyt; pC = kTRUE ;
371- gPad ->SetCursor (kBottomRight );
360+ parent ->SetCursor (kBottomRight );
372361 }
373- // case pD
362+ // case pD
374363 if (TMath::Abs (px - pxl) <= kMaxDiff && TMath::Abs (py - pyt) <= kMaxDiff ) {
375364 pxold = pxl; pyold = pyt; pD = kTRUE ;
376- gPad ->SetCursor (kBottomLeft );
365+ parent ->SetCursor (kBottomLeft );
377366 }
378-
379- if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff ) &&
380- TMath::Abs (py - pyl) < kMaxDiff ) { // top edge
367+ // top edge
368+ if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff ) && TMath::Abs (py - pyl) < kMaxDiff ) {
381369 pxold = pxl; pyold = pyl; pTop = kTRUE ;
382- gPad ->SetCursor (kTopSide );
370+ parent ->SetCursor (kTopSide );
383371 }
384-
385- if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff ) &&
386- TMath::Abs (py - pyt) < kMaxDiff ) { // bottom edge
372+ // bottom edge
373+ if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff ) && TMath::Abs (py - pyt) < kMaxDiff ) {
387374 pxold = pxt; pyold = pyt; pBot = kTRUE ;
388- gPad ->SetCursor (kBottomSide );
375+ parent ->SetCursor (kBottomSide );
389376 }
390-
391- if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff ) &&
392- TMath::Abs (px - pxl) < kMaxDiff ) { // left edge
377+ // left edge
378+ if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff ) && TMath::Abs (px - pxl) < kMaxDiff ) {
393379 pxold = pxl; pyold = pyl; pL = kTRUE ;
394- gPad ->SetCursor (kLeftSide );
380+ parent ->SetCursor (kLeftSide );
395381 }
396-
397- if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff ) &&
398- TMath::Abs (px - pxt) < kMaxDiff ) { // right edge
382+ // right edge
383+ if ((py > pyl+kMaxDiff && py < pyt-kMaxDiff ) && TMath::Abs (px - pxt) < kMaxDiff ) {
399384 pxold = pxt; pyold = pyt; pR = kTRUE ;
400- gPad ->SetCursor (kRightSide );
385+ parent ->SetCursor (kRightSide );
401386 }
402-
403- if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff ) &&
404- (py > pyl+kMaxDiff && py < pyt-kMaxDiff )) { // inside box
387+ // inside box
388+ if ((px > pxl+kMaxDiff && px < pxt-kMaxDiff ) && (py > pyl+kMaxDiff && py < pyt-kMaxDiff )) {
405389 pxold = px; pyold = py; pINSIDE = kTRUE ;
406390 if (event == kButton1Down )
407- gPad ->SetCursor (kMove );
391+ parent ->SetCursor (kMove );
408392 else
409- gPad ->SetCursor (kCross );
393+ parent ->SetCursor (kCross );
410394 }
411395
412396 fResizing = pA || pB || pC || pD || pTop || pL || pR || pBot;
413397
414398 if (!fResizing && !pINSIDE)
415- gPad ->SetCursor (kCross );
399+ parent ->SetCursor (kCross );
416400
417401 break ;
418402
@@ -569,9 +553,6 @@ void TBox::ExecuteEvent(Int_t event, Int_t px, Int_t py)
569553 if (pA || pB || pC || pD || pTop || pL || pR || pBot)
570554 parent->Modified (kTRUE );
571555
572- if (!opaque)
573- pp->SetAttLine ({-1 , 1 , -1 });
574-
575556 break ;
576557
577558 case kButton1Locate :
0 commit comments