Results 1 to 17 of 17

Thread: Relative coordinates in a GUI system [Resolved]

Threaded View

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Relative coordinates in a GUI system [Resolved]

    I'm making a GUI for directx.

    A window has either a parent (window it's displayed in) or NULL (it's the desktop).

    A window's coordinates range from 0 to GUI_SCALEX and 0 to GUI_SCALEY.

    RESX and RESY dictate the resolution for the screen.

    I've attached the code i'm using below.
    It works for the desktop window (parent of NULL), but not it's child window.

    Can anyone see what i've done wrong?

    Code:
    int VirtXtoPixels(int virtX)
    {
    	int tmpWidth = (m_pParent) ? m_pParent->m_rPosition.right-m_pParent->m_rPosition.left : RESX;
    	int tmpAdd = (m_pParent) ? m_pParent->VirtXtoPixels(m_pParent->m_rPosition.left) : 0;
    	return((int)((double)virtX*(double)tmpWidth/GUI_SCALEX) + tmpAdd);
    }
    int VirtYtoPixels(int virtY)
    {
    	int tmpHeight = (m_pParent) ? m_pParent->m_rPosition.bottom-m_pParent->m_rPosition.top : RESY;
    	int tmpAdd = (m_pParent) ? m_pParent->VirtYtoPixels(m_pParent->m_rPosition.top) : 0;
    	return((int)((double)virtY*(double)tmpHeight/GUI_SCALEY) + tmpAdd);
    }
    FYI ?: is a ternary operator with the following syntax:

    Test ? True statement : false statement
    Last edited by SLH; Sep 17th, 2004 at 03:25 PM.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width