Exemple #1
0
void IFWL_Widget::TransformTo(IFWL_Widget* pWidget,
                              FX_FLOAT& fx,
                              FX_FLOAT& fy) {
  if (m_pWidgetMgr->IsFormDisabled()) {
    CFX_SizeF szOffset;
    if (IsParent(pWidget)) {
      szOffset = GetOffsetFromParent(pWidget);
    } else {
      szOffset = pWidget->GetOffsetFromParent(this);
      szOffset.x = -szOffset.x;
      szOffset.y = -szOffset.y;
    }
    fx += szOffset.x;
    fy += szOffset.y;
    return;
  }
  CFX_RectF r;
  CFX_Matrix m;
  IFWL_Widget* parent = GetParent();
  if (parent) {
    GetWidgetRect(r);
    fx += r.left;
    fy += r.top;
    GetMatrix(m, true);
    m.TransformPoint(fx, fy);
  }
  IFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this);
  if (!form1)
    return;
  if (!pWidget) {
    form1->GetWidgetRect(r);
    fx += r.left;
    fy += r.top;
    return;
  }
  IFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget);
  if (!form2)
    return;
  if (form1 != form2) {
    form1->GetWidgetRect(r);
    fx += r.left;
    fy += r.top;
    form2->GetWidgetRect(r);
    fx -= r.left;
    fy -= r.top;
  }
  parent = pWidget->GetParent();
  if (parent) {
    pWidget->GetMatrix(m, true);
    CFX_Matrix m1;
    m1.SetIdentity();
    m1.SetReverse(m);
    m1.TransformPoint(fx, fy);
    pWidget->GetWidgetRect(r);
    fx -= r.left;
    fy -= r.top;
  }
}
Exemple #2
0
void ASI::RemoveFromLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if (pComponent->m_pData->inLayout &&
                    IsParent(pLayoutComponent, pComponent))
                {
                    /*
                     * Tell the layout component to remove
                     * the item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 2, dref, true);

                    DisconnectFromReceiver(pLayoutComponent, emitter, cref);
                    DisconnectFromReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout);

                    pComponent->m_pData->inLayout = false;

                    CRef invalidCRef;
                    pComponent->SetParent(invalidCRef);
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
void CTUI::QueueDraw(CWidget *w)
{
    if (!w->Enabled())
        return;
    
    // Uninitialized widgets aren't allowed, because we want to know any parenting and they _should_ be
    // refreshed by their parent anyway
    if (!w->GetWin())
        return;
    
    bool done = false;
    while (!done)
    {
        done = true;
        for (std::deque<CWidget *>::iterator it=m_QueuedDrawWidgets.begin();
             it!=m_QueuedDrawWidgets.end(); it++)
        {
            if (*it == w)
            {
                // Move to end of queue
                m_QueuedDrawWidgets.erase(it);
                done = false;
                break;
            }
            else if (IsParent(*it, w))
                return; // Parent is being redrawn, which will draw all childs
            else if (IsChild(*it, w))
            {
                // Remove any childs
                m_QueuedDrawWidgets.erase(it);
                done = false;
                break;
            }
        }
    }
    
    m_QueuedDrawWidgets.push_back(w);
}
void MyExit( void )
{
 ESP_QUE_ELEMENT  Qelement;
 USHORT           PidOfThisEsp;
 TIB             *pTib;
 PIB             *pPib;

 /****************************************************************************/
 /* - If we get an error in a child probe, then we need to bring that        */
 /*   probe session to the foreground and display the message.               */
 /****************************************************************************/
 if( IsParent() == FALSE )
 {
  DosGetInfoBlocks(&pTib,&pPib);

  PidOfThisEsp = (USHORT)pPib->pib_ulpid;

  Qelement.ChildPid = PidOfThisEsp;
  if( UseExecPgm() == FALSE )
   SendMsgToEspQue( ESP_QMSG_SELECT_ESP, &Qelement, sizeof(Qelement) );
  DosSleep(15000);
 }
 exit(0);
}
void OUGUIObject::UpdateSelf(float fDeltaTime, float fMX, float fMY)
{
    /** 如果鼠标不在HGE窗口内 */
    //if(!m_pHGE->Input_IsMouseOver()) return;

    bool bLButton = m_pHGE->Input_GetKeyState(HGEK_LBUTTON);
    bool bRButton = m_pHGE->Input_GetKeyState(HGEK_RBUTTON);
    bool bMButton = m_pHGE->Input_GetKeyState(HGEK_MBUTTON);
    int nWheel = m_pHGE->Input_GetMouseWheel();

    OnUpdate(fDeltaTime, fMX, fMY);

    /** 若控件不可用 */
    if(!GetEnableMode()) return;
    if(!GetShowMode()) return;

    /** 若有鼠标捕获的控件 */
    if(OUGUIObject::m_pMouseCaptureControl &&
        OUGUIObject::m_pMouseCaptureControl != this &&
        !IsParent(OUGUIObject::m_pMouseCaptureControl))
    {
        return;
    }

    /** 若有模式窗口 */
    if(OUGUIObject::m_pModalControl &&
        OUGUIObject::m_pModalControl != this &&
        !IsParent(OUGUIObject::m_pModalControl))
    {
        return;
    }

    /** 若有控件在激活状态下 */
    if(OUGUIObject::m_pActiveControl &&
        OUGUIObject::m_pActiveControl != this)
    {
        return;
    }
    
    /** 如果鼠标没有被按下,则检测是不是OnEnter */
    if(!bLButton && OnCheckCollision(fMX, fMY))
    {
        //SetMouseEnter(OnCheckCollision(fMX, fMY));
        SetMouseEnter(true);
    }
    /** 如果鼠标抬起,则检测是不是OnLeave */
    else
    if(!bLButton && !OnCheckCollision(fMX, fMY) && GetMouseEnter())
    {
        SetMouseEnter(false);

        this->m_bMouseLButton = false;
        this->m_bMouseMButton = false;
        this->m_bMouseRButton = false;
        this->m_nMouseWheel = 0;
       
        if(OUGUIObject::GetActiveControl() == this)
        {
            OUGUIObject::SetActiveControl(NULL);
        }

        return;
    }

    if(GetMouseEnter() || OUGUIObject::GetMouseCaptureControl() == this)
    {
        SetMousePos(fMX, fMY);
        SetMouseLButton(bLButton);
        SetMouseRButton(bRButton);
        SetMouseMButton(bMButton);
        SetMouseWheel(nWheel);

        /** 键盘响应 */
        for(int i = 0; i < 256; i++)
        {
            if(i == HGEK_LBUTTON) continue;
            if(i == HGEK_RBUTTON) continue;
            if(i == HGEK_MBUTTON) continue;

            if(m_pHGE->Input_KeyDown(i)) OnKeyDown(i);
            else
            if(m_pHGE->Input_KeyUp(i)) OnKeyUp(i);
        }

        OnIdle();
    }
    else
    {
        /** 清空状态 */
        SetMouseLButton(false);
        SetMouseRButton(false);
        SetMouseMButton(false);
        SetMouseWheel(nWheel);
    }
}
bool IsChild(CWidget *child, CWidget *parent)
{
    return IsParent(parent, child);
}
int main( int argc, char **argv )
{
 APIRET      rc;
 COMMAND     cmd = {0,0};
 int         n;
 char       *cp;
 char        rc_string[12];
 CONNECTION  Connection;

 EXCEPTIONREGISTRATIONRECORD  reg_rec;

 ESP_QUE_ELEMENT Qelement;


 if( argc == 1 )
  SayMsg(HELP_INVOCATION_ESP);

 /****************************************************************************/
 /*                                                                          */
 /* Parse the invocation options.                                            */
 /*                                                                          */
 /* - If this is a child debugger, then these additional parameters will     */
 /*   precede the invocation parameters inherited from the parent.           */
 /*                                                                          */
 /*   - /child=xxxxx  where child  = child debugger and                      */
 /*                         xxxxx  = child pid (for serial connections only.)*/
 /*                                                                          */
 /*   - /handle=xxxxx where handle = switch for com handle( serial only )    */
 /*                         xxxxx  = parent's com handle - inherited by      */
 /*                                  the child.                              */
 /*                                                                          */
 /****************************************************************************/
 memset( &EspParms,   0, sizeof( ESP_PARMS ) );
 memset( &Connection, 0, sizeof(Connection) );
 if( strstr( argv[1], "/child" ) )
 {
  ParseEspChildOptions( argc, argv, &EspParms, &Connection );
 }
 else
 {
  ParseOptions( argc, argv, &EspParms, &Connection );
 }

 printf("\nESP Version 5.00 \n");fflush(0);

 /****************************************************************************/
 /* - Send connection info to the router.                                    */
 /****************************************************************************/
 SendConnectionToRouter( &Connection );

 /****************************************************************************/
 /* - Make the connection.                                                   */
 /****************************************************************************/
 {
  int RcMoreInfo = 0;

  rc = ConnectInit( &RcMoreInfo );

  if( rc != 0 )
  {
   char  BadConnectMsg[32] = "";
   int   MsgId;

   if( (Connection.ConnectType == _NETBIOS) && (RcMoreInfo != 0) )
   {
    /*************************************************************************/
    /* - handle netbios specific connect errors.                             */
    /*************************************************************************/
    n     = 1;
    MsgId = ERR_NB_INADEQUATE_RESOURCES;

    switch( RcMoreInfo )
    {
     case CANT_LOAD_NETB_DLL:
      n     = 0;
      MsgId = ERR_NB_CANT_LOAD_DLL;
      break;

     case INADEQUATE_SESSIONS:
      strcpy( BadConnectMsg,"sessions");
      break;

     case INADEQUATE_COMMANDS:
      strcpy( BadConnectMsg,"commands");
      break;

     case INADEQUATE_NAMES:
      strcpy( BadConnectMsg,"names");
      break;

     default:
      n = 1;
      MsgId = ERR_BAD_CONNECT;
      sprintf( BadConnectMsg, "NetBios error rc=%d", rc );
      break;
    }
   }
   else if( (Connection.ConnectType == SOCKET) && (RcMoreInfo != 0) )
   {
    /*************************************************************************/
    /* - handle tcpip specific connect errors.                               */
    /*************************************************************************/
    switch( RcMoreInfo )
    {
     case CANT_LOAD_TCPIP_DLL:
      n     = 1;
      MsgId = ERR_TCPIP_CANT_LOAD_DLL;

      sprintf( BadConnectMsg, "%d", rc );
      break;

     case TCPIP_NOT_RUNNING:
      n     = 0;
      MsgId = ERR_TCPIP_NOT_RUNNING;
      break;

     case TCPIP_ERROR:
      n     = 0;
      MsgId = ERR_TCPIP_ERROR;
      break;

     case TCPIP_NO_SERVICES_PORT:
      n     = 0;
      MsgId = ERR_TCPIP_NO_SERVICES_PORT;
      break;

     default:
      n = 1;
      MsgId = ERR_BAD_CONNECT;
      sprintf( BadConnectMsg, "tcpip error rc=%d", rc );
      break;
    }
   }
   else
   {
    /*************************************************************************/
    /* - handle generic connect errors.                                      */
    /*************************************************************************/
    n = 1;
    MsgId = ERR_BAD_CONNECT;
    sprintf( BadConnectMsg, "rc=%d", rc );
   }
   ErrorPrintf( MsgId, n, BadConnectMsg );
  }
 }

 /****************************************************************************/
 /* - register an exception handler for the probe.                           */
 /****************************************************************************/
 reg_rec.ExceptionHandler = Handler;
 DosSetExceptionHandler(&reg_rec);

 /****************************************************************************/
 /* - Add a connect sema4 for serial connections and wait to be posted.      */
 /****************************************************************************/
 if( (SerialParallel() == SERIAL) && ( IsParent() == FALSE ) )
 {
  USHORT   EspPid;
  TIB     *pTib;
  PIB     *pPib;
  ALLPIDS *p;

  SetComHandle( EspParms.handle );

  DosGetInfoBlocks(&pTib,&pPib);
  EspPid = (USHORT)pPib->pib_ulpid;
  CreateConnectSema4( EspPid, _ESP );
  SerialConnect( JUST_WAIT, 0, _ESP, SendMsgToEspQue );
  p = GetEspPid( EspPid );
  p->Connect = CONNECTED;
 }

 /****************************************************************************/
 /* - Each child debugger will have a termination que so we can kill the     */
 /*   child debuggers on quit/restart.                                       */
 /****************************************************************************/
 if( IsParent() == FALSE )
 {
  rc = StartEspTermQue( );
  if( rc != 0 )
  {
   sprintf(rc_string, "%d",rc);
   ErrorPrintf( ERR_CANT_START_QUE, TRUE, 1, rc_string );
  }
 }
 /****************************************************************************/
 /* - Now, start the command processing loop.                                */
 /****************************************************************************/
 for(;;)
 {
  memset(&cmd,0,sizeof(cmd) );
  RmtRecv(DEFAULT_HANDLE, (char*)&cmd, sizeof(cmd));
  if( IsVerbose() ) PrintCmdMessage( cmd.api ) ;
  switch( cmd.api )
  {
   case FINDEXE:
    RxFindExe(cmd);
    break;

   case STARTUSER:
    RxStartUser( cmd );
    break;

   case GOINIT:
    RxGoInit(cmd);
    break;

   case GOENTRY:
    RxGoEntry(cmd);
    break;

   case DEFBRK:
    RxDefBrk(cmd);
    break;

   case UNDBRK:
    RxUndBrk(cmd);
    break;

   case PUTINBRK:
    RxPutInBrk(cmd);
    break;

   case PULLOUTBRK:
    RxPullOutBrk(cmd);
    break;

   case INSERTALLBRK:
    RxInsertAllBrk();
    break;

   case REMOVEALLBRK:
    RxRemoveAllBrk();
    break;

   case SELECT_SESSION:
    /*************************************************************************/
    /* - Only the parent probe can select one of the debuggee sessions, so   */
    /*   we send a message and tell him to do it.                            */
    /*************************************************************************/
    Qelement.ChildPid = GetEspProcessID();
    SendMsgToEspQue( ESP_QMSG_SELECT_SESSION, &Qelement, sizeof(Qelement) );

    memset(&cmd,0,sizeof(cmd) );

    cmd.api = SELECT_SESSION;
    RmtSend( DEFAULT_HANDLE, &cmd, sizeof(cmd) );
    break;

   case GOSTEP:
    RxGoStep(cmd);
    break;

   case GOFAST:
    RxGoFast(cmd);
    break;

   case DOSDEBUG:
    RxDosDebug( cmd );
    break;

   case GETTHREADINFO:
    RxGetThreadInfo( cmd );
    break;

   case FREEZETHREAD:
    RxFreezeThread( cmd );
    break;

   case THAWTHREAD:
    RxThawThread( cmd );
    break;

   case GETCALLSTACK:
    RxGetCallStack(cmd);
    break;

   case GETEXEORDLLENTRY:
    RxGetExeOrDllEntryOrExitPt(cmd);
    break;

   case NORMALQUIT:
    RxNormalQuit(cmd);

    /*************************************************************************/
    /* - The que has to be up until after the normal quit because the        */
    /*   system will need to post an end session message to the queue.       */
    /*************************************************************************/
    if( IsParent() )
    {
     if( SingleMultiple() == MULTIPLE )
     {
      ALLPIDS *p;
      /***********************************************************************/
      /* - Send a message to all of the child probes telling them that       */
      /*   they are going to be killed.                                      */
      /***********************************************************************/
      for( p = GetAllpids(); p ; p = p->next )
      {
       if( (p->PidFlags.IsDebug) == TRUE && (p->pid != GetEspProcessID()) )
       {
        ESP_QUE_ELEMENT Qelement;

        Qelement.ChildPid = p->EspPid;

        SendMsgToEspTermQue(ESP_PROBE_TERM, &Qelement, sizeof(Qelement) );
       }
      }
      /***********************************************************************/
      /* - send a message to the que to kill all the child probes and        */
      /*   then wait until they are all dead.                                */
      /***********************************************************************/
      ResetAllProbesAreDeadFlag( );
      SendMsgToEspQue(ESP_QMSG_PARENT_TERM,NULL,0);
      while( AllProbesAreDead() == FALSE ){ DosSleep(100) ;}
     }
     SendMsgToEspQue(ESP_QMSG_QUE_TERM,NULL,0);
    }

    CloseConnectSema4();

    cmd.api  = NORMALQUIT;
    cmd.len  = sizeof(rc);

    /*************************************************************************/
    /* - Now, tell dbg that we're finished normal quitting.                  */
    /*************************************************************************/
    RmtSend(DEFAULT_HANDLE, &cmd , sizeof(cmd) );
    RmtSend(DEFAULT_HANDLE, &rc, cmd.len );
    break;

   case SETEXECADDR:
    RxSetExecAddr(cmd);
    break;

   case DEFWPS:
    RxDefWps(cmd);
    break;

   case PUTINWPS:
    RxPutInWps(cmd);
    break;

   case PULLOUTWPS:
    RxPullOutWps(cmd);
    break;

   case GETDATABYTES:
    RxGetDataBytes(cmd);
    break;

   case GETMEMBLKS:
    RxGetMemBlocks(cmd);
    break;

   case SETXCPTNOTIFY:
    RxSetExceptions(cmd);
    break;

   case SETEXECTHREAD:
    RxSetExecThread(cmd);
    break;

   case WRITEREGS:
    RxWriteRegs(cmd);
    break;

   case GETCOREGS:
    RxGetCoRegs(cmd);
    break;

   case SETESPRUNOPTS:
    RxSetEspRunOpts(cmd);
    break;

   case TERMINATEESP:
    if( IsParent() == FALSE )
    {
     memset( &Qelement, 0, sizeof(Qelement) );
     Qelement.ChildPid = GetEspProcessID();

     SendMsgToEspQue( ESP_QMSG_CHILD_TERM, &Qelement, sizeof(Qelement) );
    }
    DosUnsetExceptionHandler(&reg_rec);
    RmtSend(DEFAULT_HANDLE, &cmd , sizeof(cmd) );
    ConnectClose( DEFAULT_HANDLE );
    exit(0);
    break;

   case START_QUE_LISTEN:
    SendMsgToEspQue(ESP_QMSG_OPEN_CONNECT,NULL,0);
    break;

   case START_ESP_QUE:
    RxStartEspQue(cmd);
    break;

   case CONNECT_ESP:
    /*************************************************************************/
    /* - Serial connection only.                                             */
    /*************************************************************************/
    {
     USHORT   GoToPid;
     USHORT   YieldPid;
     ALLPIDS *pYield;
     ALLPIDS *pGoTo;
     BOOL     TorF;

     /************************************************************************/
     /* - Receive the pid to be connected and mark it connected.             */
     /* - If this pid has not yet been assigned to a probe, then pGoTo       */
     /*   will be NULL.                                                      */
     /* - There MUST be a probe with a pid==0, so we release that probe.     */
     /*   ( The pid will be stuffed into the structure at goinit() time.)    */
     /* - Post the connect sema4 for the goto pid.                           */
     /************************************************************************/
     RmtRecv( DEFAULT_HANDLE, &GoToPid, cmd.len );
     pGoTo          = GetPid( GoToPid );

     if( pGoTo == NULL )
      pGoTo = GetPid(0);

     pGoTo->Connect = CONNECTED;


     TorF = TRUE;
     if( GoToPid == GetEspProcessID() )
      TorF = FALSE;

     /************************************************************************/
     /* - Send back verification that the connection has been made.          */
     /************************************************************************/
     memset(&cmd,0,sizeof(cmd) );

     cmd.api = SERIAL_POLL;
     RmtSend( DEFAULT_HANDLE, &cmd, sizeof(cmd) );

     PostConnectSema4( &pGoTo->ConnectSema4, TorF );

     /************************************************************************/
     /* - Disconnect/block this probe.                                       */
     /************************************************************************/
     YieldPid        = (USHORT)GetEspProcessID();
     pYield          = GetPid( YieldPid );
     pYield->Connect = DISCONNECTED;

     SerialConnect( SET_WAIT, YieldPid, _ESP, SendMsgToEspQue );
    }
    break;

   case CTRL_BREAK:
    {
     USHORT          ThisPid;
     USHORT          CtrlBreakPid;

     RmtRecv( DEFAULT_HANDLE, &CtrlBreakPid, cmd.len );

     ThisPid = (USHORT)GetEspProcessID();

     Qelement.ChildPid = CtrlBreakPid;
     Qelement.ChildSid = ThisPid;

     SendMsgToEspQue(ESP_QMSG_CTRL_BREAK, &Qelement, sizeof(Qelement));

     SerialConnect( SET_WAIT, ThisPid,  _ESP, SendMsgToEspQue );
    }
    break;

   case SERIAL_POLL:
    ReportMessage();
    break;

   default:
    cp = (char*)&cmd;
    for( n=1; n<=sizeof(cmd); n++,cp++)
     printf("%c",*cp);
    AsyncFlushModem();
    break;
  }
 }
}