~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/windows/identity/ui/htwnd.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman, Russ Allbery, Sam Hartman
  • Date: 2008-08-21 10:41:41 UTC
  • mfrom: (11.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080821104141-a0f9c4o4cpo8xd0o
Tags: 1.6.dfsg.4~beta1-4
[ Russ Allbery ]
* Translation updates:
  - Swedish, thanks Martin Bagge.  (Closes: #487669, #491774)
  - Italian, thanks Luca Monducci.  (Closes: #493962)

[ Sam Hartman ]
* Translation Updates:
    - Dutch, Thanks Vincent Zweije, Closes: #495733

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
 
95
95
htw_align_table[] = {
96
96
    {L"left", ALIGN_LEFT},
97
 
    {L"center", ALIGN_LEFT},
 
97
    {L"center", ALIGN_CENTER},
98
98
    {L"right", ALIGN_RIGHT}
99
99
};
100
100
 
463
463
 
464
464
        n = 1;
465
465
    } else if(!_wcsnicmp(start, L"b", c - start)) {
466
 
        format_push(s,d, HTW_DEFAULT, FV_BOLD, HTW_DEFAULT);
 
466
        format_push(s,d, HTW_DEFAULT, FV_BOLD, (COLORREF) HTW_DEFAULT);
467
467
    } else if(!_wcsnicmp(start, L"/b", c - start)) {
468
468
        format_pop(s);
469
469
    } else if(!_wcsnicmp(start, L"u", c - start)) {
470
 
        format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, HTW_DEFAULT);
 
470
        format_push(s,d, HTW_DEFAULT, FV_UNDERLINE, (COLORREF) HTW_DEFAULT);
471
471
    } else if(!_wcsnicmp(start, L"/u", c - start)) {
472
472
        format_pop(s);
473
473
    } else if(!_wcsnicmp(start, L"i", c - start)) {
474
 
        format_push(s,d, HTW_DEFAULT, FV_ITALIC, HTW_DEFAULT);
 
474
        format_push(s,d, HTW_DEFAULT, FV_ITALIC, (COLORREF) HTW_DEFAULT);
475
475
    } else if(!_wcsnicmp(start, L"/i", c - start)) {
476
476
        format_pop(s);
477
477
    } else if(!_wcsnicmp(start, L"large", c - start)) {
478
 
        format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, HTW_DEFAULT);
 
478
        format_push(s,d,-MulDiv(HTW_LARGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT);
479
479
    } else if(!_wcsnicmp(start, L"/large", c - start)) {
480
480
        format_pop(s);
481
481
    } else if(!_wcsnicmp(start, L"huge", c - start)) {
482
 
        format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, HTW_DEFAULT);
 
482
        format_push(s,d,-MulDiv(HTW_HUGE_SIZE, d->l_pixel_y, 72), HTW_DEFAULT, (COLORREF) HTW_DEFAULT);
483
483
    } else if(!_wcsnicmp(start, L"/huge", c - start)) {
484
484
        format_pop(s);
485
485
    } else if(!_wcsnicmp(start, L"center", c - start)) {
610
610
    lf.lfEscapement = 0;
611
611
    lf.lfOrientation = 0;
612
612
    lf.lfWeight = (d->styles[style].variation & FV_BOLD)? FW_BOLD: FW_NORMAL;
613
 
    lf.lfItalic = !!(d->styles[style].variation & FV_ITALIC);
614
 
    lf.lfUnderline = !!(d->styles[style].variation & FV_UNDERLINE);
615
 
    lf.lfStrikeOut = !!(d->styles[style].variation & FV_STRIKEOUT);
 
613
    lf.lfItalic = (BYTE) !!(d->styles[style].variation & FV_ITALIC);
 
614
    lf.lfUnderline = (BYTE) !!(d->styles[style].variation & FV_UNDERLINE);
 
615
    lf.lfStrikeOut = (BYTE) !!(d->styles[style].variation & FV_STRIKEOUT);
616
616
    lf.lfCharSet = DEFAULT_CHARSET;
617
617
    lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
618
618
    lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
642
642
    int ext_height = 0;
643
643
 
644
644
    d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
645
    if (d == NULL)
 
646
        return 0;
645
647
 
646
648
    if(!GetUpdateRect(hwnd, &r, !(d->flags & KHUI_HTWND_TRANSPARENT)))
647
649
        return 0;
661
663
        DrawEdge(hdc, &r, EDGE_SUNKEN, BF_ADJUST | BF_RECT | BF_FLAT);
662
664
#endif
663
665
 
664
 
    hbk = CreateSolidBrush(RGB(255,255,255));
 
666
    hbk = GetSysColorBrush(COLOR_WINDOW);
665
667
    FillRect(hdc, &r, hbk);
666
 
    DeleteObject(hbk);
 
668
    hbk = NULL;                 /* We don't need to destroy system
 
669
                                   brushes */
667
670
 
668
671
    /* push the default format */
669
672
    format_init(&s_stack);
671
674
    d->l_pixel_y = GetDeviceCaps(hdc, LOGPIXELSY);
672
675
    format_push(&s_stack,d, -MulDiv(HTW_NORMAL_SIZE, d->l_pixel_y, 72), FV_NONE, RGB(0,0,0));
673
676
 
674
 
    y = d->scroll_top + r.top;
 
677
    y = r.top - d->scroll_top;
675
678
 
676
679
    par_start = text;
677
680
 
732
735
 
733
736
        x = r.left - d->scroll_left;
734
737
 
735
 
        if(align == ALIGN_CENTER)
736
 
            x += (r.right - r.left)/2 - p_width / 2;
737
 
        else if(align == ALIGN_RIGHT)
738
 
            x += (r.right - r.left) - p_width;
 
738
        if(align == ALIGN_CENTER) {
 
739
            if (r.right - r.left > p_width)
 
740
                x += (r.right - r.left)/2 - p_width / 2;
 
741
        }
 
742
 
 
743
        else if(align == ALIGN_RIGHT) {
 
744
            if (r.right - r.left > p_width)
 
745
                x += (r.right - r.left) - p_width;
 
746
        }
739
747
 
740
748
        /* begin wet run */
741
749
        p = par_start;
743
751
 
744
752
        p_width = 0;
745
753
 
746
 
        while(*p) {
 
754
        while(p && *p) {
747
755
            if(*p == L'<') {
748
756
                int talign = -1;
749
757
                int n;
766
774
                    align = talign;
767
775
            } else {
768
776
                HFONT hfold;
769
 
                RECT rd,rt;
 
777
                RECT rd;
770
778
 
771
779
                c = wcschr(p, L'<');
772
780
                if(!c)
777
785
                SetTextColor(hdc, format_color(&s_stack));
778
786
 
779
787
                GetTextExtentPoint32(hdc, p, (int)(c - p), &s);
780
 
                rd.left = x + p_width - d->scroll_left;
781
 
                rd.top = y - d->scroll_top;
782
 
                rd.right = x + p_width + s.cx - d->scroll_left;
783
 
                rd.bottom = y + l_height - d->scroll_top;
 
788
                rd.left = x + p_width;
 
789
                rd.top = y;
 
790
                rd.right = rd.left + s.cx;
 
791
                rd.bottom = rd.top + l_height;
784
792
 
785
 
                if(IntersectRect(&rt, &rd, &r)) {
786
 
                    DrawText(hdc, p, (int)(c - p), &rd,
787
 
                             DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
788
 
                }
 
793
                DrawText(hdc, p, (int)(c - p), &rd,
 
794
                         DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
789
795
 
790
796
                p_width += s.cx;
791
797
 
806
812
 
807
813
    EndPaint(hwnd, &ps);
808
814
 
809
 
    if (d->ext_width < ext_width) {
 
815
    if (d->ext_width < ext_width ||
 
816
        d->ext_height < ext_height) {
810
817
        SCROLLINFO si;
811
818
        LONG l;
812
819
 
833
840
            else
834
841
                d->flags &= ~KHUI_HTWND_VSCROLL;
835
842
 
836
 
            l = GetWindowLongPtr(hwnd, GWL_STYLE);
 
843
            l = (LONG) GetWindowLongPtr(hwnd, GWL_STYLE);
837
844
            l &= ~(WS_HSCROLL | WS_VSCROLL);
838
845
 
839
846
            l |= ((d->flags & KHUI_HTWND_HSCROLL) ? WS_HSCROLL : 0) |
940
947
            BOOL rv;
941
948
 
942
949
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
950
            if (d == NULL)
 
951
                return 0;
 
952
 
943
953
            newtext = (wchar_t *) lParam;
944
954
 
945
955
            if(d->text) {
973
983
            int i;
974
984
 
975
985
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
976
 
            if(d->text)
977
 
                PFREE(d->text);
978
 
            d->text = 0;
 
986
            if (d) {
 
987
                if(d->text)
 
988
                    PFREE(d->text);
 
989
                d->text = 0;
979
990
 
980
 
            if(d->links) {
981
 
                for(i=0;i<d->max_links;i++) {
982
 
                    if(d->links[i])
983
 
                        PFREE(d->links[i]);
 
991
                if(d->links) {
 
992
                    for(i=0;i<d->max_links;i++) {
 
993
                        if(d->links[i])
 
994
                            PFREE(d->links[i]);
 
995
                    }
 
996
                    PFREE(d->links);
984
997
                }
985
 
                PFREE(d->links);
 
998
 
 
999
                clear_styles(d);
 
1000
 
 
1001
                PFREE(d);
 
1002
                SetWindowLongPtr(hwnd, 0, 0);
986
1003
            }
987
 
 
988
 
            clear_styles(d);
989
 
 
990
 
            PFREE(d);
991
1004
        }
992
1005
        break;
993
1006
 
994
1007
    case WM_ERASEBKGND:
995
1008
        {
 
1009
            HDC hdc = (HDC) wParam;
996
1010
            khui_htwnd_data * d;
 
1011
            HBRUSH hbr;
 
1012
            RECT r;
 
1013
 
997
1014
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
998
 
 
999
 
            if(d->flags & KHUI_HTWND_TRANSPARENT)
1000
 
                return TRUE;
1001
 
 
1002
 
            return FALSE;
1003
 
        }
 
1015
            if (d == NULL)
 
1016
                return FALSE;
 
1017
 
 
1018
            GetClientRect(hwnd, &r);
 
1019
            hbr = GetSysColorBrush(COLOR_WINDOW);
 
1020
            FillRect(hdc, &r, hbr);
 
1021
 
 
1022
            /* no need to destroy the brush since it's a system
 
1023
               brush. */
 
1024
 
 
1025
            return TRUE;
 
1026
        }
 
1027
 
 
1028
    case WM_SIZE:
 
1029
        {
 
1030
            khui_htwnd_data * d;
 
1031
 
 
1032
            d = (khui_htwnd_data *) (LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1033
 
 
1034
            if (d) {
 
1035
                d->ext_width = 0;
 
1036
                d->ext_height = 0;
 
1037
            }
 
1038
        }
 
1039
        return 0;
1004
1040
 
1005
1041
    case WM_PAINT:
1006
1042
        htw_paint(hwnd, uMsg, wParam, lParam);
1007
 
        break;
 
1043
        return 0;
1008
1044
 
1009
1045
    case WM_SETCURSOR:
1010
1046
        {
1014
1050
                break;
1015
1051
                
1016
1052
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1053
            if (d == NULL)
 
1054
                break;
1017
1055
 
1018
1056
            if(d->active_link >= 0) {
1019
1057
                SetCursor(d->hc_hand);
1027
1065
            khui_htwnd_data * d;
1028
1066
 
1029
1067
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1068
            if (d == NULL)
 
1069
                break;
1030
1070
 
1031
1071
            d->flags |= KHUI_HTWND_FOCUS;
1032
1072
 
1039
1079
            khui_htwnd_data * d;
1040
1080
 
1041
1081
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1082
            if (d == NULL)
 
1083
                break;
1042
1084
 
1043
1085
            d->flags &= ~KHUI_HTWND_FOCUS;
1044
1086
 
1051
1093
            khui_htwnd_data * d;
1052
1094
 
1053
1095
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1096
            if (d == NULL)
 
1097
                break;
1054
1098
 
1055
1099
            d->md_link = d->active_link;
1056
1100
 
1063
1107
            khui_htwnd_data * d;
1064
1108
 
1065
1109
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1110
            if (d == NULL)
 
1111
                break;
1066
1112
 
1067
1113
            if(d->md_link == d->active_link && d->md_link >= 0) {
1068
1114
                /* clicked */
1083
1129
            RECT r;
1084
1130
 
1085
1131
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1132
            if (d == NULL)
 
1133
                break;
1086
1134
 
1087
1135
            old_pos = new_pos = d->scroll_left;
1088
1136
            ext = d->ext_width;
1089
1137
 
1090
 
            switch(HIWORD(wParam)) {
 
1138
            switch(LOWORD(wParam)) {
 
1139
            case SB_THUMBPOSITION:
 
1140
            case SB_ENDSCROLL:
 
1141
                ZeroMemory(&si, sizeof(si));
 
1142
                si.cbSize = sizeof(si);
 
1143
                si.fMask = SIF_POS;
 
1144
                GetScrollInfo(hwnd, SB_HORZ, &si);
 
1145
                new_pos = si.nPos;
 
1146
                break;
 
1147
 
1091
1148
            case SB_THUMBTRACK:
1092
 
            case SB_THUMBPOSITION:
1093
1149
                ZeroMemory(&si, sizeof(si));
1094
1150
                si.cbSize = sizeof(si);
1095
1151
                si.fMask = SIF_TRACKPOS;
1121
1177
 
1122
1178
            GetClientRect(hwnd, &r);
1123
1179
 
1124
 
#if 0
1125
1180
            if (new_pos > ext - (r.right - r.left))
1126
1181
                new_pos = ext - (r.right - r.left);
1127
 
#endif
1128
 
            if (new_pos > ext)
1129
 
                new_pos = ext;
1130
1182
 
1131
1183
            if (new_pos < 0)
1132
1184
                new_pos = 0;
1164
1216
            int nl;
1165
1217
 
1166
1218
            d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
 
1219
            if (d == NULL)
 
1220
                break;
 
1221
 
1167
1222
            p.x = GET_X_LPARAM(lParam) + d->scroll_left;
1168
1223
            p.y = GET_Y_LPARAM(lParam) + d->scroll_top;
1169
1224
                
1179
1234
 
1180
1235
            if(d->active_link != nl) {
1181
1236
                if(d->active_link >= 0) {
1182
 
                    if(d->flags & KHUI_HTWND_TRANSPARENT)
1183
 
                        {
1184
 
                            HWND parent = GetParent(hwnd);
1185
 
                            if(parent) {
1186
 
                                InvalidateRect(parent, NULL, TRUE);
1187
 
                            }
 
1237
                    if(d->flags & KHUI_HTWND_TRANSPARENT) {
 
1238
                        HWND parent = GetParent(hwnd);
 
1239
                        if(parent) {
 
1240
                            RECT rdest = d->links[d->active_link]->r;
 
1241
 
 
1242
                            MapWindowPoints(hwnd, parent, (LPPOINT) &rdest, 2);
 
1243
                            InvalidateRect(parent, &rdest, TRUE);
1188
1244
                        }
 
1245
                    }
1189
1246
                    /* although we are invalidating the rect before setting active_link,
1190
1247
                       WM_PAINT will not be issued until wndproc returns */
1191
1248
                    InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
1194
1251
                if(d->active_link >= 0) {
1195
1252
                    /* although we are invalidating the rect before setting active_link,
1196
1253
                       WM_PAINT will not be issued until wndproc returns */
1197
 
                    if(d->flags & KHUI_HTWND_TRANSPARENT)
1198
 
                        {
1199
 
                            HWND parent = GetParent(hwnd);
1200
 
                            if(parent) {
1201
 
                                InvalidateRect(parent, NULL, TRUE);
1202
 
                            }
 
1254
                    if(d->flags & KHUI_HTWND_TRANSPARENT) {
 
1255
                        HWND parent = GetParent(hwnd);
 
1256
                        if(parent) {
 
1257
                            RECT rdest = d->links[d->active_link]->r;
 
1258
 
 
1259
                            MapWindowPoints(hwnd, parent, (LPPOINT) &rdest, 2);
 
1260
                            InvalidateRect(parent, &rdest, TRUE);
1203
1261
                        }
 
1262
                    }
1204
1263
                    InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE);
1205
1264
                }
1206
1265
            }