コード例 #1
0
//________________________________________________________
long    GetVisibleStringWidth (_String& s, _HYFont& f)
{
    static PangoLayout* textLayout       = pango_layout_new (screenPContext);
    static PangoFontDescription * fd     = pango_font_description_new ();
    static _HYFont                         stashedFont;

    if (s.sLength) {
        if (stashedFont.size!=f.size || stashedFont.style != f.style || stashedFont.face != f.face) {
            HYFont2PangoFontDesc(f,fd);
            pango_layout_set_width (textLayout,-1);
            pango_layout_set_font_description(textLayout,fd);
            stashedFont = f;
        }
        pango_layout_set_text (textLayout, s.sData,s.sLength);
        //PangoRectangle charPos;
        //pango_layout_index_to_pos (textLayout,s.sLength-1,&charPos);
        //return PANGO_PIXELS(charPos.x+charPos.width);
        PangoRectangle extents,
                       logical_ext;

        pango_layout_get_pixel_extents (textLayout,&extents,&logical_ext);
        return logical_ext.width;
    } else {
        return 0;
    }

}
コード例 #2
0
ファイル: HYPlatformPullDown.cpp プロジェクト: ArtPoon/hyphy
_HYPlatformPullDown::_HYPlatformPullDown(void)
{
    _HYPullDown * parent = (_HYPullDown*)this;
    theMenu              = gtk_combo_new ();
    backFill             = HYColorToGDKColor((_HYColor) {
        255,255,255
    });
    gtk_combo_set_value_in_list (GTK_COMBO(theMenu),true,false);
    gtk_container_add(GTK_CONTAINER(parent->parentWindow),theMenu);
    gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(theMenu)->entry),false);
    GList* children = gtk_container_get_children(GTK_CONTAINER(theMenu));
    g_signal_connect (GTK_WIDGET(children->next->data),"event",(GCallback)hy_pulldown_selection_start_callback_event,(_HYPullDown*)this);
    g_signal_connect (GTK_COMBO(theMenu)->entry,"changed",(GCallback)hy_pulldown_selection_callback,(_HYPullDown*)this);
    g_signal_connect (GTK_COMBO(theMenu)->popwin,"hide",(GCallback)hy_pulldown_unmap_event,(_HYPullDown*)this);
    g_list_free (children);
    //gtk_container_set_resize_mode(GTK_CONTAINER(theMenu), GTK_RESIZE_IMMEDIATE);
    selection      = 0;
    cbSelection    = -1;
    if (!defaultPullDownFontPD) {
        defaultPullDownFontPD = pango_font_description_new();
        defaultPullDownFont.size = defaultPullDownFont.size*fontConversionFactor;
        HYFont2PangoFontDesc (defaultPullDownFont,defaultPullDownFontPD);
    }
    gtk_widget_modify_font (theMenu, defaultPullDownFontPD);
    gtk_widget_modify_font (GTK_COMBO(theMenu)->entry, defaultPullDownFontPD);
    gtk_widget_show (theMenu);
    //g_signal_connect (GTK_COMBO(theMenu)->entry,"changed",hy_pulldown_selection_callback,(_HYPullDown*)this);

}
コード例 #3
0
ファイル: HYPlatformButton.cpp プロジェクト: mdsmith/OCLHYPHY
void		_HYPlatformButton::_SetFont (_HYFont& f)
{
	//_HYFont f2 = f;
	//f2.size = f.size*fontConversionFactor;
	HYFont2PangoFontDesc(f,buttonFontDesc);
	if (buttonControl)
		_ApplyFont ();
}
コード例 #4
0
void _HYPlatformGraphicPane::_SetFont (_HYFont f)
{
	HYFont2PangoFontDesc(f,theFont);
	pango_layout_set_font_description (textLayout, theFont ); // ref ?
	_ResetCharGlyphs ();
}
コード例 #5
0
void _HYConsoleWindow::_PaintStatusBar(Ptr,bool force)
{
    if (GTK_WIDGET_MAPPED (theWindow)) {
        _Parameter      vL;
        checkParameter (VerbosityLevelString, vL, 0.0);

        if (vL<-0.5 && !force) {
            clock_t curMeasure = clock();
            _Parameter diff = 1.0/CLOCKS_PER_SEC*(curMeasure-lastMeasure);
            if (diff < -vL) {
                return;
            }
            lastMeasure = curMeasure;
        }

        if (!stripedFillGC) {
            SetUpStatusBarStuff (theWindow);
        }

        GdkRectangle wRC  = {0,0,theWindow->allocation.width,HY_SCROLLER_WIDTH},
                     w2RC;

        if (!_hyConsoleWindowGC) {
            _hyConsoleWindowGC   = gdk_gc_new     (theWindow->window);
            gdk_gc_set_tile (_hyConsoleWindowGC, stripedFill);
            gdk_gc_set_line_attributes(_hyConsoleWindowGC,1,GDK_LINE_SOLID,GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
            _hyConsoleLayout = pango_layout_new (screenPContext);
            pango_layout_set_width (_hyConsoleLayout, -1);
            statusBarBold = pango_font_description_new ();
            statusBarNormal = pango_font_description_new ();
            _HYFont         consoleFont = {_HY_MONO_FONT,9,HY_FONT_PLAIN};
            HYFont2PangoFontDesc (consoleFont,statusBarNormal);
            consoleFont.style = HY_FONT_BOLD;
            HYFont2PangoFontDesc (consoleFont,statusBarBold);
        }

        GdkPixmap * offBitmap        = gdk_pixmap_new (theWindow->window, wRC.width, wRC.height,-1);

        if (offBitmap) {
            gdk_gc_set_fill         (_hyConsoleWindowGC,GDK_TILED);
            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,-1,-1,wRC.width+2,wRC.height+2);
            gdk_gc_set_fill         (_hyConsoleWindowGC,GDK_SOLID);
            gdk_gc_set_foreground   (_hyConsoleWindowGC,&_BLACKBRUSH_);
            gdk_draw_line(offBitmap,_hyConsoleWindowGC,0,0,wRC.width,0);

            pango_layout_set_font_description(_hyConsoleLayout,statusBarNormal);
            pango_layout_set_text(_hyConsoleLayout,fileName.getStr(),fileName.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,33,wRC.height-13,_hyConsoleLayout);

            if (inputStatus == 1) {
                pango_layout_set_text(_hyConsoleLayout,cInput.getStr(),cInput.sLength);
            } else {
                pango_layout_set_text(_hyConsoleLayout,action.getStr(),action.sLength);
            }

            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,193,wRC.height-13,_hyConsoleLayout);

            gdk_gc_set_foreground   (_hyConsoleWindowGC,&_DARKGREYBRUSH_);

            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,0,1,30,wRC.height-1);
            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,150,1,40,wRC.height-1);
            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,wRC.width-55,1,55,wRC.height-1);

            gdk_gc_set_foreground   (_hyConsoleWindowGC,&_WHITEBRUSH_);
            pango_layout_set_font_description(_hyConsoleLayout,statusBarBold);

            pango_layout_set_text(_hyConsoleLayout,cState.getStr(),cState.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,3,wRC.height-13,_hyConsoleLayout);
            pango_layout_set_text(_hyConsoleLayout,cTask.getStr(),cTask.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,151,wRC.height-13,_hyConsoleLayout);

            pango_layout_set_font_description(_hyConsoleLayout,statusBarNormal);

            pango_layout_set_text(_hyConsoleLayout,timer.getStr(),timer.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,wRC.width-53,wRC.height-13,_hyConsoleLayout);

            if (percentDone>0 || percentDone == -HY_SL_DONE) {
                GdkColor blackBrush = HYColorToGDKColor((_HYColor) {
                    80,80,80
                }),
                orangeBrush = HYColorToGDKColor((_HYColor) {
                    255,153,102
                });

                gdk_gc_set_foreground   (_hyConsoleWindowGC,&orangeBrush);
                gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,wRC.width-135,wRC.height-14,(percentDone>=0?percentDone:100.)*0.75,12);

                gdk_gc_set_foreground   (_hyConsoleWindowGC,&blackBrush);
                gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,false,wRC.width-135,wRC.height-14,75,12);

                //gdk_gc_set_foreground (_hyConsoleWindowGC,&_WHITEBRUSH_);
                _String pLine;
                if (percentDone>=0) {
                    pLine = _String(percentDone)&"%";
                } else {
                    pLine = "DONE";
                }

                pango_layout_set_text(_hyConsoleLayout,pLine.getStr(),pLine.sLength);
                gdk_draw_layout(offBitmap,_hyConsoleWindowGC,wRC.width-107,wRC.height-13,_hyConsoleLayout);
            }
        }

        gdk_draw_drawable (theWindow->window, _hyConsoleWindowGC, offBitmap, 0, 0, theWindow->allocation.x, theWindow->allocation.y+theWindow->allocation.height-wRC.height, -1, -1);
        g_object_unref (offBitmap);
    }
}
コード例 #6
0
ファイル: HYPlatformButtonBar.cpp プロジェクト: ArtPoon/hyphy
//__________________________________________________________________
void        _HYButtonBar::_DisplayToolTip      (void)
{
    // TBI

    int h = _FindClickedButton (saveMousePosV,saveMousePosH);

    if ( h>=0 && h<toolTips.lLength) {
        _String* toolTip = (_String*)toolTips(h);
        if (toolTip->sLength) {
            GdkColor      toolTipColor = HYColorToGDKColor((_HYColor) {
                0xFF,0xCC,0x66
            });

            int        bL,
                       bT;

            GetButtonLoc (h,bL,bT,false);

            PangoLayout          * ttText = pango_layout_new (screenPContext);
            PangoFontDescription * ttFont = pango_font_description_new();
            HYFont2PangoFontDesc(_hyttDisplayFont,ttFont);

            pango_layout_set_font_description (ttText, ttFont);
            pango_layout_set_width(ttText, -1);
            pango_layout_set_text (ttText, toolTip->sData, toolTip->sLength);

            PangoRectangle extents;
            pango_layout_get_pixel_extents (ttText,&extents,nil);

            toolTipBounds.y      = bT - 16;
            toolTipBounds.height = 16;

            if (toolTipBounds.y<0) {
                toolTipBounds.y = bT+buttonDim+1;
            }

            h = extents.width + 4;

            toolTipBounds.x = bL+(buttonDim-h-1)/2;

            if (toolTipBounds.x<=0) {
                toolTipBounds.x = 1;
            }

            toolTipBounds.width = h+2;

            h = toolTipBounds.x+toolTipBounds.width-parentWindow->allocation.width;

            if (h>0) {
                if (h>=toolTipBounds.x) {
                    h = toolTipBounds.x-1;
                }
                toolTipBounds.x -= h;
            }

            toolTipBounds.x += parentWindow->allocation.x;
            toolTipBounds.y += parentWindow->allocation.y;

            gdk_gc_set_foreground(bbGC,&toolTipColor);
            gdk_draw_rectangle(parentWindow->window,bbGC,true,toolTipBounds.x, toolTipBounds.y, toolTipBounds.width, toolTipBounds.height);

            toolTipColor = HYColorToGDKColor((_HYColor) {
                0,0,0
            });
            gdk_gc_set_foreground(bbGC,&toolTipColor);
            gdk_draw_rectangle(parentWindow->window,bbGC,false,toolTipBounds.x, toolTipBounds.y, toolTipBounds.width, toolTipBounds.height);

            gdk_gc_set_clip_rectangle  (bbGC, &toolTipBounds);
            gdk_draw_layout (parentWindow->window, bbGC, toolTipBounds.x+3, toolTipBounds.y+3, ttText);
            gdk_gc_set_clip_rectangle  (bbGC, nil);

            pango_font_description_free (ttFont);
            g_object_unref (ttText);

        }
    }
}