void WIDGET_HOTKEY_LIST::UpdateFromClientData()
{
    for( wxTreeListItem i = GetFirstItem(); i.IsOk(); i = GetNextItem( i ) )
    {
        WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( i );

        if( hkdata )
        {
            const auto& changed_hk = hkdata->GetChangedHotkey();
            const EDA_HOTKEY& hk = changed_hk.GetCurrentValue();

            wxString key_text = KeyNameFromKeyCode( hk.m_KeyCode );

            // mark unsaved changes
            if( changed_hk.HasUnsavedChange() )
                key_text += " *";

            SetItemText( i, 0, wxGetTranslation( hk.m_InfoMsg ) );
            SetItemText( i, 1, key_text);
        }
    }

    // Trigger a resize in case column widths have changed
    wxSizeEvent dummy_evt;
    TWO_COLUMN_TREE_LIST::OnSize( dummy_evt );
}
bool WIDGET_HOTKEY_LIST::TransferDataFromControl()
{
    for( size_t sec_index = 0; sec_index < m_sections.size(); ++sec_index )
    {
        EDA_HOTKEY_CONFIG* section = m_sections[sec_index].m_section;

        for( EDA_HOTKEY** info_ptr = section->m_HK_InfoList; *info_ptr; ++info_ptr )
        {
            EDA_HOTKEY* info = *info_ptr;

            for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
            {
                WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );

                if( !hkdata )
                    continue;

                EDA_HOTKEY& hk = hkdata->GetHotkey();

                if( hk.m_Idcommand == info->m_Idcommand )
                {
                    info->m_KeyCode = hk.m_KeyCode;
                    break;
                }
            }
        }
    }

    return true;
}
	/** Find an existing string item in the list. Returns
	VLinkedListStringItem pointer on success, NULL on failure.*/
	VLinkedListStringItem*	Find(VSTRING_CONST pszString) const
	{
		if ( pszString )
		{
			VLinkedListStringItem* pItem = GetFirstItem();

			VBOOL bCaseSensitive = m_Options.IsSet(OPTION_CASE_SENSITIVE);

			while ( pItem )
			{
				VSTRING_CONST pszThisString = pItem->String();

				if ( pszThisString )
				{
					if ( bCaseSensitive )
					{
						if ( VSTRCMP(pszString, pszThisString) == 0 )
							return pItem;
					}
					else
					{
						if ( VSTRCMP_NOCASE(pszString, pszThisString) == 0 )
							return pItem;
					}
				}

				pItem = pItem->GetNextItem();
			}
		}

		return NULL;
	}
