Пример #1
0
  void Paint( QPainter& painter, int x, int y ) const {
    painter.save();

    QRect rect( x, y, Width(), Height() );
    painter.setClipRect( rect );

    // BG
    QPen pen = QPen( QColor( 160, 160, 160 ) );
    pen.setWidth( 3 );
    painter.setPen( pen );
    painter.setBrush( QBrush( QColor( 70, 70, 70, 175 ) ) );
    painter.drawRoundedRect( rect, 10, 10 );

    // Title
    y += Padding();
    painter.setPen( QPen( Qt::white) );
    painter.setFont( mTitleFont );
    painter.drawText( x, y, Width(), TitleHeight(), Qt::AlignCenter | Qt::AlignVCenter | Qt::TextDontClip, mTitle );
    y += TitleHeight() + RowSpacing();

    // Lines
    painter.setPen( QPen( Qt::white) );
    painter.setFont( mRowFont );
    for( const QVariantMap& it : mHistory ) {
      int mx = x + Padding();
      DrawMana( painter, mx, y, RowHeight(), RowHeight(), it["mana"].toInt() );
      int cx = mx + RowHeight() + 5;
      DrawCardLine( painter, cx, y, RowWidth() - cx, RowHeight(), it["name"].toString(), it["count"].toInt() );
      y += RowHeight();
      y += RowSpacing();
    }

    painter.restore();
  }
Пример #2
0
void GameWindow_InitLicenseWindow(void)
{
	window = Widget_New("window");
	label_license = Widget_New("label");
	textbox_license = Widget_New("text_box");
	box = Widget_New(NULL);
	btn_ok = Widget_New("button");

	Window_ClientArea_Add( window, label_license );
	Window_ClientArea_Add( window, box );
	Window_ClientArea_Add( window, btn_ok );
	Widget_Container_Add( box, textbox_license );
	
	Widget_SetBackgroundColor( label_license, RGB(255,255,255) );
	Widget_SetBackgroundTransparent( label_license, FALSE );
	
	Widget_SetAlign( label_license, ALIGN_TOP_CENTER, Pos(0,0) );
	Widget_SetAlign( box, ALIGN_TOP_CENTER, Pos(0,8) );
	Widget_SetAlign( btn_ok, ALIGN_BOTTOM_CENTER, Pos(0,-5) );

	Label_TextW( label_license, TEXT_LICENSE );
	Button_TextW( btn_ok, TEXT_OK );
	TextBox_SetAutoWrap( textbox_license, TRUE );
	TextBox_SetMultiline( textbox_license, TRUE );
	TextBox_SetReadOnly( textbox_license, TRUE );
	TextBox_SetUsingStyleTags( textbox_license, TRUE );
	TextBox_TextW( textbox_license, license_text );
	TextBox_ShowCursor( textbox_license, FALSE );

	Widget_SetStyleID( window, WINDOW_STYLE_LINE );
	Widget_SetPadding( Window_GetClientArea(window), Padding(10,10,10,10) );
	Widget_SetAutoSize( btn_ok, FALSE, 0 );

	Widget_SetBorder( box, Border(1,BORDER_STYLE_SOLID,RGB(200,200,200)) );
	Widget_SetPadding( box, Padding(10,10,10,10) );
	Widget_SetSize( box, "100%", "280px" );
	Widget_SetSize( textbox_license, "100%", "100%" );

	Widget_Resize( window, WINDOW_SIZE );
	Widget_Resize( btn_ok, BTN_SIZE );

	Widget_ConnectEvent( btn_ok, EVENT_CLICKED, btn_ok_on_clicked );

	Widget_Show( textbox_license );
	Widget_Show( box );
	Widget_Show( label_license );
	Widget_Show( btn_ok );
}
Пример #3
0
UINT DumpDeviceDriversCallback(_In_ PVOID Context, _In_ UINT Notification, _In_ UINT_PTR Param1, _In_ UINT_PTR Param2)
/*++

Routine Description:

    if Context provided, Simply count
    otherwise dump files indented 2

Arguments:

    Context      - DWORD Count
    Notification - SPFILENOTIFY_QUEUESCAN
    Param1       - scan

Return Value:

    none

--*/
{
    LPDWORD count = (LPDWORD)Context;
    LPTSTR file = (LPTSTR)Param1;

    UNREFERENCED_PARAMETER(Notification);
    UNREFERENCED_PARAMETER(Param2);

    if(count) {
        count[0]++;
    } else {
        Padding(2);
        _tprintf(TEXT("%s\n"),file);
    }

    return NO_ERROR;
}
Пример #4
0
/*
 * 创建一个部件,作为滚动条的容器
 * 再创建一个部件,作为滚动条
 * 限制滚动条的移动范围
 * */
static void 
ScrollBar_Init( LCUI_Widget *widget )
{
	LCUI_ScrollBar *scrollbar;
	
	scrollbar = WidgetPrivData_New(widget, sizeof(LCUI_ScrollBar));
	scrollbar->data.max_num = 100;
	scrollbar->data.current_num = 100;
	scrollbar->data.max_size = 100;
	scrollbar->data.current_size = 100;
	scrollbar->direction = 0;
	scrollbar->callback_func = NULL;
	
	scrollbar->widget = Widget_New("button");
	/* 禁用部件的自动尺寸调整 */
	Widget_SetAutoSize( scrollbar->widget, FALSE, 0 );
	
	Widget_Container_Add( widget, scrollbar->widget );
	Widget_SetSize( scrollbar->widget, "100%", "100%" );
	Widget_LimitPos( scrollbar->widget, Pos(0,0), Pos(0,0) );
	Widget_SetBorder( widget,
	 Border(1, BORDER_STYLE_SOLID, RGB(100,100,100)) );
	Widget_SetPadding( widget, Padding(1,1,1,1) );
	Widget_SetBackgroundColor( widget, RGB(200,200,200) );
	Widget_SetBackgroundTransparent( widget, FALSE );
	Widget_Show( scrollbar->widget );
	Widget_Event_Connect( scrollbar->widget, EVENT_DRAG, ScrollBar_Drag );
}
Пример #5
0
BOOL DumpDeviceDescr(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo)
/*++

Routine Description:

    Write device description to stdout

Arguments:

    Devs    )_ uniquely identify device
    DevInfo )

Return Value:

    TRUE if success

--*/
{
    LPTSTR desc;

    desc = GetDeviceDescription(Devs,DevInfo);
    if(!desc) {
        return FALSE;
    }
    Padding(1);
    FormatToStream(stdout,MSG_DUMP_DESCRIPTION,desc);
    delete [] desc;
    return TRUE;
}
Пример #6
0
/*
 * 创建一个部件,作为滚动条的容器
 * 再创建一个部件,作为滚动条
 * 限制滚动条的移动范围
 * */
