Example #1
0
int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText,
		int nCount, int nTabs, int *pTabPos, int nTabOrig)
{
    PDC pdc;
    int line_len, sub_len;
    int nr_tab = 0, tab_pos, def_tab;
    int x_orig = x, max_x = x;
    int line_height;
    int nr_delim_newline, nr_delim_tab;

    if (nCount == 0) return 0;
    if (nCount < 0) nCount = strlen (spText);

    pdc = dc_HDC2PDC(hdc);

    line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra;
    y += pdc->alExtra;
    if (nTabs == 0 || pTabPos == NULL) {
        int ave_width = (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width)
                        (pdc->pLogFont, pdc->pLogFont->sbc_devfont);
        def_tab = ave_width * pdc->tabstop;
    }
    else
        def_tab = pTabPos [nTabs - 1];

    while (nCount) {
        line_len = substrlen (spText, nCount, '\n', &nr_delim_newline);

        nCount -= line_len + nr_delim_newline;

        nr_tab = 0;
        x = x_orig;
        tab_pos = nTabOrig;
        while (line_len) {
            int i, width;

            sub_len = substrlen (spText, line_len, '\t', &nr_delim_tab);

            width = TextOutLen (hdc, x, y, spText, sub_len);

            x += width; 
            if (x >= tab_pos) {
                while (x >= tab_pos)
                    tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++];
                for (i = 0; i < nr_delim_tab - 1; i ++)
                    tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++];
            }
            else {
                for (i = 0; i < nr_delim_tab; i ++)
                    tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++];
            }

            x = tab_pos;

            line_len -= sub_len + nr_delim_tab;
            spText += sub_len + nr_delim_tab;
        }

        if (max_x < x) max_x = x;

        spText += nr_delim_newline;
        y += line_height * nr_delim_newline;
    }

    return max_x - x_orig;
}
Example #2
0
/* re-draw */
static void draw_propsheet (HWND hwnd, HDC hdc, PCONTROL ctrl, PPROPSHEETDATA propsheet, PPROPPAGE page)
{
    int x, ty, by, text_extent;
    RECT title_rc = {0, 0, 1, 0};
    
    title_rc.bottom = propsheet->head_rc.bottom;
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        title_rc.top = propsheet->head_rc.top;
    } 
    
