home *** CD-ROM | disk | FTP | other *** search
-
- ////////////////////////////////////////////////////////////////////////////////
- //----------------------------------------------------------------------------//
- //-----project DESINGER, copyright 2002 Libor Bareτ-------------------------//
- //----------------------------------------------------------------------------//
- ////////////////////////////////////////////////////////////////////////////////
-
-
-
- #define Diagram__ScreenToClient(x) x-=32
- #define Diagram__ClientToScreen(x) x+=32
- //#define Diagram__ScreenToClient2(x) (x).top-=32;(x).bottom-=32
- //#define Diagram__ClientToScreen2(x) (x).top+=32;(x).bottom+=32
-
-
- int Diagram__MakeCellWidth(int nID){
- return (m_DiagramCells[nID].Rect.right-m_DiagramCells[nID].Rect.left);
- }
- int Diagram__MakeCellHeight(int nID){
- return (m_DiagramCells[nID].Rect.bottom-m_DiagramCells[nID].Rect.top);
- }
- //void Diagram__ScreenToClient(int &y ){
- // y +=-32;
- //}
- void Diagram__ScreenToClient2( RECT &rc){
- Diagram__ScreenToClient(rc.top);
- Diagram__ScreenToClient(rc.bottom);
- }
- //void Diagram__ClientToScreen(int &y ){
- // y +=32;
- //}
- void Diagram__ClientToScreen2(RECT & rc ){
- Diagram__ClientToScreen(rc.top);
- Diagram__ClientToScreen(rc.bottom);
- }
-
- void Diagram__GetCenterCell(int nID, int & x, int &y){
- RECT* r=&Diagram__GetCell(nID)->Rect;
- x=r->left+Diagram__MakeCellWidth(nID)/2;
- y=r->top+Diagram__MakeCellHeight(nID)/2;
- }
- void Diagram__SetInterZOrder(unsigned nID){
- // move array ...
- int a;
- if(m_nm_DiagramCellsSize != 0 && nID == m_DiagramZOrder[0]){
- return;
- }
-
- if(m_nm_DiagramCellsSize != 0 ){
- // is nID control in array ?
- int i;
- int movefrom = -1;
- for(i=0;i<m_nm_DiagramCellsSize;i++){
- if(m_DiagramZOrder[i] == nID){ // yes, it is
- movefrom =i;break;
-
- }
-
- }
- if(movefrom == -1)movefrom = m_nm_DiagramCellsSize-1;
- memcpy(&m_DiagramZOrder[1],&m_DiagramZOrder[0],sizeof(int)*movefrom);
- }
- m_DiagramZOrder[0]=nID;
-
-
- }
- void Diagram__DrawOA(string strText,unsigned nType,int left,top, char draw,int &nPlusX){
- // parser text and draw it ...
- nPlusX=3;int nFont=FONT_TAHOMA_8;
-
- if(nType & 0x00000100L/*TYPE_OA_ABSTRACT*/ )nFont=FONT_TAHOMA_ITALIC_8;
- if(nType & 0x00000010L/*TYPE_OA_DELIVER*/){if(draw)TextOut(left+nPlusX,top,"/",4,5,FONT_TAHOMA_8);nPlusX+=6;}
- if(nType & 0x00000001L/*TYPE_OA_PROTECTED*/){if(draw)TextOut(left+nPlusX,top,"#",4,5,FONT_TAHOMA_8);nPlusX+=10;}
- else if(nType & 0x00000002L/*TYPE_OA_PRIVATE*/){if(draw)TextOut(left+nPlusX,top,"-",4,5,FONT_TAHOMA_8);nPlusX+=10;}
- // parsering
- int nLen = StrVelikost(strText);
- unsigned nPos = StrPozicePod²et╪zce(strText,0,"(");
- SIZE sz;
- string sdef;
- if(nPos != 0xffff){
- sdef = StrKopie(strText,0,nPos+1);
-
- }
- else {
- sdef = strText;
- }
- GetTextExtent(sdef,sz,nFont);
- if(draw)TextOut(left+nPlusX,top,sdef,4,5,nFont);
- nPlusX+=sz.x;
- if(nPos != 0xffff){
- nPos++;
- while(nPos < nLen){
- if((strText[nPos-1] == " " || strText[nPos-1] == "(" || strText[nPos-1] == ",") && StrKopie(strText,nPos,4) == "out " || StrKopie(strText,nPos,3) == "in " || StrKopie(strText,nPos,6) == "inout "){
- int nstart = nPos;
- while(strText[nPos] != ' ' && nPos < nLen ){
- nPos++;
- }
- GetTextExtent(StrKopie(strText,nstart,nPos-nstart),sz,FONT_TAHOMA_BOLD_8);
- if(draw)TextOut(left+nPlusX,top,StrKopie(strText,nstart,nPos-nstart),4,5,FONT_TAHOMA_BOLD_8);
- nPlusX+=sz.x;
- }
- GetTextExtent(strText[nPos],sz,nFont);
- if(draw)TextOut(left+nPlusX,top,strText[nPos],4,5,nFont);
- nPlusX+=sz.x;
- nPos++;
-
-
- }
- }
-
- nPlusX+=3;
- if(nType & 0x00000008L/*TYPE_OA_CONSTANT*/){
- if(draw)TextOut(left+nPlusX,top,"{constant}",4,5,nFont);
- GetTextExtent("{constant}",sz,nFont);nPlusX+=sz.x;
- }
- if(nType & 0x00000100L/*TYPE_OA_ABSTRACT*/ ){
- if(draw)TextOut(left+nPlusX,top,"{abstract}",4,5,nFont);
- GetTextExtent("{abstract}",sz,nFont);nPlusX+=sz.x;
-
- }
- nPlusX+=8;
- }
- char Diagram__DrawDepControl(int nType,int&x , int&y, int x2, int y2,double& ratex, double& ratey,nSize, char bDraw){
- float onex = (x-x2);
- float oney = (y-y2);
- int size = sqrt((double)((onex*onex)+(oney*oney)));
- if(size <= 0)return 1;//error
- double rate;
- rate=(((double)size)/(double)nSize);
- ratex=onex/rate; // vector.size = nSize ...
- ratey=oney/rate;
- int x3= x - ratex;
- int y3= y - ratey;
- ratey/=2;
- ratex/=2;
- if(bDraw == 2)return 0;
- if(nType == 2 || nType == 1){int retx=x3*2-x,rety=y3*2-y;
-
- if(nType == 2) GrNastavBarvuPozadí(2);
- else GrNastavBarvuPozadí(5);
- GrKresliVypln╪n∞Mnohoúhelník(5,x,y,x3+(int)ratey,y3-(int)ratex,retx,rety,x3-(int)ratey,y3+(int)ratex,x,y);
- // else GrKresliMnohoúhelník(5,x,y,x3+(int)ratey,y3-(int)ratex,retx,rety,x3-(int)ratey,y3+(int)ratex,x,y);
- x=retx;y=rety;
-
- }
- else if(nType == 3){
- GrKresliMnohoúhelník(4,x,y,x3+(int)ratey,y3-(int)ratex,x3-(int)ratey,y3+(int)ratex,x,y);
- x=x3;y=y3;
-
- }
- return 0;
- }
- void Diagram__DrawLabel(unsigned nType /*LABEL TYPE*/,string strText,int x,y,x2,y2,char bDraw,RECT* lprcDst){
- if(strText=="")return;
- // label types :
- // first bit is set to '0' if is label below line else about line
- // second bit is set to '0' if is label on leftside of line (usually on side whitch is dependented)
- // supported value :
- // vl=1,0x01 vl=17,0x11
- // ----------------------
- // vl=0,0x00 vl=16,0x10
- //
- double ratex,ratey,x3,y3;
- if(Diagram__DrawDepControl(0,x,y,x2,y2,ratex,ratey,20,2))return; // only for recalculate rect and if is too small cell-rect return
- x3=ratex,y3=ratey;
- if(x <= x2){x3 =-x3;y3 =-y3;}
- SIZE szText;
- GetTextExtent(strText,szText,FONT_TAHOMA_8);szText.x+=2;szText.y+=2;
- POINT ptFrom;
- if(nType%2 == 0){
- y3=-y3;
- x3=-x3;
- }
- if(nType > 1 )SetPoint(&ptFrom,x-ratex*1.5+y3,y-ratey*1.5-x3);
- else SetPoint(&ptFrom,x2+ratex*1.5+y3,y2+ratey*1.5-x3);
- SetRect(lprcDst,ptFrom.left,ptFrom.top,ptFrom.left+((y3 < 0)?-szText.x:szText.x),ptFrom.top-((x3 < 0)?-szText.y:szText.y));
- NormalizeRect(lprcDst); // normalize coordinations of rectangle
- if(lprcDst->top <=32){lprcDst->top=32;return;}
- if(bDraw){
- FillSolidRect(lprcDst,1);
- TextOut(lprcDst->left+1,lprcDst->top+1,strText,4,1,FONT_TAHOMA_8);
- InflateRect(lprcDst,1,1,1,1);
-
- }
- }
- void Diagram__DrawDependent(int x, int y, int x2, int y2, char bDesigning, long nType,int nIDCell){
- if(bDesigning==1){GrNastavBarvuPop²edí(1);GrNastavLinku(36/*1|0x20|4*/);}
- CLASSITEM* pData;
- DIAGRAMCELL *pCell;
- long dwFlags=0;
- char sError = ((40 > abs(x2-x) && 40 > abs(y2-y)));
- if(nIDCell >= 0){
-
- pData = ((CLASSITEM*)((Diagram__GetCell(nIDCell))->pVariable));
- pCell = Diagram__GetCell(nIDCell);
- dwFlags = pCell->dwFlags;
- }
-
- double ratex,ratey,oneratex,oneratey;
- int x3,y3;
- if( nType & 2 /*TYPE_DEPENDENT_AGREGACE*/ || nType & 8/*TYPE_DEPENDENT_KOMPOZICE*/ || nType & 4){
- //ratey-=oneratey;ratex-=oneratex;
- GrNastavBarvuPozadí(2);
- if(bDesigning!=2){
- if(!(nType & 4))if(Diagram__DrawDepControl(1+((nType & 8)?1:0),x,y,x2,y2,ratex,ratey,10,bDesigning)){GrKresliLinku(x,y,x2,y2);return;}
- GrKresliLinku(x,y,x2,y2);
- }
- string str;
- if(dwFlags & 0x00000100L)str+="ordered, ";
- if(dwFlags & 0x00000400L)str+="tree, ";
- if(dwFlags & 0x00000200L) str+="list, ";
- if(dwFlags & 0x00001000L)str+="bag, ";
- if(dwFlags & 0x00000800L) str+="set, ";
- if(StrDélka(str) > 2){
- StrNastavVelikost(str,StrDélka(str)-2);
- str=" {"+str+"}";
- }
- str = pCell->ClassName+str;
-
- CenterText(x+(x2-x)/2,y+(y2-y)/2-7,str,4,1,FONT_TAHOMA_8,(bDesigning!=2),&pData[0].nRectType);
- int i;
- for(i=1;i < 5;i++)
- Diagram__DrawLabel(pData[i].nType,pData[i].strText,x,y,x2,y2,(bDesigning!=2),&pData[i].nRectType);
-
-
- }
- else if(( nType & 16/*TYPE_DEPENDENT_MESSAGE*/)){
-
-
- POINT ptCenter;POINT pt2;
- if(!sError){
- if(dwFlags & 0x00001000L){
- Diagram__DrawDepControl(1,x2,y2,x,y,ratex,ratey,10,bDesigning);
- if(Diagram__DrawDepControl(3,x,y,x2,y2,ratex,ratey,16,bDesigning))return;
-
- }else { if(Diagram__DrawDepControl(0,x2,y2,x,y,ratex,ratey,16,bDesigning))return;ratex*=-1;ratey*=-1;}
-
- }else {bDesigning=3;}
- if(bDesigning!=2)GrKresliLinku(x,y,x2,y2);
- if((80 > abs(x2-x) && 80 > abs(y2-y))||bDesigning==3)return;
- SetPoint(&ptCenter,(x2+(x-x2)/2-((x > x2 )?-ratey:ratey)*1.5),(y2 +( y-y2 )/2+((x > x2 )?-ratex:ratex)*1.5));
- x3 = ratex*6;y3 = ratey*6;
- SetPoint(&pt2,ptCenter.left+x3,ptCenter.top+y3);
- if(bDesigning!=2)GrKresliLinku(ptCenter.left-x3,ptCenter.top-y3,pt2.left,pt2.top);
- x3 = ratex;y3 = ratey;
- if(x < x2){
- x3 =-ratex;
- y3 =-ratey;
- }
-
- if(bDesigning!=2){
- if((nType & 0x00000400L)){
- GrKresliLinku(pt2.left,pt2.top,pt2.left-ratex-y3,pt2.top-ratey+x3);
- }
- GrKresliLinku(pt2.left,pt2.top,pt2.left-ratex+y3,pt2.top-ratey-x3);
- }
-
- SIZE s;
-
- int plusy=-18;
- string str;
- if(pCell->strExStereotypes != ""){str="{priority = "+pCell->strExStereotypes+"} ";}
- if(nType & 0x00000800L ){str+=" ½broadcast╗";}
- else if(nType & 0x00001000L && pCell->strExProperties != ""){
- Diagram__DrawLabel(17,pCell->strExProperties,x,y,x2,y2,(bDesigning!=2),&pData[2].nRectType);
- }
- if(str != ""){
- CenterText(ptCenter.left,ptCenter.top+plusy,str,4,5,FONT_TAHOMA_8,(bDesigning!=2),&pData[1].nRectType);
- plusy+=-13;
-
- }
- CenterText(ptCenter.left,ptCenter.top+plusy,pCell->ClassName,4,5,FONT_TAHOMA_8,(bDesigning!=2),&pData[0].nRectType);
-
- }
- else {
- if(!sError)if(Diagram__DrawDepControl(3,x,y,x2,y2,ratex,ratey,16,bDesigning))return;
-
- GrKresliLinku(x,y,x2,y2);
- string str;
- if(dwFlags & 0x00000400L)str+="disjoint, ";
- else if(dwFlags & 0x00000800L)str+="overlapping, ";
- if(dwFlags & 0x00000100L)str+="compete, ";
- else if(dwFlags & 0x00000200L)str+="incompete, ";
- if(dwFlags & 0x00001000L)str+="dynamic, ";
- else if(dwFlags & 0x00002000L)str+="static, ";
- if(StrDélka(str) > 2){
- StrNastavVelikost(str,StrDélka(str)-2);
- str="{"+str+"}";
- CenterText(x+(x2-x)/2,y+(y2-y)/2-7,str,4,1,FONT_TAHOMA_8,(bDesigning!=2),&pData[0].nRectType);
- }
-
-
- }
- GrNastavLinku(21);/*1|0x10|4*/
-
-
- }
-
-
- void Diagram__DrawCell(unsigned nIDCell,char bDraw,int & nPlusX,int & nPlusY){
- if(bDraw)HideMouse();
- DIAGRAMCELL * cell = Diagram__GetCell(nIDCell);
- int nType = cell->nType;
- long dwFlags = cell->dwFlags;
- RECT rect;
- if(nType != 4/*TYPE_CLASS_DEPENDENT*/)CopyRect(&rect,&cell->Rect);
- else CopyRect(&rect,&cell->PT);
- int nPos=0;int nState=0;char bFocus =(m_nInterCellFocus == nIDCell)?1:0;
- Diagram__ClientToScreen2(rect);
- DIAGRAMCELL* pC;
- for(nPos = 0; nPos < cell->nSizeDependents; nPos++){
- pC = Diagram__GetCell(cell->pDependents[nPos]);
- if(pC->dwFlags & 0x00000010L && pC->nBreakA == nIDCell && (pC->dwFlags & 0x00001000L || pC->dwFlags & 0x00000800L)){
- if(bDraw){FillSolidRect2(rect.left+4,rect.top+4,rect.right-2,rect.bottom-2,5);
- Draw3dRect2(rect.left+4,rect.top+4,rect.right-2,rect.bottom-2,4,4);
- }
- InflateRect(&rect,0,0,-6,-6);
- nState=1; // draw as
-
- break;
-
- }
- }
-
- nPlusY = 0;
- string ToRender;
- char FontType=0;
- if(nType < 4){ // 2/*TYPE_CLASS_FULL*/ || TYPE_CLASS_ONLY || 3/*TYPE_CLASS_OBJECT*/
-
- if(bDraw){FillSolidRect2(rect.left+1,rect.top+1,rect.right-2,rect.bottom-2,5);
- Draw3dRect2(rect.left,rect.top,rect.right-2,rect.bottom-2,4,4);
- }
-
-
- SIZE extent;
- long bAbstract = dwFlags & 0x00000100L/*TYPE_OA_ABSTRACT*/;
- GetTextExtent(cell->ClassName,extent,FONT_ARIAL_BOLD_10);
- nPlusX=0;
- if(extent.x > Diagram__MakeCellWidth(nIDCell)) nPlusX= 20+extent.x;
- else if(extent.x < Diagram__MakeCellWidth(nIDCell)){
- nPlusX = 20+(extent.x < 100 ? 100: extent.x);
-
- if(dwFlags & 0x00000040L/*TYPE_OA_UTILITY*/)ToRender+="½utility╗ ";
- if(dwFlags & 0x00000080L/*TYPE_OA_IMPLEMENT*/)ToRender+="½implement╗ ";
- if(dwFlags & 0x00000020L/*TYPE_OA_INTERFACE*/)ToRender+="½interface╗ ";
- if(dwFlags & 0x00000200L/*TYPE_OA_BIND*/)ToRender+="½bind╗ ";
- ToRender+=cell->strExStereotypes;
- if(ToRender != ""){ToRender=trim(ToRender);
- if(bDraw)DrawText(ToRender,&rect,4,5,0x00000001/*DT_CENTER*/,FONT_TAHOMA_BOLD_8);
- GetTextExtent(ToRender,extent,FONT_TAHOMA_BOLD_8);
- if(extent.x+15 > nPlusX)nPlusX=extent.x+15;
- nPlusY += 10;
- }
-
- }
- RECT ClassText;
- SetRect(&ClassText,rect.left-2,rect.top+nPlusY+6,rect.right-2,rect.bottom);
- ToRender = "";
- if(bAbstract)FontType = 1; // italic
- if(bDraw)DrawText(cell->ClassName,&ClassText,4,5,0x00000001/*DT_CENTER*/|((nType == 3/*TYPE_CLASS_OBJECT*/)?0x00000020/*DT_UNDERLINE*/:0),((FontType == 1)?FONT_ARIAL_BOLD_ITALIC_10:FONT_ARIAL_BOLD_10));
-
- cell->nBreakA = ClassText.top;
- nPlusY+=18;
-
- if(bAbstract || cell->strExProperties != ""){
- if(bAbstract){
- ToRender = "{abstract}";
- }
- ToRender+=cell->strExProperties;
- InflateRect(&ClassText,0,-17,0,+17);
- if(bDraw)DrawText(trim(ToRender),&ClassText,4,5,0x00000001/*DT_CENTER*/,FONT_TAHOMA_BOLD_8);
- GetTextExtent(ToRender,extent,FONT_TAHOMA_BOLD_8);
- if(extent.x+15 > nPlusX) nPlusX=extent.x+15;
-
- nPlusY += 23;
-
- }
-
- // if(dwFlags & TYPE_OA_ABSTRACT){
- // if(bDraw)TextOut(rect.left+((rect.right-rect.left)-extent.x)/2,rect.top+nPlusY,cell->ClassName,4,5,FONT_ARIAL_BOLD_10);
- // }
- if(nPlusY < 34)nPlusY=34;
- int nNoUse = 0;
- if(nType == 2/*TYPE_CLASS_FULL*/){
- int fgo;
- if(bDraw)LineFromTo2(rect.left,rect.top+nPlusY,rect.right-1,rect.top+nPlusY,4); // first divider
- cell->nBreakB =rect.top+nPlusY;
- if(cell->nSizeVariable == 0)nPlusY+=20;
- else {
- nPlusY+=4;
-
- for(fgo=0;fgo < cell->nSizeVariable;fgo++){
- Diagram__DrawOA(((CLASSITEM*)(cell->pVariable))[fgo].strText,((CLASSITEM*)(cell->pVariable))[fgo].nType,rect.left+5,rect.top+nPlusY,bDraw,nNoUse);
- if(!bDraw && nPlusX < nNoUse)nPlusX = nNoUse;
- nPlusY+= 13;
-
- }
- nPlusY+=4;
- }
- if(bDraw)LineFromTo2(rect.left,rect.top+nPlusY,rect.right-1,rect.top+nPlusY,4); // second divider
- cell->nBreakC =rect.top+nPlusY;
- if(cell->nSizeOperation == 0)nPlusY+=20;
- else {
- nPlusY+=4;
- for(fgo=0;fgo < cell->nSizeOperation;fgo++){
- Diagram__DrawOA(((CLASSITEM*)(cell->pOperation))[fgo].strText,((CLASSITEM*)(cell->pOperation))[fgo].nType,rect.left+5,rect.top+nPlusY,bDraw,nNoUse );
- if(!bDraw && nPlusX < nNoUse)nPlusX = nNoUse;
- nPlusY+= 13;
-
- }
- nPlusY+=4;
- }
-
-
-
- }
- }
- else {
- if(nType == 5/*TYPE_CLASS_IMG*/){
- if(bDraw){
- GrNaƒtiBMP(rect.left,rect.top,cell->ClassName,0,0,-1,-1,0);
- Draw3dRect2(rect.left,rect.top,rect.right-2,rect.bottom-2,0,3);
- }
- }
- else if(nType == 4/*TYPE_CLASS_DEPENDENT*/){
- GrNastavBarvuPop²edí((bFocus)?6:4);
- Diagram__DrawDependent(rect.left,rect.top,rect.right,rect.bottom,0,dwFlags,nIDCell);
-
- }
-
-
-
- }
- if(nType != 4/*TYPE_CLASS_DEPENDENT*/){
-
- if(nState == 1){
- InflateRect(&rect,-4,-4,6,6);
- nPlusY+=6;nPlusX+=6;
-
- }
- if(bDraw){
- char color = (bFocus)?6:7 /* BLUE*/;
- LineFromTo2(rect.left+3,rect.bottom-1,rect.right,rect.bottom-1,color);
- LineFromTo2(rect.left+3,rect.bottom,rect.right,rect.bottom,color);
- LineFromTo2(rect.right,rect.top+3,rect.right,rect.bottom,color);
- LineFromTo2(rect.right-1,rect.top+3,rect.right-1,rect.bottom,color);
- }
- nPlusX+=2;
- nPlusY+=4;
-
- }
-
- if(bDraw)ShowMouse();
-
- }
- void Diagram__DrawCellEx(int nID){
- int x,y;
- Diagram__DrawCell(nID,1,x,y);
- }
-
- //DIAGRAMCELL* Diagram__GetCell(unsigned nId){
- // return &m_DiagramCells[nId];
- //} /
-
- void Diagram__SetInterFocus( int nID ){
- int id = m_nInterCellFocus;
- if(id == nID)return;
- m_nInterCellFocus = nID;
- if(id != -1)SendMessage(2 /* IDC_DIAGRAM */,101/*DIA_KILLFOCUS*/,id,-1);
- if(nID != -1)SendMessage(2 /* IDC_DIAGRAM */,102/*DIA_SETFOCUS*/,nID,-1);
-
- }
-
- void Diagram__WCCopy(){
- int i = m_nInterCellFocus;
- if( i == -1)return; // nothing to move to ex. memory
- // this command I cannot use because I copy only memory space of m_DiagramCells[?],
- // but some datas is store outside this structure. I have to copy some variable to
- // m_MEMORY_CELL and create new space for operations and variables
- // memcpy(&m_MEMORY_CELL,&m_DiagramCells[i],sizeof(DIAGRAMCELL));
- //
- DIAGRAMCELL* pCell = &m_DiagramCells[i];
- m_MEMORY_CELL.ClassName = pCell->ClassName;
- m_MEMORY_CELL.dwFlags = pCell->dwFlags;
- m_MEMORY_CELL.nType = pCell->nType;
- CopyRect(&m_MEMORY_CELL.Rect,&pCell->Rect);
- int d;
- //GrNastavPozici(0,0);GrPiτⁿet╪zec("XXX");Wait();
- CLASSITEM * pO,*pM;
- if(pCell->nSizeOperation!=0){
- m_MEMORY_CELL.pOperation=ClassItemInit(m_MEMORY_CELL.pOperation,m_MEMORY_CELL.nSizeOperation, pCell->nSizeOperation);
- for(d=0; d < pCell->nSizeOperation; d++){
- pO = &((CLASSITEM*)pCell->pOperation)[d];
- pM = &((CLASSITEM*)m_MEMORY_CELL.pOperation)[d];
- pM->strText = pO->strText;
- pM->nType = pO->nType ;
- // GrPiτD¼íslo(d,-1,2);GrPiτⁿet╪zec((((CLASSITEM*)m_MEMORY_CELL.pOperation)[d]).strText );
- }
-
- }
- else if(m_MEMORY_CELL.nSizeOperation != 0)
- m_MEMORY_CELL.pOperation=ClassItemInit(m_MEMORY_CELL.pOperation,m_MEMORY_CELL.nSizeOperation,0);
-
- if(pCell->nSizeVariable!=0){
- m_MEMORY_CELL.pVariable=ClassItemInit(m_MEMORY_CELL.pVariable,m_MEMORY_CELL.nSizeVariable, pCell->nSizeVariable);
- for(d=0; d < pCell->nSizeVariable; d++){
- pO = &((CLASSITEM*)pCell->pVariable)[d];
- pM = &((CLASSITEM*)m_MEMORY_CELL.pVariable)[d];
- pM->strText = pO->strText;
- pM->nType = pO->nType ;
- }
-
- }
- else if(m_MEMORY_CELL.nSizeVariable != 0)
- m_MEMORY_CELL.pVariable=ClassItemInit(m_MEMORY_CELL.pVariable,m_MEMORY_CELL.nSizeVariable, 0);
-
-
- }
- unsigned Diagram__CreateCell(int x, int y, unsigned nType );
-
- void Diagram__WCPaste(){
- int id = Diagram__CreateCell(0,0,0);
- //memcpy(&m_DiagramCells[id],&m_MEMORY_CELL,sizeof(DIAGRAMCELL));
- DIAGRAMCELL * pCell = &m_DiagramCells[id];
- SetRect(&pCell->Rect,0,0,(m_MEMORY_CELL.Rect.right - m_MEMORY_CELL.Rect.left),(m_MEMORY_CELL.Rect.bottom - m_MEMORY_CELL.Rect.top));
- pCell->nType = m_MEMORY_CELL.nType;
- pCell->ClassName = m_MEMORY_CELL.ClassName;
- pCell->dwFlags = m_MEMORY_CELL.dwFlags;
- int i;
-
- for(i=0;i < m_MEMORY_CELL.nSizeOperation; i++) {
-
- if(m_MEMORY_CELL.nType < 3 ){
- Diagram__AddOperation(id,((CLASSITEM*)m_MEMORY_CELL.pOperation)[i].strText,((CLASSITEM*)m_MEMORY_CELL.pOperation)[i].nType);
- }
- }
- for(i=0;i < m_MEMORY_CELL.nSizeVariable; i++) {
- if(m_MEMORY_CELL.nType < 3){
- Diagram__AddVariable(id,((CLASSITEM*)m_MEMORY_CELL.pVariable)[i].strText,((CLASSITEM*)m_MEMORY_CELL.pVariable)[i].nType);
- }
- }
- Diagram__SetInterFocus(id);
- }
- void Diagram__OnDrawClipRect( int x,int y, int x2, int y2 );
-
- void Diagram__WCDelete(){
- int i = m_nInterCellFocus;
- if( i == -1)return; // nothing to move to ex. memory
- RECT rc;
- int xi =i;
- CopyRect(&rc,&m_DiagramCells[i].Rect);
- Diagram__DestroyCell(i);
- // delete cell from
- // a) m_DiagramCells
- int nDep;
- if(i < m_nm_DiagramCellsSize-1) {// cell cannot be last !
- for(; xi < m_nm_DiagramCellsSize-1;xi++){
- memmove(&m_DiagramCells[xi],&m_DiagramCells[xi+1],sizeof(DIAGRAMCELL));
- }
- }
- int a;
-
- for(a = 0; a < m_nm_DiagramCellsSize; a++){
- DIAGRAMCELL * pCell = &m_DiagramCells[a];
- if(pCell->nType == 4/*TYPE_CLASS_DEPENDENT*/){
- if(pCell->nBreakA == i)pCell->nBreakA=-1;
- if(pCell->nBreakB == i)pCell->nBreakB=-1;
- if(pCell->nBreakA > i)pCell->nBreakA--;
- if(pCell->nBreakB > i)pCell->nBreakB--;
-
- }
- else {
- int an=0;
- for(;an < pCell->nSizeDependents;an++){
- if(pCell->pDependents[an] > i){
- pCell->pDependents[an] -=1;
-
- }
- }
- }
-
- }
-
-
- // b) ZOrder indexer
- // where is i control in array ?
- int ix;
- int movefrom = -1;
- for(ix=0;ix<m_nm_DiagramCellsSize;ix++){
- if(m_DiagramZOrder[ix] == xi){ // yes, it is
- movefrom =ix;break;
- }
-
- }
- if(movefrom != -1){ // yes, i is in array.
- // Note : Another case wont be, but this is better/nice :-)
- for(movefrom; movefrom < m_nm_DiagramCellsSize-1;movefrom++){
- memcpy(&m_DiagramZOrder[movefrom],&m_DiagramZOrder[movefrom+1],sizeof(int));
- }
-
- }
-
-
- // c) realloc memory space :
- m_nm_DiagramCellsSize--;
- m_DiagramCells = (DIAGRAMCELL*)realloc(m_DiagramCells,sizeof(DIAGRAMCELL)*(m_nm_DiagramCellsSize));
- m_DiagramZOrder = (int*)realloc(m_DiagramZOrder,sizeof(int)*(m_nm_DiagramCellsSize));
- m_nInterCellFocus = -1;
- Diagram__OnDrawClipRect(rc.left,rc.top,rc.right,rc.bottom);
- }
- void Diagram__HideDragingRect(){
- int x,y;
- x=m_LastEvent.x-m_DiaIncrease.left;y=m_LastEvent.y-m_DiaIncrease.top;
- HideMouse();
- GrNastavBarvuPop²edí(1);
- GrNastavLinku(42/*8|2|0x20*/,0xAAAA);
- GrKresliObdélník(x+1,y+1,
- x-1+Diagram__MakeCellWidth(m_nInterCellFocus),
- y -1+Diagram__MakeCellHeight(m_nInterCellFocus));
- GrNastavLinku(21/*4|1|0x10*/,0xFFFF);
- ShowMouse();
- }
- void SetCursor(int nID){
- AnimP²edm╪tZruτ(MouseObject);
- MouseObject=AnimP²edm╪tVytvo²(nID,1,0,1);
- // SetPoint(&MOUSEOFFSET,10,10);
- ShowMouse();
- }
- void Diagram__HideAddingDependent(){
- HideMouse();
-
- if(m_LAST_POINTS.left >= 0)
- Diagram__DrawDependent(m_LAST_POINTS.left,m_LAST_POINTS.top,m_LAST_POINTS.right,m_LAST_POINTS.bottom,1,1/*TYPE_DEPENDENT_INHERITANCE*/,-1);
- m_DIAGRAM_ADDINGDEPENDENT =0;
- SetCursor(85);
-
-
-
-
- }
- void Button__SetCheck(unsigned hWnd, long bCheck );
- void AddDialog__GetName(string strText,int &nPos){
- SetWindowText(26/*IDC_ADD_NAME*/,trim(StrKopie(strText,0,nPos)));
- }
- void AddDialog__AddParaByString(string str){
- int x,i = StrPozicePod²et╪zce(str,0,":"),g;
- if(StrKopie(str,0,5)=="inout"){Button__SetCheck(24/*IDC_PARA_INOUT*/,1);x=6;g=24;}
- else if ((StrKopie(str,0,3)=="out")){Button__SetCheck(25/*IDC_PARA_OUT*/,1);x=4;g=25;}
- else if ((StrKopie(str,0,2)=="in")){Button__SetCheck(27/*IDC_PARA_IN*/,1);x=3;g=27;}
- else {Button__SetCheck(27/*IDC_PARA_IN*/,1);x=0;g=27;}
- Invalidate(g);
- SetWindowText(20/*IDC_PARA_NAME*/,trim(StrKopie(str,x,i-x)));
- Invalidate(20/*IDC_PARA_NAME*/);
- SetWindowText(19/*IDC_PARA_TYPE*/,trim(StrKopie(str,i+1,-1)));
- Invalidate(19/*IDC_PARA_TYPE*/);
-
- }
- void AddDialog__ParserString( string strText ){
- int nPos;
- int nLen = StrDélka(strText);
- char nName = 0;
- ListBox__DeleteAll(21/*IDC_PARA_LIST*/);
- for(nPos=0;nPos < nLen;nPos++){
- if(strText[nPos]=='('){
- AddDialog__GetName(strText,nPos);
- nName =1;
-
- unsigned end = StrPozicePod²et╪zce(strText,0,")");
- if(end != 0xffff){
- int nX,id=0;
- string strx;
- for(nPos++;nPos < end && strText[nPos] != ')';nPos++){
- int nX=nPos;
- for(;nPos < nLen && strText[nPos] != ')' && strText[nPos] != ',';nPos++){}
- strx = trim(StrKopie(strText,nX,nPos-nX));
- if(strx != ""){
- ListBox__AddItem(21/*IDC_PARA_LIST*/,id,strx);id++;
- }
- }
- }
- }
- if(strText[nPos]==':'){ // read type
- if(nName==0)AddDialog__GetName(strText,nPos);
- SetWindowText(12/*IDC_ADD_TYPENAME*/,trim(StrKopie(strText,nPos+1,-1)));
- }
- }
-
-
- }
-
- char Diagram__HitTestCell(int nID, int& yDest){
- if(nID < 0)return 0;
- DIAGRAMCELL* pCell = Diagram__GetCell(nID);
- int nBreakC=pCell->nBreakC+4;
- int nBreakB=pCell->nBreakB+4;
- if(nBreakB > yDest )
- return 0;
- if(nBreakB < yDest && nBreakC-8 > yDest){
- if(pCell->nSizeVariable == 0)
- return 0;
- else {
- yDest = -((yDest-nBreakB)/13+1);
- return 1;
- }
- }
- if(nBreakC < yDest && (nBreakC+pCell->nSizeOperation*13) > yDest){
- if(pCell->nSizeOperation == 0)
- return 0;
- else {
- yDest = (yDest-nBreakC)/13+1;
- return 1;
- }
- }
- return 0;
- }
- void Button__GetCheckRange(int nPosStart,int nPosEnd,long& dwFlags);
- void Diagram__OnInsert(){
- DestroyDialog();
- string declare;
- int nFocus = m_nInterCellFocus;
- long nNewState=0;
- DIAGRAMCELL* pCell = Diagram__GetFocusCell();
- long lparam= GetWindow(10 /*IDC_ADDINGDIALOG*/)->lParam;
- declare = AddDialog__CreateString();
- Button__GetCheckRange(13,18,nNewState);
- if(lparam > 0){
- if(lparam == 1){
- Diagram__AddOperation(nFocus,declare,nNewState);
- }
- else {
- Diagram__AddVariable(nFocus,declare,nNewState);
- }
- }
- else {
- CLASSITEM* pData=0;
- if(lparam == -1){
- pData =&((CLASSITEM*)(pCell->pOperation))[m_MOUSEOVER_PTY-1];
- }
- else {
- pData =&((CLASSITEM*)(pCell->pVariable))[-m_MOUSEOVER_PTY-1];
- }
- pData->strText = declare;
- pData->nType =nNewState;
- }
- if(pCell->nType = 1/*TYPE_CLASS_ONLY*/)pCell->nType = 2/*TYPE_CLASS_FULL*/;
- Diagram__RecalculateCellRect(nFocus,2);
-
-
- }
- // END OF FILE ...
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////