static void 
ScrollBar_Init( LCUI_Widget *widget )
{
	LCUI_ScrollBar *scrollbar;
	
	scrollbar = Widget_Create_PrivData(widget, sizeof(LCUI_ScrollBar));
	scrollbar->data.max_num = 100;
	scrollbar->data.current_num = 100;
	scrollbar->data.max_size = 100;
	scrollbar->data.current_size = 100;
	scrollbar->direction = 0;
	scrollbar->callback_func = NULL;
	
	scrollbar->widget = Create_Widget("button");
	/* 禁用部件的自动尺寸调整 */
	Widget_AutoSize( scrollbar->widget, FALSE, 0 );
	
	Widget_Container_Add( widget, scrollbar->widget );
	Set_Widget_Size( scrollbar->widget, "100%", "100%" );
	Limit_Widget_Pos( scrollbar->widget, Pos(0,0), Pos(0,0) ); 
	Set_Widget_Border( widget, RGB(100,100,100), Border(1,1,1,1) );
	Set_Widget_Padding( widget, Padding(1,1,1,1) );
	Set_Widget_Backcolor( widget, RGB(200,200,200) );
	Set_Widget_BG_Mode( widget, BG_MODE_FILL_BACKCOLOR );
	Show_Widget( scrollbar->widget );
	Widget_Drag_Event_Connect( scrollbar->widget, ScrollBar_Drag );
}
Пример #7
0
int join_comfirm_serv(int sockfd, struct connect_serv * conn_serv, u8 PreMod, u16 SubMod)
{
	int cnt = 0;
	u8  	input_buff[128] = {0};
	u8	send_buff[128] = {0};
	int	len = 0;
	protocol_comfirm_ready(conn_serv, PreMod, SubMod);
	memcpy(send_buff, (u8 *)ConnectCF,37 );
	Padding(send_buff, 37, input_buff, &len);
	memset(send_buff, 0, 128);
	My_AES_CBC_Encrypt(conn_serv->KEYB, input_buff, len,send_buff+4 );
	send_buff[0] = ConnectREQ.CID[0];
	send_buff[1] = ConnectREQ.CID[1];
	send_buff[2] = ConnectREQ.CID[2];
	send_buff[3] = ConnectREQ.CID[3]; 
	printf("确认连接长度:%d\n", len);
	if(write(sockfd, send_buff, len+4) != (len+4)){
		printf("发送确认请求字数不足..\n");
		return 0;
	}
	printf("发送请求结束...\n");
	sleep(2);
	free(ConnectCF);
	return 1;
}
Пример #8
0
GWEN_CONTROL_CONSTRUCTOR(Menu, ScrollControl)
{
    SetBounds(0, 0, 10, 10);
    SetDeleteOnClose(false);
    SetIconMarginDisabled(false);
    SetPadding(Padding(0, 0, 0, 0));
    _SetScrollBarHidden(true);
}
Пример #9
0
const Padding Option::getPadding() const
{
	char *tok, *p;
	int mask = 0;
	int top, left, bottom, right;

	top = left = bottom = right = 0;

	char *str = strdup(value);
	if (!(p = strtok_r(str, " ,", &tok))) goto err;
	top = strtol(p, 0, 10);
	if (strchr(p, '%'))
		mask |= PERPAD_TOP;

	if (!(p = strtok_r(NULL, " ,", &tok))) goto err;
	right = strtol(p, 0, 10);
	if (strchr(p, '%'))
		mask |= PERPAD_RIGHT;

	if ((p = strtok_r(NULL, " ,", &tok))) {
		bottom = strtol(p, 0, 10);
		if (strchr(p, '%'))
			mask |= PERPAD_BOT;

		if (!(p = strtok_r(NULL, " ,", &tok))) goto err;
		left = strtol(p, 0, 10);
		if (strchr(p, '%'))
			mask |= PERPAD_LEFT;
	}
	else {
		bottom = top;
		if (mask & PERPAD_TOP)
			mask |= PERPAD_BOT;

		right = left;
		if (mask & PERPAD_LEFT)
			mask |= PERPAD_RIGHT;
	}
	free(str);
	return Padding(mask, top, right, bottom, left);

 err:
	return Padding(0,0,0,0);
}
Пример #10
0
void Menu::_OnAddItem(MenuItem* item)
{
    item->SetTextPadding(Padding(GetIconMarginDisabled() ? 0 : 24, 0, 16, 0));
    item->SetDock(Position::TOP);
    item->SizeToContents();
    item->SetAlignment(Position::CENTER_V | Position::LEFT);
    item->_on_hover_enter.Add(this, &Menu::_OnHoverItem);

    const int width = std::max(item->Width() + 10 + 32, Width());
    SetSize(width, Height());
}
Пример #11
0
int CServer_conn_HB(int sockfd)
{
	u8 	input_buff[128] = {0};
	u8	send_buff[128] = {0};
	u8	recv_buff[128] = {0};
	u8	crc[2];
	int 	len =0;
	int 	slen = 0;
	int 	res = 0;
	memcpy(send_buff, (u8 *)&CS_HB, 24);
	Padding(send_buff, 24, input_buff, &len);
	memset(send_buff, 0, 24);
	My_AES_CBC_Encrypt(KEY.KEYB, input_buff, len, recv_buff); 
	
	send_buff[0] = CS_HB.CID[0];
	send_buff[1] = CS_HB.CID[1];
	send_buff[2] = CS_HB.CID[2];
	send_buff[3] = CS_HB.CID[3];
	
	printf("发送命令:%#x\n", 0x34);
	
	if((res = write(sockfd, send_buff, len+4)) != len+4){
		printf("发送心跳长度不足len=%d...\n", res);
		return 0;
	}
	printf("发送心跳命令成功...\n");

	if(Readable_timeout(sockfd, SOCK_TIME_OUT) == 0){
		printf("接收心跳超时...\n");
		return 0;
	}
	
	if((len = read(sockfd, recv_buff, 15)) != 15){
		printf("接收数据长度不足...\n");
		return 0;
	}
	printf("心跳接收长度为:%d\n", len);
	memset(input_buff, 0, sizeof(input_buff));
	My_AES_CBC_Decrypt(KEY.KEYB, recv_buff, len, input_buff);
	RePadding(input_buff, len, recv_buff, &slen);
	
	crc[0] = recv_buff[slen-1];
	crc[1] = recv_buff[slen-2];
	if(*(u16*)crc != getCRC(recv_buff, slen-2)){
		printf("心跳CRC校验失败...\n");
		return 0;
	}
	if(recv_buff[6] != 0x43){
		printf("接收心跳命令0x43不正确...\n");
		return 0;
	}
	printf("接收到心跳0x43命令...\n");
	return 1;
}
Пример #12
0
//---------------------------------------------------------------------------
void File_Dpx::Data_Parse()
{
    if (!IsDpx) // Is Cineon
    {
        switch (Element_Code)
        {
            case Pos_GenericSection   : GenericSectionHeader_Cineon(); break;
            case Pos_IndustrySpecific : IndustrySpecificHeader_Cineon(); break;
            case Pos_UserDefined      : UserDefinedHeader_Cineon(); break;
            case Pos_Padding          : Padding(); break;
            case Pos_ImageData        : ImageData(); break;
            default                   : ;
        }
    }
    else
    {
        switch (Element_Code)
        {
            case Pos_GenericSection   : GenericSectionHeader_Dpx(); break;
            case Pos_IndustrySpecific : IndustrySpecificHeader_Dpx(); break;
            case Pos_UserDefined      : UserDefinedHeader_Dpx(); break;
            case Pos_Padding          : Padding(); break;
            case Pos_ImageData        : ImageData(); break;
            default                   : ;
        }
    }

    do
        Sizes_Pos++; //We go automaticly to the next block
    while (Sizes_Pos<Sizes.size() && Sizes[Sizes_Pos]==0);
    if (Sizes_Pos>=Sizes.size())
    {
        Sizes.clear();
        Sizes_Pos=0;

        if (!Status[IsFilled])
            Fill();
        if (File_Offset+Buffer_Offset+Element_Size<Config->File_Current_Size)
            GoTo(Config->File_Current_Size);
    }
}
Пример #13
0
MenuItem* Menu::AddItem(const std::string& name, const std::string& icon_name, const std::string& accelerator)
{
    MenuItem* item = new MenuItem(this);
    item->SetPadding(Padding(2, 4, 4, 4));
    item->SetText(name);
    item->SetImage(icon_name);
    item->SetAccelerator(accelerator);

    _OnAddItem(item);

    return item;
}
Пример #14
0
/*
	Writing numbers with padding.

	@param in number to be written.
	@param decimals decimal places.
	@param row to write the number.
*/
void PaddedWrite(double in, byte decimals, byte row)
{
	// decimal mark
	byte dm = 0;  if(decimals > 0) dm = 1;

	// clear row
	for (byte i = 0; i < (sides[row][1] - sides[row][0]); i++)
	{
		lcd.setCursor(sides[row][0] + i, row);
		lcd.write(' ');
	}
	lcd.setCursor(Padding(in, row) - dm - decimals, row);
	lcd.print((round(in * pow(10, decimals)) / pow(10, decimals)), decimals);
}
Пример #15
0
MenuItem* ComboBox::AddItem(const std::string& label, const std::string& name)
{
    MenuItem* item = _menu->AddItem(label, "");
    item->SetName(name);
    item->SetTextPadding(Padding(2, 0, 0, 0));
    item->_on_selected.Add(this, &ComboBox::OnItemSelected);

    if (_selected_item == nullptr)
    {
        OnItemSelected(item);
    }

    return item;
}
Пример #16
0
BOOL DumpDeviceClass(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo)
/*++

Routine Description:

    Write device class information to stdout

Arguments:

    Devs    )_ uniquely identify device
    DevInfo )

Return Value:

    TRUE if success

--*/
{
    LPTSTR cls;
    LPTSTR guid;

    Padding(1);
    cls = GetDeviceStringProperty(Devs,DevInfo,SPDRP_CLASS);
    guid = GetDeviceStringProperty(Devs,DevInfo,SPDRP_CLASSGUID);
    if(!cls && !guid) {
        FormatToStream(stdout,
                        MSG_DUMP_NOSETUPCLASS
                        );
    } else {
        FormatToStream(stdout,
                        MSG_DUMP_SETUPCLASS,
                        guid ? guid : TEXT("{}"),
                        cls ? cls : TEXT("(?)")
                        );
    }

    if(cls) {
        delete [] cls;
    }
    if(guid) {
        delete [] guid;
    }

    return TRUE;
}
Пример #17
0
int32_t CWelsPreProcess::DownsamplePadding (SPicture* pSrc, SPicture* pDstPic,  int32_t iSrcWidth, int32_t iSrcHeight,
    int32_t iShrinkWidth, int32_t iShrinkHeight, int32_t iTargetWidth, int32_t iTargetHeight) {
  int32_t iRet = 0;
  SPixMap sSrcPixMap;
  SPixMap sDstPicMap;
  memset (&sSrcPixMap, 0, sizeof(sSrcPixMap));
  memset (&sDstPicMap, 0, sizeof(sDstPicMap));
  sSrcPixMap.pPixel[0]   = pSrc->pData[0];
  sSrcPixMap.pPixel[1]   = pSrc->pData[1];
  sSrcPixMap.pPixel[2]   = pSrc->pData[2];
  sSrcPixMap.iSizeInBits = g_kiPixMapSizeInBits;
  sSrcPixMap.sRect.iRectWidth  = iSrcWidth;
  sSrcPixMap.sRect.iRectHeight = iSrcHeight;
  sSrcPixMap.iStride[0]  = pSrc->iLineSize[0];
  sSrcPixMap.iStride[1]  = pSrc->iLineSize[1];
  sSrcPixMap.iStride[2]  = pSrc->iLineSize[2];
  sSrcPixMap.eFormat     = VIDEO_FORMAT_I420;

  if (iSrcWidth != iShrinkWidth || iSrcHeight != iShrinkHeight) {
    int32_t iMethodIdx = METHOD_DOWNSAMPLE;
    sDstPicMap.pPixel[0]   = pDstPic->pData[0];
    sDstPicMap.pPixel[1]   = pDstPic->pData[1];
    sDstPicMap.pPixel[2]   = pDstPic->pData[2];
    sDstPicMap.iSizeInBits = g_kiPixMapSizeInBits;
    sDstPicMap.sRect.iRectWidth  = iShrinkWidth;
    sDstPicMap.sRect.iRectHeight = iShrinkHeight;
    sDstPicMap.iStride[0]  = pDstPic->iLineSize[0];
    sDstPicMap.iStride[1]  = pDstPic->iLineSize[1];
    sDstPicMap.iStride[2]  = pDstPic->iLineSize[2];
    sDstPicMap.eFormat     = VIDEO_FORMAT_I420;

    iRet = m_pInterfaceVp->Process (iMethodIdx, &sSrcPixMap, &sDstPicMap);
  } else {
    memcpy (&sDstPicMap, &sSrcPixMap, sizeof (sDstPicMap));	// confirmed_safe_unsafe_usage
  }

  // get rid of odd line
  iShrinkWidth -= (iShrinkWidth & 1);
  iShrinkHeight -= (iShrinkHeight & 1);
  Padding ((uint8_t*)sDstPicMap.pPixel[0], (uint8_t*)sDstPicMap.pPixel[1], (uint8_t*)sDstPicMap.pPixel[2],
           sDstPicMap.iStride[0], sDstPicMap.iStride[1],	iShrinkWidth, iTargetWidth, iShrinkHeight, iTargetHeight);

  return iRet;
}
Пример #18
0
  /**
   * Walk the pattern chip through the search chip to find the best interest
   *  
   * @param cube [in] The Isis::Cube to look for an interesting area in 
   * @param sample [in] The sample postion in the cube where the chip is located
   * @param line [in] The line postion in the cube where the chip is located 
   *  
   * @return  Returns the status of the operation.  The following conditions can 
   *          occur true=Success, false=Failed
   */
  bool InterestOperator::Operate(Cube &cube, int sample, int line) {
    int pad = Padding();
    Chip chip(2*p_deltaSamp + p_samples + pad, 2*p_deltaLine + p_lines + pad);
    chip.TackCube(sample, line);
    if (p_clipPolygon != NULL) chip.SetClipPolygon(*p_clipPolygon);
    chip.Load(cube);
    // Walk the search chip and find the best interest
    int bestSamp = 0;
    int bestLine = 0;
    double smallestDist = DBL_MAX;
    double bestInterest = Isis::Null;
    for (int lin=p_lines/2 + 1; lin<=2*p_deltaLine+p_lines/2 + 1; lin++) {
      for (int samp=p_samples/2 + 1; samp<=2*p_deltaSamp+p_samples/2 + 1; samp++) {
        Chip subChip = chip.Extract(p_samples+pad, p_lines+pad, samp, lin);
        double interest = Interest(subChip);
        if (interest != Isis::Null) {
          if ((bestInterest == Isis::Null) || CompareInterests(interest,bestInterest)) {
            double dist = std::sqrt(std::pow(sample-samp,2.0)+std::pow(line-lin,2.0));
            if (interest == bestInterest && dist>smallestDist) {
              continue;
            } else {
              bestInterest = interest;
              bestSamp = samp;
              bestLine = lin;
              smallestDist = dist;
            }
          }
        }
      }
    }

    // Check to see if we went through the interest chip and never got a interest at
    // any location.
    if (bestInterest == Isis::Null || bestInterest<p_minimumInterest) return false;

    p_interestAmount = bestInterest;
    chip.SetChipPosition(bestSamp, bestLine);
    p_cubeSample = chip.CubeSample();
    p_cubeLine   = chip.CubeLine();
    return true;
  }