Exemple #4
0
NPT_UdpMulticastSocket* Server::getNewMulticastSocket()
{
    NPT_NetworkInterface* serverInterface = gMS->serverInterface();

    auto addresses = serverInterface->GetAddresses();
    if (!addresses.GetFirstItem())
    {
        throw new std::runtime_error("No usable addresses found for UPnP multicast");
    }

    NPT_SocketAddress localAddress((*addresses.GetFirstItem()).GetPrimaryAddress(), 0);

    NPT_UdpMulticastSocket* ssdpSocket = new NPT_UdpMulticastSocket();
    ssdpSocket->Bind(localAddress, true);
    ssdpSocket->SetTimeToLive(32);
    return ssdpSocket;
}
bool WIDGET_HOTKEY_LIST::CheckKeyConflicts( long aKey, const wxString& aSectionTag,
        EDA_HOTKEY** aConfKey, EDA_HOTKEY_CONFIG** aConfSect )
{
    EDA_HOTKEY* conflicting_key = NULL;
    struct EDA_HOTKEY_CONFIG* conflicting_section = NULL;

    for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
    {
        WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );

        if( !hkdata )
            continue;

        EDA_HOTKEY& hk = hkdata->GetHotkey();
        wxString tag = hkdata->GetSectionTag();

        if( aSectionTag != g_CommonSectionTag
            && tag != g_CommonSectionTag
            && tag != aSectionTag )
        {
            // This key and its conflict candidate are in orthogonal sections, so skip.
            continue;
        }

        if( aKey == hk.m_KeyCode )
        {
            conflicting_key = &hk;

            // Find the section
            HOTKEY_SECTIONS::iterator it;

            for( it = m_sections.begin(); it != m_sections.end(); ++it )
            {
                if( *it->m_section->m_SectionTag == tag )
                {
                    conflicting_section = it->m_section;
                    break;
                }
            }
        }
    }

    // Write the outparams
    if( aConfKey )
        *aConfKey = conflicting_key;

    if( aConfSect )
        *aConfSect = conflicting_section;

    return conflicting_key == NULL;
}
void WIDGET_HOTKEY_LIST::UpdateFromClientData()
{
    for( wxTreeListItem i = GetFirstItem(); i.IsOk(); i = GetNextItem( i ) )
    {
        WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( i );

        if( hkdata )
        {
            EDA_HOTKEY& hk = hkdata->GetHotkey();

            SetItemText( i, 0, wxGetTranslation( hk.m_InfoMsg ) );
            SetItemText( i, 1, KeyNameFromKeyCode( hk.m_KeyCode ) );
        }
    }
}
void CReportCtrl::_EnsureSingleCheck(int nItem)
{
	if (m_nChkStyle == RC_CHKBOX_SINGLE)
	{
		const int FIRST = nItem < 0 ? GetFirstItem(RC_ITEM_CHECKED) : nItem;
		if (FIRST >= 0)
		{
			const int ITEMS = CListCtrl::GetItemCount();
			for (int i = FIRST + 1; i < ITEMS; i++)
			{
				if (CListCtrl::GetCheck(i))
					CListCtrl::SetCheck(i, FALSE);
			}
		}		
	}
}
bool WIDGET_HOTKEY_LIST::TransferDefaultsToControl()
{
    Freeze();

    for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
    {
        WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
        if( hkdata == NULL)
            continue;

        hkdata->GetHotkey().ResetKeyCodeToDefault();
    }

    UpdateFromClientData();
    Thaw();

    return true;
}
void WIDGET_HOTKEY_LIST::OnSize( wxSizeEvent& aEvent )
{
    // Handle this manually - wxTreeListCtrl screws up the width of the first column
    wxDataViewCtrl* view = GetDataView();

    if( !view )
        return;

    wxRect rect = GetClientRect();
    view->SetSize( rect );

#ifdef wxHAS_GENERIC_DATAVIEWCTRL
    {
        wxWindow* view = GetView();
        view->Refresh();
        view->Update();
    }
#endif

    // Find the maximum width of the hotkey column
    int hk_column_width = 0;

    for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
    {
        const wxString& text = GetItemText( item, 1 );
        int width = WidthFor( text );

        if( width > hk_column_width )
            hk_column_width = width;
    }

    if( hk_column_width < HOTKEY_MIN_WIDTH )
        hk_column_width = HOTKEY_MIN_WIDTH;
    else if( hk_column_width <= 0 )
        hk_column_width = 1;

    int name_column_width = rect.width - hk_column_width - HORIZ_MARGIN;

    if( name_column_width <= 0 )
        name_column_width = 1;

    SetColumnWidth( 1, hk_column_width );
    SetColumnWidth( 0, name_column_width );
}
	//000502 new function to return string of all items
	VString Export ()
	{
		//BEEP;
		
		VLinkedListStringItem* pItem = GetFirstItem();
		VString	sOut;

		while ( pItem )
		{
			sOut.Append (pItem->String());

			//070830 this sub is for building an Export TT. we no longer want the
			//		trailing \t, too hard to read and TT parses OK without it
			//sOut.Append ("\t-\t\n,");	//000601 for Export TT. 041101 added hyphen
			sOut.Append ("\t-\n,");

			pItem = pItem->GetNextItem();
		}
		
		return sOut.String ();
	}
