Menu

how to show the tip window

Help
ollydbg
2022-08-26
2022-10-18
  • ollydbg

    ollydbg - 2022-08-26

    I see currently there are two tooltip related code which are comment out, I just try to enable it, but it does not work quite well.

    The first place:

    In this function: void mpWindow::OnMouseMove(wxMouseEvent &event)

                if (m_coordTooltip) {
                    wxString toolTipContent;
                    toolTipContent.Printf(_("X = %f\nY = %f"), p2x(event.GetX()), p2y(event.GetY()));
                    wxTipWindow** ptr = NULL;
                    wxRect rectBounds(event.GetX(), event.GetY(), 5, 5);
                    wxTipWindow* tip = new wxTipWindow(this, toolTipContent, 100, ptr, &rectBounds);
                    }
    

    This code are using the wxTipWindow class to show the tip.

    The second place:
    While in another function: mpWindow::OnMouseLeftRelease (wxMouseEvent &event), it has such code:

                if (m_coordTooltip) {
                    wxString toolTipContent;
                    toolTipContent.Printf(_("X = %f\nY = %f"), p2x(event.GetX()), p2y(event.GetY()));
                    SetToolTip(toolTipContent);
                }
    

    I see that it use the SetToolTip function, which is using the wx's wxToolTip class.

    Now, I just set the m_coordTooltip to true, and when I move the mouse, there are a lot of wxTipWindow shown on the screen, and those tip windows do not disappear. So, the first place's tip can not be used.

    While, the second place's tip code woks correctly, when I use the mouse left click and release, it does show a tip window, and about several seconds later, the tip window automatically disappeared.

    Any ideas?

    Thanks.

     
  • ollydbg

    ollydbg - 2022-08-26

    I uploaded the "bad_tip" window(the code in first place) and "good_tip" (the code in second place) window screen shots as attachments. The good tip screen shot will be uploaded in another post.

     
  • ollydbg

    ollydbg - 2022-08-26

    Here is the good tip.

     
  • Naiche Barcelos

    Naiche Barcelos - 2022-10-09

    Hi ollydbg, if you're interested, I've done lot of changes to the way wxMathPlot shows that window, I've called it TrackBox and I made it so you can bind its appearance to any mouse button. The code is available at github.com/naiche/wxMathPlot.

     
    • ollydbg

      ollydbg - 2022-10-14

      Hi, Naiche Barcelos, thanks for the reply.

      I will try your github code repo, and I see you made a good contribution to wxMathPlot.

      The TrackBox is a feature I'm expecting for many years. I'm grad that you already implemented it.

       
  • ollydbg

    ollydbg - 2022-10-14

    BTW: I have asked the original question in wx forum, see here:

    wxTipWindow vs wxToolTip used inside wxMathPlot class

    Someone replied to that question, and he suggest that I should use the native tip window. (The good_tip screen shot)

     
  • ollydbg

    ollydbg - 2022-10-14

    Hi, Naiche Barcelos. Since you github repo don't have issue option enabled, I have to wrote it here.

    In the function std::pair<mpLayer*, wxRealPoint> mpWindow::GetClosestPoint(double x, double y)

    There are some code snippet:

            if ((*li)->IsVector()) {
                mpFXYVector *vect = (mpFXYVector*)(*li);
    
                int distX, closestI=0;
                distX = x - vect->m_xs[0];             //runs through vector looking for the closest X value
                for (int i = 1; i < vect->m_ys.size(); i++) {
                    if (abs(x - vect->m_xs[i]) < distX) {
                        distX = x - vect->m_xs[i];
                        closestI = i;
                    }
                }
                double delta = sqrt(pow((x - vect->m_xs[closestI])*GetScaleX(), 2) + pow((y - vect->m_ys[closestI])*GetScaleY(), 2));
                if (delta < previousDelta) {   //compares delta of this function to previous ones, to determine the nearest point
                    //LayerName = vect->GetName();
                    layer = *li;
                    previousDelta = delta;
                    pointX = vect->m_xs[closestI];
                    pointY = vect->m_ys[closestI];
                }
            }
    

    Is this correct?
    You first find a best X value, and later to calculate the distance?
    I think the best way is to loop all the (x,y) pair in the xy vector, and find the shortest distance.

    Some other issue: I see the source file has mixed "TAB" and "4 spaces" as indent. Can you fix them?

    Thanks.

     
  • Naiche Barcelos

    Naiche Barcelos - 2022-10-17

    Hi Ollydbg, I enabled the issue option on the repo.
    I'll look into it when I have the time.
    Is the the problem only with FY? Is it working ok with FXYvectors?

     
    • ollydbg

      ollydbg - 2022-10-17

      Hi, thanks for the response.

      By reading the source code, I think to find the closest point, the current implementation of FX, FY, FXYvectors is wrong, I think the FXY is correct(You have to override the function GetNextXY:

      class MyLissajoux : public mpFXY
      {
          double m_rad;
          int    m_idx;
      public:
          MyLissajoux(double rad) : mpFXY( wxT("Lissajoux")) { m_rad=rad; m_idx=0; m_drawOutsideMargins = false;}
          virtual bool GetNextXY( double & x, double & y )
          {
              if (m_idx < 360)
              {
                  x = m_rad * cos(m_idx / 6.283185*360);
                  y = m_rad * sin(m_idx / 6.283185*360*3);
                  m_idx++;
                  return TRUE;
              }
              else
              {
                  return FALSE;
              }
          }
      
       
  • Naiche Barcelos

    Naiche Barcelos - 2022-10-17

    Fixed it for mpFY, later I'll fix the others.

     
  • Naiche Barcelos

    Naiche Barcelos - 2022-10-18

    Done, mpFX and mpFXYVector fixed.

     

Log in to post a comment.