Exemplo n.º 1
0
static MRESULT APIENTRY Char ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 mp2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * Get the message data.                                                   *
  ***************************************************************************/

  USHORT Flags    = (USHORT) SHORT1FROMMP ( mp1 ) ;
//UCHAR  Repeat   = (UCHAR)   CHAR3FROMMP ( mp1 ) ;
//UCHAR  ScanCode = (UCHAR)   CHAR4FROMMP ( mp1 ) ;

//USHORT Char     = (USHORT) SHORT1FROMMP ( mp2 ) ;
  USHORT VKey     = (USHORT) SHORT2FROMMP ( mp2 ) ;

 /***************************************************************************
  * Ignore keys being released, invalid characters, dead keys and           *
  *   invalid composite characters.                                         *
  ***************************************************************************/

  if ( ( Flags & KC_KEYUP )
    OR ( Flags & KC_INVALIDCHAR )
    OR ( Flags & KC_DEADKEY )
    OR ( Flags & KC_INVALIDCOMP ) )
  {
    Sys_BeepNote ( ) ;
    return ( MRFROMSHORT ( FALSE ) ) ;
  }

 /***************************************************************************
  * Intercept the ESC virtual key to abort margin set mode.                 *
  ***************************************************************************/

  if ( Flags & KC_VIRTUALKEY ) {

    switch ( VKey ) {

      case VK_ESC: {

        if ( Data->Capture ) {

          Data->Capture = FALSE ;
          Sys_ReleaseCapture ( ) ;

          HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ;
          WinSetPointer ( HWND_DESKTOP, Ptr ) ;

          Sys_SetFocus ( Data->HadFocus ) ;

          WorkSpace PS ( "HRuler::Char", 0, Window, Data->pDevice, int(Data->Metric) ) ;
          PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

          RECTL Rectangle ;
          WinQueryWindowRect ( Window, &Rectangle ) ;
          PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

          POINTL ButtonSize = { 8, 8 } ;
          PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

          PS.SetMix ( FM_INVERT ) ;
          PS.SetLineType ( LINETYPE_ALTERNATE ) ;
          POINTL Point = { Data->Tick, Rectangle.yBottom } ;
          PS.Move ( Point ) ;
          Point.y = Rectangle.yTop ;
          PS.DrawLine ( Point ) ;

          Data->Mode = NOTMOVING ;
        }

        break ;
      }
    }
  }

 /***************************************************************************
  * Return.                                                                 *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Exemplo n.º 2
0
static MRESULT APIENTRY Button1Up ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * If the mouse wasn't captured, return.                                   *
  ***************************************************************************/

  if ( NOT Data->Capture )
    return ( MRFROMSHORT ( FALSE ) ) ;

 /***************************************************************************
  * Get the presentation space.                                             *
  ***************************************************************************/

  WorkSpace PS ( "HRuler::Button1Up", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::Button1Up:   Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * Erase the previous hairline.                                            *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;
  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * Release the mouse.                                                      *
  ***************************************************************************/

  Data->Capture = FALSE ;
  Sys_ReleaseCapture ( ) ;

 /***************************************************************************
  * Restore the normal mouse pointer.                                       *
  ***************************************************************************/

  HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ;
  WinSetPointer ( HWND_DESKTOP, Ptr ) ;

 /***************************************************************************
  * Restore the keyboard focus.                                             *
  ***************************************************************************/

  Sys_SetFocus ( Data->HadFocus ) ;

 /***************************************************************************
  * Process final location of mouse.                                        *
  ***************************************************************************/

  switch ( Data->Mode ) {

    case MOVELEFT:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Data->Tick < 0 ) OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }
      Sys_SendMessage ( OWNER(Window), WM_SET_LEFTMARGIN, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }

    case MOVERIGHT:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Data->Tick <= Data->LeftMargin ) OR ( Data->Tick > Data->PageWidth ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }
      Sys_SendMessage ( OWNER(Window), WM_SET_RIGHTMARGIN, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }

    case MOVETAB:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Mouse.y > Rectangle.yTop )
        OR ( Mouse.y < Rectangle.yBottom )
        OR ( Data->Tick <= Data->LeftMargin )
        OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_SendMessage ( OWNER(Window), WM_CLEAR_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), 0 ) ;
        break ;
      }

      Sys_SendMessage ( OWNER(Window), WM_MOVE_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), MPFROMLONG(Data->Tick) ) ;
      break ;
    }

    case SETTAB:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Mouse.y > Rectangle.yTop )
        OR ( Mouse.y < Rectangle.yBottom )
        OR ( Data->Tick <= Data->LeftMargin )
        OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }

      Sys_SendMessage ( OWNER(Window), WM_SET_TAB, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }
  }

 /***************************************************************************
  * Reset mode.                                                             *
  ***************************************************************************/

  Data->Mode = NOTMOVING ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Exemplo n.º 3
