void ArrayCtrl::onMouseMove(const Event &event)
{
   Point2I pt = globalToLocalCoord(event.ptMouse);
   pt.x -= headerDim.x; pt.y -= headerDim.y;
   Point2I cell((pt.x < 0 ? -1 : pt.x / cellSize.x), (pt.y < 0 ? -1 : pt.y / cellSize.y));
   if(cell.x != mouseOverCell.x || cell.y != mouseOverCell.y)
   {
      if(mouseOverCell.x != -1)
      {
         setUpdateRegion( Point2I(mouseOverCell.x * cellSize.x + headerDim.x,
                           mouseOverCell.y * cellSize.y + headerDim.y), cellSize );
      }
      
      if(cell.x >= 0 && cell.x < size.x && cell.y >= 0 && cell.y < size.y)
      {
         setUpdateRegion( Point2I(cell.x * cellSize.x + headerDim.x,
                           cell.y * cellSize.y + headerDim.y), cellSize );
         mouseOverCell = cell;
      }
      else
         mouseOverCell.set(-1,-1);
         
      //set the state over flag
      stateOver = ((mouseOverCell.x != -1) && (mouseOverCell.y != -1));
   }
}
示例#2
0
void GuiTabBookCtrl::setUpdate()
{
   Parent::setUpdate();

   setUpdateRegion(Point2I(0,0), getExtent());

   calculatePageTabs();
}
void ArrayCtrl::onMouseLeave(const Event& /*event*/)
{
   setUpdateRegion( Point2I(mouseOverCell.x * cellSize.x + headerDim.x,
                           mouseOverCell.y * cellSize.y + headerDim.y), cellSize );
   mouseOverCell.set(-1,-1);
   
   //set the state over flag
   stateOver = FALSE;
}
示例#4
0
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message,
                                 WPARAM wParam, LPARAM lParam)
{
    /**   process system messages   **/
    switch (message)
    {
        // when window is first created
        case WM_CREATE:
            // start timer running
            // with an ID of ID_TIMER (macro)
            // 20 millisecond intervals
            // and no callback function (thus we'll get a message instead)
            SetTimer(hwnd, ID_TIMER, 10, 0);
            break;
        // message from timer "ID_TIMER"
        case WM_TIMER:
            setUpdateRegion(hwnd); // add rectangle to update region
            updateGame(hwnd);     // do the game math update all rectangles
            UpdateWindow(hwnd);  // send WM_PAINT if update region is not empty
            break;
        // whenever the mouse moves over our window
        case WM_MOUSEMOVE:
            // store mouse position
            mpoint_x = MAKEPOINTS(lParam);
            // update paddle rectangle immediately
            updatePaddle();
            break;
        // sent when window is being closed
        case WM_DESTROY:
            cleanUp();
            PostQuitMessage(0);    // send a WM_QUIT a 0 to the message queue
            break;
        // the system message to paint the update region
        case WM_PAINT:
            // paint all rectangles to update region
            refreshWindow(hwnd);
            break;
        // for messages that we don't deal with use the default window procedure
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}