Changeset 267 for trunk/src/comctl32/status.c
- Timestamp:
- Jul 4, 1999, 11:06:00 PM (26 years ago)
- 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:17cbratschi Exp $ */1 /* $Id: status.c,v 1.8 1999-07-04 21:05:59 cbratschi Exp $ */ 2 2 /* 3 3 * Interface code to StatusWindow widget/control … … 27 27 */ 28 28 29 /* CB: Odin problems 30 - DrawText: DT_VCENTER doesn't work 31 */ 32 29 33 #define _MAX(a,b) (((a)>(b))?(a):(b)) 30 34 #define _MIN(a,b) (((a)>(b))?(b):(a)) … … 32 36 #define HORZ_BORDER 0 33 37 #define VERT_BORDER 2 38 #define VERT_SPACE 2 //space between boder and text 34 39 #define HORZ_GAP 2 40 #define TOP_MARGIN 2 41 #define ICON_SPACE 2 42 #define TEXT_SPACE 3 35 43 36 44 #define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongA (hwnd, 0)) … … 87 95 DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST); 88 96 97 r.bottom -= VERT_SPACE; 98 r.top += VERT_SPACE; 99 89 100 /* draw the icon */ 90 101 if (part->hIcon) { 91 102 INT cy = r.bottom - r.top; 92 103 93 r.left += 2;104 r.left += ICON_SPACE; 94 105 DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL); 95 106 r.left += cy; … … 110 121 } 111 122 } 112 r.left += 3;123 r.left += TEXT_SPACE; 113 124 DrawTextW (hdc, p, lstrlenW (p), &r, align|DT_VCENTER|DT_SINGLELINE); 114 125 if (oldbkmode != TRANSPARENT) … … 232 243 GetClientRect (hwnd, &rect); 233 244 234 rect.top += VERT_BORDER;245 rect.top += TOP_MARGIN; 235 246 236 247 /* set bounds for simple rectangle */ … … 638 649 int style; 639 650 LPSTR text; 651 LPWSTR newText; 640 652 int len; 641 653 HDC hdc; … … 651 663 if (!part) return FALSE; 652 664 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; 666 690 } 667 691 part->style = style; … … 694 718 if (!part) return FALSE; 695 719 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 } 709 743 } 710 744 part->style = style; … … 837 871 if (IsWindowUnicode (hwnd)) { 838 872 self->bUnicode = TRUE; 839 if ((len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) { 873 len = lstrlenW ((LPCWSTR)lpCreate->lpszName); 874 if (len) { 840 875 self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 841 876 lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName); … … 843 878 } 844 879 else { 845 if ((len = lstrlenA ((LPCSTR)lpCreate->lpszName))) { 880 len = lstrlenA ((LPCSTR)lpCreate->lpszName); 881 if (len) { 846 882 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) { 852 889 TEXTMETRICA tm; 853 890 HFONT hOldFont; … … 857 894 self->textHeight = tm.tmHeight; 858 895 SelectObject (hdc, hOldFont); 859 ReleaseDC( 0, hdc);896 ReleaseDC(hwnd, hdc); 860 897 } 861 898 … … 883 920 GetClientRect (GetParent (hwnd), &rect); 884 921 width = rect.right - rect.left; 885 self->height = self->textHeight + 4 + VERT_BORDER;922 self->height = self->textHeight+2*VERT_BORDER+2*VERT_SPACE; 886 923 MoveWindow (hwnd, lpCreate->x, lpCreate->y-1, 887 924 width, self->height, FALSE); … … 1057 1094 if (lParam && (len = lstrlenA((LPCSTR)lParam))) { 1058 1095 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1059 lstrcpyAtoW (part->text, ( LPCSTR)lParam);1096 lstrcpyAtoW (part->text, (char*)lParam); 1060 1097 } 1061 1098 }
Note:
See TracChangeset
for help on using the changeset viewer.