コード例 #1
0
/**************************************************************************
 MUIM_Draw
**************************************************************************/
IPTR Numericbutton__MUIM_Draw(struct IClass *cl, Object *obj, struct MUIP_Draw *msg)
{
    IPTR  val;
    char *buf;
    int   width;

    DoSuperMethodA(cl,obj,(Msg)msg);

    if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE)))
        return FALSE;

    DoMethod(obj,MUIM_DrawBackground,_mleft(obj),_mtop(obj),_mwidth(obj),_mheight(obj),
             _mleft(obj),_mtop(obj),0);

    SetFont(_rp(obj),_font(obj));
    SetABPenDrMd(_rp(obj),_pens(obj)[MPEN_TEXT],_pens(obj)[MPEN_BACKGROUND],JAM1);

    get(obj, MUIA_Numeric_Value, &val);
    buf = (char*)DoMethod(obj,MUIM_Numeric_Stringify,val);
    width = TextLength(_rp(obj),buf,strlen(buf));

    Move(_rp(obj), _mleft(obj) + (_mwidth(obj) - width) / 2,
         _mtop(obj) + _font(obj)->tf_Baseline);

    Text(_rp(obj), buf, strlen(buf));

    return TRUE;
}
コード例 #2
0
ファイル: Tuning.cpp プロジェクト: cr8tr/omnidome
      void Tuning::startDrag()
      {
        if (!dataModel()) return;

        if (dataModel()->mode() != Session::Mode::SCREENSETUP) return;

        QDrag *drag         = new QDrag(this);
        QMimeData *mimeData = new QMimeData;

        // Generate pixmap for projector
        QPixmap _pixmap(128, 128);
        {
          _pixmap.fill(tuning()->color());
          QPainter _p(&_pixmap);
          QRect    _rect(0, 0, 128, 128);

          QFont _font("Helvetica", 32);
          _p.setFont(_font);

          _p.drawRect(_rect.adjusted(1, 1, -2, -2));
          _p.drawText(_rect, Qt::AlignCenter,
                      QString("%1").arg(index() + 1));
          _p.end();
        }
        drag->setPixmap(_pixmap);

        mimeData->setText(QString("%1").arg(index()));
        drag->setMimeData(mimeData);
        drag->exec();
      }
