Ignore:
Timestamp:
Feb 3, 2025, 4:59:45 AM (2 months ago)
Author:
rlwalsh
Message:

XCenter: add object & class methods to get/set icon size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/branch-1-0/src/classes/xcenter.c

    r1358 r1490  
    9999#include "shared\notebook.h"            // generic XWorkplace notebook handling
    100100
     101#include "shared\wpsh.h"
    101102#include "shared\center.h"              // public XCenter interfaces
    102103
     
    11771178
    11781179/*
     1180 *@@ xwpQueryIconSize:
     1181 *      Returns 0=mini, 1=full
     1182 *
     1183 *      A future enhancement may return the actual size
     1184 *      of a variable-size icon
     1185 */
     1186
     1187SOM_Scope ULONG SOMLINK xctr_xwpQueryIconSize(XCenter *somSelf)
     1188{
     1189    XCenterData *somThis = XCenterGetData(somSelf);
     1190    XCenterMethodDebug("XCenter","xctr_xwpQueryIconSize");
     1191
     1192    return ((_flDisplayStyle & XCS_LARGEICONS) ? 1 : 0);
     1193}
     1194
     1195/*
     1196 *@@ xwpSetIconSize:
     1197 *      Sets icon size to:  0=mini, 1=full
     1198 *      If this XCenter is open, its display will be updated.
     1199 *
     1200 *      A future enhancement may allow setting the actual size
     1201 *      of a variable-size icon
     1202 */
     1203
     1204SOM_Scope BOOL  SOMLINK xctr_xwpSetIconSize(XCenter *somSelf, ULONG ulSize)
     1205{
     1206    ULONG   style;
     1207    XCenterData *somThis = XCenterGetData(somSelf);
     1208    XCenterMethodDebug("XCenter","xctr_xwpSetIconSize");
     1209
     1210    if (ulSize > 1)
     1211        return FALSE;
     1212
     1213    // set possibly-new style
     1214    style = _flDisplayStyle;
     1215    if (ulSize)
     1216        _flDisplayStyle |= XCS_LARGEICONS;
     1217    else
     1218        _flDisplayStyle &= ~XCS_LARGEICONS;
     1219
     1220    // no change so nothing to do
     1221    if (_flDisplayStyle == style)
     1222        return TRUE;
     1223
     1224    // force recalc
     1225    _ulHeight = 0;
     1226
     1227    _wpSaveDeferred(somSelf);
     1228
     1229    // if view is currently open, post an update msg
     1230    // to ensure it occurs on this instance's thread
     1231    if (_pvOpenView)
     1232        WinPostMsg(((PXCENTERWINDATA)_pvOpenView)->Globals.hwndClient,
     1233                   XCM_REFORMAT, (MPARAM)XFMF_DISPLAYSTYLECHANGED, 0);
     1234
     1235    return TRUE;
     1236}
     1237
     1238/*
    11791239 *@@ wpInitData:
    11801240 *      this WPObject instance method gets called when the
     
    12051265    _pllAllWidgetSettings = NULL;
    12061266}
    1207 
    1208 /*
    1209  * wpObjectReady: override;     removed V0.9.9 (2001-03-13) [umoeller]
    1210  */
    12111267
    12121268/*
     
    14791535                                                // store in instance data
    14801536                                                &_pvOpenView);
     1537
     1538            // let the class know we're open
     1539            if (hwndNewView)
     1540                _xwpclsRegisterOpenView(_XCenter, somSelf, TRUE);
     1541
    14811542            // V1.0.1 (2003-02-02) [umoeller]
    14821543            fl = cmnQuerySetting(sflIntroHelpShown);
     
    17001761    M_XCenterMethodDebug("M_XCenter","xctrM_xwpclsAutoOpen");
    17011762
    1702     for (ctr = 0; ctr < XCTR_MAX_AUTO && _aulAutoOpen[ctr]; ctr++)
     1763    for (ctr = 0; ctr < XCTR_MAX_OPEN && _aulAutoOpen[ctr]; ctr++)
    17031764    {
    17041765        XCenter *obj = _wpclsObjectFromHandle(somSelf, _aulAutoOpen[ctr]);
     
    17551816
    17561817    // loop until we reach the first empty slot
    1757     found = XCTR_MAX_AUTO;
    1758     for (ctr = 0; ctr < XCTR_MAX_AUTO && _aulAutoOpen[ctr]; ctr++)
     1818    found = XCTR_MAX_OPEN;
     1819    for (ctr = 0; ctr < XCTR_MAX_OPEN && _aulAutoOpen[ctr]; ctr++)
    17591820    {
    17601821        if (_aulAutoOpen[ctr] == ulHandle)
     
    17641825    if (fAutoOpen) {
    17651826        // already present
    1766         if (found < XCTR_MAX_AUTO)
     1827        if (found < XCTR_MAX_OPEN)
    17671828            return TRUE;
    17681829
    17691830        // no room at the inn...
    1770         if (ctr >= XCTR_MAX_AUTO)
     1831        if (ctr >= XCTR_MAX_OPEN)
    17711832            return FALSE;
    17721833
     
    17761837    else {
    17771838        // not found
    1778         if (found == XCTR_MAX_AUTO)
     1839        if (found == XCTR_MAX_OPEN)
    17791840            return FALSE;
    17801841
    1781         // move the last non-zero item into the slot
    1782         // occupied by the item to be removed
    1783         // (if this is the only item, the one moved is already zero)
    1784         _aulAutoOpen[found] = _aulAutoOpen[--ctr];
     1842        // move the list down and zero the last non-zero entry
     1843        memcpy(&_aulAutoOpen[found], &_aulAutoOpen[found + 1], --ctr - found);
    17851844        _aulAutoOpen[ctr] = 0;
    17861845    }
     
    18061865    ULONG   i, j;
    18071866    char    *ptr;
    1808     char    buf[XCTR_MAX_AUTO * 8]; // somewhat larger than needed
     1867    char    buf[XCTR_MAX_OPEN * 8]; // somewhat larger than needed
    18091868
    18101869    M_XCenterMethodDebug("M_XCenter","xctrM_xwpclsSaveAutoOpen");
    18111870
    18121871    ptr = buf;
    1813     for (i = 0; i < XCTR_MAX_AUTO && _aulAutoOpen[i]; i++)
     1872    for (i = 0; i < XCTR_MAX_OPEN && _aulAutoOpen[i]; i++)
    18141873    {
    18151874        // remove entries other methods marked as invalid
    18161875        if (_aulAutoOpen[i] == (ULONG)-1) {
    1817             for (j = i + 1; j < XCTR_MAX_AUTO && _aulAutoOpen[j]; j++);
     1876            for (j = i + 1; j < XCTR_MAX_OPEN && _aulAutoOpen[j]; j++);
    18181877
    18191878            _aulAutoOpen[i] = _aulAutoOpen[--j];
     
    18341893
    18351894/*
     1895 *@@ xwpclsQueryIconSize:
     1896 *      Returns the class default: 0=mini, 1=full
     1897 *
     1898 *      A future enhancement may return the actual size
     1899 *      of a variable-size icon
     1900 */
     1901
     1902SOM_Scope ULONG  SOMLINK xctrM_xwpclsQueryIconSize(M_XCenter *somSelf)
     1903{
     1904    M_XCenterData *somThis = M_XCenterGetData(somSelf);
     1905    M_XCenterMethodDebug("M_XCenter","xwpclsQueryIconSize");
     1906
     1907    return _ulIconSize;
     1908}
     1909
     1910/*
     1911 *@@ xwpclsSetIconSize:
     1912 *      Sets the class default icon size to:  0=mini, 1=full
     1913 *      If any XCenters are open, their settings and displays will be updated
     1914 *
     1915 *      A future enhancement may allow setting the actual size
     1916 *      of a variable-size icon
     1917 */
     1918
     1919SOM_Scope BOOL  SOMLINK xctrM_xwpclsSetIconSize(M_XCenter *somSelf, ULONG ulSize)
     1920{
     1921    ULONG   ctr;
     1922    M_XCenterData *somThis = M_XCenterGetData(somSelf);
     1923    M_XCenterMethodDebug("M_XCenter","xwpclsSetIconSize");
     1924
     1925    if (ulSize > 1 ||
     1926        !PrfWriteProfileString(HINI_USERPROFILE, (PSZ)INIAPP_XWORKPLACE,
     1927                               (PSZ)INIKEY_XCENTERICONSIZE,
     1928                               ulSize ? "1" : NULL))
     1929        return FALSE;
     1930
     1931    _ulIconSize = ulSize;
     1932
     1933    for (ctr = 0; ctr < XCTR_MAX_OPEN && _aOpenViews[ctr]; ctr++)
     1934    {
     1935        if (wpshCheckObject(_aOpenViews[ctr]))
     1936            _xwpSetIconSize(_aOpenViews[ctr], ulSize);
     1937        else {
     1938            _xwpclsRegisterOpenView(somSelf, _aOpenViews[ctr], FALSE);
     1939            ctr--;
     1940        }
     1941    }
     1942
     1943    return TRUE;
     1944}
     1945
     1946/*
     1947 *@@ xwpclsRegisterOpenView:
     1948 *      Maintains a list of open XCenters.
     1949 *      Used by xwpclsSetIconSize().
     1950 */
     1951
     1952SOM_Scope void  SOMLINK xctrM_xwpclsRegisterOpenView(M_XCenter *somSelf,
     1953                                                     XCenter *pObj, BOOL fAdd)
     1954{
     1955    ULONG   ctr;
     1956    ULONG   found;
     1957    M_XCenterData *somThis = M_XCenterGetData(somSelf);
     1958    M_XCenterMethodDebug("M_XCenter","xwpclsRegisterOpenView");
     1959
     1960    // loop until we reach the first empty slot
     1961    found = XCTR_MAX_OPEN;
     1962    for (ctr = 0; ctr < XCTR_MAX_OPEN && _aOpenViews[ctr]; ctr++)
     1963    {
     1964        if (_aOpenViews[ctr] == pObj)
     1965            found = ctr;
     1966    }
     1967
     1968    if (fAdd) {
     1969        // if not found & there's room, add to list
     1970        if (found == XCTR_MAX_OPEN && ctr < XCTR_MAX_OPEN)
     1971            _aOpenViews[ctr] = pObj;
     1972    }
     1973    else
     1974    // move the list down and zero the last non-zero entry
     1975    if (found < XCTR_MAX_OPEN) {
     1976        memcpy(&_aOpenViews[found], &_aOpenViews[found + 1], --ctr - found);
     1977        _aOpenViews[ctr] = 0;
     1978    }
     1979
     1980    return;
     1981}
     1982
     1983/*
    18361984 *@@ wpclsInitData:
    18371985 *      this WPObject class method gets called when a class
     
    18532001    ULONG   handle;
    18542002    char    *ptr;
    1855     char    buf[XCTR_MAX_AUTO * 8]; // larger than needed, just in case
     2003    char    buf[XCTR_MAX_OPEN * 8]; // larger than needed, just in case
    18562004
    18572005    M_XCenterMethodDebug("M_XCenter","xctrM_wpclsInitData");
     
    18662014    // register XCenter plugins category (ctr_model.c)
    18672015    arc = ctrpRegisterCategory();
     2016
     2017    // clear list of open XCenters
     2018    memset(_aOpenViews, 0, sizeof(_aOpenViews));
     2019
     2020    // get default icon size (currently 0=mini 1=full)
     2021    _ulIconSize = PrfQueryProfileInt(HINI_USERPROFILE, (PSZ)INIAPP_XWORKPLACE,
     2022                                     (PSZ)INIKEY_XCENTERICONSIZE, 0);
    18682023
    18692024    // process the auto-open list of handles, if any
     
    18782033        // the list is formatted as "[handle][space]...nul"
    18792034        for (ctr = 0, ptr = strtok(buf, " ");
    1880              ctr < XCTR_MAX_AUTO && ptr;
     2035             ctr < XCTR_MAX_OPEN && ptr;
    18812036             ctr++, ptr = strtok(NULL, " "))
    18822037        {
Note: See TracChangeset for help on using the changeset viewer.