Ignore:
Timestamp:
Oct 30, 2009, 1:06:49 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

3rdparty: os2/xsystray: Fixed vertical centering and added support for the "Frame around statics" XCenter style option.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/3rdparty/os2/xsystray/xsystray.c

    r265 r268  
    152152
    153153#define TID_CHECKALIVE          1
    154          // check alive timer
    155 #define TID_CHECKALIVE_TIMEOUT  1000 // ms
    156          // how often to check if windows associated with icons are still alive
     154         // timer that checks if windows associated with icons are still alive
     155#define TID_CHECKALIVE_TIMEOUT  2000 // ms
     156         // how often to perform alive checks
    157157
    158158/* ******************************************************************
     
    210210 */
    211211
     212// @todo the function declarations should become not necessary when we move into
     213// XWorkplace. Let's hope the prototypes will not change until then. Let's also
     214// pray that XFLDRxxx.DLL has the _Optlink calling convention for exports and
     215// not the default __cdecl (which happens if it builds with GCC according to the
     216// XWPENTRY definition in the current xwphelpers sources)
     217
     218#define XWPENTRY _Optlink
     219
     220typedef VOID XWPENTRY GPIHDRAW3DFRAME(HPS hps,
     221                                      PRECTL prcl,
     222                                      USHORT usWidth,
     223                                      LONG lColorLeft,
     224                                      LONG lColorRight);
     225typedef GPIHDRAW3DFRAME *PGPIHDRAW3DFRAME;
     226PGPIHDRAW3DFRAME pgpihDraw3DFrame = NULL;
     227
     228typedef struct _RESOLVEFUNCTION
     229{
     230    const char  *pcszFunctionName;
     231    PFN         *ppFuncAddress;
     232} RESOLVEFUNCTION, *PRESOLVEFUNCTION;
     233RESOLVEFUNCTION G_aImports[] =
     234{
     235    { "gpihDraw3DFrame", (PFN*)&pgpihDraw3DFrame },
     236};
     237
    212238/* ******************************************************************
    213239 *
     
    255281 ********************************************************************/
    256282
     283/*
     284 *@@ FreeIconData:
     285 *      Frees all members of the ICONDATA structure and resets them to 0.
     286 */
     287
     288static
    257289VOID FreeIconData(PICONDATA pData)
    258290{
     
    271303        pData->pszToolTip = NULL;
    272304    }
     305}
     306
     307/*
     308 *@@ DrawPointer:
     309 *      Draws a pointer in a presentation space.
     310 */
     311
     312static
     313BOOL DrawPointer(HPS hps, LONG lx, LONG ly, HPOINTER hptrPointer, BOOL bMini)
     314{
     315    return WinDrawPointer(hps, lx, ly, hptrPointer, bMini ? DP_MINI : DP_NORMAL);
     316    // @todo: for icons with real alpha, do manual alpha blending
    273317}
    274318
     
    334378}
    335379
    336 static
    337 BOOL DrawPointer(HPS hps, LONG lx, LONG ly, HPOINTER hptrPointer, BOOL bMini)
    338 {
    339     return WinDrawPointer(hps, lx, ly, hptrPointer, bMini ? DP_MINI : DP_NORMAL);
    340     // @todo:
    341     // 1) for icons w/o real alpha, draw them manually by correctly selecting
    342     //    the normal or mini HBITMAP (WinDrawPointer fails to do so);
    343     // 2) for icons with real alpha, do manual alpha blending
    344 }
    345 
    346380/*
    347381 *@@ WgtPaint:
     
    365399        RECTL   rcl;
    366400        BOOL    bLeftToRight;
    367         LONG    x, lTotalWidth;
     401        LONG    x, y, lTotalWidth;
    368402        size_t  i;
    369403
     
    383417
    384418        LOGF(("rclPaint %d,%d-%d,%d\n",
    385               rclPaint.xLeft, rclPaint.xRight, rclPaint.yBottom, rclPaint.yTop));
     419              rclPaint.xLeft, rclPaint.yBottom, rclPaint.xRight, rclPaint.yTop));
    386420
    387421        // switch HPS to RGB mode
     
    394428        WinFillRect(hps, &rclPaint,
    395429                    WinQuerySysColor(HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0));
     430
     431        if ((pWidget->pGlobals->flDisplayStyle & XCS_SUNKBORDERS))
     432        {
     433            rcl.xLeft = 0;
     434            rcl.yBottom = 0;
     435            rcl.xRight = swp.cx - 1;
     436            rcl.yTop = swp.cy - 1;
     437            pgpihDraw3DFrame(hps, &rcl, 1,
     438                             pWidget->pGlobals->lcol3DDark,
     439                             pWidget->pGlobals->lcol3DLight);
     440        }
     441
     442        // always center the icon vertically (we may be given more height than
     443        // we requested)
     444        y = (swp.cy - pSysTrayData->lIconWidth) / 2;
    396445
    397446        if (bLeftToRight)
     
    420469                break;
    421470
    422             DrawPointer(hps, x, pSysTrayData->lIconPad,
    423                         pSysTrayData->pIcons[i].hIcon, DP_MINI);
     471            DrawPointer(hps, x, y, pSysTrayData->pIcons[i].hIcon, DP_MINI);
    424472            if (bLeftToRight)
    425473                x += lTotalWidth;
     
    845893                             PSZ pszErrorMsg)       // if 0 is returned, 500 bytes of error msg
    846894{
    847     ULONG       ulrc = 0;
     895    ULONG       ulrc = 0, ul = 0;
    848896    CLASSINFO   ClassInfo;
    849897
     
    852900    do
    853901    {
     902        // resolve imports from XFLDR.DLL (this is basically
     903        // a copy of the doshResolveImports code, but we can't
     904        // use that before resolving...)
     905        for (ul = 0;
     906             ul < sizeof(G_aImports) / sizeof(G_aImports[0]);
     907             ul++)
     908        {
     909            APIRET arc;
     910            if ((arc = DosQueryProcAddr(hmodXFLDR,
     911                                        0,               // ordinal, ignored
     912                                        (PSZ)G_aImports[ul].pcszFunctionName,
     913                                        G_aImports[ul].ppFuncAddress))
     914                        != NO_ERROR)
     915            {
     916                snprintf(pszErrorMsg, 500,
     917                         "Import %s failed with %ld.",
     918                         G_aImports[ul].pcszFunctionName, arc);
     919                break;
     920            }
     921        }
     922        if (ul < sizeof(G_aImports) / sizeof(G_aImports[0]))
     923            break;
     924
    854925        // register our PM window class
    855926        if (!WinRegisterClass(hab,
     
    861932            )
    862933        {
    863             LOG(("WinRegisterClass(%s) failed with %lX",
    864                  WNDCLASS_WIDGET_XSYSTRAY, WinGetLastError(hab)));
     934            snprintf(pszErrorMsg, 500,
     935                     "WinRegisterClass(%s) failed with %lX.",
     936                     WNDCLASS_WIDGET_XSYSTRAY, WinGetLastError(hab));
    865937            break;
    866938        }
     
    882954        {
    883955            // error registering class: report error then
    884             snprintf(pszErrorMsg, 500, "WinRegisterClass(%s) failed with %lX",
     956            snprintf(pszErrorMsg, 500,
     957                     "WinRegisterClass(%s) failed with %lX",
    885958                     WNDCLASS_WIDGET_XSYSTRAY_SERVER, WinGetLastError(hab));
    886959            break;
     
    896969    while (0);
    897970
    898     LOGF(("pszErrorMsg %s\n", pszErrorMsg));
     971    LOGF(("pszErrorMsg '%s'\n", pszErrorMsg));
    899972    LOGF(("ulrc %d\n", ulrc));
    900973
Note: See TracChangeset for help on using the changeset viewer.