//打印表达式列表 int TSyntaxTreeAnalyse::PrintExpr(const char * sPrefix ,ST_EXPR * pstExpr,int offset,int iLogType) { //#if 0 if (NULL == pstExpr) { return 0; } OutPutInfo(iLogType,"%s[%s]op=[%s],addr[%p],calcflag=[%s],sTorken=[%s],valueaddr[%p],exprlValue[%lld],exprsValue[%s],valueSize[%d],exprailas[%s],pColumn[%p]", GetOffSet(offset),sPrefix,TokenName[pstExpr->iOpcode],pstExpr, DescribeExprCalcFlag(pstExpr).c_str(), ReplaceNull(pstExpr->sTorken), pstExpr->pExprValue, pstExpr->pExprValue->lValue, ReplaceNull(pstExpr->pExprValue->sValue), pstExpr->pExprValue->iSize, ReplaceNull(pstExpr->pExprValue->sAlias), pstExpr->pExprValue->pColumn); PrintExpr("left",pstExpr->pLeft,offset+1, iLogType); PrintExpr("right",pstExpr->pRight,offset+1, iLogType); if (NULL != pstExpr->pFunc) { PrintExprList(pstExpr->pFunc->pFuncArgs,offset+1, iLogType); } //#endif return 0; }
//打印IDlist int TSyntaxTreeAnalyse::PrintIdList(ST_ID_LIST * pstIdList,int offset,int iLogType) { //#if 0 if (NULL == pstIdList) { return 0; } OutPutInfo(iLogType,"%s=======[%d][%d]=======",GetOffSet(offset),pstIdList->iIdNum,pstIdList->iAllocNum); for (int i = 0;i<pstIdList->iIdNum;i++) { ID_LIST_ITEM & item = pstIdList->pstItem[i]; OutPutInfo(iLogType,"%sname=[%s],pColumn=[%p],pExpr=[%p]",GetOffSet(offset),ReplaceNull(item.zName),item.pColumn,item.pExpr); } OutPutInfo(iLogType,"%s======================",GetOffSet(offset)); //#endif return 0; }
//获取字符点阵位图 //第一个字节 字宽 第二个字节 字字节数 uint8* tsf_getCharBitmap(uint16 ch) { int32 offset = GetOffSet(ch); mr_memset(Buf, 0, FONT_DES); if(offset == 0) { offset = GetOffSet(0x53e3); //返回 □ if(!offset) return (uint8*)Buf; } //第一个字节 字宽 第二个字节 字字节数 if(gMemLoad){ mr_memcpy(Buf, g_nowUse.PointBuf + offset, FONT_DES); } return (uint8*)Buf; }
//打印表达式列表 int TSyntaxTreeAnalyse::PrintExprList(ST_EXPR_LIST * pstExprList,int offset,int iLogType) { //#if 0 if (NULL != pstExprList) { OutPutInfo(iLogType,"%s======List start=====",GetOffSet(offset)); int i = 0; for (i = 0;i<pstExprList->iItemNum;i++) { OutPutInfo(iLogType,"%sitem[%d]",GetOffSet(offset),i); ST_EXPR_ITEM & Item = pstExprList->pExprItems[i]; OutPutInfo(iLogType,"%sname=[%-10s],span=[%s]",GetOffSet(offset),ReplaceNull(Item.sName),ReplaceNull(Item.sSpan)); PrintExpr("root",Item.pExpr,offset,iLogType); } OutPutInfo(iLogType,"%s======List end======",GetOffSet(offset)); } //#endif return 0; }
void EditableLabel::Update(float deltaSecond, Vector2& mousePosition) { //ResizeBox(); m_currentStateProperty = m_forStates[m_currentState]; Vector2 offset = GetOffSet(); if (m_isTyping) { StartTyping(); if (m_isFixingSize) { ResizeBox(); } } m_timeCheck += deltaSecond; Vector2 maxs; GetValueInCurrentState("maxs", maxs); Vector2 mins; GetValueInCurrentState("mins", mins); AABB2D box(mins + offset, maxs + offset); ////////////////////////////////////////////////////////////////////////// if (s_theInputSystem->IsMouseButtonDown(VK_LBUTTON) && s_theInputSystem->IsKeyDown('C')) { if (box.IsPointInside(mousePosition)) { SetDragable(true); } } else SetDragable(false); if (m_enableDrag) { Drag(mousePosition); return; } if (s_theInputSystem->WasMouseButtonJustDown(VK_LBUTTON)) { if (box.IsPointInside(mousePosition)) { m_isTyping = true; m_currentState = WIDGET_STATE_SELECT_; } else { m_currentState = WIDGET_STATE_ENABLE_; m_isTyping = false; } } }
//把一段有父子关系的Tree部分移走 void MoveItem(HTREEITEM m_startItem, HTREEITEM pItem, HTREEITEM nItem) { //详见司晋新okee程序中的Ctestview类 CMainFrame * pFWnd = (CMainFrame *)AfxGetMainWnd(); CModelTree * pTreeView = (CModelTree *)pFWnd->m_wndSplitter1.GetPane(0,2); CTreeCtrl& m_ctlTree = pTreeView->GetTreeCtrl(); HTREEITEM Item,nextItem,m_tempParentItem,lItem,m_temppItem; int no; no=Get_No_In_TreeItem(m_startItem,pTreeView); Item=m_ctlTree.InsertItem(m_ctlTree.GetItemText(m_startItem),0,1,pItem,nItem); //fqz: 修改treeitem pTreeView->m_Tree.TreeItem[no]=Item; lItem=m_startItem;//m_startItem值在以下循环中不变 nItem=Item; pItem=Item; m_temppItem=pItem;//m_temppItem值不变 while(FindNextNode(lItem,nextItem)!=FALSE)//查找下一个Node { //如果nextItem的父亲或者父亲的父亲是m_startItem; BOOL isParent=FALSE; m_tempParentItem=nextItem; //得到在nextItem的父亲在m_startItem位置 int indent=GetOffSet(m_startItem,nextItem); pItem=m_startItem; if(indent>0)//如果存在间接父子关系 { pItem=m_temppItem; for(int i=1;i<=GetOffSetLength(m_startItem,m_ctlTree.GetParentItem(nextItem));i++) FindNextNode(pItem,pItem); } else if(indent==0)//如果m_startItem和nextItem存在直接父子关系 { pItem=m_temppItem; } else if(indent==-1) break; no=Get_No_In_TreeItem(nextItem,pTreeView); nItem=m_ctlTree.InsertItem(m_ctlTree.GetItemText(nextItem),0,1,pItem,nItem); //fqz: 修改treeitem pTreeView->m_Tree.TreeItem[no]=nItem; lItem=nextItem; } m_ctlTree.DeleteItem(m_startItem); }
//打印索引信息 int TSyntaxTreeAnalyse::PrintIndex(std::vector< _ST_INDEX_VALUE> & vIndexValue,int offset,int iLogType) { //#if 0 std::vector< _ST_INDEX_VALUE>::iterator itor = vIndexValue.begin(); for(;itor != vIndexValue.end();++itor) { OutPutInfo(iLogType,"%s index[%s]",GetOffSet(offset),itor->pstTableIndex->pIndexInfo->sName); int i = 0; for(i = 0; i < MAX_INDEX_COLUMN_COUNTS;++i) { if(itor->pExprArr[i] != NULL) { PrintExpr("Expr:",itor->pExprArr[i],offset +1 ,iLogType); } } } //#endif return 0; }
void EditableLabel::ResizeBox() { Vector2 offset = GetOffSet(); Vector2 maxs; GetValueInCurrentState("maxs", maxs); Vector2 mins; GetValueInCurrentState("mins", mins); float textScale; GetValueInCurrentState("textScale", textScale); std::string text; GetValueInCurrentState("text", text); float length = text.size() * textScale *0.7f +10.0f; maxs.x = mins.x + length; for (int i = 0; i < NUM_WIDGET_STATE_; i++) { m_forStates[i].fromWidget.Set("maxs", maxs); } }
void DropdownWidget::AddNewOption(const std::string& optionStr) { Vector2 offset = GetOffSet(); Vector2 position; GetValueInCurrentState("position", position); float length; GetValueInCurrentState("length", length); float height; GetValueInCurrentState("height", height); float textScale; GetValueInCurrentState("textScale", textScale); unsigned int num = m_options.size(); Vector2 mins = Vector2(position.x,position.y-(num+1)*height)+offset; Vector2 maxs = Vector2(position.x+length,mins.y+height)+offset; RectButton* newButton = new RectButton(); newButton->SetEvent("Dropdown"); if (m_options.size() == 0) { newButton->m_parent = this; } else newButton->m_parent = m_options[0]; for (int i = 0; i < NUM_WIDGET_STATE_; i++) { newButton->m_forStates[i] = m_forStates[i]; newButton->m_forStates[i].fromCode.Set("text", optionStr); newButton->m_forStates[i].fromCode.Set("mins", mins); newButton->m_forStates[i].fromCode.Set("maxs", maxs); newButton->m_forStates[i].fromCode.Set("offset", Vector2(0.0f,0.0f)); newButton->m_forStates[i].fromCode.Set("textScale", textScale); } newButton->m_forStates[WIDGET_STATE_SELECT_].fromCode.Set("BGColor", RGBA(0.5f, 0.5f, 0.5f, 1.0f)); newButton->m_forStates[WIDGET_STATE_SELECT_].fromCode.Set("edgeColor", RGBA(1.0f, 1.0f, 1.0f, 1.0f)); newButton->Init(); //newButton->m_currentState = WIDGET_STATE_ENABLE_; m_options.push_back(newButton); }
void DropdownWidget::Update(float deltaSecond, Vector2& mousePosition) { m_currentStateProperty = m_forStates[m_currentState]; Vector2 offset = GetOffSet(); for (unsigned int i = 0; i < NUM_WIDGET_STATE_; i++) { m_forStates[i].fromWidget.Set("parentsOffset", offset); if (m_options.size()>0) { m_options[0]->m_forStates[i].fromWidget.Set("parentsOffset", offset); } } if (m_isExpend) { for (unsigned int i = 0; i < m_options.size(); i++) { NamedProperties properties; properties.Set("widget", this, "index", i); m_options[i]->Update(deltaSecond, mousePosition, &properties); if (i>=1) { m_options[i]->SetDragable(false); } } } else { NamedProperties properties; properties.Set("widget", this, "index", 0); m_options[0]->Update(deltaSecond, mousePosition, &properties); } if (!m_isExpend) { Vector2 currentOffset(0.0f, 0.0f); currentOffset = m_options[0]->GetOffSet(); Vector2 mins; Vector2 maxs; m_options[0]->GetValueInCurrentState("mins", mins); m_options[0]->GetValueInCurrentState("maxs", maxs); AABB2D box(mins+ currentOffset, maxs+ currentOffset); if (box.IsPointInside(mousePosition)) { m_isExpend = true; } } else { Vector2 currentOffset(0.0f, 0.0f); currentOffset = m_options[0]->GetOffSet(); Vector2 mins; Vector2 maxs; m_options.back()->GetValueInCurrentState("mins", mins); m_options[0]->GetValueInCurrentState("maxs", maxs); AABB2D box(mins+ currentOffset, maxs+ currentOffset); if (!box.IsPointInside(mousePosition)) { m_isExpend = false; } //for (unsigned int i = 0; i < m_options.size(); i++) //{ // m_options[i]->GetValueInCurrentState("mins", mins); // m_options[i]->GetValueInCurrentState("maxs", maxs); // box = AABB2D(mins, maxs); // if (box.IsPointInside(mousePosition) && s_theInputSystem->WasMouseButtonJustReleased(VK_LBUTTON)) // { // NamedProperties properties; // properties.Set("widget", this, "index", i); // m_options[i]->CallEvent(&properties); // //SwitchOption(i); // } //} } }