Ejemplo n.º 1
0
wxString wxToolBarBase::GetToolLongHelp(int toolid) const
{
    wxToolBarToolBase *tool = FindById(toolid);
    wxCHECK_MSG( tool, wxEmptyString, wxT("no such tool") );

    return tool->GetLongHelp();
}
Ejemplo n.º 2
0
bool wxToolBarBase::GetToolEnabled(int toolid) const
{
    wxToolBarToolBase *tool = FindById(toolid);
    wxCHECK_MSG( tool, false, wxT("no such tool") );

    return tool->IsEnabled();
}
Ejemplo n.º 3
0
bool TrackList::ApplyPendingTracks()
{
   bool result = false;

   ListOfTracks additions;
   ListOfTracks updates;
   {
      // Always clear, even if one of the update functions throws
      auto cleanup = finally( [&] { ClearPendingTracks( &additions ); } );
      UpdatePendingTracks();
      updates.swap( mPendingUpdates );
   }

   // Remaining steps must be NOFAIL-GUARANTEE so that this function
   // gives STRONG-GUARANTEE

   std::vector< std::shared_ptr<Track> > reinstated;

   for (auto &pendingTrack : updates) {
      if (pendingTrack) {
         auto src = FindById( pendingTrack->GetId() );
         if (src)
            this->Replace(src, pendingTrack), result = true;
         else
            // Perhaps a track marked for pending changes got deleted by
            // some other action.  Recreate it so we don't lose the
            // accumulated changes.
            reinstated.push_back(pendingTrack);
      }
   }

   // If there are tracks to reinstate, append them to the list.
   for (auto &pendingTrack : reinstated)
      if (pendingTrack)
         this->Add( pendingTrack ), result = true;

   // Put the pending added tracks back into the list, preserving their
   // positions.
   bool inserted = false;
   ListOfTracks::iterator first;
   for (auto &pendingTrack : additions) {
      if (pendingTrack) {
         auto iter = ListOfTracks::begin();
         std::advance( iter, pendingTrack->GetIndex() );
         iter = ListOfTracks::insert( iter, pendingTrack );
         pendingTrack->SetOwner( shared_from_this(), {iter, this} );
         pendingTrack->SetId( TrackId{ ++sCounter } );
         if (!inserted) {
            first = iter;
            inserted = true;
         }
      }
   }
   if (inserted) {
      RecalcPositions({first, this});
      result = true;
   }

   return result;
}
Ejemplo n.º 4
0
wxString wxToolBarBase::GetToolShortHelp(int id) const
{
    wxToolBarToolBase *tool = FindById(id);
    wxCHECK_MSG( tool, wxEmptyString, _T("no such tool") );

    return tool->GetShortHelp();
}
Ejemplo n.º 5
0
bool wxToolBarBase::GetToolState(int id) const
{
    wxToolBarToolBase *tool = FindById(id);
    wxCHECK_MSG( tool, false, _T("no such tool") );

    return tool->IsToggled();
}
Ejemplo n.º 6
0
void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
{
    wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));

    if ( tool )
    {
        (void)tool->SetShortHelp(helpString);
        if (tool->m_item)
        {
#if GTK_CHECK_VERSION(2, 12, 0)
            if (GTK_CHECK_VERSION(3,0,0) || gtk_check_version(2,12,0) == NULL)
            {
                gtk_tool_item_set_tooltip_text(tool->m_item,
                    wxGTK_CONV(helpString));
            }
            else
#endif
            {
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
                gtk_tool_item_set_tooltip(tool->m_item,
                    m_tooltips, wxGTK_CONV(helpString), "");
#endif
            }
        }
    }
}
Ejemplo n.º 7
0
void wxToolBarBase::SetToolClientData(int toolid, wxObject *clientData)
{
    wxToolBarToolBase *tool = FindById(toolid);

    wxCHECK_RET( tool, wxT("no such tool in wxToolBar::SetToolClientData") );

    tool->SetClientData(clientData);
}
Ejemplo n.º 8
0
void wxToolBarBase::SetToolShortHelp(int id, const wxString& help)
{
    wxToolBarToolBase *tool = FindById(id);
    if ( tool )
    {
        (void)tool->SetShortHelp(help);
    }
}
Ejemplo n.º 9
0
void wxToolBarBase::SetToolLongHelp(int toolid, const wxString& help)
{
    wxToolBarToolBase *tool = FindById(toolid);
    if ( tool )
    {
        (void)tool->SetLongHelp(help);
    }
}
Ejemplo n.º 10
0
BOOL CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps)
{
	CJabberClientPartialCaps *pCaps = FindById(nIqId);
	if (!pCaps)
		return FALSE;

	pCaps->SetCaps(jcbCaps, -1);
	return TRUE;
}
Ejemplo n.º 11
0
void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap )
{
    wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
    if ( tool )
    {
        wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));

        tool->SetDisabledBitmap(bitmap);
    }
}
Ejemplo n.º 12
0
void wxToolBarBase::EnableTool(int toolid, bool enable)
{
    wxToolBarToolBase *tool = FindById(toolid);
    if ( tool )
    {
        if ( tool->Enable(enable) )
        {
            DoEnableTool(tool, enable);
        }
    }
}
Ejemplo n.º 13
0
void wxToolBarBase::SetToggle(int toolid, bool toggle)
{
    wxToolBarToolBase *tool = FindById(toolid);
    if ( tool )
    {
        if ( tool->SetToggle(toggle) )
        {
            DoSetToggle(tool, toggle);
        }
    }
}
Ejemplo n.º 14
0
void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
{
    wxToolBarTool *tool = (wxToolBarTool *)FindById(id);

    if ( tool )
    {
        (void)tool->SetShortHelp(helpString);
        gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item,
                             wxGTK_CONV( helpString ), "");
    }
}
Ejemplo n.º 15
0
void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
{
    wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));
    if ( tool )
    {
        (void)tool->SetShortHelp(helpString);
        //TODO - other qt actions for tool tip string
//        if (tool->m_item)
//        {}
    }
}
Ejemplo n.º 16
0
void wxToolBarBase::ToggleTool(int toolid, bool toggle)
{
    wxToolBarToolBase *tool = FindById(toolid);
    if ( tool && tool->CanBeToggled() )
    {
        if ( tool->Toggle(toggle) )
        {
            UnToggleRadioGroup(tool);
            DoToggleTool(tool, toggle);
        }
    }
}
Ejemplo n.º 17
0
void CHuiFxEffectCache::ParsingEnded(TInt aHandle)
    {
    //MHuiFxEffectCacheNode **node2 = iDuplicateEffects.Find(aHandle);
    TInt index = FindById(aHandle);
    if (index == -1) return;
    MHuiFxEffectCacheNode *node = iDuplicateEffects[index].iNode;
    node->ParsingEndedBefore();
    iCachedEffects.AppendL(node); // takes ownership
    iDuplicateEffects.Remove(index);
    node->Ref(1);
    node->ParsingEndedAfter(node);
    }
