Ignore:
Timestamp:
Jul 4, 1999, 11:06:00 PM (26 years ago)
Author:
cbratschi
Message:

Unicode and other extensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/status.c

    r252 r267  
    1 /* $Id: status.c,v 1.7 1999-06-30 15:52:17 cbratschi Exp $ */
     1/* $Id: status.c,v 1.8 1999-07-04 21:05:59 cbratschi Exp $ */
    22/*
    33 * Interface code to StatusWindow widget/control
     
    2727 */
    2828
     29/* CB: Odin problems
     30 - DrawText: DT_VCENTER doesn't work
     31*/
     32
    2933#define _MAX(a,b) (((a)>(b))?(a):(b))
    3034#define _MIN(a,b) (((a)>(b))?(b):(a))
     
    3236#define HORZ_BORDER 0
    3337#define VERT_BORDER 2
     38#define VERT_SPACE  2 //space between boder and text
    3439#define HORZ_GAP    2
     40#define TOP_MARGIN  2
     41#define ICON_SPACE  2
     42#define TEXT_SPACE  3
    3543
    3644#define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongA (hwnd, 0))
     
    8795    DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
    8896
     97    r.bottom -= VERT_SPACE;
     98    r.top += VERT_SPACE;
     99
    89100    /* draw the icon */
    90101    if (part->hIcon) {
    91102        INT cy = r.bottom - r.top;
    92103
    93         r.left += 2;
     104        r.left += ICON_SPACE;
    94105        DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
    95106        r.left += cy;
     
    110121        }
    111122      }
    112       r.left += 3;
     123      r.left += TEXT_SPACE;
    113124      DrawTextW (hdc, p, lstrlenW (p), &r, align|DT_VCENTER|DT_SINGLELINE);
    114125      if (oldbkmode != TRANSPARENT)
     
    232243    GetClientRect (hwnd, &rect);
    233244
    234     rect.top += VERT_BORDER;
     245    rect.top += TOP_MARGIN;
    235246
    236247    /* set bounds for simple rectangle */
     
    638649    int style;
    639650    LPSTR text;
     651    LPWSTR newText;
    640652    int len;
    641653    HDC hdc;
     
    651663    if (!part) return FALSE;
    652664
    653     if (!(part->style & SBT_OWNERDRAW) && part->text)
    654         COMCTL32_Free (part->text);
    655     part->text = 0;
    656 
    657     if (style & SBT_OWNERDRAW) {
    658         part->text = (LPWSTR)text;
    659     }
    660     else {
    661         /* duplicate string */
    662         if (text && (len = lstrlenA(text))) {
    663             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    664             lstrcpyAtoW (part->text, text);
    665         }
     665    if (style & SBT_OWNERDRAW)
     666    {
     667      part->text = (LPWSTR)text;
     668    } else
     669    {
     670      //compare
     671      if (text && (len = lstrlenA(text)))
     672      {
     673        newText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     674        lstrcpyAtoW (newText,text);
     675      } else newText = NULL;
     676      if (lstrcmpW(part->text,newText) == 0)
     677      {
     678        COMCTL32_Free(newText);
     679        if (part->style != style)
     680        {
     681          hdc = GetDC(hwnd);
     682          STATUSBAR_RefreshPart(hwnd,part,hdc);
     683          ReleaseDC(hwnd, hdc);
     684        }
     685        return TRUE;
     686      }
     687
     688      COMCTL32_Free(part->text);
     689      part->text = newText;
    666690    }
    667691    part->style = style;
     
    694718    if (!part) return FALSE;
    695719
    696     if (!(part->style & SBT_OWNERDRAW) && part->text)
    697         COMCTL32_Free (part->text);
    698     part->text = 0;
    699 
    700     if (style & SBT_OWNERDRAW) {
    701         part->text = text;
    702     }
    703     else {
    704         /* duplicate string */
    705         if (text && (len = lstrlenW(text))) {
    706             part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    707             lstrcpyW(part->text, text);
    708         }
     720    if (style & SBT_OWNERDRAW)
     721    {
     722      part->text = text;
     723    } else
     724    {
     725      if (lstrcmpW(part->text,text) == 0)
     726      {
     727        if (part->style != style)
     728        {
     729          hdc = GetDC(hwnd);
     730          STATUSBAR_RefreshPart(hwnd,part,hdc);
     731          ReleaseDC(hwnd, hdc);
     732        }
     733        return TRUE;
     734      }
     735
     736      /* duplicate string */
     737      COMCTL32_Free(part->text);
     738      if (text && (len = lstrlenW(text)))
     739      {
     740        part->text = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     741        lstrcpyW(part->text,text);
     742      }
    709743    }
    710744    part->style = style;
     
    837871    if (IsWindowUnicode (hwnd)) {
    838872        self->bUnicode = TRUE;
    839         if ((len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) {
     873        len = lstrlenW ((LPCWSTR)lpCreate->lpszName);
     874        if (len) {
    840875            self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    841876            lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     
    843878    }
    844879    else {
    845         if ((len = lstrlenA ((LPCSTR)lpCreate->lpszName))) {
     880        len = lstrlenA ((LPCSTR)lpCreate->lpszName);
     881        if (len) {
    846882            self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    847             lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName);
    848         }
    849     }
    850 
    851     if ((hdc = GetDC (0))) {
     883            lstrcpyAtoW (self->parts[0].text, (char*)lpCreate->lpszName);
     884        }
     885    }
     886
     887    hdc = GetDC(hwnd);
     888    if (hdc) {
    852889        TEXTMETRICA tm;
    853890        HFONT hOldFont;
     
    857894        self->textHeight = tm.tmHeight;
    858895        SelectObject (hdc, hOldFont);
    859         ReleaseDC(0, hdc);
     896        ReleaseDC(hwnd, hdc);
    860897    }
    861898
     
    883920    GetClientRect (GetParent (hwnd), &rect);
    884921    width = rect.right - rect.left;
    885     self->height = self->textHeight + 4 + VERT_BORDER;
     922    self->height = self->textHeight+2*VERT_BORDER+2*VERT_SPACE;
    886923    MoveWindow (hwnd, lpCreate->x, lpCreate->y-1,
    887924                  width, self->height, FALSE);
     
    10571094        if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
    10581095            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1059             lstrcpyAtoW (part->text, (LPCSTR)lParam);
     1096            lstrcpyAtoW (part->text, (char*)lParam);
    10601097        }
    10611098    }
Note: See TracChangeset for help on using the changeset viewer.