コード例 #3
0
IPTR Levelmeter__MUIM_Setup(struct IClass *cl, Object *obj, struct MUIP_Setup *msg)
{
    struct Levelmeter_DATA *data = INST_DATA(cl, obj);
    //struct RastPort 	       rp;
    IPTR    	    	       retval;

    retval = DoSuperMethodA(cl, obj, (Msg)msg);
    if (retval)
    {
#if 0
        InitRastPort(&rp);
        SetFont(&rp,_font(obj));

        DeinitRastPort(&rp);
#endif
        data->levelbgpen = ObtainBestPen(_screen(obj)->ViewPort.ColorMap,
                                         0x4b4b4b4b,
                                         0x39393939,
                                         0x93939393,
                                         OBP_FailIfBad, FALSE,
                                         OBP_Precision, PRECISION_GUI,
                                         TAG_DONE);
    }

    return retval;
}
コード例 #4
0
ファイル: plsub.c プロジェクト: EQ4/SPTK
int font(int n)
{
   if (n < 0 || n > 19)
      return (1);
   _font(n);
   return (0);
}
コード例 #5
0
static IPTR mLampAskMinMax(struct IClass *cl, Object *obj, struct MUIP_AskMinMax *msg)
{
    struct lampData          *data = INST_DATA(cl,obj);
    struct RastPort          rp;
    struct TextExtent        te;
    UWORD                    w, h, d;

    DoSuperMethodA(cl,obj,(APTR)msg);

    CopyMem(&_screen(obj)->RastPort,&rp,sizeof(rp));

    /* Don't ask or modify ! */

    SetFont(&rp,_font(obj));
    TextExtent(&rp,"  ",2,&te);

    w = te.te_Width;
    h = te.te_Height;

    if (w>=h) d = w;
    else d = h;

    data->delta = te.te_Extent.MinY;

    msg->MinMaxInfo->MinWidth  += d;
    msg->MinMaxInfo->MinHeight += h;
    msg->MinMaxInfo->DefWidth  += d;
    msg->MinMaxInfo->DefHeight += h;
    msg->MinMaxInfo->MaxWidth  += d;
    msg->MinMaxInfo->MaxHeight += h;

    return 0;
}
コード例 #6
0
/**************************************************************************
 MUIM_AskMinMax
**************************************************************************/
IPTR Numericbutton__MUIM_AskMinMax(struct IClass *cl, Object *obj, struct MUIP_AskMinMax *msg)
{
    struct Numericbutton_DATA *data = INST_DATA(cl, obj);

    DoSuperMethodA(cl, obj, (Msg)msg);

    if (data->needs_to_recalculate_sizes)
    {
        struct RastPort rp;
        LONG min, max, val, width;

        InitRastPort(&rp);
        SetFont(&rp,_font(obj));

        width = 0;

        longget(obj, MUIA_Numeric_Min, &min);
        longget(obj, MUIA_Numeric_Max, &max);

        /* Determine the width of the knob */
        for (val=min; val<=max; val++)
        {
            LONG nw;
            char *buf;

            buf = (char*)DoMethod(obj, MUIM_Numeric_Stringify, val);
            nw  = TextLength(&rp, buf, strlen(buf));

            if (nw > width)
                width = nw;
        }

        data->max_text_width = width;
        data->text_height    = _font(obj)->tf_YSize;

        data->needs_to_recalculate_sizes = FALSE;
    }

    msg->MinMaxInfo->MinWidth  += data->max_text_width;
    msg->MinMaxInfo->MinHeight += data->text_height;
    msg->MinMaxInfo->DefWidth  += data->max_text_width;
    msg->MinMaxInfo->DefHeight += data->text_height;
    msg->MinMaxInfo->MaxWidth  += data->max_text_width;
    msg->MinMaxInfo->MaxHeight += data->text_height;

    return TRUE;
}
コード例 #7
0
ファイル: sym.cpp プロジェクト: Skibol/MuseScore
Sym::Sym(int c, int fid, qreal ax, qreal ay)
   : _code(c), fontId(fid), _attach(ax * MScore::DPI/PPI, ay * MScore::DPI/PPI)
      {
      QFont _font(fontId2font(fontId));
      QFontMetricsF fm(_font);
      if (!fm.inFont(_code)) {
            qDebug("Sym: character 0x%x(%d) are not in font <%s>\n", c, c, qPrintable(_font.family()));
            return;
            }
      w     = fm.width(_code);
      _bbox = fm.boundingRect(_code);
#ifdef USE_GLYPHS
      genGlyphs(fontId2RawFont(fontId));
#endif
      }
コード例 #8
0
ファイル: ScreenSetup.cpp プロジェクト: emervark/omnidome
    void ScreenSetup::paintEvent(QPaintEvent*)
    {
      QPainter _p(this);
      _p.setPen(QPen(QColor("#ffffff").darker(150),3));

      if (screenItems_.empty())
      {
        QFont _font("Helvetica",30 / devicePixelRatio());
        _p.setFont(_font);
        _p.setBrush(QBrush("#cccccc"));
        _p.drawText(rect(),Qt::AlignCenter,"No screen connected.");
        return;
      }

      _p.setPen(QPen(QColor("#ffffff").darker(150),3));
      _p.drawRect(transformedRect());

      /// Draw all items
      for (auto& _item : screenItems_)
      {
        _item.second->paint(_p);
      }
    }
