#include "drawTextEntity.h"#include "Vect2Matrix.h"#include "GetProperty.h"#include "periScreen.h"#include "DrawObjects.h"#include "Xcall1.h"#include "Axes.h"#include "StringBox.h"#include "math_graphics.h"#include "sciprint.h"#include "clipping.h"Include dependency graph for drawTextEntity.c:

Go to the source code of this file.
Functions | |
| int | drawTextEntity (sciPointObj *pObj) |
| void | drawStringsInPosition (StringMatrix *strings, Vect2iMatrix *cellsArray, int center[2], double angle, sciTextAlignment align) |
| void | drawStringInCell (char *string, int blCorner[2], int urCorner[2], int rotCenter[2], double angle, sciTextAlignment align) |
| void | getStringMargins (int stringSize[2], int blCorner[2], int urCorner[2], sciTextAlignment align, int *lMargin, int *bMargin) |
| void drawStringInCell | ( | char * | string, | |
| int | blCorner[2], | |||
| int | urCorner[2], | |||
| int | rotCenter[2], | |||
| double | angle, | |||
| sciTextAlignment | align | |||
| ) |
Draw a string inside a box. The box can be rotated.
| string | displayed string | |
| blCorner | Bottom left corner of the string. | |
| urCorner | Upper right corner of the string. | |
| rotCenter | Rotation center. | |
| angle | Rotation angle in radian. | |
| align | Position of the string inside the box. |
Definition at line 224 of file drawTextEntity.c.
References Abs, C2F, dr(), EPSILON, getStringBbox(), getStringMargins(), iRotate2D(), L, PD0, PI0, pos, and RAD2DEG.
Referenced by drawStringsInPosition().
00230 { 00231 int rect[4] ; 00232 int leftMargin ; 00233 int bottomMargin ; 00234 int pos[2] ; 00235 int flag = 0 ; 00236 double angleStr = RAD2DEG( angle ) ; 00237 /* get the size of the string */ 00238 getStringBbox( string, blCorner, rect ) ; 00239 00240 getStringMargins( &(rect[2]), blCorner, urCorner, align, &leftMargin, &bottomMargin ) ; 00241 00242 /* get the position unturned */ 00243 pos[0] = blCorner[0] + leftMargin ; 00244 pos[1] = blCorner[1] + bottomMargin + rect[3] ; 00245 00246 /* then turn it around the center */ 00247 if ( Abs( angle ) > EPSILON ) 00248 { 00249 iRotate2D( pos, rotCenter, angle, pos ) ; 00250 } 00251 /* then display it */ 00252 C2F(dr)("xstring",string,&(pos[0]),&(pos[1]),PI0,&flag,PI0,PI0,&angleStr, PD0,PD0,PD0,0L,0L); 00253 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void drawStringsInPosition | ( | StringMatrix * | strings, | |
| Vect2iMatrix * | cellsArray, | |||
| int | center[2], | |||
| double | angle, | |||
| sciTextAlignment | align | |||
| ) |
Given a matrix of strings and an array of cells positions, draw each strings in the corresponding cell. The array of cells must not been turned, this function manage the rotation itself. The alignment is also respected.
| strings | set of strings to display. | |
| cellsArray | position of the cells in which the strings are dispalyed. | |
| center | position of the center of the string array around which the rotation is done. | |
| angle | rotation angle in radian of the displayed matrix around its lower left point. | |
| align | position of strings inside their cells. |
Definition at line 200 of file drawTextEntity.c.
References drawStringInCell(), getMatNbCol(), getMatNbRow(), getStrMatElement(), getVect2iMatElement(), i, j, and string.
Referenced by drawTextEntity().
00205 { 00206 int nbRow = getMatNbRow( strings ) ; 00207 int nbCol = getMatNbCol( strings ) ; 00208 int i ; 00209 int j ; 00210 00211 for ( i = 0 ; i < nbRow ; i++ ) 00212 { 00213 for ( j = 0 ; j < nbCol ; j++ ) 00214 { 00215 /* get the two extreme corners of the cell in which the text will be drawn */ 00216 int * blCorner = getVect2iMatElement( cellsArray, i , j ) ; 00217 int * urCorner = getVect2iMatElement( cellsArray, i + 1, j + 1 ) ; 00218 char * string = getStrMatElement( strings, i, j ) ; 00219 drawStringInCell( string, blCorner, urCorner, center, angle, align ) ; 00220 } 00221 } 00222 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int drawTextEntity | ( | sciPointObj * | pObj | ) |
Routine which draw a text object
| pObj | the pointer on the text object |
Definition at line 21 of file drawTextEntity.c.
References C2F, close(), DEG2RAD, deleteMatrix(), dr(), drawStringsInPosition(), getPixelCoordinates(), getStringsPositions(), sciText::isclip, L, MaybeSetWinhdc(), n, newMatrix(), PD0, PI0, PixelHeight2d(), PixelWidth2d(), pTEXT_FEATURE, ReleaseWinHdc(), rotateBoundingBox(), sciClip(), sciGetAlignment(), sciGetAutoSize(), sciGetBackground(), sciGetCenterPos(), sciGetFontDeciWidth(), sciGetFontForeground(), sciGetFontOrientation(), sciGetFontStyle(), sciGetForeground(), sciGetIs3d(), sciGetIsBoxed(), sciGetIsFilled(), sciGetIsLine(), sciGetParentSubwin(), sciGetText(), sciGetTextSize(), sciGetUserSize(), sciGetVisibility(), sciUnClip(), v, sciText::x, XDouble2Pixel, sciText::y, YDouble2Pixel, and sciText::z.
Referenced by labels2D_draw(), and sciDrawObj().
00022 { 00023 int v = 0 ; 00024 double dv = 0. ; 00025 double anglestr = 0. ; 00026 int textProperties[6] ; 00027 int verb=0; 00028 int font_[2], cur_font_[2] ; 00029 int position[2] ; 00030 int textDim[2] ; 00031 double userSize[2] ; 00032 int textSize[2] ; 00033 double textPos[3] ; 00034 Vect2iMatrix * bboxes ; 00035 int globalBbox[4][2] ; 00036 sciText * ppText = pTEXT_FEATURE( pObj ) ; 00037 sciPointObj * parentSW = sciGetParentSubwin(pObj) ; 00038 00039 if (!sciGetVisibility(pObj)) 00040 { 00041 return 0 ; 00042 } 00043 00044 00045 00046 #ifdef _MSC_VER 00047 flag_DO = MaybeSetWinhdc (); 00048 #endif 00049 if ( ppText->isclip ) 00050 { 00051 sciClip(pObj); 00052 } 00053 00054 /* transform the position in pixels */ 00055 /* we don't take the axes reverse into account. This has obviously no meaning for text.*/ 00056 textPos[0] = ppText->x ; 00057 textPos[1] = ppText->y ; 00058 textPos[2] = ppText->z ; 00059 00060 if ( sciGetIs3d( pObj ) ) 00061 { 00062 /* normal case */ 00063 getPixelCoordinates( parentSW, textPos, position ) ; 00064 } 00065 else 00066 { 00067 /* for labels, the text is displayed using 2d scale. */ 00068 position[0] = XDouble2Pixel( textPos[0] ) ; 00069 position[1] = YDouble2Pixel( textPos[1] ) ; 00070 } 00071 00072 00073 sciGetUserSize( pObj, &(userSize[0]), &(userSize[1]) ) ; 00074 00075 00076 /* We take the size in 2d. */ 00077 textSize[0] = PixelWidth2d( parentSW, ppText->x, userSize[0] ) ; 00078 textSize[1] = PixelHeight2d( parentSW, ppText->y, userSize[1] ) ; 00079 00080 /* *10 parce que l'angle est conserve en 1/10eme de degre*/ 00081 /* si c'est pas nimp tout ca.... */ 00082 anglestr = (sciGetFontOrientation (pObj)/10); 00083 00084 /* set the font */ 00085 C2F(dr)("xget","font",&verb,cur_font_,&v,&v,&v,&v,&dv,&dv,&dv,&dv,5L,5L); 00086 00087 font_[0] = sciGetFontStyle (pObj); 00088 font_[1] = sciGetFontDeciWidth (pObj)/100; 00089 00090 C2F(dr)("xset","font",&font_[0],&font_[1],PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 00091 00092 /* get the bounding box of the text matrix */ 00093 /* the matrix with the bounding box of each strings in the text object */ 00094 sciGetTextSize( pObj, &(textDim[0]), &(textDim[1]) ) ; 00095 bboxes = newMatrix( textDim[0] + 1, textDim[1] + 1 ) ; 00096 00097 00098 /* we get the array not turned because the display will turn everything by itself */ 00099 /* However, the bounding box needs to be turned after */ 00100 getStringsPositions( sciGetText( pObj ) , 00101 &font_[0] , 00102 &font_[1] , 00103 position , 00104 sciGetAutoSize( pObj ) , 00105 textSize , 00106 sciGetCenterPos( pObj ), 00107 0.0 , 00108 bboxes , 00109 globalBbox ) ; 00110 00111 /* font might have changed */ 00112 C2F(dr)("xset","font",&font_[0],&font_[1],PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 00113 00114 /* wether or not we draw and/or fill the box */ 00115 /* no need to compute anything if both line_mode */ 00116 /* and fill mode are false */ 00117 /* Of course, the background should be drawn first */ 00118 if( sciGetIsBoxed (pObj) 00119 && ( sciGetIsFilled( pObj ) || sciGetIsLine( pObj ) ) ) 00120 { 00121 int xm[4], ym[4],n=4; 00122 int close=1; 00123 00124 /* we need to rotate the bounding box */ 00125 rotateBoundingBox( globalBbox, position, DEG2RAD(anglestr) ) ; 00126 00127 xm[0] = globalBbox[0][0] ; 00128 xm[1] = globalBbox[1][0] ; 00129 xm[2] = globalBbox[2][0] ; 00130 xm[3] = globalBbox[3][0] ; 00131 00132 ym[0] = globalBbox[0][1] ; 00133 ym[1] = globalBbox[1][1] ; 00134 ym[2] = globalBbox[2][1] ; 00135 ym[3] = globalBbox[3][1] ; 00136 00137 00138 00139 /* draw the background */ 00140 if ( sciGetIsFilled( pObj ) ) 00141 { 00142 textProperties[0] = sciGetBackground( pObj ) ; 00143 C2F (dr) ("xset", "dashes", textProperties, textProperties, textProperties+3, textProperties+3, textProperties+3, &v, &dv,&dv, &dv, &dv, 5L, 6L); 00144 C2F (dr) ("xset", "foreground", textProperties, textProperties, textProperties+3, textProperties+3, textProperties+3, &v,&dv, &dv, &dv, &dv, 5L, 10L); 00145 00146 C2F (dr) ("xarea", "xv", &n, xm, ym, &close, PI0, PI0, PD0, PD0, PD0, PD0, 5L,strlen("xv")); 00147 } 00148 00149 /* draw the line around the box */ 00150 if ( sciGetIsLine( pObj ) ) 00151 { 00152 textProperties[0] = sciGetForeground( pObj ) ; 00153 /* draw a rectangle around the text */ 00154 C2F (dr) ("xset", "dashes", textProperties, textProperties, textProperties+3, textProperties+3, textProperties+3, &v, &dv,&dv, &dv, &dv, 5L, 6L); 00155 C2F (dr) ("xset", "foreground", textProperties, textProperties, textProperties+3, textProperties+3, textProperties+3, &v,&dv, &dv, &dv, &dv, 5L, 10L); 00156 00157 C2F (dr) ("xlines", "xv", &n, xm, ym, &close, PI0, PI0, PD0, PD0, PD0, PD0,6L,2L); 00158 } 00159 } 00160 00161 #ifdef _MSC_VER 00162 flag_DO = MaybeSetWinhdc (); 00163 #endif 00164 /* load the object foreground and dashes color */ 00165 textProperties[0] = sciGetFontForeground (pObj);/*la dash est de la meme couleur que le foreground*/ 00166 textProperties[2] = sciGetFontDeciWidth (pObj)/100; 00167 textProperties[3] = 0 ; 00168 textProperties[4] = sciGetFontStyle(pObj); 00169 textProperties[5] = 0 ; 00170 00171 C2F (dr) ("xset", "dashes", textProperties, textProperties, textProperties+3, textProperties+3, textProperties+3, &v, &dv,&dv, &dv, &dv, 5L, 6L); 00172 C2F (dr) ("xset", "foreground", textProperties, textProperties, textProperties+3, textProperties+3, textProperties+3, &v,&dv, &dv, &dv, &dv, 5L, 10L); 00173 /* C2F(dr)("xset","font",x+4,x+2,&v, &v, &v, &v,&dv, &dv, &dv, &dv, 5L, 4L); */ 00174 00175 #ifdef _MSC_VER 00176 if ( flag_DO == 1) ReleaseWinHdc (); 00177 #endif 00178 00179 drawStringsInPosition( sciGetText( pObj ), bboxes,position, DEG2RAD(anglestr), sciGetAlignment( pObj ) ) ; 00180 /* C2F(dr)("xstring",getStrMatElement(sciGetText(pObj),0,0),&x1,&yy1,PI0,&flagx,PI0,PI0,&anglestr, PD0,PD0,PD0,0L,0L); */ 00181 00182 00183 C2F(dr)("xset","font",&cur_font_[0],&cur_font_[1],PI0,PI0,PI0,PI0,PD0,PD0,PD0,PD0,0L,0L); 00184 00185 deleteMatrix( bboxes ) ; 00186 00187 if ( ppText->isclip ) 00188 { 00189 sciUnClip(pObj); 00190 } 00191 00192 #ifdef _MSC_VER 00193 if ( flag_DO == 1) ReleaseWinHdc (); 00194 #endif 00195 00196 return 0 ; 00197 00198 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void getStringMargins | ( | int | stringSize[2], | |
| int | blCorner[2], | |||
| int | urCorner[2], | |||
| sciTextAlignment | align, | |||
| int * | lMargin, | |||
| int * | bMargin | |||
| ) |
Inside a cell, return the margin to be used for the display of a string inside a cell.
| stringSize | width and height of the string wich will be displayed. | |
| blCorner | the bottom left corner of the cell. The cell must not be turned (ie axes aligned). | |
| urCorner | the upper right corner of the cell. | |
| align | specify the position of the string inside the cell. | |
| lMargin | left margin (horizontal). | |
| bMargin | bottom margin (vertical). |
Definition at line 255 of file drawTextEntity.c.
References ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, and sciprint().
Referenced by drawStringInCell().
00261 { 00262 int cellWidth = urCorner[0] - blCorner[0] ; 00263 int cellHeight = urCorner[1] - blCorner[1] ; 00264 00265 switch( align ) 00266 { 00267 case ALIGN_LEFT: 00268 *lMargin = 0 ; 00269 break ; 00270 case ALIGN_RIGHT: 00271 *lMargin = cellWidth - stringSize[0] ; 00272 break ; 00273 case ALIGN_CENTER: 00274 /* same margin for each side */ 00275 *lMargin = ( cellWidth - stringSize[0] ) / 2 ; 00276 break ; 00277 default: 00278 sciprint("error unhandled alignment\n"); 00279 *lMargin = -1 ; 00280 *bMargin = -1 ; 00281 break ; 00282 } 00283 *bMargin = ( cellHeight - stringSize[1] ) / 2 ; 00284 00285 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.5.1