/* Draw the content window */
#ifdef _FLAT_WINDOW_STYLE
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        DrawFlatControlFrameEx (hdc, hwnd, 0, 0, propsheet->head_rc.right, 
                                ctrl->bottom - ctrl->top - (propsheet->head_rc.bottom - propsheet->head_rc.top) + 1 ,
                                1, DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    } else {
        DrawFlatControlFrameEx (hdc, hwnd, 0, propsheet->head_rc.bottom - 2,
                            propsheet->head_rc.right, ctrl->bottom - ctrl->top, 1, 
                            DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    }
#else
    
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        Draw3DThickFrameEx (hdc, hwnd, 0, 0, propsheet->head_rc.right, 
                            ctrl->bottom - ctrl->top - (propsheet->head_rc.bottom - propsheet->head_rc.top) + 2 ,
                            DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    } else {
        Draw3DThickFrameEx (hdc, hwnd, 0, propsheet->head_rc.bottom - 2, 
                            propsheet->head_rc.right, ctrl->bottom - ctrl->top,
                            DF_3DBOX_NORMAL | DF_3DBOX_NOTFILL, 0);
    }
#endif
    
    SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_CONTROL_DEF));
    
    if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
        FillBox (hdc, 0, propsheet->head_rc.top + 1, propsheet->head_rc.right, propsheet->head_rc.bottom );
    }else {
        FillBox (hdc, 0, 0, propsheet->head_rc.right, propsheet->head_rc.bottom - 2);
    }
    /* Just for PSS_SCROLLABLE style 
       if title is overload (too many titles for the propsheet) 
       we should move-right the leftmot title some pixel 
       and we should draw a small icon (left arrow) for the sheet */
    if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) {
        title_rc.right = (propsheet->overload == TRUE) ? 
          title_rc.right + GetMainWinMetrics (MWM_SB_WIDTH) : title_rc.right;
    }
    
    while (page) {
        SIZE size;
        int eff_chars, eff_len;

        /* draw some box for title */
        if (title_rc.right == 1)
            title_rc.left = title_rc.right - 1;
        else
            title_rc.left = title_rc.right;
        title_rc.right = title_rc.left + page->width;
        SelectClipRect (hdc, &title_rc);
        x = title_rc.left + _ICON_OFFSET;
        ty = title_rc.top;
        
        if (page != propsheet->active) {
            /* bottom tab or top tab */
            if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
                ty -= 2;
                by = title_rc.bottom - 2;
            } else {
                ty += 2;
                by = title_rc.bottom;
            }

        } else {
            by = title_rc.bottom ;
            FillBox (hdc, title_rc.left+1, ty, title_rc.right - title_rc.left, by);
        }

        /* draw the title's edge */
        /* pc3d style & flat & grap */
        SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_INNER));
        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            MoveTo (hdc, title_rc.left, ty);
            LineTo (hdc, title_rc.left, by - 1);
            LineTo (hdc, title_rc.right, by - 1);
        } else {
            MoveTo (hdc, title_rc.left, by - 1);
            LineTo (hdc, title_rc.left, ty);
            LineTo (hdc, title_rc.right, ty);
        }

        SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_RIGHT_OUTER));
        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            if (page != propsheet->active) {
                MoveTo (hdc, title_rc.left + 1, ty + 3);
            } else {
                MoveTo (hdc, title_rc.left + 1, ty - 2);
            }
            LineTo (hdc, title_rc.left + 1, by - 2);
            LineTo (hdc, title_rc.right - 1, by - 2);
        } else {
            if (page != propsheet->active) {
                MoveTo (hdc, title_rc.left + 1, by - 2);
            } else {
                MoveTo (hdc, title_rc.left + 1, by);
            }
            LineTo (hdc, title_rc.left + 1, ty + 1);
            LineTo (hdc, title_rc.right - 1, ty + 1);
        }
        SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_INNER));
        if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) {
            MoveTo (hdc, title_rc.right - 1, by -1);
            LineTo (hdc, title_rc.right - 1, ty);
        }else {
            if (!page->next && (title_rc.right == propsheet->head_rc.right)) {
                MoveTo (hdc, title_rc.right - 2, ty );
                LineTo (hdc, title_rc.right - 2, by - 1);
                SetPenColor(hdc, GetWindowElementColorEx (hwnd, WEC_3DFRAME_LEFT_OUTER));
                MoveTo (hdc, title_rc.right -1, ty );
                LineTo (hdc, title_rc.right -1, by - 1);
            }
            else {
                MoveTo (hdc, title_rc.right - 1, ty );
                LineTo (hdc, title_rc.right - 1, by - 1);
            }
        }
        
        /* draw the ICON */
        ty += _ICON_OFFSET + 2;
        text_extent = RECTW (title_rc) - _ICON_OFFSET * 2;
        if (page->icon) {
            DrawIcon (hdc, x, ty, GetMainWinMetrics (MWM_ICONX),
                      GetMainWinMetrics (MWM_ICONY), page->icon);
            x += GetMainWinMetrics (MWM_ICONX);
            x += _GAP_ICON_TEXT;
            text_extent -= GetMainWinMetrics (MWM_ICONX) + _GAP_ICON_TEXT;
        }
        
        /* draw the TEXT */
/* #if defined(_FLAT_WINDOW_STYLE) && !defined(_GRAY_SCREEN) */
#ifdef _FLAT_WINDOW_STYLE                    
        if (page != propsheet->active) {
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_DISABLED));
        } else {
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL));
        }
#else
        SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_CONTROL_DEF));
#endif
        text_extent -= 4;
        eff_len = GetTextExtentPoint (hdc, page->title, strlen(page->title), 
                      text_extent, &eff_chars, NULL, NULL, &size);
        TextOutLen (hdc, x + 2, ty, page->title, eff_len);
        page = page->next;
    }
    /* draw scroll button , just for PSS_SCROLLABLE style */
    if ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE && propsheet->overload == TRUE) {
        draw_scroll_button (hwnd, hdc, &title_rc, propsheet, ctrl->dwStyle);
    }
}