Exemplo n.º 1
0
Arquivo: tabbar.cpp Projeto: snori/ntk
void
TabBar::Tab::draw(DC& dc)
{
	const RGBColor ACTIVE_COLOR = ntk::app_color();// + 30;
	Rect rect = frame();
	rect.top += 1;

	dc.push_state();

	if(is_active())
	{
		dc.set_brush(ACTIVE_COLOR);
		dc.fill_rect(rect);

		dc.set_pen(ntk::outline_color());
		dc.stroke_line(rect.left_top(), rect.left_bottom());
		dc.stroke_line(rect.left_top(), rect.right_top());
		dc.stroke_line(rect.right_top(), rect.right_bottom());

		dc.set_text_color(ntk::font_color());
	}
	else
		dc.set_text_color(ntk::font_color() - 30);

	ntk::draw_string_center(dc, rect, name());

	dc.pop_state();
}
Exemplo n.º 2
0
  void ScrollingContainer::render(DC& dc)
  {
    if(m_bars_visible)
    {
      m_bottom->m_prev_sibling = nullptr;
      __try
      {
        __super::render(dc);
      }
      __finally
      {
        m_bottom->m_prev_sibling = m_content;
      }

      auto old_clip = dc.pushClipRect(D2D1::RectF(m_position.left, m_position.top, m_position.left + m_content->m_position.right, m_position.top + m_content->m_position.bottom));
      m_last_child = m_content;
      __try
      {
        renderChildren(dc, .125f);
      }
      __finally
      {
        m_last_child = m_right;
        dc.restoreClipRect(old_clip);
      }
    }
    else
    {
Exemplo n.º 3
0
inline qm_real datestring<D>::dcf(const D& date, const qm_string& dcname) const  {
	if(this->isdate())  {
		DC dc = daycounter::get(dcname);
		if(dc) return dc->dcf(date,m_date);
		else QM_FAIL("Day counter not specified");
	}
	else return m_period.dcf();
}
Exemplo n.º 4
0
void
draw_string_center(DC& dc, const Rect& rect, const String& str)
{
	uint prev_align = dc.set_text_align(TA_CENTER | TA_TOP);

	Point str_pos(
		rect.left + rect.width() /2,
		rect.top + (rect.height() - dc.string_height()) /2);
	dc.draw_string(str, str_pos);

	dc.set_text_align(prev_align);
}
Exemplo n.º 5
0
/******************************************************************
 *                  EndPage  [GDI32.@]
 *
 */
INT WINAPI EndPage(HDC hdc)
{
    INT ret = 0;
    DC *dc = get_dc_ptr( hdc );
    if(!dc) return SP_ERROR;

    if (dc->funcs->pEndPage) ret = dc->funcs->pEndPage( dc->physDev );
    if (dc->pAbortProc && !dc->pAbortProc( hdc, 0 ))
    {
        EndDoc( hdc );
        ret = 0;
    }
    release_dc_ptr( dc );
    return ret;
}
Exemplo n.º 6
0
void DropDownList::draw(DC& dc) {
    // Size
    wxSize cs = dc.GetSize();
    // Draw background & frame
    dc.SetPen  (*wxTRANSPARENT_PEN);
    dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    dc.DrawRectangle(0, 0, cs.x, cs.y);
    dc.SetFont(*wxNORMAL_FONT);
    // Draw items
    int y = marginH - visible_start;
    size_t count = itemCount();
    for (size_t i = 0 ; i < count ; ++i) {
        drawItem(dc, y, i);
        y += (int)item_size.height + lineBelow(i);
    }
}
Exemplo n.º 7
0
ThreeLevelCountReadBuffers::ThreeLevelCountReadBuffers(DC &ssd, DC &spd, DC &pd)
    : _ssd(ssd),
      _spd(spd),
      _pd(pd),
      _rcssd(ssd),
      _rcspd(spd),
      _rcpd(pd),
      _ssHeaderLen(0u),
      _spHeaderLen(0u),
      _pHeaderLen(0u),
      _ssFileBitSize(0u),
      _spFileBitSize(0u),
      _pFileBitSize(0u)
{
    ssd.setReadContext(&_rcssd);
    spd.setReadContext(&_rcspd);
    pd.setReadContext(&_rcpd);
}
Exemplo n.º 8
0
int get_events(DC& container)
{
        xlog("get_events");

        GetEventSender sender;
        container.for_each_active(TYPE_CAN,&sender);

        return 0;
}
Exemplo n.º 9
0
void
stroke_edge(DC& dc, const Rect& rect, const Pen& light_pen, const Pen& dark_pen)
{
	Pen default_pen = dc.pen();

	dc.set_pen(light_pen);
	dc.move_to(rect.left, rect.bottom -1);
	dc.stroke_line(rect.left, rect.top);
	dc.stroke_line(rect.right -1, rect.top);

	dc.set_pen(dark_pen);
	dc.stroke_line(rect.right -1, rect.bottom -1);
	dc.stroke_line(rect.left, rect.bottom -1);

	dc.set_pen(default_pen);
}
Exemplo n.º 10
0
    virtual int callback(can_message * msg,DC& container) {
        xlog("GetEventsTask::exec");
        ++counter;

        uint32_t addr = msg->id.p.addr;

        if(addr != device->addr) {
            xlog2("Wrong addr: expected[%X] got[%X]",device->addr,addr);
            return -1;
        }

        //got NACK - try to restart with the same event id
        if(msg->id.p.func == S_NACK) return handle_nack();

        int num = msg->id.p.num;
        if(idx++ != num) {
            xlog2("received packet with incorrect num[%i]",num);
            return -1;
        }

        if(num > 9) {
            xlog2("packet num[%i] > 9 : incorrect",num);
            return -1;
        }

        //here we assume that packet is correct enough
        char* data_pos = (char*)&event + pos;
        if(data_pos + msg->length > (char*)&event + sizeof(event)) {
            xlog2("possible event buffer overflow on packet[%i] with len[%i]", num, msg->length);
            device->current_event_id += 1;
            xlog2("skipping event number for device[%X] to [%i]", device->addr, device->current_event_id);
            return -1;
        }

        memcpy(data_pos,msg->data,msg->length);
        pos += msg->length;

        if(msg->id.p.end) {
            if(-1 == container.eventStorage()->save_event(device,&event)) {
                return -1;
            } else {
                xlog("task for[%X] completed event with id[%u] len[%u]",device->addr,event.EventNumber,pos);
                device->current_event_id = event.EventNumber;
                return continue_task();
            }
        }

        return 0;
    }
Exemplo n.º 11
0
SIZE mew::theme::MenuMeasureItem(PCWSTR wcsText, IImageList* pImageList, int nImage)
{
	if(!theMenuFont)
	{
		HandleSystemSettingChange();
	}

	if(str::empty(wcsText))
	{
		SIZE sz = { 0, ::GetSystemMetrics(SM_CYMENU) / 2 };
		return sz;
	}
	else
	{
		DC dc;
		dc.CreateCompatibleDC();
		SIZE sz = dc.GetTextExtent(theMenuFont, wcsText);
		SIZE ret;
		SIZE iconSize = ImageList_GetIconSize(pImageList);
		ret.cx = sz.cx + iconSize.cx + MENU_ICON_SPACE_W * 2 + MENU_TEXT_INDENT + MENU_TEXT_SPACE;
		ret.cy = math::max<int>(sz.cy + MENU_ITEM_PADDING, iconSize.cy + MENU_ICON_SPACE_H * 2);
		return ret;
	}
}
Exemplo n.º 12
0
	HBITMAP Image::GetBitmap(){
		if(_image==0) return 0;
		_Image* img = ((_Image*)_image);
		int cx = img->GetWidth();
		if(cx==0) return 0;
		int cy = img->GetHeight();
		if(cy==0) return 0;
		DC dc;
		dc.GetDC();
		HBITMAP bmp = CreateBitmap(dc,cx,cy);
		if(bmp==0){
			PrintLastErrorD(L"Image::GetBitmap: %s");
			return 0;
		}
		HDC hdc = ::CreateCompatibleDC(dc);
		dc.ReleaseDC();
		HGDIOBJ old = ::SelectObject(hdc,bmp);
		Gdiplus::Graphics gph(hdc);
		Gdiplus::Point pt[3] = {Gdiplus::Point(0,0),Gdiplus::Point(cx,0),Gdiplus::Point(0,cy)};
		gph.DrawImage((_Image*)_image,pt,3);
		bmp = (HBITMAP)::SelectObject(hdc,old);
		::DeleteDC(hdc);
		return bmp;
	}
Exemplo n.º 13
0
void PackageList::drawItem(DC& dc, int x, int y, size_t item) {
	dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2);
	PackageData& d = packages.at(item);
	RealRect rect(RealPoint(x,y),item_size);
	RealPoint pos;
	int w, h;
	// draw image
	if (d.image.Ok()) {
		dc.DrawBitmap(d.image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d.image.GetWidth())), y + 3, true);
	}
	// draw short name
	dc.SetFont(wxFont(12,wxSWISS,wxNORMAL,wxBOLD,false,_("Arial")));
	dc.GetTextExtent(capitalize(d.package->short_name), &w, &h);
	pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
	dc.DrawText(capitalize(d.package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
	// draw name
	dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
	dc.GetTextExtent(d.package->full_name, &w, &h);
	RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
	dc.DrawText(d.package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
	dc.DestroyClippingRegion();
}
Exemplo n.º 14
0
void SymbolSymmetryEditor::draw(DC& dc) {
	if (symmetry) {
		control.highlightPart(dc, *symmetry, HIGHLIGHT_BORDER);
		Color color(255,100,0);
		Vector2D center = control.rotation.tr(symmetry->center);
		Vector2D handle = control.rotation.tr(symmetry->center + symmetry->handle);
		if (symmetry->kind == SYMMETRY_REFLECTION) {
			// draw line to handle
			dc.SetPen(wxPen(color,1,wxDOT));
			dc.DrawLine(int(center.x), int(center.y), int(handle.x), int(handle.y));
			// draw handle
			dc.SetPen(*wxBLACK_PEN);
			dc.SetBrush(color);
			dc.DrawCircle(int(handle.x), int(handle.y), hovered == SELECTION_HANDLE ? 7 : 4);
		}
		// draw center
		dc.SetPen(*wxBLACK_PEN);
		dc.SetBrush(color);
		dc.DrawCircle(int(center.x), int(center.y), hovered == SELECTION_CENTER ? 8 : 5);
	}
}
Exemplo n.º 15
0
ThreeLevelCountReadBuffers::ThreeLevelCountReadBuffers(DC &ssd, DC &spd, DC &pd, ThreeLevelCountWriteBuffers &wb)
    : _ssd(ssd),
      _spd(spd),
      _pd(pd),
      _rcssd(ssd),
      _rcspd(spd),
      _rcpd(pd),
      _ssHeaderLen(wb._ssHeaderLen),
      _spHeaderLen(wb._spHeaderLen),
      _pHeaderLen(wb._pHeaderLen),
      _ssFileBitSize(wb._ssFileBitSize),
      _spFileBitSize(wb._spFileBitSize),
      _pFileBitSize(wb._pFileBitSize)
{
    ssd.setReadContext(&_rcssd);
    spd.setReadContext(&_rcspd);
    pd.setReadContext(&_rcpd);
    _rcssd.referenceWriteContext(wb._wcsse);
    _rcspd.referenceWriteContext(wb._wcspe);
    _rcpd.referenceWriteContext(wb._wcpe);
    ssd.skipBits(_ssHeaderLen * 8);
    spd.skipBits(_spHeaderLen * 8);
    pd.skipBits(_pHeaderLen * 8);
}
void Settings::readAuthFile() {
    QVariantMap map;
    if(!_telegram_settings_read_fnc(mTelegram, map))
        telegram_settings_read_fnc(mTelegram, map);

    QString pre = testMode() ? ST_TEST : ST_PRODUCTION;
    pre += "/";

    qint32 defaultDcId = m_testMode ? TEST_DEFAULT_DC_ID : Settings::defaultHostDcId();

    m_workingDcNum = map.value(pre+ST_WORKING_DC_NUM, defaultDcId).toInt();
    m_ourId = map.value(pre+ST_OUR_ID).toInt();
    m_workingDcConfigAvailabe = map.contains(pre+ST_WORKING_DC_NUM);
    qCDebug(TG_CORE_SETTINGS) << "workingDcNum:" << m_workingDcNum;
    qCDebug(TG_CORE_SETTINGS) << "ourId:" << m_ourId;

    pre += ST_DCS_ARRAY;
    pre += "/";

    qint32 n = map.value(pre + "size").toInt();
    for (qint32 i = 0; i < n; i++) {
        QString ar = pre + QString::number(i) + "/";

        qint32 dcNum = map.value(ar+ST_DC_NUM).toInt();
        DC* dc = new DC(dcNum);
        dc->setHost(map.value(ar+ST_HOST).toString());
        dc->setPort(map.value(ar+ST_PORT, 0).toInt());
        dc->setIpv6(map.value(ar+ST_IPV6).toBool());
        dc->setMediaOnly(map.value(ar+ST_MEDIA).toBool());
        dc->setState((DC::DcState)map.value(ar+ST_DC_STATE, DC::init).toInt());
        dc->setAuthKeyId(map.value(ar+ST_AUTH_KEY_ID, 0).toLongLong());
        if (dc->state() >= DC::authKeyCreated) {
            QByteArray readedBa = QByteArray::fromBase64(map.value(ar+ST_AUTH_KEY).toByteArray());
            memcpy(dc->authKey(), readedBa.data(), SHARED_KEY_LENGTH);
        }
        dc->setServerSalt(map.value(ar+ST_SERVER_SALT, 0).toLongLong());
        dc->setExpires(map.value(ar+ST_EXPIRES).toInt());

        qCDebug(TG_CORE_SETTINGS) << "DC | id:" << dc->id() << ", state:" << dc->state() <<
                    ", host:" << dc->host() << ", port:" << dc->port() <<
                    ", expires:" << dc->expires() << ", authKeyId:" << dc->authKeyId() <<
                    ", serverSalt:" << dc->serverSalt() << ", ipv6" << dc->ipv6();

        m_dcsList.insert(dcNum, dc);
    }
}
Exemplo n.º 17
0
void CTestClient::syncCase()
{
    CJsonT msg;
    CJsonTArray ja;
    
    typedef decltype(m_testCase->m_atk) DC;
    DC* pV;
    if (isAttacking())
    {
        pV = &m_testCase->m_atk;
        MT->printA("attack side sync: ");
    }
    else
    {
        pV = &m_testCase->m_def;
        MT->printD("defend side sync: ");
    }
    
    for (int i = 0; i < 11; ++i)
    {
        DC::value_type tpi = nullptr;
        for (auto it = pV->begin(); it != pV->end(); ++it)
        {
            if ((*it)->playerNumber == i)
            {
                tpi = (*it);
                break;
            }
        }
        
        switch (m_side)
        {
            case FBDefs::SIDE::LEFT:
                if (tpi)
                {
                    ja.append(tpi->position.x);
                    ja.append(tpi->position.y);
                    if (isAttacking())
                    {
                        MT->printA("x: %f, y: %f", tpi->position.x, tpi->position.y);
                    }
                    else
                    {
                        MT->printD("x: %f, y: %f", tpi->position.x, tpi->position.y);
                    }
                }
                else
                {
                    ja.append(CJsonT((float)0));
                    ja.append(CJsonT((float)0));
                }
                ja.append(CJsonT((float)0));
                ja.append(CJsonT((float)0));
                break;
            case FBDefs::SIDE::RIGHT:
                if (tpi)
                {
                    ja.append(CJsonT(tpi->position.x));
                    ja.append(CJsonT(tpi->position.y));
                    if (m_ballPos != -1)
                    {
                        MT->printA("x: %f, y: %f", tpi->position.x, tpi->position.y);
                    }
                    else
                    {
                        MT->printD("x: %f, y: %f", tpi->position.x, tpi->position.y);
                    }
                }
                else
                {
                    ja.append(CJsonT((float)FBDefs::PITCH_WIDTH-1));
                    ja.append(CJsonT(0));
                }
                ja.append(CJsonT((float)0));
                ja.append(CJsonT((float)0));
                break;
            default:
                break;
        }
        
    }
    
    msg.setChild("teamPos", ja);
    msg.setChild("side", (int)m_side);
    msg.setChild("ballPosPlayerId", m_ballPos);
    msg.setChild("timeStamp", 0);
    m_pomelo->notify("match.matchHandler.sync", msg, [](Node*, void*){});
    
    msg.release();
}
Exemplo n.º 18
0
void DropDownList::drawItem(DC& dc, int y, size_t item) {
    if (y + item_size.height <= 0 || y >= dc.GetSize().y) return; // not visible
    // draw background
    dc.SetPen(*wxTRANSPARENT_PEN);
    if (item == selected_item) {
        if (itemEnabled(item)) {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        } else {
            dc.SetBrush         (wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
            dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
        }
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else if (!itemEnabled(item)) {
        // mix between foreground and background
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
    } else if (highlightItem(item)) {
        // mix a color between selection and window
        dc.SetBrush         (lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT),
                                  wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), 0.75));
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawRectangle(marginW, y, (int)item_size.width, (int)item_size.height);
    } else {
        dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
    }
    // draw text and icon
    drawIcon(dc, marginW, y, item, item == selected_item);
    dc.DrawText(capitalize(itemText(item)), marginW + (int)icon_size.width + 1, y + text_offset);
    // draw popup icon
    if (submenu(item)) {
        draw_menu_arrow(this, dc, RealRect(marginW, y, item_size.width, item_size.height), item == selected_item);
    }
    // draw line below
    if (lineBelow(item) && item != itemCount()) {
        dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
        dc.DrawLine(marginW, y + (int)item_size.height, marginW + (int)item_size.width, y + (int)item_size.height);
    }
}