John Mitchell / lpc4088_displaymodule_GC500_2_5inch

Dependencies:   DMBasicGUI DMSupport

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GuiComponents.h Source File

GuiComponents.h

00001 /* ************************************************************************ */
00002 /*                                                                          */
00003 /*                     (C)2004-2015 IBIS Solutions ApS                      */
00004 /*                            sales@easyGUI.com                             */
00005 /*                             www.easyGUI.com                              */
00006 /*                                                                          */
00007 /*                               v6.0.9.005                                 */
00008 /*                                                                          */
00009 /*     GuiLib.c include file - do NOT reference it in your linker setup     */
00010 /*                                                                          */
00011 /* ************************************************************************ */
00012 
00013 //------------------------------------------------------------------------------
00014 void GuiLib_ClearPositionCallbacks(void)
00015 {
00016   GuiConst_INT16U I;
00017 
00018   for (I = 0; I < GuiConst_POSCALLBACK_CNT; I++)
00019     sgl.PosCallbacks[I].InUse = 0;
00020 }
00021 
00022 //------------------------------------------------------------------------------
00023 void GuiLib_SetPositionCallbackFunc(
00024    GuiConst_INT16U IndexNo,
00025    void (*PosCallbackFunc) (GuiConst_INT16U IndexNo,
00026                             GuiConst_INT16S X,
00027                             GuiConst_INT16S Y))
00028 {
00029   GuiConst_INT32S I, J;
00030 
00031   J = -1;
00032   for (I = 0; I < GuiConst_POSCALLBACK_CNT; I++)
00033     if (sgl.PosCallbacks[I].IndexNo == IndexNo)
00034     {
00035       J = I;
00036       break;
00037     }
00038   if (J == -1)
00039     for (I = 0; I < GuiConst_POSCALLBACK_CNT; I++)
00040       if (!sgl.PosCallbacks[I].InUse)
00041       {
00042         J = I;
00043         break;
00044       }
00045 
00046   if (J >= 0)
00047   {
00048     sgl.PosCallbacks[J].InUse = 1;
00049     sgl.PosCallbacks[J].PosCallbackFunc = PosCallbackFunc;
00050     sgl.PosCallbacks[J].IndexNo = IndexNo;
00051   }
00052 }
00053 
00054 #ifdef GuiConst_CURSOR_SUPPORT_ON
00055 //------------------------------------------------------------------------------
00056 //------------------------------------------------------------------------------
00057 //------------------------------------------------------------------------------
00058 static void DrawCursorItem(
00059    GuiConst_INT8U CursorVisible)
00060 {
00061 #ifndef GuiConst_CURSOR_FIELDS_OFF
00062   GuiConst_INT16S RemCursorFieldNo, I;
00063   PrefixLocate ItemMemory     RemMemory;
00064   PrefixLocate ItemMemory  *PrefixLocate CursorMemory;
00065   PrefixLocate GuiLib_ItemRec *CursorItem;
00066 
00067   if (sgl.CursorInUse && (GuiLib_ActiveCursorFieldNo >= 0))
00068   {
00069     I = -1;
00070     memcpy(&RemMemory, &sgl.Memory, sizeof(ItemMemory));
00071     while ((I = AutoRedraw_GetCursor(GuiLib_ActiveCursorFieldNo, I)) != -1)
00072     {
00073       CursorItem = AutoRedraw_GetItem(I);
00074       CursorMemory = AutoRedraw_GetItemMemory(I);
00075 
00076       if ((CursorItem == NULL) || (CursorMemory == NULL))
00077         return;
00078 
00079       memcpy(&sgl.CurItem, CursorItem, sizeof(GuiLib_ItemRec));
00080       memcpy(&sgl.Memory, CursorMemory, sizeof(ItemMemory));
00081 
00082 
00083   #ifdef GuiConst_ITEM_SCROLLBOX_INUSE
00084       if ((sgl.CurItem.TextPar[0].BitFlags & GuiLib_BITFLAG_FIELDSCROLLBOX) &&
00085           (sgl.ScrollBoxesAry[sgl.CurItem.CursorScrollBoxIndex].ScrollLineDataFunc != 0))
00086         sgl.ScrollBoxesAry[sgl.CurItem.CursorScrollBoxIndex].ScrollLineDataFunc(
00087            sgl.ScrollBoxesAry[sgl.CurItem.CursorScrollBoxIndex].MarkerStartLine[0]);
00088   #endif // GuiConst_ITEM_SCROLLBOX_INUSE
00089 
00090       if (!CursorVisible)
00091       {
00092         RemCursorFieldNo = GuiLib_ActiveCursorFieldNo;
00093         GuiLib_ActiveCursorFieldNo = -1;
00094       }
00095       else
00096         RemCursorFieldNo = 0;
00097 
00098       sgl.SwapColors = 0;
00099   #ifdef GuiConst_ITEM_SCROLLBOX_INUSE
00100       if (sgl.CurItem.TextPar[0].BitFlags & GuiLib_BITFLAG_FIELDSCROLLBOX)
00101         ScrollBox_DrawScrollLine(sgl.CurItem.CursorScrollBoxIndex,
00102            sgl.ScrollBoxesAry[sgl.CurItem.CursorScrollBoxIndex].MarkerStartLine[0]);
00103       else
00104   #endif // GuiConst_ITEM_SCROLLBOX_INUSE
00105       {
00106   #ifdef GuiConst_BITMAP_SUPPORT_ON
00107         UpdateBackgroundBitmap();
00108   #endif
00109 
00110         DrawItem(GuiLib_COL_INVERT_IF_CURSOR);
00111       }
00112 
00113       if (!CursorVisible)
00114         GuiLib_ActiveCursorFieldNo = RemCursorFieldNo;
00115     }
00116     memcpy(&sgl.Memory, &RemMemory, sizeof(ItemMemory));
00117   }
00118   #else // GuiConst_CURSOR_FIELDS_OFF
00119   CursorVisible = 0;
00120   #endif // GuiConst_CURSOR_FIELDS_OFF
00121 }
00122 
00123 //------------------------------------------------------------------------------
00124 void GuiLib_Cursor_Hide(void)
00125 {
00126 #ifndef GuiConst_CURSOR_FIELDS_OFF
00127   GuiDisplay_Lock();
00128   DrawCursorItem(0);
00129   GuiDisplay_Unlock();
00130   GuiLib_ActiveCursorFieldNo = -1;
00131 #endif // GuiConst_CURSOR_FIELDS_OFF
00132 }
00133 
00134 //------------------------------------------------------------------------------
00135 GuiConst_INT8U GuiLib_IsCursorFieldInUse(
00136    GuiConst_INT16S AskCursorFieldNo)
00137 {
00138 #ifndef GuiConst_CURSOR_FIELDS_OFF
00139   if (AskCursorFieldNo >= 0)
00140   {
00141     if (AutoRedraw_GetCursor(AskCursorFieldNo, -1) != -1)
00142       return 1;
00143   }
00144 
00145   return 0;
00146 #else // GuiConst_CURSOR_FIELDS_OFF
00147   return 0;
00148 #endif // GuiConst_CURSOR_FIELDS_OFF
00149 }
00150 
00151 //------------------------------------------------------------------------------
00152 GuiConst_INT8U GuiLib_Cursor_Select(
00153    GuiConst_INT16S NewCursorFieldNo)
00154 {
00155 #ifndef GuiConst_CURSOR_FIELDS_OFF
00156   if (NewCursorFieldNo == -1)
00157   {
00158     GuiLib_Cursor_Hide();
00159     return 0;
00160   }
00161   else if (NewCursorFieldNo >= 0)
00162   {
00163     if (AutoRedraw_GetCursor(NewCursorFieldNo, -1) != -1)
00164     {
00165       GuiDisplay_Lock();
00166 
00167       DrawCursorItem(0);
00168       GuiLib_ActiveCursorFieldNo = NewCursorFieldNo;
00169       DrawCursorItem(1);
00170 
00171       GuiDisplay_Unlock();
00172 
00173       return 1;
00174     }
00175   }
00176 
00177   return 0;
00178 #else
00179   NewCursorFieldNo = 0;
00180   return 0;
00181 #endif
00182 }
00183 
00184 //------------------------------------------------------------------------------
00185 GuiConst_INT8U GuiLib_Cursor_Down(void)
00186 {
00187 #ifndef GuiConst_CURSOR_FIELDS_OFF
00188   GuiConst_INT16S NewCursorFieldNo, Index;
00189 
00190   Index = AutoRedraw_GetNextCursor(GuiLib_ActiveCursorFieldNo);
00191 
00192   NewCursorFieldNo = AutoRedraw_GetCursorNumber(Index);
00193 
00194 #ifdef GuiConst_CURSOR_MODE_WRAP_AROUND
00195   if ((NewCursorFieldNo == GuiLib_ActiveCursorFieldNo)
00196    || (Index == -1))
00197     return GuiLib_Cursor_Home();
00198 #else
00199   if (Index == -1)
00200     return 0;
00201 #endif
00202 
00203   GuiLib_Cursor_Select(NewCursorFieldNo);
00204 
00205   return 1;
00206 #else
00207   return 0;
00208 #endif
00209 }
00210 
00211 //------------------------------------------------------------------------------
00212 GuiConst_INT8U GuiLib_Cursor_Up(void)
00213 {
00214 #ifndef GuiConst_CURSOR_FIELDS_OFF
00215   GuiConst_INT16S NewCursorFieldNo, Index;
00216 
00217   Index = AutoRedraw_GetPrevCursor(GuiLib_ActiveCursorFieldNo);
00218 
00219   NewCursorFieldNo = AutoRedraw_GetCursorNumber(Index);
00220 
00221 #ifdef GuiConst_CURSOR_MODE_WRAP_AROUND
00222   if ((NewCursorFieldNo == GuiLib_ActiveCursorFieldNo)
00223    || (Index == -1))
00224     return GuiLib_Cursor_End();
00225 #else
00226   if (Index == -1)
00227     return 0;
00228 #endif
00229 
00230   GuiLib_Cursor_Select(NewCursorFieldNo);
00231 
00232   return 1;
00233 #else
00234   return 0;
00235 #endif
00236 
00237 }
00238 
00239 //------------------------------------------------------------------------------
00240 GuiConst_INT8U GuiLib_Cursor_Home(void)
00241 {
00242 #ifndef GuiConst_CURSOR_FIELDS_OFF
00243   GuiConst_INT16S NewCursorFieldNo, Index;
00244 
00245   Index = AutoRedraw_GetFirstCursor();
00246 
00247   NewCursorFieldNo = AutoRedraw_GetCursorNumber(Index);
00248 
00249   if (NewCursorFieldNo == GuiLib_ActiveCursorFieldNo)
00250     return 0;
00251 
00252   GuiLib_Cursor_Select(NewCursorFieldNo);
00253 
00254   return 1;
00255 #else
00256   return 0;
00257 #endif
00258 }
00259 
00260 //------------------------------------------------------------------------------
00261 GuiConst_INT8U GuiLib_Cursor_End(void)
00262 {
00263 #ifndef GuiConst_CURSOR_FIELDS_OFF
00264   GuiConst_INT16S NewCursorFieldNo, Index;
00265 
00266   Index = AutoRedraw_GetLastCursor();
00267 
00268   NewCursorFieldNo = AutoRedraw_GetCursorNumber(Index);
00269 
00270   if (NewCursorFieldNo == GuiLib_ActiveCursorFieldNo)
00271     return 0;
00272 
00273   GuiLib_Cursor_Select(NewCursorFieldNo);
00274 
00275   return 1;
00276 #else
00277   return 0;
00278 #endif
00279 }
00280 //------------------------------------------------------------------------------
00281 //------------------------------------------------------------------------------
00282 //------------------------------------------------------------------------------
00283 #endif // GuiConst_CURSOR_SUPPORT_ON
00284 
00285 #ifdef GuiConst_BLINK_SUPPORT_ON
00286 //------------------------------------------------------------------------------
00287 //------------------------------------------------------------------------------
00288 //------------------------------------------------------------------------------
00289 static void BlinkBox(void)
00290 {
00291   if ((sgl.BlinkBoxRate) && (sgl.DisplayWriting))
00292     GuiLib_InvertBox(sgl.BlinkBoxX1, sgl.BlinkBoxY1, sgl.BlinkBoxX2, sgl.BlinkBoxY2);
00293   sgl.BlinkBoxInverted = !sgl.BlinkBoxInverted;
00294 }
00295 
00296 //------------------------------------------------------------------------------
00297 void GuiLib_BlinkBoxStart(
00298    GuiConst_INT16S X1,
00299    GuiConst_INT16S Y1,
00300    GuiConst_INT16S X2,
00301    GuiConst_INT16S Y2,
00302    GuiConst_INT16S Rate)
00303 {
00304   GuiLib_BlinkBoxStop();
00305   sgl.BlinkBoxX1 = X1;
00306   sgl.BlinkBoxY1 = Y1;
00307   sgl.BlinkBoxX2 = X2;
00308   sgl.BlinkBoxY2 = Y2;
00309   if (Rate < 1)
00310     sgl.BlinkBoxRate = 1;
00311   else
00312     sgl.BlinkBoxRate = Rate;
00313   sgl.BlinkBoxState = sgl.BlinkBoxRate;
00314   sgl.BlinkBoxInverted = 0;
00315   BlinkBox();
00316 }
00317 
00318 //------------------------------------------------------------------------------
00319 void GuiLib_BlinkBoxStop(void)
00320 {
00321 #ifndef GuiConst_BLINK_FIELDS_OFF
00322   GuiConst_INT16U I;
00323 #endif
00324 
00325   if (sgl.BlinkBoxRate && sgl.BlinkBoxInverted)
00326     BlinkBox();
00327   sgl.BlinkBoxRate = 0;
00328 
00329 #ifndef GuiConst_BLINK_FIELDS_OFF
00330   for (I = 0; I < GuiConst_BLINK_FIELDS_MAX; I++)
00331     if (sgl.BlinkTextItems[I].InUse && sgl.BlinkTextItems[I].Active)
00332       GuiLib_BlinkBoxMarkedItemStop(I);
00333 #endif
00334 }
00335 
00336 //------------------------------------------------------------------------------
00337 void GuiLib_BlinkBoxMarkedItem(
00338    GuiConst_INT16U BlinkFieldNo,
00339    GuiConst_INT16U CharNo,
00340    GuiConst_INT16S Rate)
00341 {
00342 #ifndef GuiConst_BLINK_FIELDS_OFF
00343   GuiConst_INT16S TextXOfs[GuiConst_MAX_TEXT_LEN + 2];
00344   TextParRec TempTextPar;
00345   GuiConst_INT8U TempPs;
00346   GuiConst_INT16U CharCnt;
00347   GuiConst_INT16U TempTextLength;
00348   GuiConst_INT8U TempFormatFieldWidth;
00349   GuiConst_INT8U TempFormatDecimals;
00350   GuiConst_INT8U TempFormatAlignment;
00351   GuiConst_INT8U TempFormatFormat;
00352   #ifdef GuiConst_REMOTE_FONT_DATA
00353   GuiConst_INT32U PrefixRom TempOfs;
00354   GuiConst_INT8U CharHeader[GuiLib_CHR_LINECTRL_OFS];
00355   #else // GuiConst_REMOTE_FONT_DATA
00356   GuiConst_INT8U PrefixRom * TempPtr;
00357   #endif // GuiConst_REMOTE_FONT_DATA
00358   #ifdef GuiConst_ITEM_TEXTBLOCK_INUSE
00359   GuiConst_INT8U CharHeader1[GuiLib_CHR_LINECTRL_OFS];
00360   GuiConst_INT8U CharHeader2[GuiLib_CHR_LINECTRL_OFS];
00361   GuiConst_INT16S TextCharLineStart[GuiConst_MAX_PARAGRAPH_LINE_CNT];
00362   GuiConst_INT16S TextCharLineEnd[GuiConst_MAX_PARAGRAPH_LINE_CNT];
00363   GuiConst_INT16S M;
00364   GuiConst_INT16S LineCnt;
00365   GuiConst_INT16S LineCnt2;
00366   GuiConst_INT16S LineLen;
00367   GuiConst_INT16S XStart, XEnd;
00368   GuiConst_INT16S P2;
00369   #endif // GuiConst_ITEM_TEXTBLOCK_INUSE
00370   GuiConst_INT16S N;
00371 #ifndef GuiConst_CHARMODE_ANSI
00372   GuiConst_INT16S P1;
00373 #endif
00374   GuiConst_TEXT PrefixGeneric *CharPtr;
00375   GuiConst_INT32S VarValue;
00376   GuiConst_INT16S TextPixelLen;
00377 
00378   if ((BlinkFieldNo >= GuiConst_BLINK_FIELDS_MAX) ||
00379       !sgl.BlinkTextItems[BlinkFieldNo].InUse)
00380     return;
00381 
00382   if (sgl.BlinkTextItems[BlinkFieldNo].Active &&
00383       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate &&
00384       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted)
00385   {
00386     if (sgl.DisplayWriting)
00387     {
00388       GuiLib_InvertBox(sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1,
00389                        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1,
00390                        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2,
00391                        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY2);
00392       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted =
00393          !sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00394       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxLast =
00395          sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00396     }
00397   }
00398 
00399   sgl.BlinkTextItems[BlinkFieldNo].Active = 0;
00400   sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate = 0;
00401 
00402   if ((BlinkFieldNo < GuiConst_BLINK_FIELDS_MAX) &&
00403        sgl.BlinkTextItems[BlinkFieldNo].InUse)
00404   {
00405     sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 = sgl.BlinkTextItems[BlinkFieldNo].X1;
00406     sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 = sgl.BlinkTextItems[BlinkFieldNo].X2;
00407     sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1 = sgl.BlinkTextItems[BlinkFieldNo].Y1;
00408     sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY2 = sgl.BlinkTextItems[BlinkFieldNo].Y2;
00409 
00410     if (sgl.BlinkTextItems[BlinkFieldNo].InUse)
00411     {
00412       TempTextPar = sgl.CurItem.TextPar[0];
00413       TempTextLength = sgl.CurItem.TextLength[0];
00414       TempFormatFieldWidth = sgl.CurItem.FormatFieldWidth;
00415       TempFormatDecimals = sgl.CurItem.FormatDecimals;
00416       TempFormatAlignment = sgl.CurItem.FormatAlignment;
00417       TempFormatFormat = sgl.CurItem.FormatFormat;
00418 
00419       sgl.CurItem.FormatFieldWidth = sgl.BlinkTextItems[BlinkFieldNo].FormatFieldWidth;
00420       sgl.CurItem.FormatDecimals = sgl.BlinkTextItems[BlinkFieldNo].FormatDecimals;
00421       sgl.CurItem.FormatAlignment = sgl.BlinkTextItems[BlinkFieldNo].FormatAlignment;
00422       sgl.CurItem.FormatFormat = sgl.BlinkTextItems[BlinkFieldNo].FormatFormat;
00423       sgl.CurItem.TextPar[0] = sgl.BlinkTextItems[BlinkFieldNo].TextPar;
00424       CharCnt = sgl.BlinkTextItems[BlinkFieldNo].CharCnt;
00425       sgl.CurItem.TextLength[0] = CharCnt;
00426 
00427       SetCurFont(sgl.BlinkTextItems[BlinkFieldNo].TextPar.FontIndex);
00428 
00429       if ((sgl.BlinkTextItems[BlinkFieldNo].ItemType == GuiLib_ITEM_TEXT) ||
00430           (sgl.BlinkTextItems[BlinkFieldNo].ItemType == GuiLib_ITEM_TEXTBLOCK))
00431       {
00432 #ifdef GuiConst_CHARMODE_UNICODE
00433         ExtractUnicodeString(
00434            (GuiConst_INT8U PrefixRom *)sgl.BlinkTextItems[BlinkFieldNo].TextPtr,
00435             sgl.CurItem.TextLength[0]);
00436   #ifdef GuiConst_ARAB_CHARS_INUSE
00437         if (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00438             GuiLib_BITFLAG_REVERSEWRITING)
00439         {
00440           CharCnt = ArabicCorrection(
00441              sgl.UnicodeTextBuf, CharCnt,
00442              (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00443               GuiLib_BITFLAG_REVERSEWRITING) > 0);
00444         }
00445   #endif // GuiConst_ARAB_CHARS_INUSE
00446 #endif // GuiConst_CHARMODE_UNICODE
00447 
00448 #ifdef GuiConst_CHARMODE_UNICODE
00449         CharPtr = (GuiConst_TEXT PrefixGeneric *)sgl.UnicodeTextBuf;
00450 #else // GuiConst_CHARMODE_UNICODE
00451         CharPtr = (GuiConst_TEXT PrefixRom *)sgl.BlinkTextItems[BlinkFieldNo].TextPtr;
00452 #endif // GuiConst_CHARMODE_UNICODE
00453         PrepareText(CharPtr,CharCnt,0);
00454       }
00455       else
00456       {
00457 #ifdef GuiConst_DISP_VAR_NOW
00458         displayVarNow = 1;
00459 #endif
00460         if (sgl.BlinkTextItems[BlinkFieldNo].VarType == GuiLib_VAR_STRING)
00461         {
00462           CharPtr = (GuiConst_TEXT PrefixGeneric *)sgl.BlinkTextItems[BlinkFieldNo].TextPtr;
00463 #ifdef GuiConst_CHARMODE_ANSI
00464           CharCnt = strlen(CharPtr);
00465 #else
00466 #ifdef GuiConst_CODEVISION_COMPILER
00467           CharCnt = GuiLib_UnicodeStrLen((GuiConst_TEXT*)CharPtr);
00468 #else // GuiConst_CODEVISION_COMPILER
00469           CharCnt = GuiLib_UnicodeStrLen(CharPtr);
00470 #endif // GuiConst_CODEVISION_COMPILER
00471 #endif // GuiConst_CHARMODE_ANSI
00472         }
00473         else
00474         {
00475           VarValue = ReadVar(sgl.BlinkTextItems[BlinkFieldNo].TextPtr,
00476                              sgl.BlinkTextItems[BlinkFieldNo].VarType);
00477 
00478           CharCnt =
00479              DataNumStr(VarValue, sgl.BlinkTextItems[BlinkFieldNo].VarType, 0);
00480 
00481 #ifdef GuiConst_CHARMODE_ANSI
00482           CharPtr = (GuiConst_TEXT PrefixGeneric *) sgl.VarNumTextStr;
00483 #else // GuiConst_CHARMODE_ANSI
00484           for (P1=0; P1<=CharCnt; P1++)
00485             sgl.VarNumUnicodeTextStr[P1] = sgl.VarNumTextStr[P1];
00486           CharPtr = (GuiConst_TEXT *) sgl.VarNumUnicodeTextStr;
00487 #endif // GuiConst_CHARMODE_ANSI
00488         }
00489 #ifdef GuiConst_CHARMODE_ANSI
00490          strcpy(sgl.AnsiTextBuf, CharPtr);
00491 #else // GuiConst_CHARMODE_ANSI
00492          GuiLib_UnicodeStrCpy(sgl.UnicodeTextBuf, CharPtr);
00493 #endif // GuiConst_CHARMODE_ANSI
00494 #ifdef   GuiConst_ARAB_CHARS_INUSE
00495          if (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00496              GuiLib_BITFLAG_REVERSEWRITING)
00497          {
00498            CharCnt = ArabicCorrection(
00499               sgl.UnicodeTextBuf, CharCnt,
00500              (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00501               GuiLib_BITFLAG_REVERSEWRITING) > 0);
00502          }
00503 #endif // GuiConst_ARAB_CHARS_INUSE
00504 #ifdef GuiConst_CHARMODE_ANSI
00505          CharPtr = sgl.AnsiTextBuf;
00506 #else // GuiConst_CHARMODE_ANSI
00507          CharPtr = sgl.UnicodeTextBuf;
00508 #endif // GuiConst_CHARMODE_ANSI
00509          PrepareText(CharPtr, CharCnt,0);
00510 
00511 #ifdef GuiConst_DISP_VAR_NOW
00512          displayVarNow = 0;
00513 #endif
00514       }
00515 
00516       if (CharNo > CharCnt)
00517       {
00518         SetCurFont(sgl.CurItem.TextPar[0].FontIndex);
00519         sgl.CurItem.TextPar[0] = TempTextPar;
00520         sgl.CurItem.TextLength[0] = TempTextLength;
00521         sgl.CurItem.FormatFieldWidth = TempFormatFieldWidth;
00522         sgl.CurItem.FormatDecimals = TempFormatDecimals;
00523         sgl.CurItem.FormatAlignment = TempFormatAlignment;
00524         sgl.CurItem.FormatFormat = TempFormatFormat;
00525         return;
00526       }
00527 
00528       if(CharNo > 0)
00529       {
00530 #ifdef GuiConst_BLINK_LF_COUNTS
00531         if (*(CharPtr + (CharNo - 1)) != GuiLib_LINEFEED)
00532 #endif
00533         {
00534           sgl.BlinkTextItems[BlinkFieldNo].Active = 0;
00535           sgl.BlinkTextItems[BlinkFieldNo].CharNo = CharNo;
00536         }
00537       }
00538 
00539 #ifdef GuiConst_ITEM_TEXTBLOCK_INUSE
00540       if ((sgl.BlinkTextItems[BlinkFieldNo].ItemType == GuiLib_ITEM_TEXTBLOCK)||
00541           (sgl.BlinkTextItems[BlinkFieldNo].ItemType == GuiLib_ITEM_VARBLOCK))
00542       {
00543         if(CharNo > 0)
00544         {
00545           TextPixelLength(sgl.BlinkTextItems[BlinkFieldNo].TextPar.Ps,
00546                           CharCnt, TextXOfs);
00547 
00548           TextCharLineStart[0] = 0;
00549           TextCharLineEnd[0] = -1;
00550 
00551           LineCnt = 1 - sgl.BlinkTextItems[BlinkFieldNo].BlindLinesAtTop;
00552           if (LineCnt >= 1)
00553             LineCnt = 1;
00554           LineCnt2 = 1;
00555           P2 = 0;
00556 
00557 
00558 #ifdef GuiConst_REMOTE_FONT_DATA
00559           GuiLib_RemoteDataReadBlock(
00560              (GuiConst_INT32U PrefixRom)GuiFont_ChPtrList[
00561               sgl.TextCharNdx[TextCharLineStart[LineCnt2 - 1]]],
00562               GuiLib_CHR_LINECTRL_OFS,
00563               CharHeader2);
00564 #endif // GuiConst_REMOTE_FONT_DATA
00565 
00566           while (P2 < CharCnt)
00567           {
00568             while ((P2 < CharCnt - 1) &&
00569                 !((ReadBytePtr(CharPtr + P2) == GuiLib_LINEFEED) ||
00570                 ((ReadBytePtr(CharPtr + P2) != ' ') && (ReadBytePtr(CharPtr + P2 + 1) == ' ')) ||
00571                 ((ReadBytePtr(CharPtr + P2) == '-') && (ReadBytePtr(CharPtr + P2 + 1) != ' '))))
00572               P2++;
00573 
00574             if (CalcCharsWidth(TextCharLineStart[LineCnt2 - 1], P2,
00575                                TextXOfs, &XStart, &XEnd) >
00576                (sgl.BlinkTextItems[BlinkFieldNo].X2 -
00577                 sgl.BlinkTextItems[BlinkFieldNo].X1 + 1))
00578             {
00579               if (TextCharLineEnd[LineCnt2 - 1] == -1)
00580               {
00581                 TextCharLineEnd[LineCnt2 - 1] = P2;
00582                 TextCharLineStart[LineCnt2] = P2 + 1;
00583                 TextCharLineEnd[LineCnt2] = -1;
00584               }
00585               else
00586               {
00587                 TextCharLineStart[LineCnt2] = TextCharLineEnd[LineCnt2 - 1] + 1;
00588                 while ((TextCharLineStart[LineCnt2] < P2) &&
00589                        (ReadBytePtr(CharPtr + TextCharLineStart[LineCnt2]) ==
00590                         ' '))
00591                   TextCharLineStart[LineCnt2]++;
00592                 TextCharLineEnd[LineCnt2] = P2;
00593               }
00594               if (LineCnt >= GuiConst_MAX_PARAGRAPH_LINE_CNT)
00595               {
00596                 P2 = CharCnt;
00597                 break;
00598               }
00599               LineCnt++;
00600               if (LineCnt > 1)
00601                 LineCnt2 = LineCnt;
00602               else
00603                 TextCharLineStart[LineCnt2 - 1] = TextCharLineStart[LineCnt2];
00604             }
00605             else
00606               TextCharLineEnd[LineCnt2 - 1] = P2;
00607             if (ReadBytePtr(CharPtr + P2) == GuiLib_LINEFEED)
00608             {
00609               TextCharLineEnd[LineCnt2 - 1] = P2 - 1;
00610               TextCharLineStart[LineCnt2] = P2 + 1;
00611               TextCharLineEnd[LineCnt2] = -1;
00612               if (LineCnt >= GuiConst_MAX_PARAGRAPH_LINE_CNT)
00613               {
00614                 P2 = CharCnt;
00615                 break;
00616               }
00617               LineCnt++;
00618               if (LineCnt > 1)
00619                 LineCnt2 = LineCnt;
00620               else
00621                 TextCharLineStart[LineCnt2 - 1] = TextCharLineStart[LineCnt2];
00622             }
00623             P2++;
00624           }
00625 
00626             if (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00627                 GuiLib_BITFLAG_REVERSEWRITING)
00628             {
00629               for (M = 0; M < LineCnt2 ; M++)
00630               {
00631                 for (P2 = TextCharLineStart[M]; P2 <= (TextCharLineStart[M] +
00632                    ((TextCharLineEnd[M] - TextCharLineStart[M] + 1) / 2) - 1);
00633                      P2++)
00634                 {
00635 #ifdef GuiConst_REMOTE_FONT_DATA
00636                   TempOfs = sgl.TextCharNdx[P2];
00637                   sgl.TextCharNdx[P2] =
00638                      sgl.TextCharNdx[TextCharLineEnd[M] - (P2 - TextCharLineStart[M])];
00639                   sgl.TextCharNdx[TextCharLineEnd[M] - (P2 - TextCharLineStart[M])] =
00640                      TempOfs;
00641 #else // GuiConst_REMOTE_FONT_DATA
00642                   TempPtr = sgl.TextCharPtrAry[P2];
00643                   sgl.TextCharPtrAry[P2] =
00644                      (GuiConst_INT8U PrefixRom *)sgl.TextCharPtrAry[
00645                      TextCharLineEnd[M] - (P2 - TextCharLineStart[M])];
00646                   sgl.TextCharPtrAry[TextCharLineEnd[M] - (P2 - TextCharLineStart[M])] =
00647                      (GuiConst_INT8U PrefixRom *)TempPtr;
00648 #endif // GuiConst_REMOTE_FONT_DATA
00649                 }
00650               }
00651               TextPixelLength(sgl.BlinkTextItems[BlinkFieldNo].TextPar.Ps,
00652                               CharCnt, TextXOfs);
00653             }
00654 
00655 #ifdef GuiConst_TEXTBOX_FIELDS_ON
00656             if (sgl.BlinkTextItems[BlinkFieldNo].BlindLinesAtTop < 0)
00657               sgl.BlinkTextItems[BlinkFieldNo].BlindLinesAtTop = 0;
00658             sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1 -=
00659                sgl.BlinkTextItems[BlinkFieldNo].TextBoxScrollPos -
00660               (sgl.BlinkTextItems[BlinkFieldNo].TextBoxLineDist *
00661                sgl.BlinkTextItems[BlinkFieldNo].BlindLinesAtTop);
00662 #endif // GuiConst_TEXTBOX_FIELDS_ON
00663 
00664             switch (sgl.BlinkTextItems[BlinkFieldNo].TextBoxVertAlignment)
00665             {
00666              case GuiLib_ALIGN_CENTER:
00667                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1 +=
00668                   (sgl.BlinkTextItems[BlinkFieldNo].Y2 -
00669                    sgl.BlinkTextItems[BlinkFieldNo].Y1 + 1 -
00670                   (sgl.BlinkTextItems[BlinkFieldNo].YSize +
00671                   (LineCnt2 - 1) *
00672                    sgl.BlinkTextItems[BlinkFieldNo].TextBoxLineDist)) / 2;
00673                break;
00674 
00675              case GuiLib_ALIGN_RIGHT:
00676                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1 +=
00677                   sgl.BlinkTextItems[BlinkFieldNo].Y2 -
00678                   sgl.BlinkTextItems[BlinkFieldNo].Y1 + 1 -
00679                  (sgl.BlinkTextItems[BlinkFieldNo].YSize +
00680                  (LineCnt2 - 1) *
00681                   sgl.BlinkTextItems[BlinkFieldNo].TextBoxLineDist);
00682                break;
00683             }
00684 
00685             for (N = 0; N < LineCnt2; N++)
00686             {
00687               if (((CharNo - 1) <= TextCharLineEnd[N])
00688                && ((CharNo - 1) >= TextCharLineStart[N]))
00689               {
00690                 if (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00691                     GuiLib_BITFLAG_REVERSEWRITING)
00692                   CharNo = TextCharLineStart[N] + TextCharLineEnd[N] + 2 - CharNo;
00693 
00694                 sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 =
00695                    sgl.BlinkTextItems[BlinkFieldNo].X1;
00696 
00697                 LineLen = CalcCharsWidth(TextCharLineStart[N],
00698                                          TextCharLineEnd[N],
00699                                          TextXOfs,
00700                                          &XStart,
00701                                          &XEnd);
00702                 switch (sgl.BlinkTextItems[BlinkFieldNo].TextBoxHorzAlignment)
00703                 {
00704                   case GuiLib_ALIGN_CENTER:
00705                    sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +=
00706                       (sgl.BlinkTextItems[BlinkFieldNo].X2 -
00707                        sgl.BlinkTextItems[BlinkFieldNo].X1 + LineLen - 1) / 2;
00708                    break;
00709 
00710                   case GuiLib_ALIGN_RIGHT:
00711                    sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +=
00712                       sgl.BlinkTextItems[BlinkFieldNo].X2 -
00713                       sgl.BlinkTextItems[BlinkFieldNo].X1 + LineLen - 1;
00714                    break;
00715                 }
00716 
00717                 sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 -= XStart;
00718                 LineLen = CalcCharsWidth(CharNo - 1,
00719                                          CharNo - 1,
00720                                          TextXOfs,
00721                                          &XStart,
00722                                          &XEnd);
00723                 sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 =
00724                    sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 + XEnd;
00725                 sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 += XStart;
00726                 sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY2 =
00727                    sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1 +
00728                    sgl.BlinkTextItems[BlinkFieldNo].YSize - 1;
00729 
00730                 sgl.BlinkTextItems[BlinkFieldNo].Active = 1;
00731                 break;
00732               }
00733 
00734 #ifndef GuiConst_BLINK_LF_COUNTS
00735               if ((N+1) < LineCnt2)
00736                 if ((TextCharLineEnd[N]+1) != TextCharLineStart[N+1])
00737                   CharNo++;
00738 #endif
00739 
00740               sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1 +=
00741                  sgl.BlinkTextItems[BlinkFieldNo].TextBoxLineDist;
00742             }
00743         }
00744         else
00745         {
00746           sgl.BlinkTextItems[BlinkFieldNo].Active = 1;
00747           sgl.BlinkTextItems[BlinkFieldNo].CharNo = CharNo;
00748         }
00749       }
00750       else
00751 #endif // GuiConst_ITEM_TEXTBLOCK_INUSE
00752       {
00753         if (sgl.BlinkTextItems[BlinkFieldNo].TextPar.BitFlags &
00754             GuiLib_BITFLAG_REVERSEWRITING)
00755         {
00756           for (N = 0; N < CharCnt / 2; N++)
00757           {
00758 #ifdef GuiConst_REMOTE_FONT_DATA
00759             TempOfs = sgl.TextCharNdx[N];
00760             sgl.TextCharNdx[N] =
00761                sgl.TextCharNdx[CharCnt - 1 - N];
00762             sgl.TextCharNdx[CharCnt - 1 - N] =
00763                TempOfs;
00764 #else
00765             TempPtr = sgl.TextCharPtrAry[N];
00766             sgl.TextCharPtrAry[N] = (GuiConst_INT8U PrefixRom *)
00767                sgl.TextCharPtrAry[CharCnt - 1 - N];
00768             sgl.TextCharPtrAry[CharCnt - 1 - N] =
00769               (GuiConst_INT8U PrefixRom *)TempPtr;
00770 #endif
00771           }
00772           CharNo =  CharCnt + 1 - CharNo;
00773         }
00774 
00775         TextPixelLen = TextPixelLength(sgl.BlinkTextItems[BlinkFieldNo].TextPar.Ps,
00776                           CharCnt, TextXOfs);
00777 
00778         switch (sgl.BlinkTextItems[BlinkFieldNo].TextPar.Alignment)
00779         {
00780           case GuiLib_ALIGN_CENTER:
00781             if (CharCnt > 0)
00782                 sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 -= TextPixelLen / 2;
00783               break;
00784           case GuiLib_ALIGN_RIGHT:
00785             sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 -= TextPixelLen - 1;
00786               break;
00787         }
00788 
00789         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 = sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +
00790            TextPixelLen - 1;
00791 
00792         if (CharNo)
00793         {
00794           if (sgl.BlinkTextItems[BlinkFieldNo].TextPar.Ps == GuiLib_PS_OFF)
00795           {
00796             sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 =
00797                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 + TextXOfs[CharNo-1] - 1;
00798             sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 =
00799                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +
00800                sgl.BlinkTextItems[BlinkFieldNo].XSize;
00801           }
00802           else if ((sgl.BlinkTextItems[BlinkFieldNo].TextPar.Ps == GuiLib_PS_NUM) &&
00803                    (sgl.TextPsMode[CharNo - 1] == 0))
00804           {
00805                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 =
00806                   sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 + TextXOfs[CharNo - 1] - 1;
00807                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 =
00808                   sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +
00809                   sgl.BlinkTextItems[BlinkFieldNo].PsNumWidth +
00810                   sgl.BlinkTextItems[BlinkFieldNo].PsSpace;
00811           }
00812           else
00813           {
00814 #ifdef GuiConst_REMOTE_FONT_DATA
00815             GuiLib_RemoteDataReadBlock((GuiConst_INT32U PrefixRom)
00816                GuiFont_ChPtrList[sgl.TextCharNdx[CharNo - 1]],
00817                GuiLib_CHR_LINECTRL_OFS, CharHeader);
00818             sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 =
00819                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +
00820                TextXOfs[CharNo-1] + CharHeader[GuiLib_CHR_XLEFT_OFS] - 1;
00821 #else
00822             sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 =
00823                sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 + TextXOfs[CharNo - 1] +
00824                ReadBytePtr(sgl.TextCharPtrAry[CharNo - 1] +
00825                GuiLib_CHR_XLEFT_OFS) - 1;
00826 #endif
00827 #ifdef GuiConst_REMOTE_FONT_DATA
00828           sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 =
00829              sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +
00830              CharHeader[GuiLib_CHR_XWIDTH_OFS] + 1;
00831 #else
00832           sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2 =
00833              sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1 +
00834              ReadBytePtr(sgl.TextCharPtrAry[CharNo - 1] +
00835              GuiLib_CHR_XWIDTH_OFS) + 1;
00836 #endif
00837           }
00838           sgl.BlinkTextItems[BlinkFieldNo].Active = 1;
00839         }
00840         else
00841         {
00842           sgl.BlinkTextItems[BlinkFieldNo].Active = 1;
00843           sgl.BlinkTextItems[BlinkFieldNo].CharNo = CharNo;
00844         }
00845       }
00846       SetCurFont(sgl.CurItem.TextPar[0].FontIndex);
00847       sgl.CurItem.TextPar[0] = TempTextPar;
00848       sgl.CurItem.TextLength[0] = TempTextLength;
00849       sgl.CurItem.FormatFieldWidth = TempFormatFieldWidth;
00850       sgl.CurItem.FormatDecimals = TempFormatDecimals;
00851       sgl.CurItem.FormatAlignment = TempFormatAlignment;
00852       sgl.CurItem.FormatFormat = TempFormatFormat;
00853 
00854     }
00855 
00856     if (sgl.BlinkTextItems[BlinkFieldNo].Active)
00857     {
00858       if (Rate < 1)
00859         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate = 1;
00860       else
00861         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate = Rate;
00862       if (sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate < 255)
00863       {
00864         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxState =
00865            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate -
00866           (sgl.RefreshClock % sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate);
00867         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted =
00868            ((sgl.RefreshClock / sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate) % 2) ==
00869              0;
00870         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxLast =
00871            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00872         if (sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted && sgl.DisplayWriting)
00873           GuiLib_InvertBox(sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1,
00874                            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1,
00875                            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2,
00876                            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY2);
00877       }
00878       else
00879       {
00880         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxState =
00881              sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate;
00882         if (sgl.DisplayWriting)
00883           GuiLib_InvertBox(sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1,
00884                            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1,
00885                            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2,
00886                            sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY2);
00887 
00888         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted =
00889                         !sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00890         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxLast =
00891                         sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00892       }
00893     }
00894   }
00895 #else // GuiConst_BLINK_FIELDS_OFF
00896   gl.Dummy1_16U = BlinkFieldNo;   // To avoid compiler warning
00897   gl.Dummy2_16U = CharNo;   // To avoid compiler warning
00898   gl.Dummy1_16S = Rate;   // To avoid compiler warning
00899 #endif // GuiConst_BLINK_FIELDS_OFF
00900 }
00901 
00902 //------------------------------------------------------------------------------
00903 void GuiLib_BlinkBoxMarkedItemStop(
00904    GuiConst_INT16U BlinkFieldNo)
00905 {
00906 #ifndef GuiConst_BLINK_FIELDS_OFF
00907   if ((BlinkFieldNo >= GuiConst_BLINK_FIELDS_MAX) ||
00908       !sgl.BlinkTextItems[BlinkFieldNo].InUse)
00909     return;
00910 
00911   if (sgl.BlinkTextItems[BlinkFieldNo].Active &&
00912       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate &&
00913       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted)
00914   {
00915     if (sgl.DisplayWriting)
00916     {
00917       GuiLib_InvertBox(sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX1,
00918                        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY1,
00919                        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxX2,
00920                        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxY2);
00921       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted =
00922          !sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00923       sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxLast =
00924          sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxInverted;
00925     }
00926   }
00927   sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate = 0;
00928   sgl.BlinkTextItems[BlinkFieldNo].Active = 0;
00929 #else // GuiConst_BLINK_FIELDS_OFF
00930   gl.Dummy1_16U = BlinkFieldNo;   // To avoid compiler warning
00931 #endif // GuiConst_BLINK_FIELDS_OFF
00932 }
00933 
00934 //------------------------------------------------------------------------------
00935 void GuiLib_BlinkBoxMarkedItemUpdate(
00936    GuiConst_INT16U BlinkFieldNo)
00937 {
00938 #ifndef GuiConst_BLINK_FIELDS_OFF
00939   if ((BlinkFieldNo >= GuiConst_BLINK_FIELDS_MAX) ||
00940       !sgl.BlinkTextItems[BlinkFieldNo].InUse)
00941     return;
00942 
00943   if (sgl.BlinkTextItems[BlinkFieldNo].Active &&
00944      ((sgl.BlinkTextItems[BlinkFieldNo].ItemType == GuiLib_ITEM_VAR) ||
00945       (sgl.BlinkTextItems[BlinkFieldNo].ItemType == GuiLib_ITEM_VARBLOCK)))
00946     GuiLib_BlinkBoxMarkedItem(
00947        BlinkFieldNo,
00948        sgl.BlinkTextItems[BlinkFieldNo].CharNo,
00949        sgl.BlinkTextItems[BlinkFieldNo].BlinkBoxRate);
00950 #else // GuiConst_BLINK_FIELDS_OFF
00951   gl.Dummy1_16U = BlinkFieldNo;   // To avoid compiler warning
00952 #endif // GuiConst_BLINK_FIELDS_OFF
00953 }
00954 //------------------------------------------------------------------------------
00955 //------------------------------------------------------------------------------
00956 //------------------------------------------------------------------------------
00957 #endif // GuiConst_BLINK_SUPPORT_ON
00958 
00959 #ifdef GuiConst_ITEM_TOUCHAREA_INUSE
00960 //------------------------------------------------------------------------------
00961 //------------------------------------------------------------------------------
00962 //------------------------------------------------------------------------------
00963 GuiConst_INT32S GuiLib_TouchCheck(
00964    GuiConst_INT16S X,
00965    GuiConst_INT16S Y)
00966 {
00967   GuiConst_INT32S TouchSearch;
00968   GuiConst_INT32S XX, YY;
00969   GuiConst_INT32S XL, XR, YT, YB;
00970   GuiConst_INT32S TouchArea;
00971 
00972   if (sgl.TouchAdjustActive)
00973   {
00974     XX = 10 * (GuiConst_INT32S)X;
00975     YY = 10 * (GuiConst_INT32S)Y;
00976     XL = sgl.TouchAdjustXTL +
00977        (YY - sgl.TouchAdjustYTL) * (sgl.TouchAdjustXBL - sgl.TouchAdjustXTL) /
00978        (sgl.TouchAdjustYBL - sgl.TouchAdjustYTL);
00979     XR = sgl.TouchAdjustXTR +
00980        (YY - sgl.TouchAdjustYTR) * (sgl.TouchAdjustXBR - sgl.TouchAdjustXTR) /
00981        (sgl.TouchAdjustYBR - sgl.TouchAdjustYTR);
00982     YT = sgl.TouchAdjustYTL +
00983        (XX - sgl.TouchAdjustXTL) * (sgl.TouchAdjustYTR - sgl.TouchAdjustYTL) /
00984        (sgl.TouchAdjustXTR - sgl.TouchAdjustXTL);
00985     YB = sgl.TouchAdjustYBL +
00986        (XX - sgl.TouchAdjustXBL) * (sgl.TouchAdjustYBR - sgl.TouchAdjustYBL) /
00987        (sgl.TouchAdjustXBR - sgl.TouchAdjustXBL);
00988     sgl.TouchConvertX = GuiConst_DISPLAY_WIDTH * (XX - XL) / (XR - XL);
00989     sgl.TouchConvertY = GuiConst_DISPLAY_HEIGHT * (YY - YT) / (YB - YT);
00990   }
00991   else
00992   {
00993     sgl.TouchConvertX = X;
00994     sgl.TouchConvertY = Y;
00995   }
00996 
00997   TouchArea = -1;
00998   if ((sgl.TouchConvertX >= 0) && (sgl.TouchConvertX < GuiConst_DISPLAY_WIDTH) &&
00999       (sgl.TouchConvertY >= 0) && (sgl.TouchConvertY < GuiConst_DISPLAY_HEIGHT))
01000     for (TouchSearch = 0; TouchSearch < sgl.TouchAreaCnt; TouchSearch++)
01001       if ((sgl.TouchConvertX >= sgl.TouchAreas[TouchSearch].X1) &&
01002           (sgl.TouchConvertX <= sgl.TouchAreas[TouchSearch].X2) &&
01003           (sgl.TouchConvertY >= sgl.TouchAreas[TouchSearch].Y1) &&
01004           (sgl.TouchConvertY <= sgl.TouchAreas[TouchSearch].Y2))
01005       {
01006         if (TouchArea == -1)
01007           TouchArea = sgl.TouchAreas[TouchSearch].IndexNo;
01008         else if (sgl.TouchAreas[TouchSearch].IndexNo < TouchArea)
01009           TouchArea = sgl.TouchAreas[TouchSearch].IndexNo;
01010       }
01011   return TouchArea;
01012 }
01013 
01014 //------------------------------------------------------------------------------
01015 GuiConst_INT32S GuiLib_TouchGet(
01016    GuiConst_INT16S X,
01017    GuiConst_INT16S Y,
01018    GuiConst_INT16S* TouchX,
01019    GuiConst_INT16S* TouchY)
01020 {
01021   GuiConst_INT32S Result;
01022 
01023   Result = GuiLib_TouchCheck(X, Y);
01024 
01025   *TouchX = sgl.TouchConvertX;
01026   *TouchY = sgl.TouchConvertY;
01027 
01028   return (Result);
01029 }
01030 
01031 //------------------------------------------------------------------------------
01032 void GuiLib_TouchAdjustReset(void)
01033 {
01034   sgl.TouchAdjustActive = 0;
01035   sgl.TouchAdjustInUse[0] = 0;
01036   sgl.TouchAdjustInUse[1] = 0;
01037   sgl.TouchAdjustInUse[2] = 0;
01038   sgl.TouchAdjustInUse[3] = 0;
01039 }
01040 
01041 //------------------------------------------------------------------------------
01042 void GuiLib_TouchAdjustSet(
01043    GuiConst_INT16S XTrue,
01044    GuiConst_INT16S YTrue,
01045    GuiConst_INT16S XMeasured,
01046    GuiConst_INT16S YMeasured)
01047 {
01048   GuiConst_INT8U I;
01049   GuiConst_INT32S XTL, YTL, XTR, YTR, XBL, YBL, XBR, YBR, XL, XR, YT, YB;
01050 
01051   if (YTrue < GuiConst_DISPLAY_HEIGHT / 2)
01052   {
01053     if (XTrue < GuiConst_DISPLAY_WIDTH / 2)
01054       I = 0;
01055     else
01056       I = 1;
01057   }
01058   else
01059   {
01060     if (XTrue < GuiConst_DISPLAY_WIDTH / 2)
01061       I = 2;
01062     else
01063       I = 3;
01064   }
01065 
01066   sgl.TouchAdjustInUse[I] = 1;
01067 
01068   sgl.TouchAdjustXTrue[I] = XTrue;
01069   sgl.TouchAdjustYTrue[I] = YTrue;
01070   sgl.TouchAdjustXMeasured[I] = XMeasured;
01071   sgl.TouchAdjustYMeasured[I] = YMeasured;
01072 
01073   if (sgl.TouchAdjustInUse[0] && sgl.TouchAdjustInUse[3])
01074   {
01075     sgl.TouchAdjustActive = 1;
01076     if (!sgl.TouchAdjustInUse[1])
01077     {
01078       sgl.TouchAdjustInUse[1] = 1;
01079       sgl.TouchAdjustXTrue[1] = sgl.TouchAdjustXTrue[3];
01080       sgl.TouchAdjustYTrue[1] = sgl.TouchAdjustYTrue[0];
01081       sgl.TouchAdjustXMeasured[1] = sgl.TouchAdjustXMeasured[3];
01082       sgl.TouchAdjustYMeasured[1] = sgl.TouchAdjustYMeasured[0];
01083     }
01084     if (!sgl.TouchAdjustInUse[2])
01085     {
01086       sgl.TouchAdjustInUse[2] = 1;
01087       sgl.TouchAdjustXTrue[2] = sgl.TouchAdjustXTrue[0];
01088       sgl.TouchAdjustYTrue[2] = sgl.TouchAdjustYTrue[3];
01089       sgl.TouchAdjustXMeasured[2] = sgl.TouchAdjustXMeasured[0];
01090       sgl.TouchAdjustYMeasured[2] = sgl.TouchAdjustYMeasured[3];
01091     }
01092   }
01093   else if (sgl.TouchAdjustInUse[1] && sgl.TouchAdjustInUse[2])
01094   {
01095     sgl.TouchAdjustActive = 1;
01096     if (!sgl.TouchAdjustInUse[0])
01097     {
01098       sgl.TouchAdjustInUse[0] = 1;
01099       sgl.TouchAdjustXTrue[0] = sgl.TouchAdjustXTrue[2];
01100       sgl.TouchAdjustYTrue[0] = sgl.TouchAdjustYTrue[1];
01101       sgl.TouchAdjustXMeasured[0] = sgl.TouchAdjustXMeasured[2];
01102       sgl.TouchAdjustYMeasured[0] = sgl.TouchAdjustYMeasured[1];
01103     }
01104     if (!sgl.TouchAdjustInUse[3])
01105     {
01106       sgl.TouchAdjustInUse[3] = 1;
01107       sgl.TouchAdjustXTrue[3] = sgl.TouchAdjustXTrue[1];
01108       sgl.TouchAdjustYTrue[3] = sgl.TouchAdjustYTrue[2];
01109       sgl.TouchAdjustXMeasured[3] = sgl.TouchAdjustXMeasured[1];
01110       sgl.TouchAdjustYMeasured[3] = sgl.TouchAdjustYMeasured[2];
01111     }
01112   }
01113 
01114   if (sgl.TouchAdjustActive)
01115   {
01116     XTL = (10 * sgl.TouchAdjustXMeasured[1]) - ((10 * sgl.TouchAdjustXTrue[1] *
01117        (sgl.TouchAdjustXMeasured[1] - sgl.TouchAdjustXMeasured[0])) /
01118        (sgl.TouchAdjustXTrue[1] - sgl.TouchAdjustXTrue[0]));
01119     XTR = (10 * sgl.TouchAdjustXMeasured[0]) +
01120        ((10 * (GuiConst_DISPLAY_WIDTH - sgl.TouchAdjustXTrue[0]) *
01121        (sgl.TouchAdjustXMeasured[1] - sgl.TouchAdjustXMeasured[0])) /
01122        (sgl.TouchAdjustXTrue[1] - sgl.TouchAdjustXTrue[0]));
01123     XBL = (10 * sgl.TouchAdjustXMeasured[3]) - ((10 * sgl.TouchAdjustXTrue[3] *
01124        (sgl.TouchAdjustXMeasured[3] - sgl.TouchAdjustXMeasured[2])) /
01125        (sgl.TouchAdjustXTrue[3] - sgl.TouchAdjustXTrue[2]));
01126     XBR = (10 * sgl.TouchAdjustXMeasured[2]) +
01127        ((10 * (GuiConst_DISPLAY_WIDTH - sgl.TouchAdjustXTrue[2]) *
01128        (sgl.TouchAdjustXMeasured[3] - sgl.TouchAdjustXMeasured[2])) /
01129        (sgl.TouchAdjustXTrue[3] - sgl.TouchAdjustXTrue[2]));
01130 
01131     YT = 5 * (sgl.TouchAdjustYTrue[0] + sgl.TouchAdjustYTrue[1]);
01132     YB = 5 * (sgl.TouchAdjustYTrue[2] + sgl.TouchAdjustYTrue[3]);
01133 
01134     sgl.TouchAdjustXTL = XBL - (YB * (XBL - XTL) / (YB - YT));
01135     sgl.TouchAdjustXBL =
01136        XTL + (((10 * GuiConst_DISPLAY_HEIGHT) - YT) * (XBL - XTL) / (YB - YT));
01137     sgl.TouchAdjustXTR = XBR - (YB * (XBR - XTR) / (YB - YT));
01138     sgl.TouchAdjustXBR =
01139        XTR + (((10 * GuiConst_DISPLAY_HEIGHT) - YT) * (XBR - XTR) / (YB - YT));
01140 
01141     YTL = (10 * sgl.TouchAdjustYMeasured[2]) - ((10 * sgl.TouchAdjustYTrue[2] *
01142        (sgl.TouchAdjustYMeasured[2] - sgl.TouchAdjustYMeasured[0])) /
01143        (sgl.TouchAdjustYTrue[2] - sgl.TouchAdjustYTrue[0]));
01144     YBL = (10 * sgl.TouchAdjustYMeasured[0]) +
01145        ((10 * (GuiConst_DISPLAY_HEIGHT - sgl.TouchAdjustYTrue[0]) *
01146        (sgl.TouchAdjustYMeasured[2] - sgl.TouchAdjustYMeasured[0])) /
01147        (sgl.TouchAdjustYTrue[2] - sgl.TouchAdjustYTrue[0]));
01148     YTR = (10 * sgl.TouchAdjustYMeasured[3]) - ((10 * sgl.TouchAdjustYTrue[3] *
01149        (sgl.TouchAdjustYMeasured[3] - sgl.TouchAdjustYMeasured[1])) /
01150        (sgl.TouchAdjustYTrue[3] - sgl.TouchAdjustYTrue[1]));
01151     YBR = (10 * sgl.TouchAdjustYMeasured[1]) +
01152        ((10 * (GuiConst_DISPLAY_HEIGHT - sgl.TouchAdjustYTrue[1]) *
01153        (sgl.TouchAdjustYMeasured[3] - sgl.TouchAdjustYMeasured[1])) /
01154        (sgl.TouchAdjustYTrue[3] - sgl.TouchAdjustYTrue[1]));
01155 
01156     XL = 5 * (sgl.TouchAdjustXTrue[0] + sgl.TouchAdjustXTrue[2]);
01157     XR = 5 * (sgl.TouchAdjustXTrue[1] + sgl.TouchAdjustXTrue[3]);
01158 
01159     sgl.TouchAdjustYTL = YTR - (XR * (YTR - YTL) / (XR - XL));
01160     sgl.TouchAdjustYTR =
01161        YTL + (((10 * GuiConst_DISPLAY_WIDTH) - XL) * (YTR - YTL) / (XR - XL));
01162     sgl.TouchAdjustYBL = YBR - (XR * (YBR - YBL) / (XR - XL));
01163     sgl.TouchAdjustYBR =
01164        YBL + (((10 * GuiConst_DISPLAY_WIDTH) - XL) * (YBR - YBL) / (XR - XL));
01165   }
01166 }
01167 //------------------------------------------------------------------------------
01168 //------------------------------------------------------------------------------
01169 //------------------------------------------------------------------------------
01170 #endif // GuiConst_ITEM_TOUCHAREA_INUSE
01171 
01172 #ifdef GuiConst_ITEM_SCROLLBOX_INUSE
01173 //------------------------------------------------------------------------------
01174 //------------------------------------------------------------------------------
01175 //------------------------------------------------------------------------------
01176 static void ScrollBox_ShowLineStruct(
01177    GuiConst_INT8U ScrollBoxIndex,
01178    GuiConst_INT16U StructToCallIndex,
01179    GuiConst_INT16S X,
01180    GuiConst_INT16S Y,
01181    GuiConst_INT8U ColorInvert)
01182 {
01183   GuiLib_StructPtr StructToCall;
01184 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01185   GuiConst_INT16S RemClippingX1, RemClippingY1, RemClippingX2, RemClippingY2;
01186 #endif //GuiConst_CLIPPING_SUPPORT_ON
01187 
01188   if (StructToCallIndex != 0xFFFF)
01189   {
01190     sgl.DisplayLevel++;
01191 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01192     RemClippingX1 = sgl.CurItem.ClipRectX1;
01193     RemClippingY1 = sgl.CurItem.ClipRectY1;
01194     RemClippingX2 = sgl.CurItem.ClipRectX2;
01195     RemClippingY2 = sgl.CurItem.ClipRectY2;
01196 #endif // GuiConst_CLIPPING_SUPPORT_ON
01197     memcpy(&sgl.CurItem, &sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxItem,
01198        sizeof(GuiLib_ItemRec));
01199     sgl.CurItem.RX = X;
01200     sgl.CurItem.RY = Y;
01201 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01202     sgl.CurItem.ClipRectX1 = RemClippingX1;
01203     sgl.CurItem.ClipRectY1 = RemClippingY1;
01204     sgl.CurItem.ClipRectX2 = RemClippingX2;
01205     sgl.CurItem.ClipRectY2 = RemClippingY2;
01206 #endif // GuiConst_CLIPPING_SUPPORT_ON
01207     StructToCall = (GuiLib_StructPtr)
01208 #ifdef GuiConst_REMOTE_STRUCT_DATA
01209        GetRemoteStructData(StructToCallIndex);
01210 #else // GuiConst_REMOTE_STRUCT_DATA
01211        (GuiLib_StructPtr)ReadWord(GuiStruct_StructPtrList[StructToCallIndex]);
01212 #endif // GuiConst_REMOTE_STRUCT_DATA
01213 
01214     if (ColorInvert == GuiLib_COL_INVERT_ON)
01215     {
01216 #ifdef GuiConst_CURSOR_SUPPORT_ON
01217       if (sgl.ScrollBoxesAry[ScrollBoxIndex].ContainsCursorFields)
01218         ColorInvert = GuiLib_COL_INVERT_IF_CURSOR;
01219 #endif // GuiConst_CURSOR_SUPPORT_ON
01220     }
01221     else
01222     {
01223 #ifdef GuiConst_BITMAP_SUPPORT_ON
01224       UpdateBackgroundBitmap();
01225 #endif
01226     }
01227 
01228     DrawStructure(StructToCall, ColorInvert);
01229     ResetLayerBufPtr();
01230     sgl.DisplayLevel--;
01231   }
01232 }
01233 
01234 //------------------------------------------------------------------------------
01235 static void ScrollBox_ShowLineBlock(
01236    GuiConst_INTCOLOR Color,
01237    GuiConst_INT8U Transparent,
01238    GuiConst_INT16S X1,
01239    GuiConst_INT16S Y1,
01240    GuiConst_INT16S X2,
01241    GuiConst_INT16S Y2)
01242 {
01243   if (!Transparent)
01244     GuiLib_FillBox(X1, Y1, X2, Y2, Color);
01245 }
01246 
01247 //------------------------------------------------------------------------------
01248 static void ScrollBox_ShowBarBlock(
01249    GuiConst_INTCOLOR ForeColor,
01250    GuiConst_INTCOLOR BackColor,
01251    GuiConst_INT8U Thickness,
01252    GuiConst_INT16S X,
01253    GuiConst_INT16S Y,
01254    GuiConst_INT16S SizeX,
01255    GuiConst_INT16S SizeY)
01256 {
01257   GuiConst_INT8U T;
01258   GuiConst_INT16S BX1, BY1, BX2, BY2;
01259 
01260   if (Thickness > 0)
01261     for (T = 0; T < Thickness; T++)
01262     {
01263       BX1 = X + T;
01264       BY1 = Y + T;
01265       BX2 = X + SizeX - 1 - T;
01266       BY2 = Y + SizeY - 1 - T;
01267       GuiLib_Box(BX1, BY1, BX2, BY2, ForeColor);
01268     }
01269   BX1 = X + Thickness;
01270   BY1 = Y + Thickness;
01271   BX2 = X + SizeX - 1 - Thickness;
01272   BY2 = Y + SizeY - 1 - Thickness;
01273   GuiLib_FillBox(BX1, BY1, BX2, BY2, BackColor);
01274 }
01275 
01276 //------------------------------------------------------------------------------
01277 static void ScrollBox_SetTopLine(
01278    GuiConst_INT8U ScrollBoxIndex)
01279 {
01280     GuiConst_INT16U LowerLimtA=0;
01281   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
01282   {
01283     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
01284        sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] -
01285        sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
01286     GuiLib_LIMIT_MINMAX(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine,
01287        LowerLimtA, sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
01288        sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines);
01289   }
01290   else
01291     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
01292        sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] -
01293        sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
01294 }
01295 
01296 //------------------------------------------------------------------------------
01297 static void ScrollBox_DrawScrollLine(
01298    GuiConst_INT8U ScrollBoxIndex,
01299    GuiConst_INT16S LineNdx)
01300 {
01301   GuiConst_INT16U N;
01302   GuiConst_INT16S SX1, SY1;
01303   GuiConst_INT16S X1, Y1, X2, Y2;
01304 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01305   GuiConst_INT16S RemClippingX1, RemClippingY1, RemClippingX2, RemClippingY2;
01306 #endif // GuiConst_CLIPPING_SUPPORT_ON
01307 
01308   if ((LineNdx < sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine) ||
01309       (LineNdx >= sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
01310                   sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines))
01311     return;
01312 
01313   X1 = sgl.ScrollBoxesAry[ScrollBoxIndex].X1 +
01314        sgl.ScrollBoxesAry[ScrollBoxIndex].LineOffsetX;
01315   Y1 = sgl.ScrollBoxesAry[ScrollBoxIndex].Y1 +
01316        sgl.ScrollBoxesAry[ScrollBoxIndex].LineOffsetY +
01317        (LineNdx - sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine) *
01318        sgl.ScrollBoxesAry[ScrollBoxIndex].LineVerticalOffset;
01319   X2 = X1 + sgl.ScrollBoxesAry[ScrollBoxIndex].LineSizeX - 1;
01320   Y2 = Y1 + sgl.ScrollBoxesAry[ScrollBoxIndex].LineSizeY - 1;
01321 
01322 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01323   RemClippingX1 = sgl.CurItem.ClipRectX1;
01324   RemClippingY1 = sgl.CurItem.ClipRectY1;
01325   RemClippingX2 = sgl.CurItem.ClipRectX2;
01326   RemClippingY2 = sgl.CurItem.ClipRectY2;
01327   GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX1, X1, X2);
01328   GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY1, Y1, Y2);
01329   GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX2, X1, X2);
01330   GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY2, Y1, Y2);
01331   GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01332                      sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01333 #endif // GuiConst_CLIPPING_SUPPORT_ON
01334 
01335   if ((LineNdx >= 0) &&
01336       (LineNdx < sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines))
01337   {
01338     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollLineDataFunc(LineNdx);
01339 
01340     SX1 = X1 + sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructOffsetX;
01341     SY1 = Y1 + sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructOffsetY;
01342     for (N = 0; N <= GuiConst_SCROLLITEM_MARKERS_MAX; N++)
01343     {
01344       if (N < GuiConst_SCROLLITEM_MARKERS_MAX)
01345       {
01346         if ((sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[N] >= 0) &&
01347             (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerSize[N] >= 1))
01348         {
01349           if ((LineNdx >= sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[N]) &&
01350               (LineNdx <= (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[N] +
01351                sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerSize[N] - 1)))
01352           {
01353             ScrollBox_ShowLineBlock(
01354                sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerColor[N],
01355                sgl.ScrollBoxesAry[ScrollBoxIndex].
01356                MarkerColorTransparent[N], X1, Y1, X2, Y2);
01357             switch (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerDrawingOrder[N])
01358             {
01359               case 0:
01360                 ScrollBox_ShowLineStruct(ScrollBoxIndex,
01361                    sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructIndex, SX1, SY1,
01362                    GuiLib_COL_INVERT_ON);
01363                 if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStructIndex[N] !=
01364                     0xFFFF)
01365                   ScrollBox_ShowLineStruct(ScrollBoxIndex,
01366                      sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStructIndex[N],
01367                      SX1, SY1, GuiLib_COL_INVERT_ON);
01368                 break;
01369 
01370               case 1:
01371                 if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStructIndex[N] !=
01372                     0xFFFF)
01373                   ScrollBox_ShowLineStruct(ScrollBoxIndex,
01374                      sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStructIndex[N],
01375                      SX1, SY1, GuiLib_COL_INVERT_ON);
01376                 ScrollBox_ShowLineStruct(ScrollBoxIndex,
01377                    sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructIndex, SX1, SY1,
01378                    GuiLib_COL_INVERT_ON);
01379                 break;
01380 
01381               case 2:
01382                 ScrollBox_ShowLineStruct(ScrollBoxIndex,
01383                    sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructIndex, SX1, SY1,
01384                    GuiLib_COL_INVERT_ON);
01385                 break;
01386 
01387               case 3:
01388                 if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStructIndex[N] !=
01389                     0xFFFF)
01390                   ScrollBox_ShowLineStruct(ScrollBoxIndex,
01391                      sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStructIndex[N],
01392                      SX1, SY1, GuiLib_COL_INVERT_ON);
01393                 break;
01394             }
01395 
01396             break;
01397           }
01398         }
01399       }
01400       else
01401       {
01402         ScrollBox_ShowLineBlock(
01403            sgl.ScrollBoxesAry[ScrollBoxIndex].LineColor,
01404            sgl.ScrollBoxesAry[ScrollBoxIndex].LineColorTransparent,
01405            X1, Y1, X2, Y2);
01406         ScrollBox_ShowLineStruct(ScrollBoxIndex,
01407            sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructIndex, SX1, SY1,
01408            GuiLib_COL_INVERT_OFF);
01409       }
01410     }
01411   }
01412   else
01413     ScrollBox_ShowLineBlock(sgl.ScrollBoxesAry[ScrollBoxIndex].LineColor,
01414        sgl.ScrollBoxesAry[ScrollBoxIndex].LineColorTransparent,
01415        X1, Y1, X2, Y2);
01416 
01417 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01418   sgl.CurItem.ClipRectX1 = RemClippingX1;
01419   sgl.CurItem.ClipRectY1 = RemClippingY1;
01420   sgl.CurItem.ClipRectX2 = RemClippingX2;
01421   sgl.CurItem.ClipRectY2 = RemClippingY2;
01422   GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01423                      sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01424 #endif // GuiConst_CLIPPING_SUPPORT_ON
01425 }
01426 
01427 //------------------------------------------------------------------------------
01428 GuiConst_INT8U GuiLib_ScrollBox_Init(
01429    GuiConst_INT8U ScrollBoxIndex,
01430    void (*DataFuncPtr) (GuiConst_INT16S LineIndex),
01431    GuiConst_INT16S NoOfLines,
01432    GuiConst_INT16S ActiveLine)
01433 {
01434   GuiConst_INT16U StructToCallIndex;
01435   GuiLib_StructPtr StructToCall;
01436   GuiLib_ItemRec RemCurItem;
01437 #ifdef GuiConst_CURSOR_SUPPORT_ON
01438   GuiConst_INT8U RemCursorInUse;
01439 #endif // GuiConst_CURSOR_SUPPORT_ON
01440 
01441   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
01442       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_READ) ||
01443       (ActiveLine >= NoOfLines))
01444     return (0);
01445 
01446   memcpy(&RemCurItem, &sgl.CurItem, sizeof(GuiLib_ItemRec));
01447 
01448   sgl.GlobalScrollBoxIndex = ScrollBoxIndex;
01449 
01450   memcpy(&sgl.CurItem, &sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxItem,
01451      sizeof(GuiLib_ItemRec));
01452   StructToCallIndex = sgl.ScrollBoxesAry[ScrollBoxIndex].LineStructIndex;
01453   if (StructToCallIndex != 0xFFFF)
01454   {
01455     sgl.DisplayLevel++;
01456     StructToCall = (GuiLib_StructPtr)
01457 #ifdef GuiConst_REMOTE_STRUCT_DATA
01458        GetRemoteStructData(StructToCallIndex);
01459 #else
01460        (GuiLib_StructPtr)ReadWord(GuiStruct_StructPtrList[StructToCallIndex]);
01461 #endif
01462     sgl.NextScrollLineReading = 1;
01463     sgl.InitialDrawing = 1;
01464 #ifdef GuiConst_CURSOR_SUPPORT_ON
01465     RemCursorInUse = sgl.CursorInUse;
01466     sgl.ScrollBoxesAry[ScrollBoxIndex].ContainsCursorFields = 0;
01467     sgl.CursorInUse = (GuiLib_ActiveCursorFieldNo >= 0);
01468     sgl.CursorFieldFound = -1;
01469     sgl.CursorActiveFieldFound = 0;
01470 #endif // GuiConst_CURSOR_SUPPORT_ON
01471     DrawStructure(StructToCall, GuiLib_COL_INVERT_OFF);
01472     ResetLayerBufPtr();
01473 #ifdef GuiConst_CURSOR_SUPPORT_ON
01474     sgl.InitialDrawing = 0;
01475     if (sgl.CursorFieldFound == -1)
01476     {
01477       sgl.CursorInUse = 0;
01478       GuiLib_ActiveCursorFieldNo = -1;
01479     }
01480     else
01481     {
01482       sgl.ScrollBoxesAry[ScrollBoxIndex].ContainsCursorFields = 1;
01483       if (sgl.CursorActiveFieldFound == 0)
01484       {
01485         GuiLib_ActiveCursorFieldNo = sgl.CursorFieldFound;
01486 
01487         DrawCursorItem(1);
01488       }
01489     }
01490     sgl.CursorInUse = sgl.CursorInUse | RemCursorInUse;
01491 #endif // GuiConst_CURSOR_SUPPORT_ON
01492     sgl.NextScrollLineReading = 0;
01493     sgl.DisplayLevel--;
01494   }
01495 
01496   SetCurFont(sgl.CurItem.TextPar[0].FontIndex);
01497   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].LineSizeY == 0) &&
01498       (sgl.ScrollBoxesAry[ScrollBoxIndex].LineSizeY2 == 0))
01499   {
01500     sgl.ScrollBoxesAry[ScrollBoxIndex].LineSizeY = sgl.CurFont->BaseLine;
01501     sgl.ScrollBoxesAry[ScrollBoxIndex].LineSizeY2 =
01502        sgl.CurFont->YSize - sgl.CurFont->BaseLine - 1;
01503   }
01504 
01505 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01506   GuiLib_SetClipping(sgl.CurItem.ClipRectX1,sgl.CurItem.ClipRectY1,
01507                      sgl.CurItem.ClipRectX2,sgl.CurItem.ClipRectY2);
01508 #endif // GuiConst_CLIPPING_SUPPORT_ON
01509 
01510   StructToCallIndex = sgl.ScrollBoxesAry[ScrollBoxIndex].MakeUpStructIndex;
01511   if (StructToCallIndex != 0xFFFF)
01512   {
01513     sgl.DisplayLevel++;
01514     memcpy(&sgl.CurItem, &sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxItem,
01515        sizeof(GuiLib_ItemRec));
01516     sgl.CurItem.RX = sgl.ScrollBoxesAry[sgl.GlobalScrollBoxIndex].X1;
01517     sgl.CurItem.RY = sgl.ScrollBoxesAry[sgl.GlobalScrollBoxIndex].Y1;
01518     StructToCall = (GuiLib_StructPtr)
01519 #ifdef GuiConst_REMOTE_STRUCT_DATA
01520        GetRemoteStructData(StructToCallIndex);
01521 #else
01522        (GuiLib_StructPtr)ReadWord(GuiStruct_StructPtrList[StructToCallIndex]);
01523 #endif
01524     DrawStructure(StructToCall,GuiLib_COL_INVERT_OFF);
01525     ResetLayerBufPtr();
01526     sgl.DisplayLevel--;
01527   }
01528 
01529   sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollLineDataFunc = DataFuncPtr;
01530   sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] = ActiveLine;
01531   sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine = ActiveLine;
01532   sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines = NoOfLines;
01533   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0) &&
01534       (NoOfLines < sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines))
01535     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines = NoOfLines;
01536   sgl.ScrollBoxesAry[ScrollBoxIndex].InUse = GuiLib_SCROLL_STRUCTURE_USED;
01537   ScrollBox_SetTopLine(ScrollBoxIndex);
01538   GuiLib_ScrollBox_Redraw(ScrollBoxIndex);
01539   sgl.ScrollBoxesAry[ScrollBoxIndex].LastScrollTopLine = 0xFFFF;
01540 
01541   memcpy(&sgl.CurItem, &RemCurItem, sizeof(GuiLib_ItemRec));
01542 
01543   return (1);
01544 }
01545 
01546 //------------------------------------------------------------------------------
01547 GuiConst_INT8U GuiLib_ScrollBox_Redraw(
01548    GuiConst_INT8U ScrollBoxIndex)
01549 {
01550   GuiConst_INT16S N, ScrollStartLine, ScrollStopLine;
01551   GuiLib_ItemRec RemCurItem;
01552 #ifndef GuiConst_SCROLLITEM_BAR_NONE
01553 #define GuiLib_SCROLL_REDRAW_VAR
01554 #else
01555 #ifndef GuiConst_SCROLLITEM_INDICATOR_NONE
01556 #define GuiLib_SCROLL_REDRAW_VAR
01557 #endif
01558 #endif
01559 #ifdef GuiLib_SCROLL_REDRAW_VAR
01560   GuiLib_StructPtr StructToCall;
01561   GuiConst_INT16U StructToCallIndex;
01562   GuiConst_INT16S SX1, SY1;
01563   GuiConst_INT16S X1, Y1;
01564 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01565   GuiConst_INT16S SX2, SY2;
01566   GuiConst_INT16S X2, Y2;
01567   GuiConst_INT16S RemClippingX1, RemClippingY1, RemClippingX2, RemClippingY2;
01568 #endif // GuiConst_CLIPPING_SUPPORT_ON
01569 #endif // GuiLib_SCROLL_REDRAW_VAR
01570 #ifndef GuiConst_SCROLLITEM_BAR_NONE
01571   GuiConst_INT16S BarMarkerY;
01572   GuiConst_INT16S BarMarkerHeight;
01573   GuiConst_INT16S BarMarkerMovementDY;
01574   GuiConst_INT32S N1, N2;
01575 #endif // GuiConst_SCROLLITEM_BAR_NONE
01576   GuiConst_INT32S BackColor;
01577 
01578   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
01579       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
01580     return (0);
01581 
01582   memcpy(&RemCurItem, &sgl.CurItem, sizeof(GuiLib_ItemRec));
01583 
01584   sgl.GlobalScrollBoxIndex = ScrollBoxIndex;
01585 
01586   ScrollStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
01587   ScrollStopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
01588      sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines - 1;
01589   if (sgl.ScrollBoxesAry[ScrollBoxIndex].LastScrollTopLine ==
01590       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine)
01591   {
01592     if ((sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine == -1) ||
01593         (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] == -1))
01594     {
01595       if (sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine !=
01596           sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0])
01597       {
01598         if (sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine == -1)
01599         {
01600           ScrollStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
01601           ScrollStopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
01602         }
01603         else
01604         {
01605           ScrollStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine;
01606           ScrollStopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine;
01607         }
01608       }
01609     }
01610     else if (sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine <
01611              sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0])
01612     {
01613       ScrollStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine;
01614       if (ScrollStartLine < sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine)
01615         ScrollStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
01616       ScrollStopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
01617     }
01618     else if (sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine >
01619              sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0])
01620     {
01621       ScrollStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
01622       ScrollStopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine;
01623       GuiLib_LIMIT_MAX(ScrollStartLine,
01624          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
01625          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines - 1);
01626     }
01627   }
01628 
01629   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollLineDataFunc != 0)
01630     for (N = ScrollStartLine; N <= ScrollStopLine; N++)
01631       ScrollBox_DrawScrollLine(ScrollBoxIndex, N);
01632 
01633   sgl.ScrollBoxesAry[ScrollBoxIndex].LastScrollTopLine =
01634      sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
01635   sgl.ScrollBoxesAry[ScrollBoxIndex].LastMarkerLine =
01636      sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
01637 
01638 #ifndef GuiConst_SCROLLITEM_BAR_NONE
01639   if (sgl.ScrollBoxesAry[ScrollBoxIndex].BarType != GuiLib_MARKER_NONE)
01640   {
01641     SX1 = sgl.ScrollBoxesAry[ScrollBoxIndex].BarPositionX;
01642     SY1 = sgl.ScrollBoxesAry[ScrollBoxIndex].BarPositionY;
01643     X1 = SX1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerLeftOffset;
01644     Y1 = SY1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerTopOffset;
01645 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01646     SX2 = SX1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeX - 1;
01647     SY2 = SY1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeY - 1;
01648     X2 = SX2 - sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerRightOffset;
01649     Y2 = SY2 - sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBottomOffset;
01650     RemClippingX1 = sgl.CurItem.ClipRectX1;
01651     RemClippingY1 = sgl.CurItem.ClipRectY1;
01652     RemClippingX2 = sgl.CurItem.ClipRectX2;
01653     RemClippingY2 = sgl.CurItem.ClipRectY2;
01654     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX1, SX1, SX2);
01655     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY1, SY1, SY2);
01656     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX2, SX1, SX2);
01657     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY2, SY1, SY2);
01658     GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01659                        sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01660 #endif // GuiConst_CLIPPING_SUPPORT_ON
01661 
01662     StructToCallIndex = sgl.ScrollBoxesAry[ScrollBoxIndex].BarStructIndex;
01663     if (StructToCallIndex != 0xFFFF)
01664     {
01665       ScrollBox_ShowBarBlock(
01666          sgl.ScrollBoxesAry[ScrollBoxIndex].BarForeColor,
01667          sgl.ScrollBoxesAry[ScrollBoxIndex].BarBackColor,
01668          0,
01669          SX1,
01670          SY1,
01671          sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeX,
01672          sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeY);
01673 
01674       sgl.DisplayLevel++;
01675       memcpy(&sgl.CurItem,
01676              &sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxItem,
01677              sizeof(GuiLib_ItemRec));
01678       sgl.CurItem.RX = SX1;
01679       sgl.CurItem.RY = SY1;
01680       StructToCall = (GuiLib_StructPtr)
01681 #ifdef GuiConst_REMOTE_STRUCT_DATA
01682          GetRemoteStructData(StructToCallIndex);
01683 #else
01684          (GuiLib_StructPtr)ReadWord(GuiStruct_StructPtrList[StructToCallIndex]);
01685 #endif
01686       DrawStructure(StructToCall, GuiLib_COL_INVERT_OFF);
01687       ResetLayerBufPtr();
01688       sgl.DisplayLevel--;
01689     }
01690     else
01691       ScrollBox_ShowBarBlock(
01692          sgl.ScrollBoxesAry[ScrollBoxIndex].BarForeColor,
01693          sgl.ScrollBoxesAry[ScrollBoxIndex].BarBackColor,
01694          sgl.ScrollBoxesAry[ScrollBoxIndex].BarThickness,
01695          SX1,
01696          SY1,
01697          sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeX,
01698          sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeY);
01699 
01700 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01701     sgl.CurItem.ClipRectX1 = RemClippingX1;
01702     sgl.CurItem.ClipRectY1 = RemClippingY1;
01703     sgl.CurItem.ClipRectX2 = RemClippingX2;
01704     sgl.CurItem.ClipRectY2 = RemClippingY2;
01705     GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01706                        sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01707 #endif // GuiConst_CLIPPING_SUPPORT_ON
01708 
01709     if (sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines >
01710         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines)
01711     {
01712 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01713       RemClippingX1 = sgl.CurItem.ClipRectX1;
01714       RemClippingY1 = sgl.CurItem.ClipRectY1;
01715       RemClippingX2 = sgl.CurItem.ClipRectX2;
01716       RemClippingY2 = sgl.CurItem.ClipRectY2;
01717       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX1, X1, X2);
01718       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY1, Y1, Y2);
01719       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX2, X1, X2);
01720       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY2, Y1, Y2);
01721       GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01722                          sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01723 #endif // GuiConst_CLIPPING_SUPPORT_ON
01724 
01725       BarMarkerHeight = 0;
01726       BarMarkerMovementDY = sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeY -
01727          sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBottomOffset -
01728          sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerTopOffset;
01729 
01730       switch (sgl.ScrollBoxesAry[ScrollBoxIndex].BarType)
01731       {
01732         case GuiLib_MARKER_ICON:
01733           sgl.CurFont = (GuiLib_FontRecPtr)ReadWord(GuiFont_FontList[
01734              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerIconFont]);
01735           BarMarkerHeight = sgl.CurFont->YSize;
01736           break;
01737 
01738         case GuiLib_MARKER_BITMAP:
01739           BarMarkerHeight =
01740              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBitmapHeight;
01741           break;
01742 
01743         case GuiLib_MARKER_FIXED_BLOCK:
01744           BarMarkerHeight =
01745              sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeX -
01746              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerLeftOffset -
01747              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerRightOffset;
01748           break;
01749 
01750         case GuiLib_MARKER_VARIABLE_BLOCK:
01751           BarMarkerHeight =
01752              (((10 * BarMarkerMovementDY *
01753              sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines) + 5) /
01754              sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines) / 10;
01755           GuiLib_LIMIT_MIN(BarMarkerHeight, 4);
01756           break;
01757       }
01758 
01759       N1 = sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
01760          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines;
01761       N2 = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
01762       GuiLib_LIMIT_MINMAX(N2, 0, N1);
01763       BarMarkerY = (((10 * (BarMarkerMovementDY - BarMarkerHeight) *
01764          N2) + 5) / N1) / 10;
01765 
01766       switch (sgl.ScrollBoxesAry[ScrollBoxIndex].BarType)
01767       {
01768         case GuiLib_MARKER_ICON:
01769           sgl.CurItem.X1 = X1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerIconOffsetX;
01770           sgl.CurItem.Y1 = Y1 + BarMarkerY +
01771              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerIconOffsetY +
01772              sgl.CurFont->BaseLine;
01773           sgl.CurItem.TextPar[0].FontIndex =
01774              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerIconFont;
01775           sgl.CurItem.TextPar[0].Alignment = GuiLib_ALIGN_LEFT;
01776           sgl.CurItem.TextPar[0].Ps = GuiLib_PS_OFF;
01777           sgl.CurItem.TextPar[0].BitFlags = 0;
01778           sgl.CurItem.TextPar[0].BackBoxSizeX = 0;
01779           sgl.CurItem.TextPar[0].BackBorderPixels = 0;
01780           DrawText(sgl.ScrollBoxesAry[ScrollBoxIndex].BarIconPtr, 1, 0,
01781              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerForeColor,
01782              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBackColor,
01783              sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerTransparent);
01784           break;
01785 
01786         case GuiLib_MARKER_BITMAP:
01787           if (sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBitmapIsTransparent)
01788             BackColor =
01789                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBitmapTranspColor;
01790           else
01791             BackColor = -1;
01792           GuiLib_ShowBitmap(sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBitmapIndex,
01793              X1, Y1 + BarMarkerY, BackColor);
01794           break;
01795 
01796         case GuiLib_MARKER_FIXED_BLOCK:
01797         case GuiLib_MARKER_VARIABLE_BLOCK:
01798           if (sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerTransparent)
01799             GuiLib_Box(X1, Y1 + BarMarkerY,
01800                X1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeX -
01801                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerLeftOffset -
01802                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerRightOffset - 1,
01803                Y1 + BarMarkerY + BarMarkerHeight - 1,
01804                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerForeColor);
01805           else
01806             GuiLib_BorderBox(X1, Y1 + BarMarkerY,
01807                X1 + sgl.ScrollBoxesAry[ScrollBoxIndex].BarSizeX -
01808                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerLeftOffset -
01809                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerRightOffset - 1,
01810                Y1 + BarMarkerY + BarMarkerHeight - 1,
01811                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerForeColor,
01812                sgl.ScrollBoxesAry[ScrollBoxIndex].BarMarkerBackColor);
01813           break;
01814       }
01815 
01816 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01817       sgl.CurItem.ClipRectX1 = RemClippingX1;
01818       sgl.CurItem.ClipRectY1 = RemClippingY1;
01819       sgl.CurItem.ClipRectX2 = RemClippingX2;
01820       sgl.CurItem.ClipRectY2 = RemClippingY2;
01821       GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01822                          sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01823 #endif // GuiConst_CLIPPING_SUPPORT_ON
01824     }
01825   }
01826 #endif
01827 
01828 #ifndef GuiConst_SCROLLITEM_INDICATOR_NONE
01829   if (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorType != GuiLib_INDICATOR_NONE)
01830   {
01831     SX1 = sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorPositionX;
01832     SY1 = sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorPositionY;
01833     X1 = SX1 + sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerLeftOffset;
01834     Y1 = SY1 + sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerTopOffset;
01835 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01836     SX2 = SX1 + sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorSizeX - 1;
01837     SY2 = SY1 + sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorSizeY - 1;
01838     X2 = SX2 - sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerRightOffset;
01839     Y2 = SY2 - sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerBottomOffset;
01840     RemClippingX1 = sgl.CurItem.ClipRectX1;
01841     RemClippingY1 = sgl.CurItem.ClipRectY1;
01842     RemClippingX2 = sgl.CurItem.ClipRectX2;
01843     RemClippingY2 = sgl.CurItem.ClipRectY2;
01844     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX1, SX1, SX2);
01845     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY1, SY1, SY2);
01846     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX2, SX1, SX2);
01847     GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY2, SY1, SY2);
01848     GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01849                        sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01850 #endif // GuiConst_CLIPPING_SUPPORT_ON
01851 
01852     StructToCallIndex = sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorStructIndex;
01853     if (StructToCallIndex != 0xFFFF)
01854     {
01855       ScrollBox_ShowBarBlock(
01856          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorForeColor,
01857          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorBackColor,
01858          0,
01859          SX1,
01860          SY1,
01861          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorSizeX,
01862          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorSizeY);
01863 
01864       sgl.DisplayLevel++;
01865       memcpy(&sgl.CurItem,
01866              &sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxItem,
01867              sizeof(GuiLib_ItemRec));
01868       sgl.CurItem.RX = SX1;
01869       sgl.CurItem.RY = SY1;
01870       StructToCall = (GuiLib_StructPtr)
01871 #ifdef GuiConst_REMOTE_STRUCT_DATA
01872          GetRemoteStructData(StructToCallIndex);
01873 #else
01874          (GuiLib_StructPtr)ReadWord(GuiStruct_StructPtrList[StructToCallIndex]);
01875 #endif
01876       DrawStructure(StructToCall, GuiLib_COL_INVERT_OFF);
01877       ResetLayerBufPtr();
01878       sgl.DisplayLevel--;
01879     }
01880     else
01881       ScrollBox_ShowBarBlock(
01882          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorForeColor,
01883          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorBackColor,
01884          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorThickness,
01885          SX1,
01886          SY1,
01887          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorSizeX,
01888          sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorSizeY);
01889 
01890 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01891     sgl.CurItem.ClipRectX1 = RemClippingX1;
01892     sgl.CurItem.ClipRectY1 = RemClippingY1;
01893     sgl.CurItem.ClipRectX2 = RemClippingX2;
01894     sgl.CurItem.ClipRectY2 = RemClippingY2;
01895     GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01896                        sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01897 #endif // GuiConst_CLIPPING_SUPPORT_ON
01898 
01899     if ((sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorLine >= 0) &&
01900         (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorLine >=
01901          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine) &&
01902         (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorLine <
01903         (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
01904          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines)))
01905     {
01906 #ifdef GuiConst_CLIPPING_SUPPORT_ON
01907       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX1, X1, X2);
01908       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY1, Y1, Y2);
01909       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectX2, X1, X2);
01910       GuiLib_LIMIT_MINMAX(sgl.CurItem.ClipRectY2, Y1, Y2);
01911       GuiLib_SetClipping(sgl.CurItem.ClipRectX1, sgl.CurItem.ClipRectY1,
01912                          sgl.CurItem.ClipRectX2, sgl.CurItem.ClipRectY2);
01913 #endif // GuiConst_CLIPPING_SUPPORT_ON
01914 
01915       switch (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorType)
01916       {
01917         case GuiLib_MARKER_ICON:
01918           sgl.CurFont = (GuiLib_FontRecPtr)ReadWord(GuiFont_FontList[
01919              sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerIconFont]);
01920           sgl.CurItem.X1 =
01921              X1 + sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerIconOffsetX;
01922           sgl.CurItem.Y1 =
01923              Y1 + sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerIconOffsetY +
01924              sgl.CurFont->BaseLine +
01925              sgl.ScrollBoxesAry[ScrollBoxIndex].LineVerticalOffset *
01926              (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorLine -
01927              sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine);
01928           sgl.CurItem.TextPar[0].FontIndex =
01929              sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerIconFont;
01930           sgl.CurItem.TextPar[0].Alignment = GuiLib_ALIGN_LEFT;
01931           sgl.CurItem.TextPar[0].Ps = GuiLib_PS_OFF;
01932           sgl.CurItem.TextPar[0].BitFlags = 0;
01933           sgl.CurItem.TextPar[0].BackBoxSizeX = 0;
01934           sgl.CurItem.TextPar[0].BackBorderPixels = 0;
01935           DrawText(sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorIconPtr, 1, 0,
01936                    sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerForeColor,
01937                    sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerBackColor,
01938                    sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerTransparent);
01939           break;
01940 
01941         case GuiLib_MARKER_BITMAP:
01942           if (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerBitmapIsTransparent)
01943             BackColor =
01944                sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerBitmapTranspColor;
01945           else
01946             BackColor = -1;
01947           GuiLib_ShowBitmap(
01948              sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorMarkerBitmapIndex,
01949              X1, Y1 + sgl.ScrollBoxesAry[ScrollBoxIndex].LineVerticalOffset *
01950              (sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorLine -
01951              sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine), BackColor);
01952           break;
01953       }
01954     }
01955   }
01956 #endif // GuiConst_SCROLLITEM_INDICATOR_NONE
01957 
01958   memcpy(&sgl.CurItem, &RemCurItem, sizeof(GuiLib_ItemRec));
01959 
01960   return (1);
01961 }
01962 
01963 //------------------------------------------------------------------------------
01964 GuiConst_INT8U GuiLib_ScrollBox_RedrawLine(
01965    GuiConst_INT8U ScrollBoxIndex,
01966    GuiConst_INT16U ScrollLine)
01967 {
01968   GuiLib_ItemRec RemCurItem;
01969 
01970   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
01971       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
01972       (ScrollLine > (sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1)) ||
01973       (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollLineDataFunc == 0))
01974     return (0);
01975 
01976   memcpy(&RemCurItem, &sgl.CurItem, sizeof(GuiLib_ItemRec));
01977   sgl.GlobalScrollBoxIndex = ScrollBoxIndex;
01978 
01979   ScrollBox_DrawScrollLine(ScrollBoxIndex, ScrollLine);
01980 
01981   memcpy(&sgl.CurItem, &RemCurItem, sizeof(GuiLib_ItemRec));
01982 
01983   return (1);
01984 }
01985 
01986 //------------------------------------------------------------------------------
01987 GuiConst_INT8U GuiLib_ScrollBox_Close(
01988    GuiConst_INT8U ScrollBoxIndex)
01989 {
01990   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
01991       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
01992     return (0);
01993 
01994   sgl.ScrollBoxesAry[ScrollBoxIndex].InUse = GuiLib_SCROLL_STRUCTURE_READ;
01995 
01996   return (1);
01997 }
01998 
01999 //------------------------------------------------------------------------------
02000 GuiConst_INT8U GuiLib_ScrollBox_Down(
02001    GuiConst_INT8U ScrollBoxIndex)
02002 {
02003   GuiConst_INT16U ScrollBottomLine;
02004   GuiConst_INT16S RemScrollTopLine;
02005   GuiConst_INT16S RemMarkerStartLine;
02006 
02007   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02008       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
02009     return (0);
02010 
02011   RemScrollTopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
02012   RemMarkerStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
02013 
02014   ScrollBottomLine = (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
02015      sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines - 1);
02016 
02017   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxType)
02018   {
02019     if (ScrollBottomLine >= (sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1))
02020     {
02021       if ((sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 1)
02022 #ifdef GuiConst_SCROLL_MODE_WRAP_AROUND
02023          || (sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 2)
02024 #endif
02025                                                         )
02026         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = 0;
02027     }
02028     else
02029       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine++;
02030   }
02031   else if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] >= 0)
02032   {
02033     if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
02034     {
02035       if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] ==
02036          (sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1))
02037       {
02038         if ((sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 1)
02039 #ifdef GuiConst_SCROLL_MODE_WRAP_AROUND
02040            || (sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 2)
02041 #endif
02042                                                           )
02043         {
02044           sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = 0;
02045           sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] = 0;
02046         }
02047       }
02048       else if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] <
02049          ScrollBottomLine - sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs)
02050         sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0]++;
02051       else
02052       {
02053         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine++;
02054         GuiLib_LIMIT_MAX(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine,
02055            sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02056            sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines);
02057         sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0]++;
02058       }
02059     }
02060     else
02061     {
02062       if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] ==
02063          (sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1))
02064       {
02065         if ((sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 1)
02066 #ifdef GuiConst_SCROLL_MODE_WRAP_AROUND
02067            || (sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 2)
02068 #endif
02069                                                           )
02070         {
02071           sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02072              -sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
02073           sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] = 0;
02074         }
02075       }
02076       else
02077       {
02078         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine++;
02079         sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0]++;
02080       }
02081     }
02082   }
02083 
02084   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine != RemScrollTopLine) ||
02085       (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] != RemMarkerStartLine))
02086   {
02087     GuiLib_ScrollBox_Redraw(ScrollBoxIndex);
02088     return (1);
02089   }
02090   else
02091     return (0);
02092 }
02093 
02094 //------------------------------------------------------------------------------
02095 GuiConst_INT8U GuiLib_ScrollBox_Up(
02096    GuiConst_INT8U ScrollBoxIndex)
02097 {
02098   GuiConst_INT16S RemScrollTopLine;
02099   GuiConst_INT16S RemMarkerStartLine;
02100 
02101   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02102       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
02103     return (0);
02104 
02105   RemScrollTopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
02106   RemMarkerStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
02107 
02108   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxType)
02109   {
02110     if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine == 0)
02111     {
02112       if ((sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 1)
02113 #ifdef GuiConst_SCROLL_MODE_WRAP_AROUND
02114          || (sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 2)
02115 #endif
02116                                                         )
02117         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02118            sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02119            sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines;
02120         GuiLib_LIMIT_MIN(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine, 0);
02121     }
02122     else
02123       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine--;
02124   }
02125   else if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] >= 0)
02126   {
02127     if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
02128     {
02129       if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] == 0)
02130       {
02131         if ((sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 1)
02132 #ifdef GuiConst_SCROLL_MODE_WRAP_AROUND
02133            || (sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 2)
02134 #endif
02135                                                           )
02136         {
02137           sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02138              sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02139              sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines;
02140           GuiLib_LIMIT_MIN(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine, 0);
02141           sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] =
02142              sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1;
02143         }
02144       }
02145       else if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] >
02146                sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
02147                sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs)
02148         sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0]--;
02149       else
02150       {
02151         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine--;
02152         GuiLib_LIMIT_MIN(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine, 0);
02153         sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0]--;
02154       }
02155     }
02156     else
02157     {
02158       if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] == 0)
02159       {
02160         if ((sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 1)
02161 #ifdef GuiConst_SCROLL_MODE_WRAP_AROUND
02162            || (sgl.ScrollBoxesAry[ScrollBoxIndex].WrapMode == 2)
02163 #endif
02164                                                           )
02165         {
02166           sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02167              sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1 -
02168              sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
02169           sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] =
02170              sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1;
02171         }
02172       }
02173       else
02174       {
02175         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine--;
02176         sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0]--;
02177       }
02178     }
02179   }
02180 
02181   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine != RemScrollTopLine) ||
02182       (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] != RemMarkerStartLine))
02183   {
02184     GuiLib_ScrollBox_Redraw(ScrollBoxIndex);
02185     return (1);
02186   }
02187   else
02188     return (0);
02189 }
02190 
02191 //------------------------------------------------------------------------------
02192 GuiConst_INT8U GuiLib_ScrollBox_Home(
02193    GuiConst_INT8U ScrollBoxIndex)
02194 {
02195   GuiConst_INT16S RemScrollTopLine;
02196   GuiConst_INT16S RemMarkerStartLine;
02197 
02198   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02199       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
02200     return (0);
02201 
02202   RemScrollTopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
02203   RemMarkerStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
02204 
02205   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxType)
02206     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = 0;
02207   else
02208   {
02209     if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
02210       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = 0;
02211     else
02212       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02213          -sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
02214     if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] >= 0)
02215       sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] = 0;
02216   }
02217 
02218   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine != RemScrollTopLine) ||
02219       (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] != RemMarkerStartLine))
02220   {
02221     GuiLib_ScrollBox_Redraw(ScrollBoxIndex);
02222     return (1);
02223   }
02224   else
02225     return (0);
02226 }
02227 
02228 //------------------------------------------------------------------------------
02229 GuiConst_INT8U GuiLib_ScrollBox_End(
02230    GuiConst_INT8U ScrollBoxIndex)
02231 {
02232   GuiConst_INT16S RemScrollTopLine;
02233   GuiConst_INT16S RemMarkerStartLine;
02234 
02235   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02236       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
02237     return (0);
02238 
02239   RemScrollTopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
02240   RemMarkerStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
02241 
02242   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxType)
02243     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = GuiLib_GET_MAX(
02244        sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02245        sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines, 0);
02246   else
02247   {
02248     if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
02249       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = GuiLib_GET_MAX(
02250          sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02251          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines, 0);
02252     else
02253       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02254          sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1 -
02255          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
02256     if (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] >= 0)
02257       sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] =
02258          sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1;
02259   }
02260 
02261   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine != RemScrollTopLine) ||
02262       (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] != RemMarkerStartLine))
02263   {
02264     GuiLib_ScrollBox_Redraw(ScrollBoxIndex);
02265     return (1);
02266   }
02267   else
02268     return (0);
02269 }
02270 
02271 //------------------------------------------------------------------------------
02272 GuiConst_INT8U GuiLib_ScrollBox_To_Line(
02273    GuiConst_INT8U ScrollBoxIndex,
02274    GuiConst_INT16S NewLine)
02275 {
02276   GuiConst_INT16S RemScrollTopLine;
02277   GuiConst_INT16S RemMarkerStartLine;
02278   GuiConst_INT16S TopLine;
02279   GuiConst_INT16S LowerLimtA = 0;
02280 
02281   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02282       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
02283       (NewLine >= sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines))
02284     return(0);
02285 
02286   RemScrollTopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine;
02287   RemMarkerStartLine = sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0];
02288 
02289   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollBoxType)
02290   {
02291     TopLine = sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02292               sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines;
02293     GuiLib_LIMIT_MIN(TopLine, 0);
02294     if (NewLine > TopLine)
02295       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = TopLine;
02296     else
02297       sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine = NewLine;
02298   }
02299   else if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
02300   {
02301     if ((NewLine != -1) &&
02302         ((NewLine < sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine) ||
02303         (NewLine >= (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine +
02304          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines))))
02305     {
02306       if (NewLine > (sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02307           sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines +
02308           sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs))
02309         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02310            sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02311            sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines;
02312       else
02313         sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02314            NewLine - sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
02315 
02316       GuiLib_LIMIT_MINMAX(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine,
02317          NewLine - sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines + 1,
02318          NewLine + sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines - 1);
02319       GuiLib_LIMIT_MINMAX(sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine, LowerLimtA,
02320          sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02321          sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines);
02322     }
02323   }
02324   else
02325     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02326        NewLine - sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollStartOfs;
02327   sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] = NewLine;
02328 
02329   if ((sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine != RemScrollTopLine) ||
02330       (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[0] != RemMarkerStartLine))
02331   {
02332     GuiLib_ScrollBox_Redraw(ScrollBoxIndex);
02333     return (1);
02334   }
02335   else
02336     return (0);
02337 }
02338 
02339 //------------------------------------------------------------------------------
02340 GuiConst_INT8U GuiLib_ScrollBox_SetLineMarker(
02341    GuiConst_INT8U ScrollBoxIndex,
02342    GuiConst_INT16U ScrollLineMarkerIndex,
02343    GuiConst_INT16S StartLine,
02344    GuiConst_INT16U Size)
02345 {
02346   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02347       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
02348       (ScrollLineMarkerIndex >= GuiConst_SCROLLITEM_MARKERS_MAX) ||
02349       (StartLine >= sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines))
02350     return (0);
02351 
02352   sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[ScrollLineMarkerIndex] =
02353      GuiLib_GET_MINMAX(StartLine, -1,
02354      (GuiConst_INT16S)sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1);
02355   if ((ScrollLineMarkerIndex == 0) && (Size > 1))
02356     Size = 1;
02357   sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerSize[ScrollLineMarkerIndex] = Size;
02358   if (ScrollLineMarkerIndex == 0)
02359     ScrollBox_SetTopLine(ScrollBoxIndex);
02360 
02361   return (1);
02362 }
02363 
02364 //------------------------------------------------------------------------------
02365 GuiConst_INT16S GuiLib_ScrollBox_GetActiveLine(
02366    GuiConst_INT8U ScrollBoxIndex,
02367    GuiConst_INT16U ScrollLineMarkerIndex)
02368 {
02369   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02370       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
02371       (ScrollLineMarkerIndex >= GuiConst_SCROLLITEM_MARKERS_MAX))
02372     return (-1);
02373 
02374   return (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerStartLine[ScrollLineMarkerIndex]);
02375 }
02376 
02377 //------------------------------------------------------------------------------
02378 GuiConst_INT16S GuiLib_ScrollBox_GetActiveLineCount(
02379    GuiConst_INT8U ScrollBoxIndex,
02380    GuiConst_INT16U ScrollLineMarkerIndex)
02381 {
02382   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02383       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
02384       (ScrollLineMarkerIndex >= GuiConst_SCROLLITEM_MARKERS_MAX))
02385     return (-1);
02386 
02387   return (sgl.ScrollBoxesAry[ScrollBoxIndex].MarkerSize[ScrollLineMarkerIndex]);
02388 }
02389 
02390 //------------------------------------------------------------------------------
02391 GuiConst_INT8U GuiLib_ScrollBox_SetIndicator(
02392    GuiConst_INT8U ScrollBoxIndex,
02393    GuiConst_INT16S StartLine)
02394 {
02395 #ifdef GuiConst_SCROLLITEM_INDICATOR_NONE
02396   gl.Dummy1_8U = ScrollBoxIndex;   // To avoid compiler warning
02397   gl.Dummy1_16S = StartLine;   // To avoid compiler warning
02398   return (0);
02399 #else
02400   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02401       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
02402       (StartLine >= sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines))
02403     return (0);
02404 
02405   sgl.ScrollBoxesAry[ScrollBoxIndex].IndicatorLine = GuiLib_GET_MINMAX(
02406      StartLine, -1,
02407      (GuiConst_INT16S)sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines - 1);
02408 
02409   return (1);
02410 #endif
02411 }
02412 
02413 //------------------------------------------------------------------------------
02414 GuiConst_INT8U GuiLib_ScrollBox_SetTopLine(
02415    GuiConst_INT8U ScrollBoxIndex,
02416    GuiConst_INT16S TopLine)
02417 {
02418   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02419       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED) ||
02420       (TopLine >= sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines))
02421     return (0);
02422 
02423   if (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollMode == 0)
02424     sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine =
02425        GuiLib_GET_MINMAX(TopLine, 0,
02426        sgl.ScrollBoxesAry[ScrollBoxIndex].NumberOfLines -
02427        sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollVisibleLines);
02428 
02429   return (1);
02430 }
02431 
02432 //------------------------------------------------------------------------------
02433 GuiConst_INT16S GuiLib_ScrollBox_GetTopLine(
02434    GuiConst_INT8U ScrollBoxIndex)
02435 {
02436   if ((ScrollBoxIndex >= GuiConst_SCROLLITEM_BOXES_MAX) ||
02437       (sgl.ScrollBoxesAry[ScrollBoxIndex].InUse != GuiLib_SCROLL_STRUCTURE_USED))
02438     return (-1);
02439 
02440   return (sgl.ScrollBoxesAry[ScrollBoxIndex].ScrollTopLine);
02441 }
02442 //------------------------------------------------------------------------------
02443 //------------------------------------------------------------------------------
02444 //------------------------------------------------------------------------------
02445 #endif // GuiConst_ITEM_SCROLLBOX_INUSE
02446 
02447 #ifdef GuiConst_ITEM_GRAPH_INUSE
02448 //------------------------------------------------------------------------------
02449 //------------------------------------------------------------------------------
02450 //------------------------------------------------------------------------------
02451 #ifdef GuiConst_CLIPPING_SUPPORT_ON
02452 //------------------------------------------------------------------------------
02453 static void Graph_SetClipping(
02454    GuiConst_INT8U GraphIndex)
02455 {
02456   GuiLib_SetClipping(sgl.GraphAry[GraphIndex].GraphItem.ClipRectX1,
02457                      sgl.GraphAry[GraphIndex].GraphItem.ClipRectY1,
02458                      sgl.GraphAry[GraphIndex].GraphItem.ClipRectX2,
02459                      sgl.GraphAry[GraphIndex].GraphItem.ClipRectY2);
02460 }
02461 
02462 //------------------------------------------------------------------------------
02463 static void Graph_ResetClipping(void)
02464 {
02465   GuiLib_ResetClipping();
02466 }
02467 #endif // GuiConst_CLIPPING_SUPPORT_ON
02468 
02469 //------------------------------------------------------------------------------
02470 static void Graph_CalcScaleX(
02471    GuiConst_INT8U GraphIndex,
02472    GuiConst_INT8U AxisIndex)
02473 {
02474   GuiConst_INT32S D1,D2;
02475 
02476   D1 = (sgl.GraphAry[GraphIndex].GraphItem.X2 -
02477        sgl.GraphAry[GraphIndex].GraphItem.X1 -
02478        sgl.GraphAry[GraphIndex].OriginOffsetX);
02479   D1 = D1 * 10000;
02480   D2 = (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].NumbersMaxValue -
02481            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].NumbersMinValue);
02482   D1 = D1/D2;
02483   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Scale = D1;
02484 }
02485 
02486 //------------------------------------------------------------------------------
02487 static void Graph_CalcScaleY(
02488    GuiConst_INT8U GraphIndex,
02489    GuiConst_INT8U AxisIndex)
02490 {
02491   GuiConst_INT32S D1,D2;
02492 
02493   D1 = (sgl.GraphAry[GraphIndex].GraphItem.Y2 -
02494        sgl.GraphAry[GraphIndex].GraphItem.Y1-
02495        sgl.GraphAry[GraphIndex].OriginOffsetY);
02496   D1 = D1 * 10000;
02497   D2 = (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].NumbersMaxValue -
02498            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].NumbersMinValue);
02499   D1 = D1/D2;
02500   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Scale= D1;
02501 }
02502 
02503 //------------------------------------------------------------------------------
02504 static GuiConst_INT32S Graph_CalcNumbersMaxValue(
02505    GuiConst_INT8U GraphIndex,
02506    GuiConst_INT8U AxisIndex,
02507    GuiConst_INT8U AxisType)
02508 {
02509   GuiConst_INT32S MV;
02510 
02511   MV = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].NumbersMaxValue;
02512   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].TicksMinor)
02513     MV -= sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].NumbersAtEnd *
02514           sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].NumbersStepMinor;
02515   else if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].TicksMajor)
02516     MV -= sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].NumbersAtEnd *
02517           sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][AxisType].NumbersStepMajor;
02518   return(MV);
02519 }
02520 
02521 //------------------------------------------------------------------------------
02522 static void Graph_DrawXAxis(
02523    GuiConst_INT8U GraphIndex,
02524    GuiConst_INT8U AxisIndex)
02525 {
02526   GuiConst_INT16S X, Y;
02527   GuiConst_INT16S DX, DY;
02528   GuiConst_INT32S TX, TY;
02529   #ifdef GuiConst_FLOAT_SUPPORT_ON
02530   double TDX;
02531   #endif
02532   GuiConst_INT32S F;
02533   GuiConst_INT16S HW;
02534   GuiConst_INT32S MV;
02535   GuiConst_INT16U StrLen;
02536   GuiConst_INT16U I;
02537   GuiConst_INT8U Align;
02538 
02539   Y = sgl.GraphAry[GraphIndex].OrigoY +
02540       sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Offset;
02541 
02542   MV = Graph_CalcNumbersMaxValue(GraphIndex, AxisIndex, GuiLib_GRAPHAXIS_X);
02543 
02544   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Line)
02545   {
02546     X = sgl.GraphAry[GraphIndex].GraphItem.X2 -
02547         sgl.GraphAry[GraphIndex].GraphItem.X1 + 1;
02548     for (I = 0; I < sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]; I++)
02549       if (sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].Offset < X)
02550         X = sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].Offset;
02551     X += sgl.GraphAry[GraphIndex].OriginOffsetX;
02552     if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02553         LineNegative)
02554       GuiLib_FillBox(sgl.GraphAry[GraphIndex].GraphItem.X1,
02555                      Y,
02556                      sgl.GraphAry[GraphIndex].GraphItem.X1 + X - 1,
02557                      Y,
02558                      sgl.GraphAry[GraphIndex].ForeColor);
02559     if ((sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y] > 1) &&
02560          sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02561          LineBetweenAxes)
02562       GuiLib_FillBox(sgl.GraphAry[GraphIndex].GraphItem.X1 + X - 1,
02563                      Y,
02564                      sgl.GraphAry[GraphIndex].GraphItem.X1 +
02565                      sgl.GraphAry[GraphIndex].OriginOffsetX,
02566                      Y,
02567                      sgl.GraphAry[GraphIndex].ForeColor);
02568     GuiLib_FillBox(sgl.GraphAry[GraphIndex].GraphItem.X1 +
02569                    sgl.GraphAry[GraphIndex].OriginOffsetX,
02570                    Y,
02571                    sgl.GraphAry[GraphIndex].GraphItem.X2,
02572                    Y,
02573                    sgl.GraphAry[GraphIndex].ForeColor);
02574   }
02575 
02576   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Arrow)
02577   {
02578     DX = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02579          ArrowLength;
02580     HW = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02581          ArrowWidth / 2;
02582     for (DY = -HW; DY <= HW; DY++)
02583       GuiLib_Line(sgl.GraphAry[GraphIndex].GraphItem.X2 - DX,
02584                   Y + DY,
02585                   sgl.GraphAry[GraphIndex].GraphItem.X2,
02586                   Y,
02587                   sgl.GraphAry[GraphIndex].ForeColor);
02588   }
02589 
02590   Graph_CalcScaleX(GraphIndex, AxisIndex);
02591 
02592   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].TicksMajor)
02593   {
02594     HW = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02595          TicksMajorWidth / 2;
02596     TX = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02597          NumbersMinValue;
02598     F = TX % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02599              NumbersStepMajor;
02600     if (F != 0)
02601     {
02602       TX -= F;
02603       if (TX < sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02604                NumbersMinValue)
02605         TX += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02606               NumbersStepMajor;
02607     }
02608     while (TX <= MV)
02609     {
02610       DX = sgl.GraphAry[GraphIndex].OrigoX + ((TX -
02611            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02612            NumbersMinValue) *
02613            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Scale) /
02614            10000;
02615       if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02616           NumbersAtOrigo ||
02617          (TX != sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02618                 NumbersMinValue))
02619         GuiLib_FillBox(
02620            DX - HW,
02621            Y,
02622            DX - HW +
02623            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02624            TicksMajorWidth - 1,
02625            Y + sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02626            TicksMajorLength - 1,
02627            sgl.GraphAry[GraphIndex].ForeColor);
02628       TX += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02629             NumbersStepMajor;
02630     }
02631   }
02632 
02633   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].TicksMinor)
02634   {
02635     HW = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02636          TicksMinorWidth / 2;
02637     TX = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02638          NumbersMinValue;
02639     F = TX % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02640              NumbersStepMinor;
02641     if (F != 0)
02642     {
02643       TX -= F;
02644       if (TX < sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02645                NumbersMinValue)
02646         TX += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02647               NumbersStepMinor;
02648     }
02649     while (TX <= MV)
02650     {
02651       DX = sgl.GraphAry[GraphIndex].OrigoX + ((TX -
02652            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02653            NumbersMinValue) *
02654            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Scale) /
02655            10000;
02656       if ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02657           NumbersAtOrigo ||
02658          (TX != sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02659                 NumbersMinValue)) &&
02660          ((!sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02661             TicksMajor) ||
02662          (TX % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02663                NumbersStepMajor != 0)))
02664         GuiLib_FillBox(
02665            DX - HW,
02666            Y,
02667            DX - HW +
02668            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02669            TicksMinorWidth - 1,
02670            Y + sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02671            TicksMinorLength - 1,
02672            sgl.GraphAry[GraphIndex].ForeColor);
02673       TX += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02674             NumbersStepMinor;
02675     }
02676   }
02677 
02678   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Numbers)
02679   {
02680     memcpy(&sgl.CurItem, &sgl.GraphAry[GraphIndex].GraphItem, sizeof(GuiLib_ItemRec));
02681 
02682     DY = Y;
02683     if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02684        TicksMajor)
02685       DY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02686          TicksMajorLength;
02687     SetCurFont(sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].FontIndex);
02688     DY += ReadByte(sgl.CurFont->BaseLine);
02689     DY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02690        NumbersOffset;
02691 
02692     TX = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02693        NumbersMinValue;
02694     F = TX % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02695              NumbersStepMajor;
02696     if (F != 0)
02697     {
02698       TX -= F;
02699       if (TX < sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02700                NumbersMinValue)
02701         TX += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02702               NumbersStepMajor;
02703     }
02704     switch (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].FormatAlignment)
02705     {
02706       case GuiLib_FORMAT_ALIGNMENT_LEFT:
02707         Align = GuiLib_ALIGN_LEFT;
02708         break;
02709       case GuiLib_FORMAT_ALIGNMENT_CENTER:
02710         Align = GuiLib_ALIGN_CENTER;
02711         break;
02712       case GuiLib_FORMAT_ALIGNMENT_RIGHT:
02713         Align = GuiLib_ALIGN_RIGHT;
02714         break;
02715     }
02716     while (TX <= MV)
02717     {
02718       DX = sgl.GraphAry[GraphIndex].OrigoX + ((TX -
02719            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02720            NumbersMinValue) *
02721            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Scale) /
02722            10000;
02723       if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02724           NumbersAtOrigo ||
02725          (TX != sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02726                 NumbersMinValue))
02727       {
02728         #ifdef GuiConst_FLOAT_SUPPORT_ON
02729         TDX = TX;
02730         #endif
02731         GuiLib_DrawVar(
02732            DX,
02733            DY,
02734            sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].FontIndex,
02735            #ifdef GuiConst_FLOAT_SUPPORT_ON
02736            &TDX,
02737            GuiLib_VAR_DOUBLE,
02738            #else
02739            &TX,
02740            GuiLib_VAR_SIGNED_LONG,
02741            #endif
02742            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].FormatFormat,
02743            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].FormatFieldWidth,
02744            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].FormatAlignment,
02745            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].FormatDecimals,
02746            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02747               BitFlags & GuiLib_BITFLAG_FORMATSHOWSIGN) > 0),
02748            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02749               BitFlags & GuiLib_BITFLAG_FORMATZEROPADDING) > 0),
02750            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02751               BitFlags & GuiLib_BITFLAG_FORMATTRAILINGZEROS) > 0),
02752            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02753               BitFlags & GuiLib_BITFLAG_FORMATTHOUSANDSSEP) > 0),
02754            Align,
02755            sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].Ps,
02756            1,   // Transparent
02757            ((sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].BitFlags &
02758             GuiLib_BITFLAG_UNDERLINE) > 0),
02759            0,
02760            0,
02761            0,
02762            0,
02763            sgl.GraphAry[GraphIndex].GraphItem.ForeColor,
02764            sgl.GraphAry[GraphIndex].GraphItem.BackColor);
02765       }
02766       TX += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
02767          NumbersStepMajor;
02768     }
02769   }
02770 }
02771 
02772 //------------------------------------------------------------------------------
02773 static void Graph_DrawYAxis(
02774    GuiConst_INT8U GraphIndex,
02775    GuiConst_INT8U AxisIndex)
02776 {
02777   GuiConst_INT16S X, Y;
02778   GuiConst_INT16S DX, DY;
02779   GuiConst_INT32S TX, TY;
02780   #ifdef GuiConst_FLOAT_SUPPORT_ON
02781   double TDY;
02782   #endif
02783   GuiConst_INT32S F;
02784   GuiConst_INT16S HW;
02785   GuiConst_INT32S MV;
02786   GuiConst_INT16U StrLen;
02787   GuiConst_INT16U I;
02788   GuiConst_INT8U Align;
02789 
02790   X = sgl.GraphAry[GraphIndex].OrigoX +
02791       sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Offset;
02792 
02793   MV = Graph_CalcNumbersMaxValue(GraphIndex, AxisIndex, GuiLib_GRAPHAXIS_Y);
02794 
02795   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Line)
02796   {
02797     Y = 0;
02798     for (I = 0; I < sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]; I++)
02799       if (sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].Offset > Y)
02800         Y = sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].Offset;
02801     Y = sgl.GraphAry[GraphIndex].OriginOffsetY - Y;
02802     if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02803         LineNegative)
02804       GuiLib_FillBox(X,
02805                      sgl.GraphAry[GraphIndex].GraphItem.Y2 - Y,
02806                      X,
02807                      sgl.GraphAry[GraphIndex].GraphItem.Y2,
02808                      sgl.GraphAry[GraphIndex].ForeColor);
02809     if ((sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X] > 1) &&
02810          sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02811          LineBetweenAxes)
02812       GuiLib_FillBox(X,
02813                      sgl.GraphAry[GraphIndex].GraphItem.Y2 -
02814                      sgl.GraphAry[GraphIndex].OriginOffsetY,
02815                      X,
02816                      sgl.GraphAry[GraphIndex].GraphItem.Y2 - Y,
02817                      sgl.GraphAry[GraphIndex].ForeColor);
02818     GuiLib_FillBox(X,
02819                    sgl.GraphAry[GraphIndex].GraphItem.Y1,
02820                    X,
02821                    sgl.GraphAry[GraphIndex].GraphItem.Y2 -
02822                    sgl.GraphAry[GraphIndex].OriginOffsetY,
02823                    sgl.GraphAry[GraphIndex].ForeColor);
02824   }
02825 
02826   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Arrow)
02827   {
02828     DY = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02829          ArrowLength;
02830     HW = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02831          ArrowWidth / 2;
02832     for (DX = -HW; DX <= HW; DX++)
02833       GuiLib_Line(X - DX,
02834                   sgl.GraphAry[GraphIndex].GraphItem.Y1 + DY,
02835                   X,
02836                   sgl.GraphAry[GraphIndex].GraphItem.Y1,
02837                   sgl.GraphAry[GraphIndex].ForeColor);
02838   }
02839 
02840   Graph_CalcScaleY(GraphIndex, AxisIndex);
02841 
02842   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].TicksMajor)
02843   {
02844     HW = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02845          TicksMajorWidth / 2;
02846     TY = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02847          NumbersMinValue;
02848     F = TY % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02849              NumbersStepMajor;
02850     if (F != 0)
02851     {
02852       TY -= F;
02853       if (TY < sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02854                NumbersMinValue)
02855         TY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02856               NumbersStepMajor;
02857     }
02858     while (TY <= MV)
02859     {
02860       DY = sgl.GraphAry[GraphIndex].OrigoY - ((TY -
02861            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02862            NumbersMinValue) *
02863            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Scale) /
02864            10000;
02865       if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02866           NumbersAtOrigo ||
02867          (TY != sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02868                 NumbersMinValue))
02869         GuiLib_FillBox(
02870            X - sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02871            TicksMajorLength + 1,
02872            DY - HW,
02873            X,
02874            DY - HW +
02875            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02876            TicksMajorWidth - 1,
02877            sgl.GraphAry[GraphIndex].ForeColor);
02878       TY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02879             NumbersStepMajor;
02880     }
02881   }
02882 
02883   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].TicksMinor)
02884   {
02885     HW = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02886          TicksMinorWidth / 2;
02887     TY = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02888          NumbersMinValue;
02889     F = TY % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02890              NumbersStepMinor;
02891     if (F != 0)
02892     {
02893       TY -= F;
02894       if (TY < sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02895                NumbersMinValue)
02896         TY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02897               NumbersStepMinor;
02898     }
02899     while (TY <= MV)
02900     {
02901       DY = sgl.GraphAry[GraphIndex].OrigoY - ((TY -
02902            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02903            NumbersMinValue) *
02904            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Scale) /
02905            10000;
02906       if ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02907           NumbersAtOrigo ||
02908          (TY != sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02909                 NumbersMinValue)) &&
02910          ((!sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02911           TicksMajor) ||
02912          (TY % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02913                NumbersStepMajor != 0)))
02914         GuiLib_FillBox(
02915            X - sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02916            TicksMinorLength + 1,
02917            DY - HW,
02918            X,
02919            DY - HW +
02920            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02921            TicksMinorWidth - 1,
02922            sgl.GraphAry[GraphIndex].ForeColor);
02923       TY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02924             NumbersStepMinor;
02925     }
02926   }
02927 
02928   if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Numbers)
02929   {
02930     memcpy(&sgl.CurItem, &sgl.GraphAry[GraphIndex].GraphItem, sizeof(GuiLib_ItemRec));
02931 
02932     SetCurFont(sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].FontIndex);
02933 
02934     sgl.CurItem.TextPar[0].BitFlags =
02935        sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].BitFlags;
02936     sgl.CurItem.FormatFieldWidth =
02937        sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatFieldWidth;
02938     sgl.CurItem.FormatDecimals =
02939        sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatDecimals;
02940     sgl.CurItem.FormatAlignment =
02941        sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatAlignment;
02942     sgl.CurItem.FormatFormat =
02943        sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatFormat;
02944 
02945     DX = X;
02946     if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02947        TicksMajor)
02948       DX -= sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02949          TicksMajorLength;
02950     DX -= sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02951        NumbersOffset;
02952 
02953     TY = sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02954        NumbersMinValue;
02955     F = TY % sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02956              NumbersStepMajor;
02957     if (F != 0)
02958     {
02959       TY -= F;
02960       if (TY < sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02961                NumbersMinValue)
02962         TY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02963               NumbersStepMajor;
02964     }
02965     switch (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatAlignment)
02966     {
02967       case GuiLib_FORMAT_ALIGNMENT_LEFT:
02968         Align = GuiLib_ALIGN_LEFT;
02969         break;
02970       case GuiLib_FORMAT_ALIGNMENT_CENTER:
02971         Align = GuiLib_ALIGN_CENTER;
02972         break;
02973       case GuiLib_FORMAT_ALIGNMENT_RIGHT:
02974         Align = GuiLib_ALIGN_RIGHT;
02975         break;
02976     }
02977     while (TY <= MV)
02978     {
02979       DY = sgl.GraphAry[GraphIndex].OrigoY - ((TY -
02980            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02981            NumbersMinValue) *
02982            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Scale) /
02983            10000;
02984       if (sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02985           NumbersAtOrigo ||
02986          (TY != sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
02987                 NumbersMinValue))
02988       {
02989         #ifdef GuiConst_FLOAT_SUPPORT_ON
02990         TDY = TY;
02991         #endif
02992         GuiLib_DrawVar(
02993            DX,
02994            DY + GuiLib_FONT_MID_Y(ReadByte(sgl.CurFont->BaseLine),
02995                                   ReadByte(sgl.CurFont->TopLine)),
02996            sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].FontIndex,
02997            #ifdef GuiConst_FLOAT_SUPPORT_ON
02998            &TDY,
02999            GuiLib_VAR_DOUBLE,
03000            #else
03001            &TY,
03002            GuiLib_VAR_SIGNED_LONG,
03003            #endif
03004            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatFormat,
03005            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatFieldWidth,
03006            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatAlignment,
03007            sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].FormatDecimals,
03008            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03009               BitFlags & GuiLib_BITFLAG_FORMATSHOWSIGN) > 0),
03010            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03011               BitFlags & GuiLib_BITFLAG_FORMATZEROPADDING) > 0),
03012            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03013               BitFlags & GuiLib_BITFLAG_FORMATTRAILINGZEROS) > 0),
03014            ((sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03015               BitFlags & GuiLib_BITFLAG_FORMATTHOUSANDSSEP) > 0),
03016            Align,
03017            sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].Ps,
03018            1,   // Transparent
03019            ((sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].BitFlags &
03020               GuiLib_BITFLAG_UNDERLINE) > 0),
03021            0,
03022            0,
03023            0,
03024            0,
03025            sgl.GraphAry[GraphIndex].GraphItem.ForeColor,
03026            sgl.GraphAry[GraphIndex].GraphItem.BackColor);
03027       }
03028       TY += sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03029          NumbersStepMajor;
03030     }
03031   }
03032 }
03033 
03034 //------------------------------------------------------------------------------
03035 static void Graph_DrawDataPoint(
03036    GuiConst_INT8U GraphIndex,
03037    GuiConst_INT8U DataSetIndex,
03038    GuiConst_INT16U DataIndex,
03039    GuiConst_INT16S X,
03040    GuiConst_INT16S Y,
03041    GuiConst_INT16S LastX,
03042    GuiConst_INT16S LastY)
03043 {
03044   GuiConst_INT16S DX1, DY1;
03045   GuiConst_INT16S DX2, DY2;
03046   GuiConst_INT16S HW;
03047   GuiConst_INT16S AY;
03048 
03049   switch (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Representation)
03050   {
03051     case GuiLib_GRAPH_DATATYPE_DOT:
03052       if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Thickness == 0)
03053         GuiLib_Circle(
03054            X, Y,
03055            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width,
03056            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor,
03057            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor);
03058       else if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].
03059                Thickness == 1)
03060         GuiLib_Circle(
03061            X, Y,
03062            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width,
03063            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor,
03064            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor);
03065       else
03066       {
03067         GuiLib_Circle(
03068            X, Y,
03069            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width,
03070            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor,
03071            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03072         GuiLib_Circle(
03073            X, Y,
03074            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width-
03075               sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Thickness,
03076            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor,
03077            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor);
03078       }
03079       break;
03080 
03081     case GuiLib_GRAPH_DATATYPE_LINE:
03082       if (DataIndex ==
03083           sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataFirst)
03084         GuiLib_Dot(
03085            X, Y,
03086            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03087       else
03088         GuiLib_Line(
03089            LastX, LastY,
03090            X, Y,
03091            sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03092       break;
03093 
03094     case GuiLib_GRAPH_DATATYPE_BAR:
03095       AY = sgl.GraphAry[GraphIndex].OrigoY +
03096            sgl.GraphAry[GraphIndex].GraphAxes[0][GuiLib_GRAPHAXIS_X].Offset;
03097       DX2 = X + (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width / 2);
03098       DX1 = DX2 - sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width + 1;
03099       if (DX1 > DX2)
03100         DX1 = DX2;
03101       DY1 = AY;
03102       DY2 = Y;
03103       if (Y < AY)
03104         DY1--;
03105       if (Y != AY)
03106       {
03107         if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Thickness == 0)
03108         {
03109           if (!sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].
03110                BackColorTransparent)
03111             GuiLib_FillBox(
03112                DX1, DY1,
03113                DX2, DY2,
03114                sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor);
03115         }
03116         else
03117         {
03118           OrderCoord(&DX1, &DX2);
03119           OrderCoord(&DY1, &DY2);
03120           DrawBorderBox(
03121              DX1, DY1,
03122              DX2, DY2,
03123              sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor,
03124              sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].BackColor,
03125              sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].
03126                 BackColorTransparent,
03127              sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Thickness);
03128         }
03129       }
03130       break;
03131 
03132     case GuiLib_GRAPH_DATATYPE_CROSS:
03133       HW = sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width;
03134       DX1 = X - HW;
03135       DY1 = Y - HW;
03136       DX2 = X + HW;
03137       DY2 = Y + HW;
03138       GuiLib_Line(
03139          DX1, Y,
03140          DX2, Y,
03141          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03142       GuiLib_Line(
03143          X, DY1,
03144          X, DY2,
03145          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03146       break;
03147 
03148     case GuiLib_GRAPH_DATATYPE_X:
03149       HW = sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Width;
03150       DX1 = X - HW;
03151       DY1 = Y - HW;
03152       DX2 = X + HW;
03153       DY2 = Y + HW;
03154       GuiLib_Line(
03155          DX1, DY1,
03156          DX2, DY2,
03157          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03158       GuiLib_Line(
03159          DX1, DY2,
03160          DX2, DY1,
03161          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].ForeColor);
03162       break;
03163   }
03164 }
03165 
03166 //------------------------------------------------------------------------------
03167 static void Graph_DrawDataSet(
03168    GuiConst_INT8U GraphIndex,
03169    GuiConst_INT8U DataSetIndex)
03170 {
03171   GuiConst_INT16S DX = 0, DY = 0;
03172   GuiConst_INT16S LastDX, LastDY;
03173   GuiConst_INT32S TX, TY;
03174   GuiConst_INT16U DataIndex;
03175   GuiConst_INT16U DataCount;
03176 
03177   Graph_CalcScaleX(GraphIndex,
03178                    sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX);
03179   Graph_CalcScaleY(GraphIndex,
03180                    sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY);
03181 
03182   DataIndex = sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataFirst;
03183   for (DataCount = 1;
03184        DataCount <= sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount;
03185        DataCount++)
03186   {
03187     TX =
03188        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[DataIndex].X;
03189     TY =
03190        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[DataIndex].Y;
03191 
03192     LastDX = DX;
03193     LastDY = DY;
03194     DX = sgl.GraphAry[GraphIndex].OrigoX + ((TX -
03195          sgl.GraphAry[GraphIndex].GraphAxes[
03196          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX]
03197          [GuiLib_GRAPHAXIS_X].NumbersMinValue) *
03198          sgl.GraphAry[GraphIndex].GraphAxes[
03199          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX]
03200          [GuiLib_GRAPHAXIS_X].Scale) / 10000;
03201     DY = sgl.GraphAry[GraphIndex].OrigoY - ((TY -
03202          sgl.GraphAry[GraphIndex].GraphAxes[
03203          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY]
03204          [GuiLib_GRAPHAXIS_Y].NumbersMinValue) *
03205          sgl.GraphAry[GraphIndex].GraphAxes[
03206          sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY]
03207          [GuiLib_GRAPHAXIS_Y].Scale) / 10000;
03208 
03209     Graph_DrawDataPoint(
03210        GraphIndex,
03211        DataSetIndex,
03212        DataIndex,
03213        DX, DY,
03214        LastDX, LastDY);
03215 
03216     if (DataIndex >= sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount)
03217       DataIndex = 0;
03218     else
03219       DataIndex++;
03220   }
03221 }
03222 
03223 //------------------------------------------------------------------------------
03224 GuiConst_INT8U GuiLib_Graph_Close(
03225    GuiConst_INT8U GraphIndex)
03226 {
03227   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03228       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03229     return (0);
03230 
03231   sgl.GraphAry[GraphIndex].InUse = GuiLib_GRAPH_STRUCTURE_UNDEF;
03232   sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X] = 0;
03233   sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y] = 0;
03234   sgl.GraphAry[GraphIndex].GraphDataSetCnt = 0;
03235 
03236   return (1);
03237 }
03238 
03239 //------------------------------------------------------------------------------
03240 GuiConst_INT8U GuiLib_Graph_AddDataSet(
03241    GuiConst_INT8U GraphIndex,
03242    GuiConst_INT8U DataSetIndex,
03243    GuiConst_INT8U XAxisIndex,
03244    GuiConst_INT8U YAxisIndex,
03245    GuiLib_GraphDataPoint *DataPtr,
03246    GuiConst_INT16U DataSize,
03247    GuiConst_INT16U DataCount,
03248    GuiConst_INT16U DataFirst)
03249 {
03250   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03251       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03252     return (0);
03253   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03254       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03255     return (0);
03256   if (DataCount > DataSize)
03257     return (0);
03258   if (DataFirst >= DataSize)
03259     return (0);
03260 
03261   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr = DataPtr;
03262   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataSize = DataSize;
03263   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataFirst = DataFirst;
03264   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount = DataCount;
03265   if ((XAxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03266       (XAxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]))
03267     XAxisIndex = 0;
03268   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX = XAxisIndex;
03269   if ((YAxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03270       (YAxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]))
03271     YAxisIndex = 0;
03272   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY = YAxisIndex;
03273 
03274   return (1);
03275 }
03276 
03277 //------------------------------------------------------------------------------
03278 GuiConst_INT8U GuiLib_Graph_RemoveDataSet(
03279    GuiConst_INT8U GraphIndex,
03280    GuiConst_INT8U DataSetIndex)
03281 {
03282   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03283       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03284     return (0);
03285   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03286       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03287     return (0);
03288 
03289   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount = 0;
03290   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataSize = 0;
03291 
03292   return (1);
03293 }
03294 
03295 //------------------------------------------------------------------------------
03296 GuiConst_INT8U GuiLib_Graph_AddDataPoint(
03297    GuiConst_INT8U GraphIndex,
03298    GuiConst_INT8U DataSetIndex,
03299    GuiConst_INT32S X,
03300    GuiConst_INT32S Y)
03301 {
03302   GuiConst_INT16U I;
03303 
03304   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03305       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03306     return (0);
03307   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03308       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03309     return (0);
03310   if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount >=
03311       sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataSize)
03312     return (0);
03313 
03314   I = (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataFirst +
03315        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount) %
03316        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataSize;
03317   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount++;
03318 
03319   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[I].X = X;
03320   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[I].Y = Y;
03321 
03322   return (1);
03323 }
03324 
03325 //------------------------------------------------------------------------------
03326 GuiConst_INT8U GuiLib_Graph_ShowDataSet(
03327    GuiConst_INT8U GraphIndex,
03328    GuiConst_INT8U DataSetIndex)
03329 {
03330   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03331       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03332     return (0);
03333   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03334       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03335     return (0);
03336 
03337   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Visible = 1;
03338 
03339   return (1);
03340 }
03341 
03342 //------------------------------------------------------------------------------
03343 GuiConst_INT8U GuiLib_Graph_HideDataSet(
03344    GuiConst_INT8U GraphIndex,
03345    GuiConst_INT8U DataSetIndex)
03346 {
03347   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03348       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03349     return (0);
03350   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03351       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03352     return (0);
03353 
03354   sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Visible = 0;
03355 
03356   return (1);
03357 }
03358 
03359 //------------------------------------------------------------------------------
03360 GuiConst_INT8U GuiLib_Graph_ShowXAxis(
03361    GuiConst_INT8U GraphIndex,
03362    GuiConst_INT8U AxisIndex)
03363 {
03364   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03365       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03366     return (0);
03367   if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03368       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]))
03369     return (0);
03370 
03371   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Visible = 1;
03372 
03373   return (1);
03374 }
03375 
03376 //------------------------------------------------------------------------------
03377 GuiConst_INT8U GuiLib_Graph_HideXAxis(
03378    GuiConst_INT8U GraphIndex,
03379    GuiConst_INT8U AxisIndex)
03380 {
03381   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03382       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03383     return (0);
03384   if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03385       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]))
03386     return (0);
03387 
03388   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].Visible = 0;
03389 
03390   return (1);
03391 }
03392 
03393 //------------------------------------------------------------------------------
03394 GuiConst_INT8U GuiLib_Graph_ShowYAxis(
03395    GuiConst_INT8U GraphIndex,
03396    GuiConst_INT8U AxisIndex)
03397 {
03398   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03399       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03400     return (0);
03401   if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03402       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]))
03403     return (0);
03404 
03405   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Visible = 1;
03406 
03407   return (1);
03408 }
03409 
03410 //------------------------------------------------------------------------------
03411 GuiConst_INT8U GuiLib_Graph_HideYAxis(
03412    GuiConst_INT8U GraphIndex,
03413    GuiConst_INT8U AxisIndex)
03414 {
03415   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03416       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03417     return (0);
03418   if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03419       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]))
03420     return (0);
03421 
03422   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].Visible = 0;
03423 
03424   return (1);
03425 }
03426 
03427 //------------------------------------------------------------------------------
03428 GuiConst_INT8U GuiLib_Graph_SetXAxisRange(
03429    GuiConst_INT8U GraphIndex,
03430    GuiConst_INT8U AxisIndex,
03431    GuiConst_INT32S MinValue,
03432    GuiConst_INT32S MaxValue)
03433 {
03434   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03435       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03436     return (0);
03437   if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03438       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]))
03439     return (0);
03440 
03441   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
03442      NumbersMinValue = MinValue;
03443   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_X].
03444      NumbersMaxValue = MaxValue;
03445 
03446   return (1);
03447 }
03448 
03449 //------------------------------------------------------------------------------
03450 GuiConst_INT8U GuiLib_Graph_SetYAxisRange(
03451    GuiConst_INT8U GraphIndex,
03452    GuiConst_INT8U AxisIndex,
03453    GuiConst_INT32S MinValue,
03454    GuiConst_INT32S MaxValue)
03455 {
03456   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03457       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03458     return (0);
03459   if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03460       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]))
03461     return (0);
03462 
03463   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03464      NumbersMinValue = MinValue;
03465   sgl.GraphAry[GraphIndex].GraphAxes[AxisIndex][GuiLib_GRAPHAXIS_Y].
03466      NumbersMaxValue = MaxValue;
03467 
03468   return (1);
03469 }
03470 
03471 //------------------------------------------------------------------------------
03472 GuiConst_INT8U GuiLib_Graph_ResetXAxisOrigin(
03473    GuiConst_INT8U GraphIndex,
03474    GuiConst_INT8S AxisIndex)
03475 {
03476   GuiConst_INT8U AxisIndex1,AxisIndex2;
03477   GuiConst_INT8U I;
03478 
03479   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03480       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03481     return (0);
03482   if (AxisIndex == -1)
03483   {
03484     AxisIndex1 = 0;
03485     AxisIndex2 = sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X] - 1;
03486   }
03487   else if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03488       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]))
03489     return (0);
03490   else
03491   {
03492     AxisIndex1 = AxisIndex;
03493     AxisIndex2 = AxisIndex;
03494   }
03495 
03496   for (I = AxisIndex1; I <= AxisIndex2; I++)
03497   {
03498     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].NumbersMinValue =
03499        sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].NumbersMinValueOrg;
03500     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].NumbersMaxValue =
03501        sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].NumbersMaxValueOrg;
03502   }
03503 
03504   return (1);
03505 }
03506 
03507 //------------------------------------------------------------------------------
03508 GuiConst_INT8U GuiLib_Graph_OffsetXAxisOrigin(
03509    GuiConst_INT8U GraphIndex,
03510    GuiConst_INT8S AxisIndex,
03511    GuiConst_INT32S Offset)
03512 {
03513   GuiConst_INT8U AxisIndex1,AxisIndex2;
03514   GuiConst_INT8U I;
03515 
03516   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03517       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03518     return (0);
03519   if (AxisIndex == -1)
03520   {
03521     AxisIndex1 = 0;
03522     AxisIndex2 = sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X] - 1;
03523   }
03524   else if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03525       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X]))
03526     return (0);
03527   else
03528   {
03529     AxisIndex1 = AxisIndex;
03530     AxisIndex2 = AxisIndex;
03531   }
03532 
03533   for (I = AxisIndex1; I <= AxisIndex2; I++)
03534   {
03535     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].NumbersMinValue += Offset;
03536     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].NumbersMaxValue += Offset;
03537   }
03538 
03539   return (1);
03540 }
03541 
03542 //------------------------------------------------------------------------------
03543 GuiConst_INT8U GuiLib_Graph_ResetYAxisOrigin(
03544    GuiConst_INT8U GraphIndex,
03545    GuiConst_INT8S AxisIndex)
03546 {
03547   GuiConst_INT8U AxisIndex1,AxisIndex2;
03548   GuiConst_INT8U I;
03549 
03550   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03551       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03552     return (0);
03553   if (AxisIndex == -1)
03554   {
03555     AxisIndex1 = 0;
03556     AxisIndex2 = sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y] - 1;
03557   }
03558   else if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03559       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]))
03560     return (0);
03561   else
03562   {
03563     AxisIndex1 = AxisIndex;
03564     AxisIndex2 = AxisIndex;
03565   }
03566 
03567   for (I = AxisIndex1; I <= AxisIndex2; I++)
03568   {
03569     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].NumbersMinValue =
03570        sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].NumbersMinValueOrg;
03571     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].NumbersMaxValue =
03572        sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].NumbersMaxValueOrg;
03573   }
03574 
03575   return (1);
03576 }
03577 
03578 //------------------------------------------------------------------------------
03579 GuiConst_INT8U GuiLib_Graph_OffsetYAxisOrigin(
03580    GuiConst_INT8U GraphIndex,
03581    GuiConst_INT8S AxisIndex,
03582    GuiConst_INT32S Offset)
03583 {
03584   GuiConst_INT8U AxisIndex1,AxisIndex2;
03585   GuiConst_INT8U I;
03586 
03587   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03588       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03589     return (0);
03590   if (AxisIndex == -1)
03591   {
03592     AxisIndex1 = 0;
03593     AxisIndex2 = sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y] - 1;
03594   }
03595   else if ((AxisIndex >= GuiConst_GRAPH_AXES_MAX) ||
03596       (AxisIndex >= sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y]))
03597     return (0);
03598   else
03599   {
03600     AxisIndex1 = AxisIndex;
03601     AxisIndex2 = AxisIndex;
03602   }
03603 
03604   for (I = AxisIndex1; I <= AxisIndex2; I++)
03605   {
03606     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].NumbersMinValue += Offset;
03607     sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].NumbersMaxValue += Offset;
03608   }
03609 
03610   return (1);
03611 }
03612 
03613 //------------------------------------------------------------------------------
03614 GuiConst_INT8U GuiLib_Graph_Redraw(
03615    GuiConst_INT8U GraphIndex)
03616 {
03617   GuiConst_INT16S I;
03618 
03619   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03620       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03621     return (0);
03622 
03623 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03624   Graph_SetClipping(GraphIndex);
03625 #endif
03626 
03627   GuiLib_Graph_DrawAxes(GraphIndex);
03628 
03629   for (I = sgl.GraphAry[GraphIndex].GraphDataSetCnt - 1; I >= 0; I--)
03630     GuiLib_Graph_DrawDataSet(GraphIndex, I);
03631 
03632 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03633   Graph_ResetClipping();
03634 #endif
03635 
03636   return (1);
03637 }
03638 
03639 //------------------------------------------------------------------------------
03640 GuiConst_INT8U GuiLib_Graph_DrawAxes(
03641    GuiConst_INT8U GraphIndex)
03642 {
03643   GuiConst_INT16S I;
03644 
03645   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03646       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03647     return (0);
03648 
03649 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03650   Graph_SetClipping(GraphIndex);
03651 #endif
03652 
03653   if (!(sgl.GraphAry[GraphIndex].GraphItem.TextPar[0].BitFlags &
03654         GuiLib_BITFLAG_TRANSPARENT))
03655     GuiLib_FillBox(sgl.GraphAry[GraphIndex].GraphItem.X1,
03656                    sgl.GraphAry[GraphIndex].GraphItem.Y1,
03657                    sgl.GraphAry[GraphIndex].GraphItem.X2,
03658                    sgl.GraphAry[GraphIndex].GraphItem.Y2,
03659                    sgl.GraphAry[GraphIndex].GraphItem.BackColor);
03660 
03661   for (I = sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_X] - 1;
03662        I >= 0; I--)
03663     if (sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_X].Visible)
03664       Graph_DrawXAxis(GraphIndex, I);
03665 
03666   for (I = sgl.GraphAry[GraphIndex].GraphAxesCnt[GuiLib_GRAPHAXIS_Y] - 1;
03667        I >= 0; I--)
03668     if (sgl.GraphAry[GraphIndex].GraphAxes[I][GuiLib_GRAPHAXIS_Y].Visible)
03669       Graph_DrawYAxis(GraphIndex, I);
03670 
03671 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03672   Graph_ResetClipping();
03673 #endif
03674 
03675   return (1);
03676 }
03677 
03678 //------------------------------------------------------------------------------
03679 GuiConst_INT8U GuiLib_Graph_DrawDataSet(
03680    GuiConst_INT8U GraphIndex,
03681    GuiConst_INT8U DataSetIndex)
03682 {
03683   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03684       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03685     return (0);
03686   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03687       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03688     return (0);
03689   if (!sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Visible)
03690     return (0);
03691   if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataSize == 0)
03692     return (0);
03693 
03694 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03695   Graph_SetClipping(GraphIndex);
03696 #endif
03697 
03698   Graph_DrawDataSet(GraphIndex, DataSetIndex);
03699 
03700 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03701   Graph_ResetClipping();
03702 #endif
03703 
03704   return (1);
03705 }
03706 
03707 //------------------------------------------------------------------------------
03708 GuiConst_INT8U GuiLib_Graph_DrawDataPoint(
03709    GuiConst_INT8U GraphIndex,
03710    GuiConst_INT8U DataSetIndex,
03711    GuiConst_INT16U DataIndex)
03712 {
03713   GuiConst_INT16S Y;
03714   GuiConst_INT16S DX, DY;
03715   GuiConst_INT16S LastDX, LastDY;
03716   GuiConst_INT32S TX, TY;
03717 
03718   if ((GraphIndex >= GuiConst_GRAPH_MAX) ||
03719       (sgl.GraphAry[GraphIndex].InUse != GuiLib_GRAPH_STRUCTURE_USED))
03720     return (0);
03721   if ((DataSetIndex >= GuiConst_GRAPH_DATASETS_MAX) ||
03722       (DataSetIndex >= sgl.GraphAry[GraphIndex].GraphDataSetCnt))
03723     return (0);
03724   if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataSize == 0)
03725     return (0);
03726   if (!sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Visible)
03727     return (0);
03728   if (DataIndex >= sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount)
03729     return (0);
03730 
03731 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03732   Graph_SetClipping(GraphIndex);
03733 #endif
03734 
03735   Graph_CalcScaleX(GraphIndex,
03736                    sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX);
03737   Graph_CalcScaleY(GraphIndex,
03738                    sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY);
03739 
03740   TX = sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[DataIndex].X;
03741   TY = sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[DataIndex].Y;
03742   DX = sgl.GraphAry[GraphIndex].OrigoX + ((TX -
03743        sgl.GraphAry[GraphIndex].GraphAxes[
03744        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX]
03745        [GuiLib_GRAPHAXIS_X].NumbersMinValue) *
03746        sgl.GraphAry[GraphIndex].GraphAxes[
03747        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX]
03748        [GuiLib_GRAPHAXIS_X].Scale) / 10000;
03749   DY = sgl.GraphAry[GraphIndex].OrigoY - ((TY -
03750        sgl.GraphAry[GraphIndex].GraphAxes[
03751        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY]
03752        [GuiLib_GRAPHAXIS_Y].NumbersMinValue) *
03753        sgl.GraphAry[GraphIndex].GraphAxes[
03754        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY]
03755        [GuiLib_GRAPHAXIS_Y].Scale) / 10000;
03756   if (sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].Representation ==
03757       GuiLib_GRAPH_DATATYPE_LINE)
03758   {
03759     if (DataIndex == 0)
03760       DataIndex = sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataCount - 1;
03761     else
03762       DataIndex--;
03763 
03764     TX =
03765        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[DataIndex].X;
03766     TY =
03767        sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].DataPtr[DataIndex].Y;
03768     LastDX = sgl.GraphAry[GraphIndex].OrigoX + ((TX -
03769             sgl.GraphAry[GraphIndex].GraphAxes[
03770             sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX]
03771             [GuiLib_GRAPHAXIS_X].NumbersMinValue) *
03772             sgl.GraphAry[GraphIndex].GraphAxes[
03773             sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexX]
03774             [GuiLib_GRAPHAXIS_X].Scale) / 10000;
03775     LastDY = sgl.GraphAry[GraphIndex].OrigoY - ((TY -
03776              sgl.GraphAry[GraphIndex].GraphAxes[
03777              sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY]
03778              [GuiLib_GRAPHAXIS_Y].NumbersMinValue) *
03779              sgl.GraphAry[GraphIndex].GraphAxes[
03780              sgl.GraphAry[GraphIndex].GraphDataSets[DataSetIndex].AxisIndexY]
03781              [GuiLib_GRAPHAXIS_Y].Scale) / 10000;
03782   }
03783   else
03784   {
03785     LastDX = DX;
03786     LastDY = DY;
03787   }
03788 
03789   Graph_DrawDataPoint(
03790      GraphIndex,
03791      DataSetIndex,
03792      DataIndex,
03793      DX, DY,
03794      LastDX, LastDY);
03795 
03796 #ifdef GuiConst_CLIPPING_SUPPORT_ON
03797   Graph_ResetClipping();
03798 #endif
03799 
03800   return (1);
03801 }
03802 //------------------------------------------------------------------------------
03803 //------------------------------------------------------------------------------
03804 //------------------------------------------------------------------------------
03805 #endif // GuiConst_ITEM_GRAPH_INUSE
03806 
03807 #ifdef GuiConst_ITEM_GRAPHICS_LAYER_FILTER_INUSE
03808 //------------------------------------------------------------------------------
03809 //------------------------------------------------------------------------------
03810 //------------------------------------------------------------------------------
03811 static GuiConst_INT16S IndexOfGraphicsLayer(
03812    GuiConst_INT16S GraphicsLayerIndex)
03813 {
03814   GuiConst_INT16S I;
03815 
03816   if (GraphicsLayerIndex == GuiLib_GRAPHICS_LAYER_BASE)
03817     return(GuiLib_GRAPHICS_LAYER_BASE);
03818   else if (GraphicsLayerIndex == GuiLib_GRAPHICS_LAYER_PREVIOUS)
03819   {
03820     if (sgl.GraphicsLayerLifoCnt <= 1)
03821       return(GuiLib_GRAPHICS_LAYER_BASE);
03822     else
03823       return(sgl.GraphicsLayerLifo[sgl.GraphicsLayerLifoCnt - 2]);
03824   }
03825   else if (GraphicsLayerIndex == GuiLib_GRAPHICS_LAYER_CURRENT)
03826   {
03827     if (sgl.GraphicsLayerLifoCnt > 0)
03828       return(sgl.GraphicsLayerLifo[sgl.GraphicsLayerLifoCnt - 1]);
03829     else
03830       return(GuiLib_GRAPHICS_LAYER_BASE);
03831   }
03832   else if (GraphicsLayerIndex < 0)
03833     return(GuiLib_GRAPHICS_LAYER_BASE);
03834   else if (sgl.GraphicsLayerLifoCnt <= 1)
03835     return(GuiLib_GRAPHICS_LAYER_BASE);
03836   for (I = 0; I < sgl.GraphicsLayerLifoCnt; I++)
03837     if (sgl.GraphicsLayerLifo[I] == GraphicsLayerIndex)
03838       return(GraphicsLayerIndex);
03839   return(GuiLib_GRAPHICS_LAYER_BASE);
03840 }
03841 
03842 //------------------------------------------------------------------------------
03843 static GuiConst_INT8U GraphicsLayer_Push(
03844    GuiConst_INT8U GraphicsLayerIndex)
03845 {
03846   GuiConst_INT16S I;
03847 
03848   if (GraphicsLayerIndex >= GuiConst_GRAPHICS_LAYER_MAX)
03849     return(0);
03850   if (sgl.GraphicsLayerList[GraphicsLayerIndex].InUse != GuiLib_GRAPHICS_LAYER_USED)
03851     return(0);
03852   if (sgl.GraphicsLayerLifoCnt == GuiConst_GRAPHICS_LAYER_MAX)
03853     return(0);
03854   for (I = 0; I < sgl.GraphicsLayerLifoCnt; I++)
03855     if (sgl.GraphicsLayerLifo[I] == GraphicsLayerIndex)
03856       return(0);
03857 
03858   sgl.GraphicsLayerLifo[sgl.GraphicsLayerLifoCnt] = GraphicsLayerIndex;
03859   sgl.GraphicsLayerLifoCnt++;
03860   sgl.GraphicsLayerList[GraphicsLayerIndex].BaseAddress =
03861    &sgl.LayerBuf[(GuiConst_INT32U)ReadWord(
03862    GuiStruct_GraphicsLayerOfs[GraphicsLayerIndex])];
03863 
03864   sgl.CurLayerBufPtr = sgl.GraphicsLayerList[GraphicsLayerIndex].BaseAddress;
03865   sgl.CurLayerLineSize = sgl.GraphicsLayerList[GraphicsLayerIndex].LineSize;
03866   sgl.CurLayerWidth = sgl.GraphicsLayerList[GraphicsLayerIndex].Width;
03867   sgl.CurLayerHeight = sgl.GraphicsLayerList[GraphicsLayerIndex].Height;
03868   sgl.CurLayerBytes =
03869      sgl.GraphicsLayerList[GraphicsLayerIndex].Height *
03870      sgl.GraphicsLayerList[GraphicsLayerIndex].LineSize;
03871   sgl.BaseLayerDrawing = 0;
03872 
03873   return(1);
03874 }
03875 
03876 //------------------------------------------------------------------------------
03877 static GuiConst_INT8U GraphicsLayer_Pop(
03878    GuiConst_INT16S GraphicsLayerIndex)
03879 {
03880   GuiConst_INT16S I;
03881 
03882   if (GraphicsLayerIndex == GuiLib_GRAPHICS_LAYER_BASE)
03883     sgl.GraphicsLayerLifoCnt = 0;
03884   else if ((GraphicsLayerIndex == GuiLib_GRAPHICS_LAYER_PREVIOUS) &&
03885            (sgl.GraphicsLayerLifoCnt > 0))
03886   {
03887     sgl.GraphicsLayerLifoCnt--;
03888     GraphicsLayerIndex = sgl.GraphicsLayerLifo[sgl.GraphicsLayerLifoCnt - 1];
03889   }
03890   else if (GraphicsLayerIndex < 0)
03891     return(0);
03892   else if (sgl.GraphicsLayerLifoCnt <= 1)
03893     return(0);
03894   else
03895   {
03896     for (I = sgl.GraphicsLayerLifoCnt - 2; I >= 0; I--)
03897       if (sgl.GraphicsLayerLifo[I] == GraphicsLayerIndex)
03898       {
03899         sgl.GraphicsLayerLifoCnt = I + 1;
03900         break;
03901       }
03902     if (I == -1)
03903       return(0);
03904   }
03905 
03906   if (sgl.GraphicsLayerLifoCnt == 0)
03907     ResetLayerBufPtr();
03908   else
03909   {
03910     sgl.CurLayerBufPtr = sgl.GraphicsLayerList[GraphicsLayerIndex].BaseAddress;
03911     sgl.CurLayerLineSize = sgl.GraphicsLayerList[GraphicsLayerIndex].LineSize;
03912     sgl.CurLayerWidth = sgl.GraphicsLayerList[GraphicsLayerIndex].Width;
03913     sgl.CurLayerHeight = sgl.GraphicsLayerList[GraphicsLayerIndex].Height;
03914     sgl.CurLayerBytes =
03915        sgl.GraphicsLayerList[GraphicsLayerIndex].Height *
03916        sgl.GraphicsLayerList[GraphicsLayerIndex].LineSize;
03917     sgl.BaseLayerDrawing = 0;
03918   }
03919 
03920   return(1);
03921 }
03922 
03923 //------------------------------------------------------------------------------
03924 static void GraphicsLayer_Copy(
03925    GuiConst_INT8U *DestAddress,
03926    GuiConst_INT16U DestLineSize,
03927    GuiConst_INT16S DestX,
03928    GuiConst_INT16S DestY,
03929    GuiConst_INT8U *SourceAddress,
03930    GuiConst_INT16U SourceLineSize,
03931    GuiConst_INT16S SourceX,
03932    GuiConst_INT16S SourceY,
03933    GuiConst_INT16U Width,
03934    GuiConst_INT16U Height)
03935 {
03936   GuiConst_INT16S LineSize;
03937 
03938   SourceAddress +=
03939      SourceY * SourceLineSize + GuiConst_PIXEL_BYTE_SIZE * SourceX;
03940   DestAddress += DestY * DestLineSize + GuiConst_PIXEL_BYTE_SIZE * DestX;
03941   LineSize = GuiConst_PIXEL_BYTE_SIZE * Width;
03942   while (Height > 0)
03943   {
03944     memcpy(DestAddress, SourceAddress, LineSize);
03945     SourceAddress += SourceLineSize;
03946     DestAddress += DestLineSize;
03947     Height--;
03948   }
03949 }
03950 
03951 //------------------------------------------------------------------------------
03952 GuiConst_INT8U GuiLib_GraphicsFilter_Init(
03953    GuiConst_INT8U GraphicsFilterIndex,
03954    void (*FilterFuncPtr)
03955      (GuiConst_INT8U *DestAddress,
03956       GuiConst_INT16U DestLineSize,
03957       GuiConst_INT8U *SourceAddress,
03958       GuiConst_INT16U SourceLineSize,
03959       GuiConst_INT16U Width,
03960       GuiConst_INT16U Height,
03961       GuiConst_INT32S FilterPars[10]))
03962 {
03963   if (GraphicsFilterIndex >= GuiConst_GRAPHICS_FILTER_MAX)
03964     return (0);
03965 
03966   sgl.GraphicsFilterList[GraphicsFilterIndex].GraphicsFilterFunc = FilterFuncPtr;
03967 
03968   return (1);
03969 }
03970 //------------------------------------------------------------------------------
03971 //------------------------------------------------------------------------------
03972 //------------------------------------------------------------------------------
03973 #endif // GuiConst_ITEM_GRAPHICS_LAYER_FILTER_INUSE
03974 
03975 #ifdef GuiConst_TEXTBOX_FIELDS_ON
03976 //------------------------------------------------------------------------------
03977 //------------------------------------------------------------------------------
03978 //------------------------------------------------------------------------------
03979 GuiConst_INT16S *TextBox_Scroll_GetPosRec(GuiConst_INT8U TextBoxIndex)
03980 {
03981   GuiConst_INT16S I;
03982   GuiConst_INT16S *result = NULL;
03983 
03984   for (I=0;I<GuiConst_TEXTBOX_FIELDS_MAX;I++)
03985   {
03986     if (sgl.TextBoxScrollPositions[I].index == TextBoxIndex)
03987     {
03988       result = &sgl.TextBoxScrollPositions[I].pos;
03989       break;
03990     }
03991   }
03992 
03993   return result;
03994 }
03995 //------------------------------------------------------------------------------
03996 static GuiConst_INT16S TextBox_Scroll_CalcEndPos(
03997    GuiLib_ItemRec PrefixLocate *TextBoxItem,
03998    GuiConst_INT8U PerLine)
03999 {
04000   GuiConst_INT16S H;
04001 
04002   H = TextBoxItem->Y2 -
04003       TextBoxItem->Y1 + 1;
04004   if (PerLine)
04005     return (TextBoxItem->CompPars.CompTextBox.LineDist *
04006        (TextBoxItem->CompPars.CompTextBox.Lines -
04007        (H / TextBoxItem->CompPars.CompTextBox.LineDist)));
04008   else
04009     return (TextBoxItem->CompPars.CompTextBox.Lines *
04010        TextBoxItem->CompPars.CompTextBox.LineDist - H);
04011 }
04012 #endif // GuiConst_TEXTBOX_FIELDS_ON
04013 
04014 //------------------------------------------------------------------------------
04015 static GuiConst_INT8U TextBox_Scroll_To(
04016    GuiConst_INT8U TextBoxIndex,
04017    GuiConst_INT16S NewPos,
04018    GuiConst_INT8U PerLine,
04019    GuiConst_INT8U AbsoluteMove)
04020 {
04021 #ifdef GuiConst_TEXTBOX_FIELDS_ON
04022   GuiLib_ItemRec PrefixLocate *TextBoxItem;
04023   GuiConst_INT16S TextBox;
04024   GuiConst_INT16S PrefixLocate *ScrollPos;
04025 
04026   TextBox = AutoRedraw_GetTextBox(TextBoxIndex, -1);
04027 
04028   if (TextBox == -1)
04029     return (0);
04030 
04031   TextBoxItem = AutoRedraw_GetItem(TextBox);
04032 
04033   if (TextBoxItem == NULL)
04034     return (0);
04035   else
04036   {
04037     ScrollPos = TextBox_Scroll_GetPosRec(TextBoxIndex);
04038 
04039     if (ScrollPos == NULL)
04040       return (0);
04041 
04042     if (PerLine)
04043       NewPos *= TextBoxItem->CompPars.CompTextBox.LineDist;
04044 
04045     switch (AbsoluteMove)
04046     {
04047       case 0:
04048         *ScrollPos += NewPos;
04049         break;
04050 
04051       case 1:
04052         *ScrollPos = NewPos;
04053         break;
04054 
04055       case 2:
04056         *ScrollPos = TextBox_Scroll_CalcEndPos(TextBoxItem, PerLine);
04057         break;
04058     }
04059 
04060     TextBoxItem->CompPars.CompTextBox.ScrollPos = *ScrollPos;
04061 
04062     memcpy(&sgl.CurItem, TextBoxItem, sizeof(GuiLib_ItemRec));
04063 
04064     GuiDisplay_Lock();
04065 
04066     sgl.DisplayLevel = 0;
04067     sgl.SwapColors = 0;
04068     DrawItem(GuiLib_COL_INVERT_OFF);
04069 
04070     GuiDisplay_Unlock();
04071     return (1);
04072   }
04073 #else
04074   gl.Dummy1_8U = TextBoxIndex;   // To avoid compiler warning
04075   gl.Dummy1_16S = NewPos;   // To avoid compiler warning
04076   gl.Dummy2_8U = PerLine;   // To avoid compiler warning
04077   gl.Dummy3_8U = AbsoluteMove;   // To avoid compiler warning
04078   return (0);
04079 #endif
04080 }
04081 
04082 //------------------------------------------------------------------------------
04083 GuiConst_INT8U GuiLib_TextBox_Scroll_Up(
04084    GuiConst_INT8U TextBoxIndex)
04085 {
04086   return (TextBox_Scroll_To(TextBoxIndex, -1, 1, 0));
04087 }
04088 
04089 //------------------------------------------------------------------------------
04090 GuiConst_INT8U GuiLib_TextBox_Scroll_Down(
04091    GuiConst_INT8U TextBoxIndex)
04092 {
04093   return (TextBox_Scroll_To(TextBoxIndex, 1, 1, 0));
04094 }
04095 
04096 //------------------------------------------------------------------------------
04097 GuiConst_INT8U GuiLib_TextBox_Scroll_Home(
04098    GuiConst_INT8U TextBoxIndex)
04099 {
04100   return (TextBox_Scroll_To(TextBoxIndex, 0, 1, 1));
04101 }
04102 
04103 //------------------------------------------------------------------------------
04104 GuiConst_INT8U GuiLib_TextBox_Scroll_End(
04105    GuiConst_INT8U TextBoxIndex)
04106 {
04107   return (TextBox_Scroll_To(TextBoxIndex, 0, 1, 2));
04108 }
04109 
04110 //------------------------------------------------------------------------------
04111 GuiConst_INT8U GuiLib_TextBox_Scroll_To_Line(
04112    GuiConst_INT8U TextBoxIndex,
04113    GuiConst_INT16S NewLine)
04114 {
04115   return (TextBox_Scroll_To(TextBoxIndex, NewLine, 1, 1));
04116 }
04117 
04118 //------------------------------------------------------------------------------
04119 GuiConst_INT8U GuiLib_TextBox_Scroll_Up_Pixel(
04120    GuiConst_INT8U TextBoxIndex)
04121 {
04122   return (TextBox_Scroll_To(TextBoxIndex, -1, 0, 0));
04123 }
04124 
04125 //------------------------------------------------------------------------------
04126 GuiConst_INT8U GuiLib_TextBox_Scroll_Down_Pixel(
04127    GuiConst_INT8U TextBoxIndex)
04128 {
04129   return (TextBox_Scroll_To(TextBoxIndex, 1, 0, 0));
04130 }
04131 
04132 //------------------------------------------------------------------------------
04133 GuiConst_INT8U GuiLib_TextBox_Scroll_Home_Pixel(
04134    GuiConst_INT8U TextBoxIndex)
04135 {
04136   return (TextBox_Scroll_To(TextBoxIndex, 0, 0, 1));
04137 }
04138 
04139 //------------------------------------------------------------------------------
04140 GuiConst_INT8U GuiLib_TextBox_Scroll_End_Pixel(
04141    GuiConst_INT8U TextBoxIndex)
04142 {
04143   return (TextBox_Scroll_To(TextBoxIndex, 0, 0, 2));
04144 }
04145 
04146 //------------------------------------------------------------------------------
04147 GuiConst_INT8U GuiLib_TextBox_Scroll_To_PixelLine(
04148    GuiConst_INT8U TextBoxIndex,
04149    GuiConst_INT16S NewPixelLine)
04150 {
04151   return (TextBox_Scroll_To(TextBoxIndex, NewPixelLine, 0, 1));
04152 }
04153 
04154 //------------------------------------------------------------------------------
04155 static GuiConst_INT8U TextBox_Scroll_Get_Pos(
04156    GuiConst_INT8U TextBoxIndex,
04157    GuiConst_INT8U PerLine)
04158 {
04159 #ifdef GuiConst_TEXTBOX_FIELDS_ON
04160   GuiConst_INT16S P;
04161   GuiLib_ItemRec PrefixLocate*TextBoxItem;
04162   GuiConst_INT16S TextBox;
04163   GuiConst_INT16S PrefixLocate *ScrollPos;
04164 
04165   TextBox = AutoRedraw_GetTextBox(TextBoxIndex, -1);
04166 
04167   if (TextBox == -1)
04168     return (GuiLib_TEXTBOX_SCROLL_ILLEGAL_NDX);
04169 
04170   TextBoxItem = AutoRedraw_GetItem(TextBox);
04171 
04172   if (TextBoxItem == NULL)
04173     return (GuiLib_TEXTBOX_SCROLL_ILLEGAL_NDX);
04174 
04175   ScrollPos = TextBox_Scroll_GetPosRec(TextBoxIndex);
04176 
04177   if (ScrollPos == NULL)
04178     return (GuiLib_TEXTBOX_SCROLL_ILLEGAL_NDX);
04179 
04180   P = TextBox_Scroll_CalcEndPos(TextBoxItem, PerLine);
04181   if (*ScrollPos == 0)
04182     return (GuiLib_TEXTBOX_SCROLL_AT_HOME);
04183   else if (*ScrollPos == P)
04184     return (GuiLib_TEXTBOX_SCROLL_AT_END);
04185   else if (*ScrollPos < 0)
04186     return (GuiLib_TEXTBOX_SCROLL_ABOVE_HOME);
04187   else if (*ScrollPos > P)
04188     return (GuiLib_TEXTBOX_SCROLL_BELOW_END);
04189   else
04190     return (GuiLib_TEXTBOX_SCROLL_INSIDE_BLOCK);
04191 
04192 #else
04193   gl.Dummy1_8U = TextBoxIndex;   // To avoid compiler warning
04194   gl.Dummy2_8U = PerLine;   // To avoid compiler warning
04195   return (GuiLib_TEXTBOX_SCROLL_ILLEGAL_NDX);
04196 #endif
04197 }
04198 
04199 //------------------------------------------------------------------------------
04200 GuiConst_INT8U GuiLib_TextBox_Scroll_Get_Pos(
04201    GuiConst_INT8U TextBoxIndex)
04202 {
04203   return (TextBox_Scroll_Get_Pos(TextBoxIndex, 1));
04204 }
04205 
04206 //------------------------------------------------------------------------------
04207 GuiConst_INT8U GuiLib_TextBox_Scroll_Get_Pos_Pixel(
04208    GuiConst_INT8U TextBoxIndex)
04209 {
04210   return (TextBox_Scroll_Get_Pos(TextBoxIndex, 0));
04211 }
04212 
04213 //------------------------------------------------------------------------------
04214 GuiConst_INT8U GuiLib_TextBox_Scroll_FitsInside(
04215    GuiConst_INT8U TextBoxIndex)
04216 {
04217 #ifdef GuiConst_TEXTBOX_FIELDS_ON
04218   GuiLib_ItemRec PrefixLocate *TextBoxItem;
04219   GuiConst_INT16S TextBox;
04220   GuiConst_INT16S PrefixLocate *ScrollPos;
04221 
04222   TextBox = AutoRedraw_GetTextBox(TextBoxIndex, -1);
04223 
04224   if (TextBox == -1)
04225     return (0);
04226 
04227   TextBoxItem = AutoRedraw_GetItem(TextBox);
04228 
04229   if (TextBoxItem == NULL)
04230     return (0);
04231 
04232   return (TextBox_Scroll_CalcEndPos(TextBoxItem, 0) < 0);
04233 #else
04234   gl.Dummy1_8U = TextBoxIndex;   // To avoid compiler warning
04235   return (0);
04236 #endif
04237 }
04238 //------------------------------------------------------------------------------
04239 //------------------------------------------------------------------------------
04240 GuiConst_INTCOLOR GuiLib_SetButtonDisabledColor(GuiConst_INTCOLOR PixelColor)
04241 {
04242 #ifdef GuiConst_ITEM_BUTTON_INUSE
04243   sgl.ButtonColorOverride = GuiLib_TRUE;
04244   sgl.DisabledButtonColor = PixelColor;
04245 #endif
04246 
04247   return PixelColor;
04248 }
04249 //------------------------------------------------------------------------------
04250