[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Exact size of the TextRectangle?

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Exact size of the TextRectangle?

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Redisdead   (1 post)  [Biography] bio
Date Tue 14 Apr 2009 04:24 AM (UTC)  quote  ]
Message
When using a negative number in TextRectangle's bottom argument (I suppose it does the same for other arguments too), the GetInfo(275) returns that negative number. It'd be nice if it'd return the actual bottom place of the TextRectangle.

Is there any way to calculate/get the current TextRectangle's height and width? I want to make an icon bar that fits exactly next to it.
[Go to top] top

Posted by Worstje   Netherlands  (867 posts)  [Biography] bio
Date Reply #1 on Tue 14 Apr 2009 09:24 AM (UTC)  quote  ]

Amended on Tue 14 Apr 2009 09:28 AM (UTC) by Worstje

Message
You can calculate it. Have a look at GetInfo(). I believe selectors 280 and 281 are what you are looking for. Simple math can do the rest. :)

On a side note - if you want it pixel perfect, you'll also have to keep the border width and border offset in mind. It can be tricky to figure out how that works although with a bit of work you'll figure out how those values come into it.

The Previewer plugin I wrote a while back has a skin that does a fair amount of fiddling with the text rectangle to position it precisely below the text rectangle. You may want to check it out if you want something to look at, although it's a little bit of a mess (lacks comments and also does some other things not directly involving the textrectangle).
[Go to top] top

Posted by Nick Gammon   Australia  (18,801 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Tue 14 Apr 2009 09:44 AM (UTC)  quote  ]

Amended on Tue 14 Apr 2009 09:46 AM (UTC) by Nick Gammon

Message
True, I prefer to return what you set it to, so if you need to alter it, you can.

The code to actually calculate the "real" rectangle is here (in C++):


// returns the text rectangle, if any, noramlized
RECT CMUSHView::GetTextRectangle (const bool bIncludeBorder)
  {
CMUSHclientDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

  CRect TextRectangle (pDoc->m_TextRectangle);

RECT r;

  GetClientRect (&r);

  if (pDoc->m_TextRectangle != CRect (0, 0, 0, 0))
    {
    // they can use -n on right/bottom to indicate offset from side

    if (TextRectangle.right <= 0)
      {
      TextRectangle.right += r.right;
      // ensure not negative
      TextRectangle.right = max (TextRectangle.right, TextRectangle.left + 20);
      }


    if (TextRectangle.bottom <= 0)
      {
      TextRectangle.bottom += r.bottom;
      // ensure not negative
      TextRectangle.bottom = max (TextRectangle.bottom, TextRectangle.top + 20);
      }

    if (bIncludeBorder)
      TextRectangle.InflateRect (pDoc->m_TextRectangleBorderOffset, pDoc->m_TextRectangleBorderOffset);

    return TextRectangle;
    }

  return r;

  } // end of CMUSHView::GetTextRectangle


Basically, pDoc->m_TextRectangle is what you supplied to the TextRectangle call.

The call to GetClientRect above returns the same as GetInfo 280 and 281, as Worstje said. So, armed with those pieces of information, you can calculate exactly what the program considers to the the rectangle at a given moment (bearing in mind it may change if you resize the window).


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,470 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]