コード例 #9
0
IPTR Register__MUIM_Setup(struct IClass *cl, Object *obj, struct MUIP_Setup *msg)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    WORD    	    i, h = 0;

    if (!DoSuperMethodA(cl, obj, (Msg)msg))
    {
        return FALSE;
    }

    _font(obj) = zune_font_get(obj, MUIV_Font_Title);
    data->fonth = _font(obj)->tf_YSize;
    data->fontb = _font(obj)->tf_Baseline;

    h = 0;

    i = data->fonth + REGISTERTAB_EXTRA_HEIGHT;
    h = (i > h) ? i : h;

    data->tab_height = h;
    data->ty = data->fontb + 1 + (data->tab_height - data->fonth) / 2;

    /*      D(bug("Register_Setup : data->height=%d\n", data->tab_height)); */

    for(i = 0; i < data->numitems; i++)
    {
        data->items[i].textlen = strlen(data->items[i].text);
    }

    data->total_hspacing = (data->columns + 1) * INTERTAB - 2;
    /*      D(bug("Register_AskMinMax : data->total_hspacing = %d\n", data->total_hspacing)); */

    data->min_width = data->total_hspacing * 3;
    data->def_width = data->total_hspacing;

    if (!(muiGlobalInfo(obj)->mgi_Prefs->register_truncate_titles))
    {
        struct RastPort temprp;
        int i;
        WORD textpixmax;

        InitRastPort(&temprp);
        SetFont(&temprp, _font(obj));

        textpixmax = 0;
        for(i = 0; i < data->numitems; i++)
        {
            WORD textpix = TextLength(&temprp, data->items[i].text, data->items[i].textlen);
            textpixmax = MAX(textpix, textpixmax);
        }
        data->def_width += (textpixmax + TEXTSPACING + 1) * data->numitems;
        data->def_width = MAX(data->min_width, data->def_width);

        DeinitRastPort(&temprp);
    }

    SetHardCoord(obj,data);
    muiAreaData(obj)->mad_Flags     	|= (MADF_INNERLEFT | MADF_INNERTOP | MADF_INNERRIGHT | MADF_INNERBOTTOM);

    DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR)&data->ehn);

    return TRUE;
}
コード例 #10
0
/**************************************************************************
   Render tab bar
**************************************************************************/
static void RenderRegisterTab(struct IClass *cl, Object *obj, ULONG flags)
{
    struct Register_DATA *data = INST_DATA(cl, obj);
    WORD tabx;

    /*
     * Erase / prepare for drawing
     */
    if (flags & MADF_DRAWOBJECT)
    {
        DoMethod(obj, MUIM_DrawParentBackground, data->left, data->top,
                 data->framewidth, data->tab_height - 1, data->left, data->top, 0);
    }
    else
    {
        /* draw parent bg over oldactive */
        IPTR method;
        WORD old_left, old_top, old_width, old_height;
        struct RegisterTabItem *ri = &data->items[data->oldactive];
        if (data->oldactive >= data->columns) method = MUIM_DrawBackground;
        else method = MUIM_DrawParentBackground;

        old_left = _left(obj) + ri->x1 - 2;
        old_top = _top(obj) + ri->y1;
        old_width = ri->x2 - ri->x1 + 5;
        old_height = data->tab_height - 1;
        DoMethod(obj, method, old_left, old_top,
                 old_width, old_height, old_left, old_top, 0);
        SetDrMd(_rp(obj), JAM1);
        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
        RectFill(_rp(obj), old_left, old_top + old_height, old_left + old_width, old_top + old_height);
    }

    SetDrMd(_rp(obj), JAM1);
    SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);
    SetFont(_rp(obj), _font(obj));
    SetSoftStyle(_rp(obj), FS_NORMAL, AskSoftStyle(_rp(obj)));


    /*
     * Draw new graphics
     */
    /* register frame */
    if (flags & MADF_DRAWOBJECT || (data->active / data->columns != data->oldactive / data->columns))
    {
        int i,y,tabs_on_bottom = 0;

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHINE]);

        RectFill(_rp(obj), data->left,
                 data->top + data->tab_height - 1,
                 data->left,
                 data->top + data->tab_height + data->frameheight - 1);

        y = data->top + data->tab_height - 1;

        for (i=0; i<data->rows; i++)
        {
            if (!tabs_on_bottom && (i > data->active/data->columns))
            {
                y = _bottom(obj) - muiAreaData(obj)->mad_InnerBottom + data->tab_height;
                tabs_on_bottom = 1;
            }

            RectFill(_rp(obj), data->left + 1, y, data->left + data->framewidth - 2, y);
            y += data->tab_height;
        }

        SetAPen(_rp(obj), _pens(obj)[MPEN_SHADOW]);

        RectFill(_rp(obj), data->left + data->framewidth - 1,
                 data->top + data->tab_height - 1,
                 data->left + data->framewidth - 1,
                 data->top + data->tab_height + data->frameheight - 1);

        RectFill(_rp(obj), data->left + 1,
                 data->top + data->tab_height + data->frameheight - 1,
                 data->left + data->framewidth - 2,
                 data->top + data->tab_height + data->frameheight - 1);
        for(i = 0, tabx = 0; i < data->numitems; i++)
        {
            RenderRegisterTabItem(cl, obj, i);
        }
    }
    else
    {
        /* If active register has been changed and is on same row we simply draw both registers only */
        RenderRegisterTabItem(cl, obj, data->active);
        RenderRegisterTabItem(cl, obj, data->oldactive);
    }

}
コード例 #11
0
static void DrawKnob(Object *obj, struct Numericbutton_DATA *data, BOOL force)
{
    struct RastPort *rp, *saverp;
    LONG    	     x, val, pixeloffset, textlen, pixellen;
    STRPTR  	     text;

    pixeloffset = data->popwin->MouseX - data->pop_innerx - 2 - data->knob_clickoffset_x;

    val = DoMethod(obj, MUIM_Numeric_ScaleToValue, 0,
                   data->pop_innerw - data->knob_width, pixeloffset);

    data->knob_left = data->pop_innerx + pixeloffset;
    data->knob_top = data->pop_innery;
    data->knob_val = val;

    if (!force && (data->knob_left == data->knob_prev_left))
    {
        return;
    }
    data->knob_prev_left = data->knob_left;

    if (data->knob_left < data->pop_innerx)
    {
        data->knob_left = data->pop_innerx;
    }
    else if (data->knob_left > data->pop_innerx + data->pop_innerw - data->knob_width)
    {
        data->knob_left = data->pop_innerx + data->pop_innerw - data->knob_width;
    }

    saverp = _rp(obj);
    _rp(obj) = rp = data->popwin->RPort;

    SetABPenDrMd(rp, _pens(obj)[MPEN_SHINE], 0, JAM1);
    RectFill(rp, data->knob_left, data->knob_top,
             data->knob_left, data->knob_top + data->knob_height - 1);
    RectFill(rp, data->knob_left + 1, data->knob_top,
             data->knob_left + data->knob_width - 1, data->knob_top);
    SetAPen(rp, _pens(obj)[MPEN_SHADOW]);
    RectFill(rp, data->knob_left + data->knob_width - 1, data->knob_top + 1,
             data->knob_left + data->knob_width - 1, data->knob_top + data->knob_height - 1);
    RectFill(rp, data->knob_left + 1, data->knob_top + data->knob_height - 1,
             data->knob_left + data->knob_width - 2, data->knob_top + data->knob_height - 1);

    if (data->knob_bg)
    {
#warning "Ugly hack?"

        struct IBox old_mad_Box = muiAreaData(obj)->mad_Box;

        muiAreaData(obj)->mad_Box.Left   = data->knob_left + 1;
        muiAreaData(obj)->mad_Box.Top    = data->knob_top +  1;
        muiAreaData(obj)->mad_Box.Width  = data->knob_width - 2;
        muiAreaData(obj)->mad_Box.Height = data->knob_height - 2;

        zune_imspec_draw(data->knob_bg, muiRenderInfo(obj),
                         data->knob_left + 1,
                         data->knob_top + 1,
                         data->knob_width - 2,
                         data->knob_height - 2,
                         0,
                         0,
                         0);

        muiAreaData(obj)->mad_Box = old_mad_Box;
    }
    else
    {
        SetAPen(rp, _pens(obj)[MPEN_BACKGROUND]);
        RectFill(rp, data->knob_left + 1, data->knob_top + 1,
                 data->knob_left + data->knob_width - 2,
                 data->knob_top + data->knob_height - 2);
    }

    SetFont(rp, _font(obj));

    text = (STRPTR)DoMethod(obj, MUIM_Numeric_Stringify, val);
    textlen = strlen(text);
    pixellen = TextLength(_rp(obj), text, textlen);

    SetAPen(rp, _pens(obj)[MPEN_TEXT]);
    Move(rp, data->knob_left + 2 + (data->knob_width - 4 - pixellen) / 2,
         data->knob_top + 1 + rp->TxBaseline);
    Text(rp, text, textlen);

    SetAPen(rp, _pens(obj)[MPEN_BACKGROUND]);

    if (data->knob_left - 1 >= data->pop_innerx)
    {
        RectFill(rp, data->pop_innerx, data->pop_innery,
                 data->knob_left - 1, data->pop_innery + data->pop_innerh - 1);
    }

    x = data->knob_left + data->knob_width;
    if (x <= data->pop_innerx + data->pop_innerw - 1)
    {
        RectFill(rp, x, data->pop_innery,
                 data->pop_innerx + data->pop_innerw - 1,
                 data->pop_innery + data->pop_innerh - 1);
    }

    _rp(obj) = saverp;
}