Exemple #1
0
int IGraphics::GetMouseControlIdx(int x, int y, bool mo)
{
	if (mMouseCapture >= 0) {
		return mMouseCapture;
	}
  
  bool allow; // this is so that mouseovers can still be called when a control is greyed out

	// The BG is a control and will catch everything, so assume the programmer
	// attached the controls from back to front, and return the frontmost match.
  int i = mControls.GetSize() - 1;
  IControl** ppControl = mControls.GetList() + i;
	for (/* */; i >= 0; --i, --ppControl) {
    IControl* pControl = *ppControl;
    
    if (mo) {
      if (pControl->GetMOWhenGrayed())
        allow = true;
      else
        allow = !pControl->IsGrayed();
    }
    else {
      allow = !pControl->IsGrayed();
    }

    if (!pControl->IsHidden() && allow && pControl->IsHit(x, y)) {
      return i;
    }
	}
	return -1;
}
Exemple #2
0
// The OS is announcing what needs to be redrawn,
// which may be a larger area than what is strictly dirty.
bool IGraphics::Draw(IRECT* pR)
{
//  #pragma REMINDER("Mutex set while drawing")
//  WDL_MutexLock lock(&mMutex);

  int i, j, n = mControls.GetSize();
  if (!n)
  {
    return true;
  }

  if (mStrict)
  {
    mDrawRECT = *pR;
    int n = mControls.GetSize();
    IControl** ppControl = mControls.GetList();
    for (int i = 0; i < n; ++i, ++ppControl)
    {
      IControl* pControl = *ppControl;
      if (!(pControl->IsHidden()) && pR->Intersects(pControl->GetRECT()))
      {
        pControl->Draw(this);
      }
      pControl->SetClean();
    }
  }
  else
  {
    IControl* pBG = mControls.Get(0);
    if (pBG->IsDirty())   // Special case when everything needs to be drawn.
    {
      mDrawRECT = *(pBG->GetRECT());
      for (int j = 0; j < n; ++j)
      {
        IControl* pControl2 = mControls.Get(j);
        if (!j || !(pControl2->IsHidden()))
        {
          pControl2->Draw(this);
          pControl2->SetClean();
        }
      }
    }
    else
    {
      for (i = 1; i < n; ++i)   // loop through all controls starting from one (not bg)
      {
        IControl* pControl = mControls.Get(i); // assign control i to pControl
        if (pControl->IsDirty())   // if pControl is dirty
        {

          // printf("control %i is Dirty\n", i);

          mDrawRECT = *(pControl->GetRECT()); // put the rect in the mDrawRect member variable
          for (j = 0; j < n; ++j)   // loop through all controls
          {
            IControl* pControl2 = mControls.Get(j); // assign control j to pControl2

            // if control1 == control2 OR control2 is not hidden AND control2's rect intersects mDrawRect
            if (!pControl2->IsHidden() && (i == j || pControl2->GetRECT()->Intersects(&mDrawRECT)))
            {
              //if ((i == j) && (!pControl2->IsHidden())|| (!(pControl2->IsHidden()) && pControl2->GetRECT()->Intersects(&mDrawRECT))) {
              //printf("control %i and %i \n", i, j);

              pControl2->Draw(this);
            }
          }
          pControl->SetClean();
        }
      }
    }
  }

#ifndef NDEBUG
  if (mShowControlBounds) 
  {
    for (int j = 1; j < mControls.GetSize(); j++)
    {
      IControl* pControl = mControls.Get(j);
      DrawRect(&CONTROL_BOUNDS_COLOR, pControl->GetRECT());
    }
    
    WDL_String str;
    str.SetFormatted(32, "x: %i, y: %i", mMouseX, mMouseY);
    IText txt(20, &CONTROL_BOUNDS_COLOR);
    IRECT rect(Width() - 150, Height() - 20, Width(), Height());
    DrawIText(&txt, str.Get(), &rect);
  }
#endif

  return DrawScreen(pR);
}
Exemple #3
0
// The OS is announcing what needs to be redrawn,
// which may be a larger area than what is strictly dirty.
bool IGraphics::Draw(IRECT* pR)
{
//  #pragma REMINDER("Mutex set while drawing")
//  WDL_MutexLock lock(&mMutex);
  
  int i, j, n = mControls.GetSize();
  if (!n) {
    return true;
  }

  if (mStrict) {
    mDrawRECT = *pR;
    int n = mControls.GetSize();
    IControl** ppControl = mControls.GetList();
    for (int i = 0; i < n; ++i, ++ppControl) {
      IControl* pControl = *ppControl;
      if (!(pControl->IsHidden()) && pR->Intersects(pControl->GetRECT())) {
        pControl->Draw(this);    
      }
      pControl->SetClean();
    }
  }
  else {
    IControl* pBG = mControls.Get(0);
    if (pBG->IsDirty()) { // Special case when everything needs to be drawn.
      mDrawRECT = *(pBG->GetRECT());
      for (int j = 0; j < n; ++j) {
        IControl* pControl2 = mControls.Get(j);
        if (!j || !(pControl2->IsHidden())) {
          pControl2->Draw(this);
          pControl2->SetClean();
        }
      }
    }
    else {
      for (i = 1; i < n; ++i) { // loop through all controls starting from one (not bg)
        IControl* pControl = mControls.Get(i); // assign control i to pControl
        if (pControl->IsDirty()) { // if pControl is dirty
          
         // printf("control %i is Dirty\n", i);
          
          mDrawRECT = *(pControl->GetRECT()); // put the rect in the mDrawRect member variable
          for (j = 0; j < n; ++j) { // loop through all controls
            IControl* pControl2 = mControls.Get(j); // assign control j to pControl2
            
            // if control1 == control2 OR control2 is not hidden AND control2's rect intersects mDrawRect
            if (!pControl2->IsHidden() && (i == j || pControl2->GetRECT()->Intersects(&mDrawRECT))) {
            //if ((i == j) && (!pControl2->IsHidden())|| (!(pControl2->IsHidden()) && pControl2->GetRECT()->Intersects(&mDrawRECT))) {
              //printf("control %i and %i \n", i, j);

              pControl2->Draw(this);
            }
          }
          pControl->SetClean();
        }
      }
    }
  }

  return DrawScreen(pR);

}