0
static MRESULT APIENTRY Button1Down ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  WorkSpace PS ( "HRuler::Button1Down", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::Button1Down: Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * If the mouse isn't touching in the button area, return.                 *
  ***************************************************************************/

  if ( Mouse.y < Rectangle.yTop - ButtonSize.y ) {
     Sys_BeepNote ( ) ;
     return ( MRFROMSHORT ( FALSE ) ) ;
  } /* endif */

 /***************************************************************************
  * If the mouse is beyond the margins, return.                             *
  ***************************************************************************/

  if ( ( Mouse.x < Data->LeftMargin ) OR ( Mouse.x > Data->RightMargin+ButtonSize.x ) ) {
     Sys_BeepNote ( ) ;
     return ( MRFROMSHORT ( FALSE ) ) ;
  } /* endif */

 /***************************************************************************
  * If mouse is touching the left margin button, set mode to MOVELEFT.      *
  ***************************************************************************/

  if ( ( Mouse.x >= Data->LeftMargin ) AND ( Mouse.x <= Data->LeftMargin+ButtonSize.x ) ) {
     Data->Mode = MOVELEFT ;
     Data->Ptr = Data->MarginPtr ;
  } /* endif */

 /***************************************************************************
  * If mouse is touching the right margin button, set mode to MOVERIGHT.    *
  ***************************************************************************/

  else if ( ( Mouse.x >= Data->RightMargin-ButtonSize.x ) AND ( Mouse.x <= Data->RightMargin ) ) {
     Data->Mode = MOVERIGHT ;
     Data->Ptr = Data->MarginPtr ;
  } /* endif */

 /***************************************************************************
  * Else, find which tab-stop, if any, we're touching.                      *
  ***************************************************************************/

  else {
     for ( int i=0; i<Data->TabCount; i++ ) {
        if ( ( Mouse.x >= Data->Tabs[i] ) AND ( Mouse.x <= Data->Tabs[i]+ButtonSize.x ) ) {
           Data->Mode = MOVETAB ;
           Data->TabIndex = USHORT ( i ) ;
           break ;
        } /* endif */
     } /* endfor */

     if ( i >= Data->TabCount ) {
        Data->Mode = SETTAB ;
     } /* endif */

     Data->Ptr = Data->TabstopPtr ;
  } /* endif */

 /***************************************************************************
  * Capture the mouse.                                                      *
  ***************************************************************************/

  Data->Capture = TRUE ;
  Sys_SetCapture ( Window ) ;

 /***************************************************************************
  * Set the new mouse pointer.                                              *
  ***************************************************************************/

  WinSetPointer ( HWND_DESKTOP, Data->Ptr ) ;

 /***************************************************************************
  * Get the keyboard focus.                                                 *
  ***************************************************************************/

  Data->HadFocus = WinQueryFocus ( HWND_DESKTOP ) ;
  Sys_SetFocus ( Window ) ;

 /***************************************************************************
  * Save the current hairline position.                                     *
  ***************************************************************************/

  Data->Tick = TICK(Mouse.x) ;

 /***************************************************************************
  * Draw a hairline showing the current position.                           *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;
  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Exemplo n.º 4
0
static MRESULT APIENTRY MouseMove ( HWND Window, MESG msg, MPARAM1 mp1, MPARAM2 mp2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * If the mouse wasn't captured, return.                                   *
  ***************************************************************************/

  if ( NOT Data->Capture )
    return ( Sys_DefWindowProc ( Window, msg, mp1, mp2 ) ) ;

 /***************************************************************************
  * Get the presentation space.                                             *
  ***************************************************************************/

  WorkSpace PS ( "HRuler::MouseMove", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::MouseMove:   Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * Erase the previous hairline.                                            *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;

  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * Save the current hairline position.                                     *
  ***************************************************************************/

  Data->Tick = TICK(Mouse.x) ;

 /***************************************************************************
  * Draw a hairline showing the current position.                           *
  ***************************************************************************/

  Point.x = Data->Tick ;
  Point.y = Rectangle.yBottom ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Exemplo n.º 5
0
static MRESULT APIENTRY SetTick ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

  /**************************************************************************
   * Find the instance data.                                                *
   **************************************************************************/

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Get the new tick-mark position from the message.                       *
   **************************************************************************/

   LONG Tick = LONGFROMMP ( mp1 ) ;

  /**************************************************************************
   * If only the tick-mark has changed, move it.                            *
   **************************************************************************/

   if ( Data->Tick != Tick ) {

     /***********************************************************************
      * Get the presentation space.                                         *
      ***********************************************************************/

      WorkSpace PS ( "HRuler::SetTick", 0, Window, Data->pDevice, int(Data->Metric) ) ;
      PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

     /***********************************************************************
      * Find out some background information.                               *
      ***********************************************************************/

      RECTL Rectangle ;
      WinQueryWindowRect ( Window, &Rectangle ) ;
      PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

     /***********************************************************************
      * Erase the previous hairline.                                        *
      ***********************************************************************/

      if ( Data->Tick ) {
         PS.SetMix ( FM_INVERT ) ;
         PS.SetLineType ( LINETYPE_ALTERNATE ) ;
         POINTL Point = { Data->Tick, Rectangle.yBottom } ;
         PS.Move ( Point ) ;
         Point.y = Rectangle.yTop ;
         PS.DrawLine ( Point ) ;
      } /* endif */

     /***********************************************************************
      * Save the current hairline position.                                 *
      ***********************************************************************/

      Data->Tick = Tick ;

     /***********************************************************************
      * Draw a hairline showing the current position.                       *
      ***********************************************************************/

      if ( Data->Tick ) {
         PS.SetMix ( FM_INVERT ) ;
         PS.SetLineType ( LINETYPE_ALTERNATE ) ;
         POINTL Point = { Data->Tick, Rectangle.yBottom } ;
         PS.Move ( Point ) ;
         Point.y = Rectangle.yTop ;
         PS.DrawLine ( Point ) ;
      } /* endif */

   } /* endif */
 
  /**************************************************************************
   * We're done.                                                            *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}