Пример #19
0
int CServer_send(int sockfd, unsigned char *buff, unsigned int len)
{
	u8 	input_buff[128] = {0};
	u8	send_buff[128] = {0};
	u8	recv_buff[1024] = {0};
	u8	crc[2];
	int slen = 0, res = 0;
	int i;
	memcpy(send_buff, buff, len);
	Padding(send_buff, len, input_buff, &slen);
	memset(send_buff, 0, len);
	My_AES_CBC_Encrypt(KEY.KEYB,input_buff, slen, send_buff+4);
	send_buff[0] = buff[8];
	send_buff[1] = buff[9];
	send_buff[2] = buff[10];
	send_buff[3] = buff[11];

	for(i = 0; i< slen+4; i++)
		printf("%d ", send_buff[i]);
	printf("\n发送命令:%#x\n 长度:%d\n", buff[7], slen+4);
	if((res = write(sockfd, send_buff, slen+4))!=slen+4){
		printf("发送数据不足:len=%d\n", res);
		return 0;
	}
	if(Readable_timeout(sockfd, SOCK_TIME_OUT) == 0){
		printf("接收回复超时...\n");
		return 0;
	}
	if( !(res = read(sockfd, recv_buff, sizeof(recv_buff)))){
		printf("接收失败,服务器关闭套接口...\n");
		return 0;
	}
	
	if( !CServer_recv_deal(recv_buff, res))
	{
		printf("接收数据处理失败...\n");
		return 0;
	}
	printf("接收数据成功...\n");
	return 1;
}
Пример #20
0
GWEN_CONTROL_CONSTRUCTOR(ComboBox, Button)
{
    _menu = new Menu(this);
    _menu->SetHidden(true);
    _menu->SetIconMarginDisabled(true);
    _menu->SetTabable(false);

    ControlsInternal::ComboBoxDownArrow* down_arrow = new ControlsInternal::ComboBoxDownArrow(this);
    down_arrow->SetComboBox(this);

    _button = down_arrow;
    _selected_item = nullptr;

    SetAlignment(Position::LEFT | Position::CENTER_V);
    SetKeyboardInputEnabled(true);
    SetMargin(Margin(3, 0, 0, 0));
    SetSize(100, 20);
    SetTabable(true);
    SetText("");
    SetTextPadding(Padding(4, 0, 0, 0));
}
Пример #21
0
GWEN_CONTROL_CONSTRUCTOR(ProgressBar, Label)
{
    _bar_padding = Gwen::Padding(2, 2, 2, 2);
    _progress = 0;
    _maximum_progress = 100;
    _display_label = true;
    _as_percentage = true;

    SetAlignment(Position::CENTER);
    SetBounds(Rectangle(0, 0, 128, 32));
    SetHorizontal();
    SetMouseInputEnabled(true);
    SetTextPadding(Padding(3, 0, 3, 0));

    Gwen::Skin::Base* skin = GetSkin();
    assert(skin != nullptr);
    if (skin != nullptr)
    {
        SetColor(skin->Colors.ProgressBar.Bar);
        SetTextColor(skin->Colors.ProgressBar.Text);
    }
}
Пример #22
0
int CServ_conn_req(int sockfd,  u32 cid)
{
	u8 	input_buff[128] = {0};
	u8	send_buff[128] = {0};
	u8	recv_buff[128] = {0};
	u8	aes_buff[128] = {0};
	int 	len = 0;
	int slen = 0;
	int i;
	unsigned char *p = (u8*)CServer_req;

//	signal(SIGALRM, commu_alarm);

	protocol_CSREQ_ready();
//	for(i = 0; i<=27;i++)
//		printf("%d ", p[i]);
//	printf("\n");
	
	memcpy(send_buff, (u8*)CServer_req, 28);
	Padding(send_buff, 28, input_buff, &len);
	printf("padding....%d\n", input_buff[len-1]);
	memset(send_buff, 0, 128);
// 报错。。。。
	My_AES_CBC_Encrypt(KEY.KEYB, input_buff, len, aes_buff); 
	My_AES_CBC_Decrypt(KEY.KEYB, aes_buff, len, input_buff);
	memset(aes_buff, 0, sizeof(aes_buff));
	RePadding(input_buff, len, aes_buff, &slen);
//	for(i = 0; i<=slen-1;i++)
//		printf("%d ", aes_buff[i]);
//	printf("\n");
	
	memset(input_buff, 0, sizeof(input_buff));
	Padding(aes_buff, 28, input_buff, &len);
	memset(send_buff, 0, 128);
// 报错。。。。
	memset(aes_buff, 0, sizeof(aes_buff));
	My_AES_CBC_Encrypt(KEY.KEYB, input_buff, len, aes_buff);
	 

	memcpy(send_buff+4, aes_buff, len);
	send_buff[0] = ConnectREQ.CID[0];
	send_buff[1] = ConnectREQ.CID[1];
	send_buff[2] = ConnectREQ.CID[2];
	send_buff[3] = ConnectREQ.CID[3];
//	for(i = 0; i<36;i++)
//		printf("%d ", send_buff[i]);
//	printf("\n");
	printf("确认连接长度...\n");

	int res = -1;
	if(write(sockfd, send_buff, len+4) != (len + 4)){
		return 0;
	}
	printf("data len:%d\n", len+4);
	printf("send data to connect success...\n");

	// 读取回复
	sleep(1);
//	alarm(SOCK_TIME_OUT);
	if(Readable_timeout(sockfd, SOCK_TIME_OUT)==0)
	{
		printf("connect server receive timeout...\n");
		return 0;
	}
	if(!(res = read(sockfd, recv_buff, sizeof(recv_buff))) ){
//		alarm(0);
//		write(sockfd, "helloworld", 10);
		printf("接收len = %d connect server失败...\n", res);
		return 0;
	}
//	alarm(0);
	memset(input_buff, 0, sizeof(input_buff));
	My_AES_CBC_Decrypt(KEY.KEYB, recv_buff, res, input_buff);
	memset(send_buff, 0, sizeof(send_buff));
	RePadding(input_buff, res, recv_buff, &slen);
	
	printf("decode len:%d\n", slen);
	u8	crc[2];
	crc[0] = recv_buff[27];
	crc[1] = recv_buff[26];
	if( *(u16 *)crc !=getCRC(recv_buff, 26)){
		printf("recv connect server crc  error...\n");
		return 0;
	}

	if(recv_buff[7] != 0x21)
	{
		printf("CServer command x021 error...\n");
		return 0;
	}
	printf("recv command:%#x\n", 0x21);
	free(CServer_req);

	return 1;
}
Пример #23
0
static void 
TextBox_Init( LCUI_Widget *widget )
/* 初始化文本框相关数据 */
{
	LCUI_TextBox *textbox;
	
	widget->valid_state = WIDGET_STATE_ACTIVE | WIDGET_STATE_OVERLAY;
	widget->valid_state |= (WIDGET_STATE_NORMAL | WIDGET_STATE_DISABLE);
	textbox = WidgetPrivData_New(widget, sizeof(LCUI_TextBox));
	textbox->text = Widget_New( "label" );
	textbox->cursor = Widget_New( NULL );
	textbox->scrollbar[0] = Widget_New( "scrollbar" );
	textbox->scrollbar[1] = Widget_New( "scrollbar" );
	/* 不可获得焦点 */
	textbox->text->focus = FALSE;
	textbox->cursor->focus = FALSE;
	textbox->scrollbar[0]->focus = FALSE;
	textbox->scrollbar[1]->focus = FALSE;
	textbox->limit_mode = 0;
	textbox->block_size = 256;
	textbox->show_placeholder = FALSE;
	LCUIWString_Init( &textbox->placeholder );
	TextStyle_Init( &textbox->placeholder_style );
	TextStyle_FontColor( &textbox->placeholder_style, RGB(100,100,100) );
	Label_AutoSize( textbox->text, FALSE, 0 );
	Widget_SetSize( textbox->text, "100%", "100%" );
	
	/* 添加至相应的容器 */
	Widget_Container_Add( textbox->text, textbox->cursor ); 
	Widget_Container_Add( widget, textbox->text ); 
	Widget_Container_Add( widget, textbox->scrollbar[0] );
	Widget_Container_Add( widget, textbox->scrollbar[1] );
	/* 设置滚动条的尺寸 */
	Widget_SetSize( textbox->scrollbar[0], "10px", NULL );
	Widget_SetSize( textbox->scrollbar[1], NULL, "10px" );
	Widget_SetAlign( textbox->scrollbar[0], ALIGN_TOP_RIGHT, Pos(0,0) );
	Widget_SetAlign( textbox->scrollbar[1], ALIGN_BOTTOM_LEFT, Pos(0,0) );
	/* 滚动条设为横向 */
	ScrollBar_SetDirection( textbox->scrollbar[1], 1 );
	/* 将回调函数与滚动条连接 */
	ScrollBar_Connect( textbox->scrollbar[0], TextBox_TextLayer_VertScroll, widget );
	ScrollBar_Connect( textbox->scrollbar[1], TextBox_HoriScroll_TextLayer, widget );
	Widget_Show( textbox->text );
	
	Queue_Init( &textbox->text_block_buff, sizeof(LCUI_TextBlock), destroy_textblock );
	
	TextLayer_UsingStyleTags( Label_GetTextLayer(textbox->text), FALSE );
	Widget_SetPadding( widget, Padding(2,2,2,2) );
	Widget_SetBackgroundColor( textbox->cursor, RGB(0,0,0) );
	Widget_SetBackgroundTransparent( textbox->cursor, FALSE );
	Widget_SetBackgroundTransparent( widget, FALSE );
	
	Widget_Resize( textbox->cursor, Size(1, 14) );
	/* 设置可点击区域的alpha值要满足的条件 */
	Set_Widget_ClickableAlpha( textbox->cursor, 0, 1 );
	Set_Widget_ClickableAlpha( textbox->text, 0, 1 );
	
	/* 设定定时器,每1秒闪烁一次 */
	if( __timer_id == -1 ) {
		__timer_id = set_timer( 500, blink_cursor, TRUE );
	}
	Widget_Event_Connect( widget, EVENT_DRAG, TextBox_TextLayer_Click );
	/* 关联 FOCUS_OUT 和 FOCUS_IN 事件 */
	Widget_Event_Connect( widget, EVENT_FOCUSOUT, _putout_textbox_cursor );
	Widget_Event_Connect( widget, EVENT_FOCUSIN, _putin_textbox_cursor );
	/* 关联按键输入事件 */
	Widget_Event_Connect( widget, EVENT_KEYBOARD, TextBox_Input );
	/* 默认不启用多行文本模式 */
	TextBox_Multiline( widget, FALSE );
}
Пример #24
0
 int RowWidth() const {
   return Width() - Padding() * 2;
 }