Ejemplo n.º 18
0
bool wxToolBarBase::SetDropdownMenu(int toolid, wxMenu* menu)
{
    wxToolBarToolBase * const tool = FindById(toolid);
    wxCHECK_MSG( tool, false, wxT("invalid tool toolid") );

    wxCHECK_MSG( tool->GetKind() == wxITEM_DROPDOWN, false,
                    wxT("menu can be only associated with drop down tools") );

    tool->SetDropdownMenu(menu);

    return true;
}
Ejemplo n.º 19
0
bool wxToolMenuBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id_)
{
    const int id = (signed short)id_;

    wxToolBarToolBase *tool = FindById(id);
    if ( !tool )
    {
        bool checked = false;
        if ( m_menuBar )
        {
            wxMenuItem *item = m_menuBar->FindItem(id);
            if ( item && item->IsCheckable() )
            {
                item->Toggle();
                checked = item->IsChecked();
            }
        }

        wxCommandEvent event(wxEVT_MENU);
        event.SetEventObject(this);
        event.SetId(id);
        event.SetInt(checked);

        return GetEventHandler()->ProcessEvent(event);
    }

    if ( tool->CanBeToggled() )
    {
        LRESULT state = ::SendMessage(GetHwnd(), TB_GETSTATE, id, 0);
        tool->Toggle((state & TBSTATE_CHECKED) != 0);
    }

    bool toggled = tool->IsToggled();

    // avoid sending the event when a radio button is released, this is not
    // interesting
    if ( !tool->CanBeToggled() || tool->GetKind() != wxITEM_RADIO || toggled )
    {
        // OnLeftClick() can veto the button state change - for buttons which
        // may be toggled only, of course.
        if ( !OnLeftClick((int)id, toggled) && tool->CanBeToggled() )
        {
            // revert back
            toggled = !toggled;
            tool->SetToggle(toggled);

            ::SendMessage(GetHwnd(), TB_CHECKBUTTON, id, MAKELONG(toggled, 0));
        }
    }

    return true;
}
Ejemplo n.º 20
0
void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
{
    wxToolBarTool* tool = static_cast<wxToolBarTool*>(FindById(id));

    if ( tool )
    {
        (void)tool->SetShortHelp(helpString);
        if (tool->m_item)
        {
            gtk_tool_item_set_tooltip(tool->m_item,
                m_tooltips, wxGTK_CONV(helpString), "");
        }
    }
}
Ejemplo n.º 21
0
//
// Okay, so we've left the tool we're in ... we must check if the tool we're
// leaving was a 'sprung push button' and if so, spring it back to the up
// state.
//
void wxToolBar::SpringUpButton(
  int                               vId
)
{
    wxToolBarToolBase*              pTool = FindById(vId);

    if (pTool && pTool->CanBeToggled())
    {
        if (pTool->IsToggled())
            pTool->Toggle();

        DrawTool(pTool);
    }
} // end of wxToolBar::SpringUpButton
Ejemplo n.º 22
0
int InsertById(mlink * h, id_tm key, id_tm nid)
{
	mlink *where = h;

	if (NULL == h)
		return -1;

	if (NULL == (where = FindById(where, key)))
		return -1;

	if (-1 == Insert(where, nid))
		return -1;

	return 0;
}
Ejemplo n.º 23
0
void Track::SetY(int y)
{
   auto pList = mList.lock();
   if (pList && !pList->mPendingUpdates.empty()) {
      auto orig = pList->FindById( GetId() );
      if (orig && orig != this) {
         // delegate, and rely on the update to copy back
         orig->SetY(y);
         pList->UpdatePendingTracks();
         return;
      }
   }

   DoSetY(y);
}
Ejemplo n.º 24
0
int ChangeById(mlink * h, id_tm who, mem_t sz, maddr_t * addr)
{
	mlink *p = h;

	if (NULL == h || sz < 0)
		return -1;

	if (NULL == (p = FindById(p, who)))
		return -1;

	if (-1 == Change(p, sz, addr))
		return -1;

	return 0;
}
Ejemplo n.º 25
0
bool MCNativeControl::FindByNameOrId(const char *p_name, MCNativeControl*& r_control)
{
	char *t_id_end;
	uint32_t t_id;
	t_id = strtoul(p_name, &t_id_end, 10);
	if (t_id_end != p_name)
		return FindById(t_id, r_control);
	
	for(MCNativeControl *t_control = s_native_controls; t_control != nil; t_control = t_control -> m_next)
		if (!t_control -> m_deleted && t_control -> GetName() != nil && MCCStringEqualCaseless(t_control -> GetName(), p_name))
		{
			r_control = t_control;
			return true;
		}
	
	return false;
}
Ejemplo n.º 26
0
void CToolBar::MakeDropdownTool(int id)
{
	wxToolBarToolBase* pOldTool = FindById(id);
	if (!pOldTool)
		return;

	wxToolBarToolBase* pTool = new wxToolBarToolBase(0, id,
		pOldTool->GetLabel(), pOldTool->GetNormalBitmap(), pOldTool->GetDisabledBitmap(),
		wxITEM_DROPDOWN, NULL, pOldTool->GetShortHelp(), pOldTool->GetLongHelp());

	int pos = GetToolPos(id);
	wxASSERT(pos != wxNOT_FOUND);

	DeleteToolByPos(pos);
	InsertTool(pos, pTool);
	Realize();
}
Ejemplo n.º 27
0
bool MCAd::FindByNameOrId(const char *p_name, MCAd *&r_ad)
{   
	char *t_id_end;
	uint32_t t_id;
	t_id = strtoul(p_name, &t_id_end, 10);
	if (t_id_end != p_name)
		return FindById(t_id, r_ad);
	
	for(MCAd *t_ad = s_ads; t_ad != nil; t_ad = t_ad -> m_next)
		if (t_ad -> GetName() != nil && MCCStringEqualCaseless(t_ad -> GetName(), p_name))
		{
			r_ad = t_ad;
			return true;
		}
	
	return false;
}
Ejemplo n.º 28
0
void Track::SetLinked(bool l)
{
   auto pList = mList.lock();
   if (pList && !pList->mPendingUpdates.empty()) {
      auto orig = pList->FindById( GetId() );
      if (orig && orig != this) {
         // delegate, and rely on RecalcPositions to copy back
         orig->SetLinked(l);
         return;
      }
   }

   DoSetLinked(l);

   if (pList) {
      pList->RecalcPositions(mNode);
      pList->ResizingEvent(mNode);
   }
}
Ejemplo n.º 29
0
void TrackList::UpdatePendingTracks()
{
   auto pUpdater = mUpdaters.begin();
   for (const auto &pendingTrack : mPendingUpdates) {
      // Copy just a part of the track state, according to the update
      // function
      const auto &updater = *pUpdater;
      auto src = FindById( pendingTrack->GetId() );
      if (pendingTrack && src) {
         if (updater)
            updater( *pendingTrack, *src );
         pendingTrack->DoSetY(src->GetY());
         pendingTrack->DoSetHeight(src->GetActualHeight());
         pendingTrack->DoSetMinimized(src->GetMinimized());
         pendingTrack->DoSetLinked(src->GetLinked());
      }
      ++pUpdater;
   }
}
Ejemplo n.º 30
0
void wxRibbonToolBar::ToggleTool(int tool_id, bool checked)
{
    wxRibbonToolBarToolBase* tool = FindById(tool_id);
    wxCHECK_RET(tool != NULL , "Invalid tool id");
    if(checked)
    {
        if((tool->state & wxRIBBON_TOOLBAR_TOOL_TOGGLED) == 0)
        {
            tool->state |= wxRIBBON_TOOLBAR_TOOL_TOGGLED;
            Refresh();
        }
    }
    else
    {
        if(tool->state & wxRIBBON_TOOLBAR_TOOL_TOGGLED)
        {
            tool->state &= ~wxRIBBON_TOOLBAR_TOOL_TOGGLED;
            Refresh();
        }
    }
}