Exemple #1
0
void TaskToolbar::DeleteButtons()
{
	DeleteButton(ID_TASK_COPY_TAGGED);
	DeleteButton(ID_TASK_GEN_SLIDE_SHOW);
	DeleteButton(ID_TASK_EXPORT);
	DeleteButton(ID_TASK_EXTRACT_JPEG);
	DeleteButton(ID_TASK_DELETE);
}
//================================================================================================================
void MenuEditorSystem::OnMouseDown(WPARAM btnState, int x, int y)
{
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		if (dragStartX == -1)
		{
			dragStartX = x;
			dragStartY = y;
		}

		dragPrevX = x;
		dragPrevY = y;
		
		stampPressed = true;
		
		CalculateSelectedMousePosition(x, y);
		
		// Adds a new button to the menu from the selected button image in the button cache if in button
		// place mode
		AddButton();
		
		// Selects a button so it can be moved, if it is moving then this will be skipped
		// so that the button can be placed back on the menu with a left click
		bool goingToMove = MoveButtonStart();
		// If a button is being moved place the button at the clicked position if in button move mode
		if (!goingToMove) MoveButtonEnd();
		
		// Selects a button so it can be cloned, if it is moving then this will be skipped
		// so that the button clone can be added to the menu with a left click
		bool goingToClone = CloneButtonStart();
		// If a button is being moved place the button at the clicked position if in button clone mode
		if (!goingToClone) CloneButtonEnd();
		
		// Selects a button on the menu and deletes it if in button delete mode
		DeleteButton();
		
		// Selects the button to be resized if in button resize mode
		ResizeButtonStart();
		
		// If applicable, Add a text if in text mode
		AddText();
		
		// Selects a text so it can be moved, if it is moving then this will be skipped
		// so that the text can be placed back on the menu with a left click
		goingToMove = MoveTextStart();
		// If a text is being moved place the text at the clicked position if in text move mode
		if (!goingToMove) MoveTextEnd();
		
		// Selects a text so it can be cloned, if it is moving then this will be skipped
		// so that the text clone can be added to the menu with a left click
		goingToClone = CloneTextStart();
		// If a text is being moved place the text at the clicked position if in text clone mode
		if (!goingToClone) CloneTextEnd();
		
		// Selects a text on the menu and deletes it if in text delete mode
		DeleteText();
	}
}
Exemple #3
0
void CNativeToolbar::alignSeparatorWidth()
{
    int nSepPos = -1;
    for ( int i = 0; i < (int)m_arButtons.size()-1; i++ )
    {
        if ( m_arButtons.elementAt(i)->isSeparator() )
        {
            if ( nSepPos == -1 )
                nSepPos = i;
            else
                return; //if more than one separator, do anything
        }
    }

    if ( nSepPos == -1 )
        return;

    //right align all buttons after single separator
    CRect rcFirstBtn, rcLastBtn, rcToolbar, rcSep;
    GetItemRect(0,&rcFirstBtn);
    GetItemRect(m_arButtons.size()-1,&rcLastBtn);
    GetItemRect(nSepPos,&rcSep);
    getAppWindow().GetClientRect(&rcToolbar);
    int nAdd = rcToolbar.Width() - 2*rcFirstBtn.left - rcLastBtn.right;
    int nSepWidth = rcSep.Width();
    nSepWidth += nAdd;
    if ( nSepWidth < 0 )
        nSepWidth = 0;
    
    m_arButtons.elementAt(nSepPos)->m_nItemWidth = nSepWidth;

    DeleteButton(nSepPos);
    TBBUTTON btn = {0};
/*
    if ( nSepWidth <= 114 ) //maximum size for empty button
    {
        btn.fsStyle = TBSTYLE_BUTTON;
        btn.iBitmap = I_IMAGENONE;
            
        InsertButton(nSepPos, &btn);

        TBBUTTONINFO oBtnInfo = {0};
        oBtnInfo.cbSize = sizeof(TBBUTTONINFO);
        oBtnInfo.dwMask = TBIF_BYINDEX|TBIF_SIZE;

        oBtnInfo.cx = nSepWidth;

        SetButtonInfo(nSepPos, &oBtnInfo);

    }else   */
    {
        btn.fsStyle = TBSTYLE_SEP;
        btn.iBitmap = nSepWidth;

        InsertButton(nSepPos, &btn);
    }

    AutoSize();
}
HRESULT CMenuToolbarBase::ClearToolbar()
{
    while (DeleteButton(0))
    {
        // empty;
    }
    m_hasSizes = FALSE;
    return S_OK;
}
void CMuleToolbarCtrl::OnTbnReset(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
{
	// First get rid of old buttons
	// while saving their states
	for (int i = GetButtonCount()-1; i >= 0; i--)
	{
		TBBUTTON Button;
		GetButton(i, &Button);
		for (int j = 0; j < m_buttoncount ; j++)
		{
			if (TBButtons[j].idCommand == Button.idCommand)
			{
				TBButtons[j].fsState = Button.fsState;
				TBButtons[j].fsStyle = Button.fsStyle;
				TBButtons[j].iString = Button.iString;
			}
		}
		DeleteButton(i);
	}

	TBBUTTON sepButton;
	sepButton.idCommand = 0;
	sepButton.fsStyle = TBSTYLE_SEP;
	sepButton.fsState = TBSTATE_ENABLED;
	sepButton.iString = -1;
	sepButton.iBitmap = -1;
	
	// set default configuration 
	CString config = strDefaultToolbar;
	// MORPH START show less controls
	if (thePrefs.IsLessControls())
		config=strDefaultLessControlsToolbar;
	// MORPH END  show less controls

	for (int i = 0; i <config.GetLength(); i += 2)
	{
		int index = _tstoi(config.Mid(i, 2));
		if (index == 99)
		{
			AddButtons(1, &sepButton);
			continue;
		}
		AddButtons(1, &TBButtons[index]);
	}

	// save new (default) configuration 
	thePrefs.SetToolbarSettings(config);

	Localize();		// we have to localize the button-text

	theApp.emuledlg->ShowConnectionState();

	ChangeTextLabelStyle(thePrefs.GetToolbarLabelSettings(), false, true);
	SetAllButtonsWidth();	// then calc and set the button width
	AutoSize();
}
Exemple #6
0
void CNativeToolbar::removeAllButtons()
{
    if ( m_hWnd )
    {
        int nCount = GetButtonCount();
        for( int i = 0; i < nCount; i++)
            DeleteButton(0);

        SetImageList(NULL);
    }

    m_listImages.Destroy();
    m_arButtons.removeAllElements();
}
void CToolBarCtrlX::DeleteAllButtons()
{
	int iButtons = GetButtonCount();
	for (int i = 0; i < iButtons; i++)
		DeleteButton(0);
}
//================================================================================================================
void MenuEditorSystem::OnMouseMove(WPARAM btnState, int x, int y)
{
	int dX, dY, tdX, tdY;
	
	// Calculate movement delta from previous frame
	if (dragPrevX != -1)
	{
		dX = x - dragPrevX;
		dY = y - dragPrevY;
		tdX = x - dragStartX;
		tdY = y - dragStartY;
	}
	
	if (gridMode == GM_Snap)
	{
		XMFLOAT2 selToolPoint = SnapToGrid(x, y);
		
		m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0);
		
		// Move a button display cover if in button mode
		UpdateDisplaySprite(selToolPoint.x, selToolPoint.y);
		
		// If a button or text is being moved then continue to move it
		MoveButton(selToolPoint.x, selToolPoint.y);
		MoveText(selToolPoint.x, selToolPoint.y);
		
		HighlightButton(selToolPoint.x, selToolPoint.y);
		HighlightText(selToolPoint.x, selToolPoint.y);
	}
	else
	{
		// Move a button display cover if in button mode
		UpdateDisplaySprite(x, y);
		
		// If a button or text is being moved then continue to move it
		MoveButton(x, y);
		MoveText(x, y);
		
		HighlightButton(x, y);
		HighlightText(x, y);
	}
	
	// Start a left button drag of an item
	if ((btnState & MK_LBUTTON) != 0)
	{
		CalculateSelectedMousePosition(x, y);
		
		stampPressed = true;
		
		// If applicable, Add a button
		AddButton();
		
		// If applicable, Add a text
		AddText();
		
		// Selects a button on the map and deletes it if in button delete mode
		DeleteButton();
		
		// Selects a text on the map and deletes it if in text delete mode
		DeleteText();
	}
	
	// Remember current mouse co-ordinates for next frame
	if (dragPrevX != -1)
	{
		dragPrevX = x;
		dragPrevY = y;
	}
}
Exemple #9
0
void TestBtn(void)
{
	PWindow pWinSon0 = NULL;
	PButton pBtnSon0 = NULL;
	PEditView pEditSon0 = NULL;
	PCheckBox pBkBoxSon0 = NULL;
	PWindow pWinParent = NULL;
	int iRnd;
	int i;
	int iParent;
	CRect rect;
	CFont font;
	CBrush brush;
	INT iID;

	iID = 1;

	InitHeapPool(INIT_HEAP_DEFAULT);

	InitGUI();
	Log("start...\n");

	pWinParent = CreateWindowE(0, pWinRoot, iID++);

	rect.m_iLeft = 10;
	rect.m_iTop = 10;
	rect.m_iHeigh = 200;
	rect.m_iWidth = 300;

	pWinParent->m_pfSelWinRect(P2H(pWinParent), &rect, NULL);
	SetWinBKColor(pWinParent, 0xFF000000);

	pBtnSon0 = CreateButton(pWinParent, iID++, "btn1", 0, WIN_MSG_BUTTON, WinOnUsrProc);
	rect.m_iLeft = 80;
	rect.m_iTop = 10;
	rect.m_iHeigh = 50;
	rect.m_iWidth = 50;
	pBtnSon0->m_pfSelWinRect(P2H(pBtnSon0), &rect, NULL);
	SetWinBKColor(&pBtnSon0->m_baseWin, 0xFF00FF00);
	font.m_color = 0xFF000000;

	pBtnSon0->m_pfSelWinFont(P2H(pBtnSon0), &font, NULL);

	pWinSon0 = CreateWindowE(0, pWinParent, iID++);
	rect.m_iLeft = 50;
	rect.m_iTop = 10;
	rect.m_iHeigh = 50;
	rect.m_iWidth = 50;
	pWinSon0->m_pfSelWinRect(P2H(pWinSon0), &rect, NULL);
	SetWinBKColor(pWinSon0, 0xFFFF0000);

	pEditSon0 = CreateEditView(pWinParent, iID++, "you are pig stupid, fool is your nick name kill youyou are pig stupid, fool is your nick name kill you", 0/*EDIT_VIEW_MULTI_LINE*/);
	rect.m_iLeft = 30;
	rect.m_iTop = 90;
	rect.m_iHeigh = 50;
	rect.m_iWidth = 100;
	pEditSon0->m_pfSelWinRect(P2H(pEditSon0), &rect, NULL);
	pEditSon0->m_pfSelWinFont(P2H(pEditSon0), &font, NULL);
	brush.m_color = 0xFFFFFFFF;
	pEditSon0->m_pfSelWinBrush(P2H(pEditSon0), &brush, NULL);
	pEditSon0->m_iCurEdit =  10;

	pBkBoxSon0 = CreateCheckBox(pWinParent, iID++, "CheckMe", TRUE, 0);
	rect.m_iLeft = 146;
	rect.m_iTop = 80;
	rect.m_iHeigh = 24;
	rect.m_iWidth = 100;
	pBkBoxSon0->m_pfSelWinRect(P2H(pBkBoxSon0), &rect, NULL);
	pBkBoxSon0->m_pfSelWinFont(P2H(pBkBoxSon0), &font, NULL);
	brush.m_color = 0xFFFF00FF;
	pBkBoxSon0->m_pfSelWinBrush(P2H(pBkBoxSon0), &brush, NULL);

	Log("window flow...\n");
	FlowWindow0(pWinRoot, WindowFlow);

	//pWinTmp = FindWindowByID(25);
	//Log("find...");
	//WindowFlow(pWinTmp);

	PrintScreen();

#if 0
	pWinTmp = FindWindowByID(2);

	if(pWinTmp == NULL)
	{
		Log("NULL pointer\r\n");
	}

	Log("OK\r\n");

	ReorderWindow(pWinTmp);
	FlowWindow0(pWinRoot, WindowFlow);
#endif


	while(TRUE)
	{
		int x;
		int y;
		int iRet;
		PPoint pPoint;
		scanf("%d %d", &x, &y);
		pPoint = (PPoint)Malloc(sizeof(CPoint));
		pPoint->m_iX = x;
		pPoint->m_iY = y;

		iRet = pWinRoot->m_pfPostMessage(P2H(pWinRoot), WIN_MSG_ID_CLICK_SCREEN_DOWN, 0, pPoint);
		Log("iRet[%d]\r\n", iRet);
		WinFlowMain();

		FlowWindow0(pWinRoot, WindowFlow);
		PrintScreen();
	}

	DeleteEditView(pEditSon0);
	DeleteButton(pBtnSon0);
}
Exemple #10
0
char Proc_Display(char *NC)
{
  CHECK_BOX Disp_Check[3]                            ;
  char key,Event,temp[1],active_digit,rx_char        ;
  char index,down_id=0xFF,i,flicker = 0              ;
  union
  {
    unsigned int  pos[2]                             ;
    char byte[4]                                     ;
  }TPoint                                            ;
  Color     = Black                                  ;
  Color_BK  = 0xEF9F                                 ;
  Clear_LCD(Color_BK)                                ;
  DrawRectFill(0,0,240,25,Blue)                      ;
  DrawRectFill(0,295,240,25,Blue)                    ;
  ShowIcon24(217,0,24,23,ICON_CLOSE)                 ;
  Color    = 0xFFFF                                  ;
  Color_BK = Blue                                    ;
  PutStringCN16(4,4,"数码管控制")                    ;
  PutStringCN16(200,300,"退出")                      ;
  Color    = Black                                   ;
  Color_BK = WINDOW_BK_COLOR                         ;
  DrawFrame(3,80,232,48)                             ;
  DrawRectFill(4,81,232,46,Black)                    ;
  DrawPanel(6,160,228,72,"")                         ;
  CreateButton(1,"<",15, 175,45,20)                 ;
  CreateButton(2,">",70, 175,45,20)                 ;
  CreateButton(3,"+",125,175,45,20)                 ;
  CreateButton(4,"-",180,175,45,20)                 ;  
  for(active_digit=1;active_digit<9;active_digit++)
  {
    temp[0] = Find_Data(LED[active_digit-1].data)    ;
    if(!(LED[active_digit-1].mode&DIGIT_OFF))
      Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                   87,Red,Black                  )   ; 
    if(!(LED[active_digit-1].data&SEGDP))
      DrawRectFill((active_digit-1)*29+30,120,
                  3,3,Red)                           ;
  }
  for(active_digit=1;active_digit<9;active_digit++)
  {
    DrawFrame((active_digit-1)*29+14,139,11,11)      ;    
    DrawRectFill((active_digit-1)*29+15,140,10,10,Dark_Grey); 
  }
  DrawRectFill(15,140,10,10,Green)                   ; 
  active_digit = 1                                   ;
  CreateCheck(&Disp_Check[0],25 ,210,12,12,"闪烁")   ;
  CreateCheck(&Disp_Check[1],90 ,210,12,12,"消隐")   ;
  CreateCheck(&Disp_Check[2],150,210,12,12,"小数点") ;
  if(LED[active_digit-1].mode&DIGIT_FLICKER)
    CheckCheck(&Disp_Check[0])                       ;
  if(LED[active_digit-1].mode&DIGIT_OFF)
    CheckCheck(&Disp_Check[1])                       ;
  if(!(LED[active_digit-1].data&SEGDP))
    CheckCheck(&Disp_Check[2])                       ;   
  temp[0]      = 0x00                                ;
  for(;;)
  {
    OS_WaitMail(&MBKeyTP)                            ;
    OS_GetMail1(&MBKeyTP, &Event)                    ;
    OS_GetMail1(&MBKeyTP, &key)                      ; 
    OS_GetMail1(&MBKeyTP, &rx_char)                  ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[0])           ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[1])           ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[2])           ; 
    OS_GetMail1(&MBKeyTP, &TPoint.byte[3])           ;     
    if(Event&EVENT_TP_TOUCHED)
    {
      index = InScopeButton(TPoint.pos[0],
                            TPoint.pos[1] )          ;
      if(index==0xFF)
      {
        OS_Use(&SemaLCD)                             ; 
        SetButtonUp(down_id)                         ;
        down_id = index                              ;
        OS_Unuse(&SemaLCD)                           ;            
      }
      else if(index!=down_id)
      {
        OS_Use(&SemaLCD)                             ; 
        SetButtonUp(down_id)                         ;
        down_id = index                              ;
        SetButtonDown(down_id)                       ;
        OS_Unuse(&SemaLCD)                           ;            
      }
    }
    else if(Event&EVENT_TP_PRESSED)  
    {  
      index = InScopeButton(TPoint.pos[0],
                            TPoint.pos[1] )          ;
      OS_Use(&SemaLCD)                               ; 
      SetButtonUp(index)                             ;
      down_id  = 0xFF                                ;
      OS_Unuse(&SemaLCD)                             ; 
      switch(index)
      {
      case 1:
        if(active_digit>1)
        {
          active_digit--                              ;
          DrawRectFill((active_digit)*29+15,140,10,10,Dark_Grey); 
          DrawRectFill((active_digit-1)*29+15,140,10,10,Green); 
          if(LED[active_digit-1].mode&DIGIT_FLICKER)
            CheckCheck(&Disp_Check[0])               ;
          else
            unCheckCheck(&Disp_Check[0])             ;
          if(LED[active_digit-1].mode&DIGIT_OFF)
            CheckCheck(&Disp_Check[1])               ;
          else
            unCheckCheck(&Disp_Check[1])             ;
          if(!(LED[active_digit-1].data&SEGDP))
            CheckCheck(&Disp_Check[2])               ;
          else
            unCheckCheck(&Disp_Check[2])             ;
        }
        break                                        ;
      case 2:
        if(active_digit<8)
        {
          active_digit++                              ;
          DrawRectFill((active_digit-2)*29+15,140,10,10,Dark_Grey); 
          DrawRectFill((active_digit-1)*29+15,140,10,10,Green); 
          if(LED[active_digit-1].mode&DIGIT_FLICKER)
            CheckCheck(&Disp_Check[0])               ;
          else
            unCheckCheck(&Disp_Check[0])             ;
          if(LED[active_digit-1].mode&DIGIT_OFF)
            CheckCheck(&Disp_Check[1])               ;
          else
            unCheckCheck(&Disp_Check[1])             ;
          if(!(LED[active_digit-1].data&SEGDP))
            CheckCheck(&Disp_Check[2])               ;
          else
            unCheckCheck(&Disp_Check[2])             ;
        }
        break                                        ;
      case 3:        
        temp[0] = Find_Data(LED[active_digit-1].data);
        if(++temp[0]>9)   temp[0] = 0                ;
        LED[active_digit-1].data |= 0x7F             ;
        LED[active_digit-1].data &= SMG[temp[0]]     ;
        Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                     87,Red,Black                 )  ;        
        break                                        ;
      case 4:        
        temp[0] = Find_Data(LED[active_digit-1].data);
        if(--temp[0]>250)   temp[0] = 9              ;
        LED[active_digit-1].data |= 0x7F             ;
        LED[active_digit-1].data &= SMG[temp[0]]     ;
        Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                     87,Red,Black                 )  ;        
        break                                        ;
      }
      for(i=0;i<3;i++)
      {
        if(!InCheckScope(TPoint.pos[0],
                         TPoint.pos[1],
                         &Disp_Check[i]))
        {
          if(Disp_Check[i].status&CHECK_CHECKED)
          {
            unCheckCheck(&Disp_Check[i])             ;
            switch(i)
            {
            case 0:
              LED_Flicker_Digit(active_digit,0)      ; 
              temp[0] = Find_Data(LED[active_digit-1].data)                ;
              if(!(LED[active_digit-1].mode&DIGIT_OFF))
              {
                Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                             87,Red,Black                  )     ; 
                if(!(LED[active_digit-1].data&SEGDP))
                  DrawRectFill((active_digit-1)*29+30,120,3,3,Red)          ;
              }
              break                                  ;
            case 1:
              temp[0] = Find_Data(LED[active_digit-1].data)  ;
              Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                           87,Red,Black                  )   ; 
              if(!(LED[active_digit-1].data&SEGDP))
                  DrawRectFill((active_digit-1)*29+30,120,3,3,Red)    ;
              LED[active_digit-1].mode  &=~DIGIT_OFF ;
              break                                  ;
            case 2:
              LED[active_digit-1].data  |= SEGDP     ;
              DrawRectFill((active_digit-1)*29+30,120,
                            3,3,Black)               ;
              break                                  ;
            }
          }
          else
          {
            CheckCheck(&Disp_Check[i])               ;
            switch(i)
            {
            case 0:
              LED_Flicker_Digit(active_digit,1)      ; 
              break                                  ;
            case 1:
              temp[0] = Find_Data(LED[active_digit-1].data)  ;
              Draw7Seg2436(temp[0],(active_digit-1)*29+5,
                           87,Black,Black                )   ; 
              DrawRectFill((active_digit-1)*29+30,120,
                            3,3,Black)               ;
              LED[active_digit-1].mode  |= DIGIT_OFF ;
              break                                  ;
            case 2:
              LED[active_digit-1].data  &=~SEGDP     ;
              DrawRectFill((active_digit-1)*29+30,120,
                           3,3,Red)                  ;
              break                                  ;
            }
          }
          break                                      ;
        }
      }
      if(  (TPoint.pos[0]<230&&TPoint.pos[0]>200&&TPoint.pos[1]>295)
         ||(TPoint.pos[0]>220&&TPoint.pos[1]<20             ))
          break                                      ;      
    }
    else if(Event&EVENT_FLICKER)
    {
      if(flicker++>0)
      {
        for(i=1;i<9;i++)
        {
          temp[0] = Find_Data(LED[i-1].data)                ;
          if(  !(LED[i-1].mode&DIGIT_OFF)
             && (LED[i-1].mode&DIGIT_FLICKER))
          {
            Draw7Seg2436(temp[0],(i-1)*29+5,
                         87,Red,Black                  )     ; 
            if(!(LED[i-1].data&SEGDP))
              DrawRectFill((i-1)*29+30,120,3,3,Red)          ;
          }
        }
        flicker  = 0x00                                    ;
      }
      else
      {
        for(i=1;i<9;i++)
        {
          temp[0] = Find_Data(LED[i-1].data)                ;
          if(  !(LED[i-1].mode&DIGIT_OFF)
             && (LED[i-1].mode&DIGIT_FLICKER))
          {
            Draw7Seg2436(temp[0],(i-1)*29+5,
                         87,Black,Black                 )   ; 
            if(!(LED[i-1].data&SEGDP))
              DrawRectFill((i-1)*29+30,120,3,3,Black)      ;
          }
        }
      }                  
    }
  } 
  DeleteButton(1)                                    ;
  DeleteButton(2)                                    ;
  DeleteButton(3)                                    ;
  DeleteButton(4)                                    ;
  return 0x00                                        ;
}