Changeset 235 for trunk/src/helpers


Ignore:
Timestamp:
Dec 12, 2002, 12:50:50 PM (23 years ago)
Author:
umoeller
Message:

Minor changes.

Location:
trunk/src/helpers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dialog.c

    r232 r235  
    9292#include "helpers\gpih.h"
    9393#include "helpers\linklist.h"
     94#include "helpers\nlscache.h"
    9495#include "helpers\standards.h"
    9596#include "helpers\stringh.h"
     
    14971498                    strhncpy0(szText2, pcszText, sizeof(szText2));
    14981499
     1500                #ifdef DEBUG_DIALOG_WINDOWS
    14991501                _Pmpf(("Crash creating control of class 0x%lX (%s), title 0x%lX (%s)",
    15001502                        szClass2,
    15011503                        szText2));
     1504                #endif
     1505
    15021506                arc = ERROR_PROTECTION_VIOLATION;
    15031507            } END_CATCH();
     
    17611765                        LONG        cxWidestRowsMinBox = pOwningTable->cxMinBox; // pWidestRow->cxMinBox;
    17621766
     1767                        #ifdef DEBUG_DIALOG_WINDOWS
    17631768                        _Pmpf(("  pWidestRow->cxMinBox %d", pWidestRow->cxMinBox));
    17641769                        _Pmpf(("  pOwningTable->cxMinBox %d", pOwningTable->cxMinBox));
     1770                        #endif
    17651771
    17661772                        // now, since we're supposed to set our own CONTENT
     
    18601866                                    strhncpy0(szTemp, pControlDef->pcszText, sizeof(szTemp));
    18611867                                    strcpy(szTemp + 35, "...");
     1868
     1869                                    #ifdef DEBUG_DIALOG_WINDOWS
    18621870                                    _PmpfF(("   widest column is [%s] cxMinContent %d",
    18631871                                            szTemp,
    18641872                                            pCorrespondingColumn->cxMinContent));
     1873                                    #endif
    18651874                                }
    18661875                            }
     
    22422251                    }
    22432252
     2253                    #ifdef DEBUG_DIALOG_WINDOWS
    22442254                    _Pmpf(("    cxMax found is %d", cxMax));
     2255                    #endif
    22452256
    22462257                    pTableDef->cxMinBox =   cxMax
     
    23942405 *
    23952406 *@@changed V1.0.0 (2002-08-18) [umoeller]: mostly rewritten for new algorithm
     2407 *@@changed V1.0.1 (2002-12-11) [umoeller]: added interface into nlsGetString
    23962408 */
    23972409
     
    24462458                // copy control fields
    24472459                pColumn->pcszClass = pControlDef->pcszClass;
    2448                 pColumn->pcszText = pControlDef->pcszText;
     2460
     2461                if (pControlDef->pcszText == LOAD_STRING)
     2462                    pColumn->pcszText = nlsGetString(pControlDef->usID);
     2463                            // V1.0.1 (2002-12-11) [umoeller]
     2464                else
     2465                    pColumn->pcszText = pControlDef->pcszText;
     2466
    24492467                pColumn->flStyle = pControlDef->flStyle;
    24502468                pColumn->usID = pControlDef->usID;
     
    25692587
    25702588    if (!(pDlgData = NEW(DLGPRIVATE)))
    2571         return (ERROR_NOT_ENOUGH_MEMORY);
     2589        return ERROR_NOT_ENOUGH_MEMORY;
    25722590
    25732591    ZERO(pDlgData);
     
    38943912        }
    38953913
    3896     return (MBID_CANCEL);
     3914    return MBID_CANCEL;
    38973915}
    38983916
     
    39663984    {
    39673985        // SHOW DIALOG
    3968         return (dlghProcessMessageBox(hwndDlg,
    3969                                       ulAlarmFlag,
    3970                                       flFlags));
     3986        return dlghProcessMessageBox(hwndDlg,
     3987                                     ulAlarmFlag,
     3988                                     flFlags);
    39713989    }
    39723990
     
    39793997                  MB_CANCEL | MB_MOVEABLE);
    39803998
    3981     return (DID_CANCEL);
     3999    return DID_CANCEL;
    39824000}
    39834001
     
    41194137    xstrClear(&strTitle);
    41204138
    4121     return (pszReturn);
     4139    return pszReturn;
    41224140}
    41234141
     
    43134331    }
    43144332
    4315     return (hwndFound);
     4333    return hwndFound;
    43164334}
    43174335
     
    43464364                               (MPARAM)TRUE,        // upclick
    43474365                               0);
    4348                     return (TRUE);
     4366                    return TRUE;
    43494367                }
    43504368            }
     
    43544372    }
    43554373
    4356     return (FALSE);
     4374    return FALSE;
    43574375}
    43584376
  • trunk/src/helpers/nlscache.c

    r222 r235  
    8383STATIC ULONG               G_cEntities = 0;
    8484
    85 /*
    86  *@@ ReplaceEntities:
     85STATIC HMTX        G_hmtxStringsCache = NULLHANDLE;
     86STATIC TREE        *G_StringsCache;
     87STATIC LONG        G_cStringsInCache = 0;
     88
     89
     90/*
     91 *@@ nlsReplaceEntities:
    8792 *
    8893 *@@added V0.9.16 (2001-09-29) [umoeller]
    8994 */
    9095
    91 STATIC ULONG ReplaceEntities(PXSTRING pstr)
     96ULONG nlsReplaceEntities(PXSTRING pstr)
    9297{
    9398    ULONG ul,
     
    107112    }
    108113
    109     return (rc);
    110 }
    111 
    112 /*
    113  *@@ LoadString:
    114  *
    115  *@@added V0.9.18 (2002-03-08) [umoeller]
    116  */
    117 
    118 STATIC void LoadString(ULONG ulID,
    119                        PSZ *ppsz,
    120                        PULONG pulLength)        // out: length of new string (ptr can be NULL)
     114    return rc;
     115}
     116
     117/*
     118 *@@ nlsLoadString:
     119 *
     120 *@@changed V0.9.0 [umoeller]: "string not found" is now re-allocated using strdup (avoids crashes)
     121 *@@changed V0.9.0 (99-11-28) [umoeller]: added more meaningful error message
     122 *@@changed V0.9.2 (2000-02-26) [umoeller]: made temporary buffer larger
     123 *@@changed V0.9.16 (2001-09-29) [umoeller]: added entities support
     124 *@@changed V0.9.16 (2002-01-26) [umoeller]: added pulLength param
     125 *@@changed V1.0.0 (2002-09-17) [umoeller]: optimized
     126 *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
     127 */
     128
     129VOID nlsLoadString(ULONG ulID,
     130                   PSZ *ppsz,
     131                   PULONG pulLength)        // out: length of new string (ptr can be NULL)
    121132{
    122133    CHAR szBuf[500];
     
    138149
    139150    xstrInitCopy(&str, szBuf, 0);
    140     ReplaceEntities(&str);
     151    nlsReplaceEntities(&str);
    141152    *ppsz = str.psz;
    142153    if (pulLength)
     
    144155    // do not free string
    145156}
    146 
    147 STATIC HMTX        G_hmtxStringsCache = NULLHANDLE;
    148 STATIC TREE        *G_StringsCache;
    149 STATIC LONG        G_cStringsInCache = 0;
    150157
    151158/*
     
    202209
    203210/*
     211 *@@ Unload:
     212 *      removes all loaded strings from memory.
     213 *
     214 *@@added V0.9.9 (2001-04-04) [umoeller]
     215 *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
     216 */
     217
     218STATIC VOID Unload(VOID)
     219{
     220    // to delete all nodes, build a temporary
     221    // array of all string node pointers;
     222    // we don't want to rebalance the tree
     223    // for each node
     224    LONG            cNodes = G_cStringsInCache;
     225    PSTRINGTREENODE *papNodes
     226        = (PSTRINGTREENODE*)treeBuildArray(G_StringsCache,
     227                                           &cNodes);
     228    if (papNodes)
     229    {
     230        // delete all nodes in array
     231        ULONG ul;
     232        for (ul = 0;
     233             ul < cNodes;
     234             ul++)
     235        {
     236            free(papNodes[ul]);
     237        }
     238
     239        free(papNodes);
     240    }
     241
     242    // reset the tree to "empty"
     243    treeInit(&G_StringsCache,
     244             &G_cStringsInCache);
     245}
     246
     247/*
    204248 *@@ nlsInitStrings:
    205249 *      initializes the NLS strings cache. Call this
     
    214258                    ULONG cEntities)            // in: array item count of paEntities or 0
    215259{
    216     G_hab = hab;
    217     G_hmod = hmod;
    218     G_paEntities = paEntities;
    219     G_cEntities = cEntities;
     260    BOOL    fLocked = FALSE;
     261
     262    TRY_LOUD(excpt1)
     263    {
     264        if (fLocked = LockStrings())
     265        {
     266            if (G_cStringsInCache)
     267                // not first call:
     268                Unload();
     269
     270            G_hab = hab;
     271            G_hmod = hmod;
     272            G_paEntities = paEntities;
     273            G_cEntities = cEntities;
     274        }
     275    }
     276    CATCH(excpt1) {} END_CATCH();
     277
     278    if (fLocked)
     279        UnlockStrings();
    220280}
    221281
     
    275335 *@@changed V0.9.16 (2001-10-19) [umoeller]: fixed bad string count which was never set
    276336 *@@changed V0.9.16 (2002-01-26) [umoeller]: optimized heap locality
     337 *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
    277338 */
    278339
     
    299360                ULONG   ulLength = 0;
    300361
    301                 LoadString(ulStringID,
    302                            &psz,
    303                            &ulLength);
     362                nlsLoadString(ulStringID,
     363                              &psz,
     364                              &ulLength);
    304365
    305366                if (    (!psz)
     
    336397        UnlockStrings();
    337398
    338     return (pszReturn);
    339 }
    340 
    341 
     399    return pszReturn;
     400}
     401
     402
  • trunk/src/helpers/winh.c

    r232 r235  
    345345}
    346346
     347/*
     348 *@@ winhDestroyWindow:
     349 *      wrapper around WinDestroyWindow that also sets
     350 *      *phwnd to NULLHANDLE to avoid loose window
     351 *      handles lying around.
     352 *
     353 *@@added V1.0.1 (2002-12-11) [umoeller]
     354 */
     355
     356BOOL winhDestroyWindow(HWND *phwnd)
     357{
     358    if (    (*phwnd)
     359         && (WinDestroyWindow(*phwnd))
     360       )
     361    {
     362        *phwnd = NULLHANDLE;
     363
     364        return TRUE;
     365    }
     366
     367    return FALSE;
     368}
    347369
    348370/*
Note: See TracChangeset for help on using the changeset viewer.