void main() { int gd=DETECT,gm,maxy,x,style; char str[40]; struct linesettingstype ls; initgraph(&gd,&gm,"d:\\tc\\bgi"); maxy=getmaxy(); setcolor(WHITE); outtextxy(10,20,"Normal Width"); x=20; for(style=0;style<=4;style++) { setlinestyle(style,0,1); if(style==0) getlinesettings(&ls); if(style==4) { setlinestyle(4,15,1); line(x,50,x,maxy-50); } else line(x,50,x,maxy-50); itoa(style,str,10); outtextxy(x,maxy-20,str); x=x+50; } outtextxy(375,20,"Thick Width"); x=375; for(style=0;style<=4;style++) { setlinestyle(style,0,3); if(style==4) { setlinestyle(4,35,3); line(x,50,x,maxy-50); } else line(x,50,x,maxy-50); itoa(style,str,10); outtextxy(x,maxy-20,str); x=x+50; } setlinestyle(ls.linestyle,ls.upattern,ls.thickness); getch(); closegraph(); restorecrtmode(); }
void draw_frame( int x1, int y1, int x2, int y2 ) { struct linesettingstype tmp; getlinesettings( &tmp ); setlinestyle( SOLID_LINE, 0, THICK_WIDTH ); setwritemode( 0 ); y1 += 4; #ifdef NOALIGN x1 += 40; x2 += 40; #else x1 += align; x2 += align; #endif moveto( x1, y1 ); lineto( x2, y1 ); lineto( x2, y2 ); lineto( x1, y2 ); lineto( x1, y1 ); moveto( x1 + 1, y1 + 1 ); setlinestyle( tmp.linestyle, tmp.upattern, tmp.thickness ); }
static void DisplayVirtualRect(int x1,int y1,int x2,int y2) { #ifdef __TURBOC__ struct linesettingstype SaveLineStyle; getlinesettings(&SaveLineStyle); setlinestyle(4,0x5555,1); #else int old_style; old_style=getlinestyle(); setlinestyle(0x5555); #endif MouseHidden(); rectangle(x1,y1,x2,y2); #ifdef __TURBOC__ setlinestyle(SaveLineStyle.linestyle,SaveLineStyle.upattern, SaveLineStyle.thickness); #else setlinestyle(old_style); #endif MouseShow(); }
int main() { int unidad = 0,modo; int fondo,dibujo,i; fillsettingstype p; viewporttype v; palettetype palette; linesettingstype linea; textsettingstype letra; initgraph (&unidad,&modo,"c:\\bc\\bgi"); if (graphresult() != 0) { cout << "Error al tratar de pasar al modo grafico\n"; getch(); return 1; } graphdefaults(); getfillsettings (&p); getviewsettings (&v); getpalette (&palette); fondo = getbkcolor(); dibujo = getcolor(); getlinesettings (&linea); gettextsettings (&letra); restorecrtmode(); printf ("%s\n","Patron para colorear y color"); printf ("%d\n",p.pattern); printf ("%d\n",p.color); // Retorna el numero de la celda... printf ("%s\n","Oprima una tecla...."); getch(); printf ("%s\n","Dimensiones del viewport"); printf ("%d %s %d\n",v.left,",",v.top); printf ("%d %s %d\n",v.right,",",v.bottom); if (v.clip) printf ("%s\n","True"); else printf ("%s\n","False"); printf ("%s\n","Oprima una tecla...."); getch(); printf ("%s\n","Estado original de la palette"); printf ("%s %d\n","Size=",palette.size); for (i = 0; i <= palette.size-1; i++ ) printf ("%d\n",palette.colors [i]); printf ("Oprima una tecla....\n"); getch(); printf ("Color de fondo y color para dibujar\n"); printf ("%d\n",fondo); printf ("%d\n",dibujo); printf ("Oprima una tecla....\n"); getch(); printf ("Estilo de linea y patron\n"); printf ("%d\n",linea.linestyle); printf ("%d\n",linea.upattern); printf ("Oprima una tecla....\n"); getch(); printf ("Estilo de letra y dimensiones\n"); printf ("%d\n",letra.font); printf ("%d\n",letra.direction); printf ("%d\n",letra.charsize); printf ("%d\n",letra.horiz); printf ("%d\n",letra.vert); printf ("Oprima una tecla....\n"); getch(); return 0; }
void PageDraw(HPAGE PageHandle,HWND Window,int DrawLeft, int DrawTop,int DrawRight,int DrawBottom) { int SaveColor; struct viewporttype TmpViewPort; #ifdef __TURBOC__ struct linesettingstype SaveLineStyle; #else unsigned short old_style; #endif ORDINATETYPE BoxDrawLeft,BoxDrawTop,BoxDrawRight,BoxDrawBottom; ORDINATETYPE BoxXY[2*MAXPOLYGONNUMBER]; HBOX HBox; Pages *MidPage; int Left,Top,Right,Bottom; int PageLeft,PageTop,PageRight,PageBottom; WindowGetRect(Window,&Left,&Top,&Right,&Bottom); if (!RectangleIsInRectangle(DrawLeft,DrawTop,DrawRight,DrawBottom, Left,Top,Right,Bottom)) return; if (DrawRight>=Right-Left) DrawRight=Right-Left-1; if (DrawBottom>=Bottom-Top) DrawBottom=Bottom-Top-1; if (DrawLeft<0) DrawLeft=0; if (DrawTop<0) DrawTop=0; BoxDrawLeft=WindowXToUserX(DrawLeft); BoxDrawTop=WindowYToUserY(DrawTop); BoxDrawRight=WindowXToUserX(DrawRight); BoxDrawBottom=WindowYToUserY(DrawBottom); MidPage=HandleLock(ItemGetHandle(PageHandle)); if (MidPage==NULL) return; PageLeft=UserXToWindowX(0); PageTop=UserYToWindowY(0); PageRight=UserXToWindowX(PageGetPageWidth(MidPage)); PageBottom=UserYToWindowY(PageGetPageHeight(MidPage)); if(GlobalTextBlockStart<GlobalTextBlockEnd) // must clear now block DisplayBlock(GlobalBoxHeadHandle,GlobalTextBlockStart,GlobalTextBlockEnd); SaveColor=getcolor(); MouseHidden(); TextCursorOff(); getviewsettings(&TmpViewPort); setviewport(Left,Top,Right,Bottom,1); /*---- clear page -----*/ setfillstyle(1,EGA_WHITE); bar(DrawLeft,DrawTop,DrawRight,DrawBottom); /*--- draw page border ---*/ setcolor(PAGEBORDERCOLOR); rectangle(PageLeft,PageTop,PageRight,PageBottom); if(!IsInGlobalBrowser()) DrawPageFootHead(PageHandle,TRUE,TRUE); if(!fEditor) { #ifdef __TURBOC__ getlinesettings(&SaveLineStyle); setlinestyle(4,0x5555,1); #else old_style=getlinestyle(); setlinestyle(0xffff); #endif /*--- draw page shadow ---*/ setcolor(EGA_DARKGRAY); line(((PageLeft>0)?PageLeft:0)+3,PageBottom+1,PageRight+3,PageBottom+1); line(((PageLeft>0)?PageLeft:0)+3,PageBottom+2,PageRight+3,PageBottom+2); line(((PageLeft>0)?PageLeft:0)+3,PageBottom+3,PageRight+3,PageBottom+3); line(PageRight+1,((PageTop>0)?PageTop:0)+3,PageRight+1,PageBottom+3); line(PageRight+2,((PageTop>0)?PageTop:0)+3,PageRight+2,PageBottom+3); line(PageRight+3,((PageTop>0)?PageTop:0)+3,PageRight+3,PageBottom+3); /*--- draw box align line ---*/ setcolor(EGA_LIGHTBLUE); /*------------ use 0x5555 -- #ifdef __TURBOC__ setlinestyle(4,0x5f5f,1); #else setlinestyle(0x5f5f); #endif ----------------*/ setlinestyle(0x8888); PageLeft=UserXToWindowX(PageGetMarginLeft(MidPage))-1; PageTop=UserYToWindowY(PageGetMarginTop(MidPage))-1; PageRight=UserXToWindowX(PageGetPageWidth(MidPage)- PageGetMarginRight(MidPage))+1; PageBottom=UserYToWindowY(PageGetPageHeight(MidPage)- PageGetMarginBottom(MidPage))+1; line(UserXToWindowX(0),PageTop, UserXToWindowX(PageGetPageWidth(MidPage)),PageTop); line(UserXToWindowX(0),PageBottom, UserXToWindowX(PageGetPageWidth(MidPage)),PageBottom); line(PageLeft,UserYToWindowY(0),PageLeft, UserYToWindowY(PageGetPageHeight(MidPage))); line(PageRight,UserYToWindowY(0),PageRight, UserYToWindowY(PageGetPageHeight(MidPage))); #ifdef __TURBOC__ setlinestyle(SaveLineStyle.linestyle,SaveLineStyle.upattern, SaveLineStyle.thickness); #else setlinestyle(old_style); #endif } HandleUnlock(ItemGetHandle(PageHandle)); setcolor(EGA_BLACK); HBox=PageGetBoxHead(PageHandle); while (HBox) { ORDINATETYPE BoxLeft,BoxTop,BoxRight,BoxBottom; TextBoxs *MidBox; int BoxDots; MidBox=HandleLock(ItemGetHandle(HBox)); if (MidBox==NULL) break; BoxGetPolygonDrawBorder((Boxs *)MidBox,&BoxDots,BoxXY); PolygonGetMinRectangle(BoxDots,BoxXY,&BoxLeft,&BoxTop,&BoxRight,&BoxBottom); if (RectangleIsInRectangle(BoxDrawLeft,BoxDrawTop,BoxDrawRight,BoxDrawBottom, BoxLeft,BoxTop,BoxRight,BoxBottom)||TextBoxGetBoxType(MidBox)==TEXTBOX) { HBOX LinkBox; BoxDraw(HBox, (HBox==GlobalBoxHeadHandle)?DRAWBORDERWITHRECATNGLE: DRAWVIRTUALBORDOR); if (TextBoxGetBoxType(MidBox)==TEXTBOX && (GlobalBoxTool==IDX_UNLINK||GlobalBoxTool==IDX_LINK) && (LinkBox=TextBoxGetPrevLinkBox(MidBox))!=0 ) { ORDINATETYPE Left2,Top2,Right2,Bottom2; BoxGetRect(HBox,&BoxLeft,&BoxTop,&BoxRight,&BoxBottom); BoxXY[0]=BoxLeft; BoxXY[1]=BoxTop; BoxPolygonRotate(1,BoxXY,(PictureBoxs *)MidBox); BoxPolygonToWindowXY(1,BoxXY); BoxLeft=BoxXY[0]; BoxTop=BoxXY[1]; if(ItemGetFather(LinkBox)==PageHandle) { BoxGetRect(LinkBox,&Left2,&Top2,&Right2,&Bottom2); BoxXY[0]=Right2; BoxXY[1]=Bottom2; BoxPolygonRotate(1,BoxXY,HandleLock(ItemGetHandle(LinkBox))); HandleUnlock(ItemGetHandle(LinkBox)); BoxPolygonToWindowXY(1,BoxXY); } else { BoxXY[0]=getmaxx(); BoxXY[1]=0; // screen (Right,Top) } line(BoxLeft,BoxTop,BoxXY[0],BoxXY[1]); } } HandleUnlock(ItemGetHandle(HBox)); HBox=ItemGetNext(HBox); } if (GlobalGroupGetSign()) GroupDrawAllBorder(DRAWXORBORDER); setviewport(TmpViewPort.left,TmpViewPort.top,TmpViewPort.right, TmpViewPort.bottom,TmpViewPort.clip); setcolor(SaveColor); MouseShow(); return; }