Example #1
0
BOOL X11OpUiInfo::GetUICSSFont(int css_font_value, FontAtt &font)
{
	// spec says:
	// If no font with the indicated characteristics exists on a given
	// platform, the user agent should either intelligently substitute 
	// (e.g., a smaller version of the "caption" font might be used for
	// the "smallcaption" font), or substitute a user agent default font.
	// http://www.w3.org/TR/css3-fonts/#font
	//
	// But no *nix browser nor Opera on other platforms substitutes
	// "intelligently" atm and we have no good estimate, what is nice size for
	// small_caption. [pobara 2010-05-18]
	OP_SYSTEM_FONT sys_font;
	switch(css_font_value)
	{
	case CSS_VALUE_menu:		sys_font = OP_SYSTEM_FONT_UI_MENU; break;
	case CSS_VALUE_message_box:	sys_font = OP_SYSTEM_FONT_UI_DIALOG; break;
	case CSS_VALUE_caption:
	case CSS_VALUE_icon:
	case CSS_VALUE_small_caption:
	case CSS_VALUE_status_bar:	sys_font = OP_SYSTEM_FONT_UI; break;
	default:
#ifdef DEBUG
		printf("X11OpUiInfo::GetUICSSFont(): Unknown font code %d.\n", css_font_value);
#endif
		return FALSE;
	}
	GetSystemFont(sys_font, font);
	return TRUE;
}
Example #2
0
void CSideBar::SetTooltipFont()
{
	TVTest::Style::Font Font;

	GetSystemFont(DrawUtil::FONT_STATUS,&Font);
	CreateDrawFont(Font,&m_TooltipFont);
	m_Tooltip.SetFont(m_TooltipFont.GetHandle());
}
Example #3
0
// This function init DC.
// set the default parameters.
static void dc_InitDC(PDC pdc, HWND hWnd, BOOL bIsClient)
{
    PCONTROL pCtrl;

    pdc->hwnd = hWnd;
    pdc->gc = PHYSICALGC;

    pdc->bkcolor = PIXEL_lightwhite;
    pdc->bkmode = 0;

    pdc->brushtype = BT_SOLID;
    pdc->brushcolor = PIXEL_lightwhite;
    pdc->BrushOrig.x = pdc->BrushOrig.y = 0;

    pdc->pentype = PT_SOLID;
    pdc->pencolor = PIXEL_black;
    pdc->CurPenPos.x = pdc->CurPenPos.y = 0;

    pdc->textcolor = PIXEL_black;
    if (!(pdc->pLogFont = GetWindowFont (hWnd)))
        pdc->pLogFont = GetSystemFont (SYSLOGFONT_WCHAR_DEF);
    pdc->tabstop = 8;
    pdc->CurTextPos.x = pdc->CurTextPos.y = 0;
    pdc->cExtra = pdc->alExtra = pdc->blExtra = 0;

    pdc->mapmode = MM_TEXT;
    pdc->ViewOrig.x = pdc->ViewOrig.y = 0;
    pdc->ViewExtent.x = pdc->ViewExtent.y = 1;
    pdc->WindowOrig.x = pdc->WindowOrig.y = 0;
    pdc->WindowExtent.x = pdc->WindowExtent.y = 1;

    // assume that the local clip region is empty.
  
    // Get global clip region info and generate effective clip region.
    pdc->pGCRInfo = GetGCRgnInfo (hWnd);

    pthread_mutex_lock (&pdc->pGCRInfo->lock);

    pdc->oldage = pdc->pGCRInfo->age;
    ClipRgnCopy (&pdc->ecrgn, &pdc->pGCRInfo->crgn);

    if (bIsClient)
        WndClientRect (pdc->hwnd, &pdc->DevRC);
    else
        WndRect (pdc->hwnd, &pdc->DevRC);

    pdc->bIsClient = bIsClient;
    if (bIsClient)
        IntersectClipRect (&pdc->ecrgn, &pdc->DevRC);

    pCtrl = Control (pdc->hwnd);
    if (pCtrl && !(pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN))
        RestrictControlECRGN (&pdc->ecrgn, pCtrl);

    pthread_mutex_unlock (&pdc->pGCRInfo->lock);

}
Example #4
0
static void dc_Init_ScreenDC (void)
{
    __mg_screen_dc.DataType = TYPE_HDC;
    __mg_screen_dc.DCType   = TYPE_SCRDC;
    __mg_screen_dc.hwnd = 0;
    __mg_screen_dc.gc = PHYSICALGC;

    __mg_screen_dc.bkcolor = PIXEL_lightwhite;
    __mg_screen_dc.bkmode = 0;

    __mg_screen_dc.brushtype = BT_SOLID;
    __mg_screen_dc.brushcolor = PIXEL_lightwhite;
    __mg_screen_dc.BrushOrig.x = __mg_screen_dc.BrushOrig.y = 0;

    __mg_screen_dc.pentype = PT_SOLID;
    __mg_screen_dc.pencolor = PIXEL_black;
    __mg_screen_dc.CurPenPos.x = __mg_screen_dc.CurPenPos.y = 0;

    __mg_screen_dc.textcolor = PIXEL_black;
    __mg_screen_dc.pLogFont = GetSystemFont (SYSLOGFONT_WCHAR_DEF);
    __mg_screen_dc.tabstop = 8;
    __mg_screen_dc.CurTextPos.x = __mg_screen_dc.CurTextPos.y = 0;
    __mg_screen_dc.cExtra = __mg_screen_dc.alExtra = __mg_screen_dc.blExtra = 0;

    __mg_screen_dc.ViewOrig.x = __mg_screen_dc.ViewOrig.y = 0;
    __mg_screen_dc.ViewExtent.x = __mg_screen_dc.ViewExtent.y = 1;
    __mg_screen_dc.WindowOrig.x = __mg_screen_dc.WindowOrig.y = 0;
    __mg_screen_dc.WindowExtent.x = __mg_screen_dc.WindowExtent.y = 1;

    __mg_screen_dc.bIsClient = FALSE;

    // init local clip region
    InitClipRgn (&__mg_screen_dc.lcrgn, &sg_FreeClipRectList);
    // init effective clip region
    InitClipRgn (&__mg_screen_dc.ecrgn, &sg_FreeClipRectList);

    // init global clip region information
    __mg_screen_dc.pGCRInfo = NULL;
    __mg_screen_dc.oldage = 0;

    __mg_screen_dc.DevRC.left = 0;
    __mg_screen_dc.DevRC.top  = 0;
    __mg_screen_dc.DevRC.right = WIDTHOFPHYGC - 1;
    __mg_screen_dc.DevRC.bottom = HEIGHTOFPHYGC - 1;

    // Set local clip region and effetive clip region to the screen.
    SetClipRgn (&__mg_screen_dc.lcrgn, &__mg_screen_dc.DevRC);
    SetClipRgn (&__mg_screen_dc.ecrgn, &__mg_screen_dc.DevRC);
}
/* a simple edit window */
static int MyeditWindowProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    int w = 0;
    SIZE Size;
    static char *pBuffer = NULL;
    static int pos = 0, len = 0;
    HDC hdc;

    switch (message) {
        case MSG_CREATE:
            SetWindowFont(hWnd, GetSystemFont(SYSLOGFONT_DEFAULT));
            if (!CreateCaret (hWnd, NULL, 1, GetSysCharHeight())) {
                return -1;
            }
            pBuffer = (char *) calloc(1, 11);
            *pBuffer = 0;
            break;

        case MSG_SETFOCUS:
            hdc = GetClientDC(hWnd);
            w = GetTextExtent (hdc, pBuffer, pos, &Size);
            SetCaretPos(hWnd, w, 0);
            //SetCaretPos(hWnd, pos*GetSysCharWidth(), 0);
            ShowCaret(hWnd);
            ReleaseDC(hdc);
            break;

        case MSG_KILLFOCUS:
            HideCaret(hWnd);
            break;

        case MSG_CHAR:
            switch (wParam) {
                case '\t':
                case '\b':
                case '\n':
                    SetCaretBlinkTime(hWnd, GetCaretBlinkTime(hWnd)-100);
                    break;

                default:
                    {
                        char ch, buf[11];
                        char *tmp;
                        ch = wParam;
                        if (!isalpha(ch) && !isdigit(ch))
                            break;
                        if (len == 10)
                            break;
                        tmp = pBuffer+pos;
                        if (*tmp != 0) {
                            strcpy(buf, tmp);
                            strcpy(tmp+1, buf);
                        }
                        *tmp = ch;
                        pos++;
                        len++;

                        hdc = GetClientDC(hWnd);
                        InvalidateRect(hWnd, NULL, TRUE);
                        w = GetTextExtent (hdc, pBuffer, pos, &Size);
                        SetCaretPos(hWnd, w, 0);
                        //SetCaretPos(hWnd, pos*GetSysCharWidth(), 0);
                        ShowCaret(hWnd);
                        ReleaseDC(hdc);
                    }
                    break;
            }
            break;

        case MSG_KEYDOWN:
            switch (wParam) {
                case SCANCODE_CURSORBLOCKLEFT:
                    pos = MAX(pos-1, 0);
                    break;
                case SCANCODE_CURSORBLOCKRIGHT:
                    pos = MIN(pos+1, len);
                    break;
                case SCANCODE_BACKSPACE:
                    {
                        char buf[11];
                        char *tmp;
                        if (len == 0 || pos == 0)
                            break;
                        tmp = pBuffer+pos;
                        strcpy(buf, tmp);
                        strcpy(tmp-1, buf);
                        pos--;
                        len--;
                        break;
                    }
            }
            if (wParam == SCANCODE_CURSORBLOCKLEFT || wParam == SCANCODE_CURSORBLOCKRIGHT ||
                    wParam == SCANCODE_BACKSPACE) {
                hdc = GetClientDC(hWnd);
                InvalidateRect(hWnd, NULL, TRUE);
                w = GetTextExtent (hdc, pBuffer, pos, &Size);
                //SetCaretPos(hWnd, pos*GetSysCharWidth(), 0);
                SetCaretPos(hWnd, w, 0);
                ReleaseDC(hdc);
            }
            break;

        case MSG_PAINT:
            hdc = BeginPaint(hWnd);
            TextOut(hdc, 0, 0, pBuffer);
            EndPaint(hWnd, hdc);
            return 0;

        case MSG_DESTROY:
            DestroyCaret (hWnd);
            if (pBuffer)
                free(pBuffer);
            return 0;
    }

    return DefaultControlProc(hWnd, message, wParam, lParam);
}
Example #6
0
bool VtStart (PCONINFO con)
{
    const char* charset;

    /* A serious and strange bug here, at first ymin and knj1 is not
       initialized to 0, it works fine in Linux (maybe the malloc in
       Linux will automatically zero the memory), but doesn't work in
       FreeBSD. FreeBSD's calloc zero the memory, but malloc not!!!
       So I need to initialize all the member here */

    con->x = con->y = 0;
    con->dispxmax = con->cols;
    con->dispymax = con->rows;
    con->xmax = con->cols - 1;
    con->ymax = con->rows - 1;
    con->ymin = 0;
    con->tab = 8;
    con->fcol = 7;
    con->bcol = 0;
    con->attr = 0;
    con->esc = NULL;
    con->g[0] = con->g[1] = CS_LEFT;
    con->trans = CS_LEFT;
    con->soft = con->ins = con->wrap = false;
    con->sb = 0;
    con->db = LATCH_1;

#ifdef USECCEWAY
    con->knj1 = 0;
    con->knj1x = con->knj1y = 0;
#endif

    con->cursorsw = true;

    con->textBuff = (u_char *)calloc (con->cols, con->rows);
    con->attrBuff = (u_char *)calloc (con->cols, con->rows);
    con->flagBuff = (u_char *)calloc (con->cols, con->rows);
    if (con->textBuff == NULL || con->attrBuff == NULL ||
            con->flagBuff == NULL)
        return false;

    con->textSize = con->cols * (con->rows);

    con->currentScroll = con->scrollLine = 0;
    con->scroll = 0;
    con->textHead = 0;

    con->textClear = false;
    con->terminate = 0;

    if (con->log_font == NULL) {
        PLOGFONT sys_font = GetSystemFont (SYSLOGFONT_WCHAR_DEF);
        if (sys_font->mbc_devfont)
            charset = sys_font->mbc_devfont->charset_ops->name;
        else
            charset = sys_font->sbc_devfont->charset_ops->name;
    }
    else {
        if (con->log_font->mbc_devfont)
            charset = con->log_font->mbc_devfont->charset_ops->name;
        else
            charset = con->log_font->sbc_devfont->charset_ops->name;
    }

    con->sysCoding = CODE_GB;
    if (strcmp (charset, FONT_CHARSET_GBK) == 0)
        con->sysCoding = CODE_GBK;
    else if (strcmp (charset, FONT_CHARSET_BIG5) == 0)
        con->sysCoding = CODE_BIG5;

    memset (con->varg, MAX_NARG, 0);
    con->narg = 0;
    con->question = 0;

    con->m_captured = false;
    con->m_oldx = con->m_oldy = 0;
    con->m_origx = con->m_origy = -1;

    return true;
}