Пример #25
0
 int Height() const {
   return ( mHistory.count() - 1 ) * RowSpacing() + // Spacing between items
     mHistory.count() * RowHeight() + // Height per item
     TitleHeight() + RowSpacing() + // Title
     Padding() * 2; // Overall padding
 }
Пример #26
0
const Padding Object::getSizeHintPadding () const
{
  Evas_Coord l, r, t, b;
  evas_object_size_hint_padding_get (o, &l, &r, &t, &b);
  return Padding (l, r, t, b);
}
Пример #27
0
BOOL DumpDeviceDriverFiles(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo)
/*++

Routine Description:

    Dump information about what files were installed for driver package
    <tab>Installed using OEM123.INF section [abc.NT]
    <tab><tab>file...

Arguments:

    Devs    )_ uniquely identify device
    DevInfo )

Return Value:

    none

--*/
{
    //
    // do this by 'searching' for the current driver
    // mimmicing a copy-only install to our own file queue
    // and then parsing that file queue
    //
    SP_DEVINSTALL_PARAMS deviceInstallParams;
    SP_DRVINFO_DATA driverInfoData;
    SP_DRVINFO_DETAIL_DATA driverInfoDetail;
    HSPFILEQ queueHandle = INVALID_HANDLE_VALUE;
    DWORD count;
    DWORD scanResult;
    BOOL success = FALSE;

    ZeroMemory(&driverInfoData,sizeof(driverInfoData));
    driverInfoData.cbSize = sizeof(driverInfoData);

    if(!FindCurrentDriver(Devs,DevInfo,&driverInfoData)) {
        Padding(1);
        FormatToStream(stdout, MSG_DUMP_NO_DRIVER);
        return FALSE;
    }

    //
    // get useful driver information
    //
    driverInfoDetail.cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
    if(!SetupDiGetDriverInfoDetail(Devs,DevInfo,&driverInfoData,&driverInfoDetail,sizeof(SP_DRVINFO_DETAIL_DATA),NULL) &&
       GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
        //
        // no information about driver or section
        //
        goto final;
    }
    if(!driverInfoDetail.InfFileName[0] || !driverInfoDetail.SectionName[0]) {
        goto final;
    }

    //
    // pretend to do the file-copy part of a driver install
    // to determine what files are used
    // the specified driver must be selected as the active driver
    //
    if(!SetupDiSetSelectedDriver(Devs, DevInfo, &driverInfoData)) {
        goto final;
    }

    //
    // create a file queue so we can look at this queue later
    //
    queueHandle = SetupOpenFileQueue();

    if ( queueHandle == (HSPFILEQ)INVALID_HANDLE_VALUE ) {
        goto final;
    }

    //
    // modify flags to indicate we're providing our own queue
    //
    ZeroMemory(&deviceInstallParams, sizeof(deviceInstallParams));
    deviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
    if ( !SetupDiGetDeviceInstallParams(Devs, DevInfo, &deviceInstallParams) ) {
        goto final;
    }

    //
    // we want to add the files to the file queue, not install them!
    //
    deviceInstallParams.FileQueue = queueHandle;
    deviceInstallParams.Flags |= DI_NOVCP;

    if ( !SetupDiSetDeviceInstallParams(Devs, DevInfo, &deviceInstallParams) ) {
        goto final;
    }

    //
    // now fill queue with files that are to be installed
    // this involves all class/co-installers
    //
    if ( !SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES, Devs, DevInfo) ) {
        goto final;
    }

    //
    // we now have a list of delete/rename/copy files
    // iterate the copy queue twice - 1st time to get # of files
    // 2nd time to get files
    // (WinXP has API to get # of files, but we want this to work
    // on Win2k too)
    //

    count = 0;
    scanResult = 0;
    //
    // call once to count
    //
    SetupScanFileQueue(queueHandle,SPQ_SCAN_USE_CALLBACK,NULL,DumpDeviceDriversCallback,&count,&scanResult);
    Padding(1);
    FormatToStream(stdout, count ? MSG_DUMP_DRIVER_FILES : MSG_DUMP_NO_DRIVER_FILES, count, driverInfoDetail.InfFileName, driverInfoDetail.SectionName);
    //
    // call again to dump the files
    //
    SetupScanFileQueue(queueHandle,SPQ_SCAN_USE_CALLBACK,NULL,DumpDeviceDriversCallback,NULL,&scanResult);

    success = TRUE;