Exemple #11
0
void RunMenu(unsigned char Menu_Index)
{
  unsigned char key = 0xFF , menu_index  , SubMenuIndex                   ;
  unsigned char First_Item , Active_Item , Active_Item_Index              ;
  unsigned char CallBackIndex                                             ;

  Clear_LCD(Color_BK)                                                     ;
  DrawRectFill(0,0,240,25,Blue)                                           ;
  DrawRectFill(0,295,240,25,Blue)                                         ;
  Color    = 0xFFFF                                                       ;
  Color_BK = Blue                                                         ;
  PutStringCN16(4,4,Menus[Menu_Index].MenuTitle)                          ;
  Color    = Black                                                        ;
  Color_BK = WINDOW_BK_COLOR                                              ;  
  
  Clear_LCD(STATUS_BK_COLOR)                                              ;
  Color_BK = STATUS_BK_COLOR                                              ;
  PutStringCN24(10,294,"确认")                                            ; // 底栏
  PutStringCN24(185,294,"取消")                                           ; 
  LoadMenu(MAIN_MENU,PERMISSION)                                          ;
  Initial_Menu()                                                          ;
  for(;;)
  {
    key = GetKeyPress()                                                   ;
    switch(key)
    {
    case Up: case Down: case Left: case Right:
      MenuMessage(key)                                                    ;
      break                                                               ;
    case  8:
      MenuMessage(Up)                                                     ;
      break                                                               ;
    case  0:
      MenuMessage(Down)                                                   ;
      break                                                               ;
    case Esc:
      {
//        if(Current_Menu[0][6]!=EMPTY)
//          Item_OP[Current_Menu[0][6]](0,0)                                ; // 菜单执行函数
        menu_index = GetMenuIndex()                                       ;
        if(Menus[menu_index].MasterMenu!=EMPTY)
//          return Menus[menu_index].MasterMenu                             ;
        {
          LoadMenu(Menus[menu_index].MasterMenu,PERMISSION)               ;
          Initial_Menu()                                                  ;
        }
        break                                                             ;
      }
    case OK: case Enter:
      {
        First_Item          = GetFirstItem()                              ;
        Active_Item         = GetActiveItem()                             ;
        Active_Item_Index   = GetActiveItemIndex()                        ;        
        if(MENU_ITEM[Active_Item_Index].CallBackFuncIndex!=EMPTY)           // 有操作函数
        {
          CallBackIndex= MENU_ITEM[Active_Item_Index].CallBackFuncIndex   ;
          SubMenuIndex = MENU_ITEM[Active_Item_Index].SubMenuIndex        ;
          if(SubMenuIndex!=EMPTY)                                           // 有操作函数且有动态子菜单
          {
            SubMenuIndex = MENU_ITEM[Active_Item_Index].SubMenuIndex      ; 
            if(Item_OP[CallBackIndex](0,Active_Item_Index  )==0x00)         // 生成子菜单成功
              Initial_Menu()                                              ; // 初始化动态子菜单
            else
              Redraw_Menu(First_Item,Active_Item)                         ; // 未生成子菜单,重画原菜单
          }
          else
          {
            Item_OP[CallBackIndex](0,Active_Item_Index  )                 ; // 无动态子菜单
            Redraw_Menu(First_Item,Active_Item)                           ; // 重画菜单
          }
        }
        
/*        
        if(MENU_ITEM[Item_Index].CallBackFuncIndex!=EMPTY)
        {
          Item_OP[MENU_ITEM[Item_Index].CallBackFuncIndex](0,Active_Index);
          if(  (MENU_ITEM[Item_Index].SubMenuIndex!=EMPTY)
             &&(Master_Or_Sub==GOTO_SUB                  ))
            return MENU_ITEM[Item_Index].SubMenuIndex                     ;
          Redraw_Menu(First_Index,Active_Index,(UCHAR**)P_Current_Menu)   ;          
        }
        else
*/      
        else  
        if(MENU_ITEM[Active_Item_Index].SubMenuIndex!=EMPTY)
//          return MENU_ITEM[Item_Index].SubMenuIndex                       ;
        {
          LoadMenu(MENU_ITEM[Active_Item_Index].SubMenuIndex,PERMISSION)  ;
          Initial_Menu()                                                  ;
        }
        break                                                             ;          
      }
    case Power:
      return                                                              ;
    default:
      break                                                               ;
    }
  }
}  
	/** Add a string object to the list in sorted order. Return VTRUE on
	success, VFALSE on failure. pItem must be valid, however the string
	object contained within it is not required to have a string, it can
	be empty.*/
	VBOOL					Add(VLinkedListStringItem* pItem)
	{
		/* pItem must be known! It can be a NULL string however.*/
		VASSERT(pItem)

		VSTRING_CONST pszString = pItem->String();

		/* Should we check for duplicate?*/
		if (	pszString &&
				m_Options.IsSet(OPTION_NO_DUPLICATES) && Find(pszString) )
			return VFALSE;

		/* No other strings in list? No sorting to be done?*/
		if ( !m_pFirstItem || m_Options.IsSet(OPTION_UNSORTED) )
			VLinkedListManager::Add(pItem);
		/* NULL string? Add at beginning of list.*/
		else if ( !VSTRLEN_CHECK(pszString) )
			VLinkedListManager::Add(pItem, VTRUE);
		/* Insert into linked list at sorted location.*/
		else
		{
			/* Find the item that comes before this one alphabetically,
			and insert there.*/
			VLinkedListStringItem* pThisItem =
				GetFirstItem();

			VLinkedListStringItem* pPreviousItem =
				NULL;

			VBOOL bCaseSensitive =
				m_Options.IsSet(OPTION_CASE_SENSITIVE);

			VBOOL bAscending =
				m_Options.IsSet(OPTION_SORT_ASCENDING);

			while ( pThisItem )
			{
				VBOOL	bBefore =	VFALSE;
				VINT	nInsert =	0;

				/* If this string is empty, insert before.*/
				if ( pThisItem->IsEmpty() )
					bBefore = VTRUE;
				else
					nInsert =	(bCaseSensitive)
								? VSTRCMP(	pszString,
											pThisItem->String())
								: VSTRCMP_NOCASE(	pszString,
													pThisItem->String());

				if (	bBefore ||
						(bAscending && nInsert <= 0) ||
						(!bAscending && nInsert >= 0) )
				{
					/* Insert into linked list before this item.*/
					if ( pPreviousItem )
						pPreviousItem->m_pNextItem = pItem;
					else
						m_pFirstItem = pItem;

					pItem->m_pNextItem = pThisItem;

					/* Offset count in base class.*/
					m_nItemCount++;

					/* Exit loop now.*/
					break;
				}
				else
				{
					pPreviousItem = pThisItem;
					pThisItem =		pThisItem->GetNextItem();

					/* Did we hit the end of the list? If yes, insert now.*/
					if ( !pThisItem )
					{
						pPreviousItem->m_pNextItem =	pItem;
						m_pLastItem =					pItem;

						/* Offset count in base class.*/
						m_nItemCount++;
					}
				}
			}
		}

		return VTRUE;
	}