final:
Пример #28
0
BOOL DumpDeviceResources(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo)
/*++

Routine Description:

    Dump Resources to stdout

Arguments:

    Devs    )_ uniquely identify device
    DevInfo )

Return Value:

    none

--*/
{
    SP_DEVINFO_LIST_DETAIL_DATA devInfoListDetail;
    ULONG status = 0;
    ULONG problem = 0;
    LOG_CONF config = 0;
    BOOL haveConfig = FALSE;

    //
    // see what state the device is in
    //
    devInfoListDetail.cbSize = sizeof(devInfoListDetail);
    if((!SetupDiGetDeviceInfoListDetail(Devs,&devInfoListDetail)) ||
            (CM_Get_DevNode_Status_Ex(&status,&problem,DevInfo->DevInst,0,devInfoListDetail.RemoteMachineHandle)!=CR_SUCCESS)) {
        return FALSE;
    }

    //
    // see if the device is running and what resources it might be using
    //
    if(!(status & DN_HAS_PROBLEM)) {
        //
        // If this device is running, does this devinst have a ALLOC log config?
        //
        if (CM_Get_First_Log_Conf_Ex(&config,
                                     DevInfo->DevInst,
                                     ALLOC_LOG_CONF,
                                     devInfoListDetail.RemoteMachineHandle) == CR_SUCCESS) {
            haveConfig = TRUE;
        }
    }
    if(!haveConfig) {
        //
        // If no config so far, does it have a FORCED log config?
        // (note that technically these resources might be used by another device
        // but is useful info to show)
        //
        if (CM_Get_First_Log_Conf_Ex(&config,
                                     DevInfo->DevInst,
                                     FORCED_LOG_CONF,
                                     devInfoListDetail.RemoteMachineHandle) == CR_SUCCESS) {
            haveConfig = TRUE;
        }
    }

    if(!haveConfig) {
        //
        // if there's a hardware-disabled problem, boot-config isn't valid
        // otherwise use this if we don't have anything else
        //
        if(!(status & DN_HAS_PROBLEM) || (problem != CM_PROB_HARDWARE_DISABLED)) {
            //
            // Does it have a BOOT log config?
            //
            if (CM_Get_First_Log_Conf_Ex(&config,
                                         DevInfo->DevInst,
                                         BOOT_LOG_CONF,
                                         devInfoListDetail.RemoteMachineHandle) == CR_SUCCESS) {
                haveConfig = TRUE;
            }
        }
    }

    if(!haveConfig) {
        //
        // if we don't have any configuration, display an apropriate message
        //
        Padding(1);
        FormatToStream(stdout,(status & DN_STARTED) ? MSG_DUMP_NO_RESOURCES : MSG_DUMP_NO_RESERVED_RESOURCES );
        return TRUE;
    }
    Padding(1);
    FormatToStream(stdout,(status & DN_STARTED) ? MSG_DUMP_RESOURCES : MSG_DUMP_RESERVED_RESOURCES );

    //
    // dump resources
    //
    DumpDeviceResourcesOfType(DevInfo->DevInst,devInfoListDetail.RemoteMachineHandle,config,ResType_All);

    //
    // release handle
    //
    CM_Free_Log_Conf_Handle(config);

    return TRUE;
}
Пример #29
0
BOOL DumpDeviceResourcesOfType(_In_ DEVINST DevInst, _In_ HMACHINE MachineHandle, _In_ LOG_CONF Config, _In_ RESOURCEID ReqResId)
{
    RES_DES prevResDes = (RES_DES)Config;
    RES_DES resDes = 0;
    RESOURCEID resId = ReqResId;
    ULONG dataSize;
    PBYTE resDesData;
    BOOL  retval = FALSE;

    UNREFERENCED_PARAMETER(DevInst);

    while(CM_Get_Next_Res_Des_Ex(&resDes,prevResDes,ReqResId,&resId,0,MachineHandle)==CR_SUCCESS) {
        if(prevResDes != Config) {
            CM_Free_Res_Des_Handle(prevResDes);
        }
        prevResDes = resDes;
        if(CM_Get_Res_Des_Data_Size_Ex(&dataSize,resDes,0,MachineHandle)!=CR_SUCCESS) {
            continue;
        }
        resDesData = new BYTE[dataSize];
        if(!resDesData) {
            continue;
        }
        if(CM_Get_Res_Des_Data_Ex(resDes,resDesData,dataSize,0,MachineHandle)!=CR_SUCCESS) {
            delete [] resDesData;
            continue;
        }
        switch(resId) {
            case ResType_Mem: {

                PMEM_RESOURCE  pMemData = (PMEM_RESOURCE)resDesData;
                if(pMemData->MEM_Header.MD_Alloc_End-pMemData->MEM_Header.MD_Alloc_Base+1) {
                    Padding(2);
                    _tprintf(TEXT("MEM : %08I64x-%08I64x\n"),pMemData->MEM_Header.MD_Alloc_Base,pMemData->MEM_Header.MD_Alloc_End);
                    retval = TRUE;
                }
                break;
            }

            case ResType_IO: {

                PIO_RESOURCE   pIoData = (PIO_RESOURCE)resDesData;
                if(pIoData->IO_Header.IOD_Alloc_End-pIoData->IO_Header.IOD_Alloc_Base+1) {
                    Padding(2);
                    _tprintf(TEXT("IO  : %04I64x-%04I64x\n"),pIoData->IO_Header.IOD_Alloc_Base,pIoData->IO_Header.IOD_Alloc_End);
                    retval = TRUE;
                }
                break;
            }

            case ResType_DMA: {

                PDMA_RESOURCE  pDmaData = (PDMA_RESOURCE)resDesData;
                Padding(2);
                _tprintf(TEXT("DMA : %u\n"),pDmaData->DMA_Header.DD_Alloc_Chan);
                retval = TRUE;
                break;
            }

            case ResType_IRQ: {

                PIRQ_RESOURCE  pIrqData = (PIRQ_RESOURCE)resDesData;

                Padding(2);
                _tprintf(TEXT("IRQ : %u\n"),pIrqData->IRQ_Header.IRQD_Alloc_Num);
                retval = TRUE;
                break;
            }
        }
        delete [] resDesData;
    }
    if(prevResDes != Config) {
        CM_Free_Res_Des_Handle(prevResDes);
    }
    return retval;
}
Пример #30
0
BOOL DumpDeviceStatus(_In_ HDEVINFO Devs, _In_ PSP_DEVINFO_DATA DevInfo)
/*++

Routine Description:

    Write device status to stdout

Arguments:

    Devs    )_ uniquely identify device
    DevInfo )

Return Value:

    none

--*/
{
    SP_DEVINFO_LIST_DETAIL_DATA devInfoListDetail;
    ULONG status = 0;
    ULONG problem = 0;
    BOOL hasInfo = FALSE;
    BOOL isPhantom = FALSE;
    CONFIGRET cr = CR_SUCCESS;

    devInfoListDetail.cbSize = sizeof(devInfoListDetail);
    if((!SetupDiGetDeviceInfoListDetail(Devs,&devInfoListDetail)) ||
            ((cr = CM_Get_DevNode_Status_Ex(&status,&problem,DevInfo->DevInst,0,devInfoListDetail.RemoteMachineHandle))!=CR_SUCCESS)) {
        if ((cr == CR_NO_SUCH_DEVINST) || (cr == CR_NO_SUCH_VALUE)) {
            isPhantom = TRUE;
        } else {
            Padding(1);
            FormatToStream(stdout,MSG_DUMP_STATUS_ERROR);
            return FALSE;
        }
    }
    //
    // handle off the status/problem codes
    //
    if (isPhantom) {
        Padding(1);
        FormatToStream(stdout,MSG_DUMP_PHANTOM);
        return TRUE;
    }
    if((status & DN_HAS_PROBLEM) && problem == CM_PROB_DISABLED) {
        hasInfo = TRUE;
        Padding(1);
        FormatToStream(stdout,MSG_DUMP_DISABLED);
        return TRUE;
    }
    if(status & DN_HAS_PROBLEM) {
        hasInfo = TRUE;
        Padding(1);
        FormatToStream(stdout,MSG_DUMP_PROBLEM,problem);
    }
    if(status & DN_PRIVATE_PROBLEM) {
        hasInfo = TRUE;
        Padding(1);
        FormatToStream(stdout,MSG_DUMP_PRIVATE_PROBLEM);
    }
    if(status & DN_STARTED) {
        Padding(1);
        FormatToStream(stdout,MSG_DUMP_STARTED);
    } else if (!hasInfo) {
        Padding(1);
        FormatToStream(stdout,MSG_DUMP_NOTSTARTED);
    }
    return TRUE;
}