Example #1
0
void wxRadioBox::DoSetItemToolTip(unsigned int n, wxToolTip *tooltip)
{
    wxCharBuffer buf;
    if ( !tooltip )
        tooltip = GetToolTip();
    if ( tooltip )
        buf = wxGTK_CONV(tooltip->GetTip());

    wxToolTip::Apply(GTK_WIDGET(m_buttonsInfo[n]->button), buf);
}
Example #2
0
void nuiLabel::SetText(const nglString& Text)
{
  if (GetToolTip() == mText) // Reset the tooltip shown when text is truncated as it's maybe no more usefull
    SetToolTip(nglString::Empty);
  nglString t(mText);
  mText = Text;
  mText.TrimRight(_T("\n\r\t"));
  mText.Replace('\r','\n');
  if (t == mText) // Only redisplay if the text has really changed!
    return;
  mTextChanged = true;
  InvalidateLayout();
}
Example #3
0
void wxTabbedCtrl::DeletePage(int pg) {
    SetSelection(pg);
    wxASSERT_MSG(pg >= 0 && pg < GetPageCount(), "Got invalid page number");
    tipTab = -1;
    GetToolTip()->Enable( false );
    pages_type::iterator it = pages.begin() + pg;
    pages.erase(it);
    if(pg < active)
        active--;
    else if(active==pg && active==GetPageCount())
        active--;
    SetVisible( active );
}
Example #4
0
QVariant QtPropertyData::data(int role) const
{
	QVariant ret;

	switch(role)
	{
	case Qt::EditRole:
	case Qt::DisplayRole:
		ret = GetAlias();
		if(!ret.isValid())
		{
			ret = GetValue();
		}
		break;
    case Qt::ToolTipRole:
        ret = GetToolTip();
        if (!ret.isValid())
        {
            ret = data(Qt::DisplayRole);
        }
        break;
	case Qt::CheckStateRole:
		if(GetFlags() & Qt::ItemIsUserCheckable)
		{
            ret = GetValue();
            if ( !ret.isValid() )
            {
                ret = Qt::PartiallyChecked;
            }
            else
            {
			    ret = GetValue().toBool() ? Qt::Checked : Qt::Unchecked;
            }
		}
		break;
	case Qt::FontRole:
	case Qt::DecorationRole:
	case Qt::BackgroundRole:
	case Qt::ForegroundRole:
		ret = style.value(role);
		break;
	default:
		break;
	}

	return ret;
}
Example #5
0
void TimeTextCtrl::EnableMenu(bool enable)
{
#if wxUSE_TOOLTIPS
   wxString tip(_("Use right mouse button or context key to change format"));
   if (enable)
      SetToolTip(tip);
   else {
      wxToolTip *tt = GetToolTip();
      if (tt && tt->GetTip() == tip)
         SetToolTip(NULL);
   }
#endif
   mMenuEnabled = enable;
   mButtonWidth = enable ? 9 : 0;
   Layout();
   Fit();
}
void CLibraryFileView::OnLibraryLaunch()
{
	GetToolTip()->Hide();

	CStringList oList;

	{
		CSingleLock oLock( &Library.m_pSection );
		if ( ! oLock.Lock( 250 ) ) return;

		POSITION posSel = StartSelectedFileLoop();
		while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
		{
			oList.AddTail( pFile->GetPath() );
		}
	}

	CFileExecutor::Execute( oList );
}
Example #7
0
BOOL TabBase::OnToolTipText(UINT, NMHDR* hdr, LRESULT* result)
{
  TOOLTIPTEXTA* ttta = (TOOLTIPTEXTA*)hdr;
  TOOLTIPTEXTW* tttw = (TOOLTIPTEXTW*)hdr;

  UINT_PTR id = hdr->idFrom;
  if (hdr->code == TTN_NEEDTEXTA && (ttta->uFlags & TTF_IDISHWND) ||
      hdr->code == TTN_NEEDTEXTW && (tttw->uFlags & TTF_IDISHWND))
  {
    id = ((UINT)(WORD)::GetDlgCtrlID((HWND)id));
  }

  CString tipText = GetToolTip(id);
  if (hdr->code == TTN_NEEDTEXTA)
    lstrcpyn(ttta->szText,tipText,sizeof ttta->szText / sizeof ttta->szText[0]);
  else
    _mbstowcsz(tttw->szText,tipText,sizeof tttw->szText / sizeof tttw->szText[0]);

  *result = 0;
  ::SetWindowPos(hdr->hwndFrom,HWND_TOP,0,0,0,0,
    SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
  return TRUE;
}
Example #8
0
VOID CXElement::On_CXMsg_MouseEnter( CXMsg_MouseEnter& arg )
{
	CString toolTip;
	if (XSUCCEEDED(GetToolTip(toolTip)))
	{
		CXMsg_GetRealWnd msg;
		_SendXMsg(msg);
		if (!msg.wnd)
		{
			return;
		}
		HWND hWnd = 0;
		msg.wnd->GetHWnd(hWnd);
		if (!m_toolTip.IsWindow())
		{
			m_toolTip.Create(hWnd, NULL, NULL, TTS_ALWAYSTIP | TTS_NOPREFIX,WS_EX_TOPMOST);
			if (!m_toolTip.IsWindow())
			{
				WTF;
			}
			m_toolTip.SetWindowLongPtr(GWLP_USERDATA,(LONG_PTR)hWnd);

			CSize size;
			GetSize(size);
			m_toolTip.SetMaxTipWidth(260);
			m_toolTip.AddTool(hWnd,_T(""));
			m_toolTip.SetDelayTime( TTDT_AUTOPOP, static_cast<int>(GetDoubleClickTime() * 10) ) ;
			m_toolTip.SetDelayTime( TTDT_RESHOW, static_cast<int>(GetDoubleClickTime() * 10) ) ;
			m_toolTip.Activate(TRUE);
		}
		MSG mouseMsg = { hWnd, WM_MOUSEMOVE, 0, MAKELONG (arg.pt.x,arg.pt.y)};
		m_toolTip.RelayEvent(&mouseMsg);

		m_toolTip.UpdateTipText((LPCTSTR)toolTip,hWnd);
	}
	arg.msgHandled = TRUE;
}
Example #9
0
void CLibraryView::OnRButtonDown(UINT nFlags, CPoint point)
{
	GetToolTip()->Hide();

	CWnd::OnRButtonDown( nFlags, point );
}
/*
================
CSyntaxRichEditCtrl::OnToolTipNotify
================
*/
BOOL CSyntaxRichEditCtrl::OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult)
{
	TOOLTIPTEXTA *pTTTA = (TOOLTIPTEXTA *)pNMHDR;
	TOOLTIPTEXTW *pTTTW = (TOOLTIPTEXTW *)pNMHDR;

	*pResult = 0;

	idStr name;

	if (GetNameForMousePosition(name)) {
		CString toolTip;

		if (GetToolTip == NULL || !GetToolTip(name, toolTip)) {

			int keyWordIndex = FindKeyWord(name, name.Length());

			if (keyWordIndex != -1 && keyWords[keyWordIndex].description[0] != '\0') {
				toolTip = keyWords[keyWordIndex].description;
			} else {
				toolTip = name.c_str();
			}
		}

		AFX_MODULE_THREAD_STATE *state = AfxGetModuleThreadState();

		// set max tool tip width to enable multi-line tool tips using "\r\n" for line breaks
		state->m_pToolTip->SetMaxTipWidth(500);

		// set the number of milliseconds after which the tool tip automatically disappears
		state->m_pToolTip->SetDelayTime(TTDT_AUTOPOP, 5000 + toolTip.GetLength() * 50);

#ifndef _UNICODE

		if (pNMHDR->code == TTN_NEEDTEXTA) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			lstrcpyn(m_pchTip, toolTip, toolTip.GetLength() + 1);
			pTTTW->lpszText = (WCHAR *)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			_mbstowcsz(m_pwchTip, toolTip, toolTip.GetLength() + 1);
			pTTTW->lpszText = (WCHAR *)m_pwchTip;
		}

#else

		if (pNMHDR->code == TTN_NEEDTEXTA) {
			delete m_pchTip;
			m_pchTip = new TCHAR[toolTip.GetLength() + 2];
			_wcstombsz(m_pchTip, toolTip, toolTip.GetLength() + 1);
			pTTTA->lpszText = (LPTSTR)m_pchTip;
		} else {
			delete m_pwchTip;
			m_pwchTip = new WCHAR[toolTip.GetLength() + 2];
			lstrcpyn(m_pwchTip, toolTip, toolTip.GetLength() + 1);
			pTTTA->lpszText = (LPTSTR) m_pwchTip;
		}

#endif

		return TRUE;
	}

	return FALSE;
}
Example #11
0
bool nuiLabel::SetRect(const nuiRect& rRect)
{
  bool needRecalcLayout = false;

  if (mUseEllipsis || mWrapping)
    needRecalcLayout = (rRect.GetWidth() != mRect.GetWidth());
    
  nuiWidget::SetRect(rRect);

  nuiRect ideal(mIdealLayoutRect);


  if (needRecalcLayout || ideal.GetWidth() > mRect.GetWidth())
  {
    if (mUseEllipsis)
    {
      CalcLayout();
      nuiSize diff = ideal.GetWidth() - mRect.GetWidth();
      int NbLetterToRemove = ToNearest(diff / (ideal.GetWidth() / mText.GetLength())) + 3;
      nglString text = mText;
      if (NbLetterToRemove > 0)
      {
        int len = text.GetLength();
        text.DeleteRight(MIN(NbLetterToRemove, len));
        text.Append(_T("..."));
      }
      delete mpLayout;
      mpLayout = new nuiTextLayout(mpFont);
      mpLayout->SetWrapX(0);
      mpLayout->SetTextLayoutMode(mTextLayoutMode);
      mpLayout->SetUnderline(mUnderline);
      mpLayout->SetStrikeThrough(mStrikeThrough);
      mpLayout->Layout(text);
      GetLayoutRect();
    }
    else if (mWrapping)
    {
      CalcLayout();
      delete mpLayout;
      mpLayout = new nuiTextLayout(mpFont, mOrientation);
      delete mpIdealLayout;
      mpIdealLayout = new nuiTextLayout(mpFont, mOrientation);
      mpLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight);
      mpIdealLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight);
      mpLayout->SetTextLayoutMode(mTextLayoutMode);
      mpLayout->SetUnderline(mUnderline);
      mpLayout->SetStrikeThrough(mStrikeThrough);
      mpIdealLayout->SetTextLayoutMode(mTextLayoutMode);
      mpIdealLayout->SetUnderline(mUnderline);
      mpIdealLayout->SetStrikeThrough(mStrikeThrough);
      mpLayout->Layout(mText);
      mpIdealLayout->Layout(mText);
      GetLayoutRect();
    }

    SetToolTip(mText);
    InvalidateLayout();
  }
  else
  {
    if (GetToolTip() == mText)
      SetToolTip(nglString::Empty);
  }

  return true;
}
Example #12
0
void wxRibbonToolBar::OnMouseMove(wxMouseEvent& evt)
{
    wxPoint pos(evt.GetPosition());
    wxRibbonToolBarToolBase *new_hover = NULL;

    size_t group_count = m_groups.GetCount();
    size_t g, t;
    for(g = 0; g < group_count; ++g)
    {
        wxRibbonToolBarToolGroup* group = m_groups.Item(g);
        if(group->position.x <= pos.x && pos.x < group->position.x + group->size.x
            && group->position.y <= pos.y && pos.y < group->position.y + group->size.y)
        {
            size_t tool_count = group->tools.GetCount();
            pos -= group->position;
            for(t = 0; t < tool_count; ++t)
            {
                wxRibbonToolBarToolBase* tool = group->tools.Item(t);
                if(tool->position.x <= pos.x && pos.x < tool->position.x + tool->size.x
                    && tool->position.y <= pos.y && pos.y < tool->position.y + tool->size.y)
                {
                    pos -= tool->position;
                    new_hover = tool;
                    break;
                }
            }
            break;
        }
    }

#if wxUSE_TOOLTIPS
    if(new_hover)
    {
        SetToolTip(new_hover->help_string);
    }
    else if(GetToolTip())
    {
        UnsetToolTip();
    }
#endif

    if(new_hover && new_hover->state & wxRIBBON_TOOLBAR_TOOL_DISABLED)
    {
        new_hover = NULL; // A disabled tool can not be hilighted
    }

    if(new_hover != m_hover_tool)
    {
        if(m_hover_tool)
        {
            m_hover_tool->state &= ~(wxRIBBON_TOOLBAR_TOOL_HOVER_MASK
                | wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK);
        }
        m_hover_tool = new_hover;
        if(new_hover)
        {
            long what = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED;
            if(new_hover->dropdown.Contains(pos))
                what = wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED;

            new_hover->state |= what;

            if(new_hover == m_active_tool)
            {
                new_hover->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK;
                new_hover->state |= (what << 2);
            }
        }
        Refresh(false);
    }
    else if(m_hover_tool && m_hover_tool->kind == wxRIBBON_BUTTON_HYBRID)
    {
        long newstate = m_hover_tool->state &~wxRIBBON_TOOLBAR_TOOL_HOVER_MASK;
        long what = wxRIBBON_TOOLBAR_TOOL_NORMAL_HOVERED;
        if(m_hover_tool->dropdown.Contains(pos))
            what = wxRIBBON_TOOLBAR_TOOL_DROPDOWN_HOVERED;
        newstate |= what;
        if(newstate != m_hover_tool->state)
        {
            m_hover_tool->state = newstate;
            if(m_hover_tool == m_active_tool)
            {
                m_hover_tool->state &= ~wxRIBBON_TOOLBAR_TOOL_ACTIVE_MASK;
                m_hover_tool->state |= (what << 2);
            }
            Refresh(false);
        }
    }
}
Example #13
0
void GLCanvas::OnMouseMove(wxMouseEvent &event)
{
    wxSize size = GetSize();
    wxPoint pos = event.GetPosition();

    if (pos.x > size.x - _buttonSize && pos.y < _numButtons * _buttonSize)
    {
        wxString tooltip;
        int index = pos.y / _buttonSize;
        switch (index)
        {
            case 0:
                tooltip = _("Show grid");
                break;

            case 1:
                tooltip = _("Show bounding box");
                break;

            case 2:
                tooltip = _("Show coordinate system");
                break;

            case 3:
                tooltip = _("Show joint constraints");
                break;

            case 4:
                tooltip = _("Show rotation axis");
                break;

            case 5:
                tooltip = _("Show label");
                break;

            case 6:
                tooltip = _("Move to skeleton");
                break;

            case 7:
                tooltip = _("Settings");
                break;

            default:
                tooltip = _("");
                break;
        }
        wxToolTip* prevToolTip = GetToolTip();
        if (prevToolTip == nullptr || prevToolTip->GetTip() != tooltip)
        {
            SetToolTip(tooltip);
        }
    }
    else if (GetToolTip() != nullptr)
    {
        UnsetToolTip();
    }

    if (_style & SINGLE_SENSOR_MODE)
    {
        return;
    }

    // get the delta of the mouse movement
    wxPoint delta = pos - _prevMousePos;
    _prevMousePos = pos;

    if (_rClicked)
    {
        _xRotation -= 0.1f * M_PI/180.0f * float(delta.y);
        if (_xRotation > M_PI/2.0)
        {
            _xRotation = M_PI/2.0;
        }
        else if (_xRotation < -M_PI/2.0)
        {
            _xRotation = -M_PI/2.0;
        }
        _yRotation -= 0.1f * M_PI/180.0f * float(delta.x);
        _cameraFront = Vector3(cos(_xRotation) * sin(_yRotation), sin(_xRotation), cos(_xRotation) * cos(_yRotation)).normalized();
        _cameraUp = Vector3(sin(_yRotation - M_PI/2.0f), 0.0f, cos(_yRotation - M_PI/2.0f)).cross(_cameraFront).normalized();
        _cameraRight = _cameraFront.cross(_cameraUp).normalized();
        //_prevMousePos = event.GetPosition();
        // wxPoint cursorPos = ClientToScreen(_prevMousePos);
        // WarpPointer(_prevMousePos.x, _prevMousePos.y);
        // SetCursorPos(cursorPos.x, cursorPos.y);
        Refresh();
    }
    if (_lClicked)
    {
        _cameraPosition -= _cameraSpeed * float(delta.x) * _cameraRight;
        _cameraPosition += _cameraSpeed * float(delta.y) * _cameraUp;
        //_cameraPosition.y() += _cameraSpeed * float(delta.y);
        // _prevMousePos = event.GetPosition();

        // warp pointer causes glcanvas to freeze (under linux). Consider not hiding the cursor
        // WarpPointer(_prevMousePos.x, _prevMousePos.y);
        Refresh();
    }
}
Example #14
0
wxString HtmlText::GetPlainLabel() const
{
    wxToolTip * tip = GetToolTip();
    return tip ? tip->GetTip() : wxString(wxEmptyString);
}
Example #15
0
CFrame::CFrame(wxFrame* parent,
		wxWindowID id,
		const wxString& title,
		const wxPoint& pos,
		const wxSize& size,
		bool _UseDebugger,
		bool _BatchMode,
		bool ShowLogWindow,
		long style)
	: CRenderFrame(parent, id, title, pos, size, style)
	, g_pCodeWindow(NULL), g_NetPlaySetupDiag(NULL), g_CheatsWindow(NULL)
	, m_ToolBar(NULL), m_ToolBarDebug(NULL), m_ToolBarAui(NULL)
	, m_GameListCtrl(NULL), m_Panel(NULL)
	, m_RenderFrame(NULL), m_RenderParent(NULL)
	, m_LogWindow(NULL), m_LogConfigWindow(NULL)
	, m_FifoPlayerDlg(NULL), UseDebugger(_UseDebugger)
	, m_bBatchMode(_BatchMode), m_bEdit(false), m_bTabSplit(false), m_bNoDocking(false)
	, m_bGameLoading(false)
{
	for (int i = 0; i <= IDM_CODEWINDOW - IDM_LOGWINDOW; i++)
		bFloatWindow[i] = false;

	if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;

	// Give it a console early to show potential messages from this onward
	ConsoleListener *Console = LogManager::GetInstance()->GetConsoleListener();
	if (SConfig::GetInstance().m_InterfaceConsole) Console->Open();

	// Start debugging maximized
	if (UseDebugger) this->Maximize(true);
	// Debugger class
	if (UseDebugger)
	{
		g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, IDM_CODEWINDOW);
		LoadIniPerspectives();
		g_pCodeWindow->Load();
	}

	// Create toolbar bitmaps
	InitBitmaps();

	// Give it a status bar
	SetStatusBar(CreateStatusBar(2, wxST_SIZEGRIP, ID_STATUSBAR));
	if (!SConfig::GetInstance().m_InterfaceStatusbar)
		GetStatusBar()->Hide();

	// Give it a menu bar
	CreateMenu();

	// ---------------
	// Main panel
	// This panel is the parent for rendering and it holds the gamelistctrl
	m_Panel = new CPanel(this, IDM_MPANEL);

	m_GameListCtrl = new CGameListCtrl(m_Panel, LIST_CTRL,
			wxDefaultPosition, wxDefaultSize,
			wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT);

	wxBoxSizer *sizerPanel = new wxBoxSizer(wxHORIZONTAL);
	sizerPanel->Add(m_GameListCtrl, 1, wxEXPAND | wxALL);
	m_Panel->SetSizer(sizerPanel);
	// ---------------

	// Manager
	m_Mgr = new wxAuiManager(this, wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);

	m_Mgr->AddPane(m_Panel, wxAuiPaneInfo()
			.Name(_T("Pane 0")).Caption(_T("Pane 0")).PaneBorder(false)
			.CaptionVisible(false).Layer(0).Center().Show());
	if (!g_pCodeWindow)
		m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo()
				.Name(_T("Pane 1")).Caption(_("Logging")).CaptionVisible(true)
				.Layer(0).FloatingSize(wxSize(600, 350)).CloseButton(true).Hide());
	AuiFullscreen = m_Mgr->SavePerspective();

	// Create toolbar
	RecreateToolbar();
	if (!SConfig::GetInstance().m_InterfaceToolbar) DoToggleToolbar(false);

	m_LogWindow = new CLogWindow(this, IDM_LOGWINDOW);
	m_LogWindow->Hide();
	m_LogWindow->Disable();

	g_TASInputDlg = new TASInputDlg(this);
	Movie::SetInputManip(TASManipFunction);

	State::SetOnAfterLoadCallback(OnAfterLoadCallback);

	// Setup perspectives
	if (g_pCodeWindow)
	{
		// Load perspective
		DoLoadPerspective();
	}
	else
	{
		if (SConfig::GetInstance().m_InterfaceLogWindow)
			ToggleLogWindow(true);
		if (SConfig::GetInstance().m_InterfaceLogConfigWindow)
			ToggleLogConfigWindow(true);
		if (SConfig::GetInstance().m_InterfaceConsole)
			ToggleConsole(true);
	}

	// Show window
	Show();

	// Commit
	m_Mgr->Update();

	#ifdef _WIN32
		SetToolTip(wxT(""));
		GetToolTip()->SetAutoPop(25000);
	#endif

	#if defined(HAVE_XRANDR) && HAVE_XRANDR
		m_XRRConfig = new X11Utils::XRRConfiguration(X11Utils::XDisplayFromHandle(GetHandle()),
				X11Utils::XWindowFromHandle(GetHandle()));
	#endif

	// -------------------------
	// Connect event handlers

	m_Mgr->Bind(wxEVT_AUI_RENDER, &CFrame::OnManagerResize, this);
	// ----------

	// Update controls
	UpdateGUI();
}
Example #16
0
void wxRibbonButtonBar::OnMouseMove(wxMouseEvent& evt)
{
    wxPoint cursor(evt.GetPosition());
    wxRibbonButtonBarButtonInstance* new_hovered = NULL;
    wxRibbonButtonBarButtonInstance* tooltipButton = NULL;
    long new_hovered_state = 0;

    wxRibbonButtonBarLayout* layout = m_layouts.Item(m_current_layout);
    size_t btn_count = layout->buttons.Count();
    size_t btn_i;
    for(btn_i = 0; btn_i < btn_count; ++btn_i)
    {
        wxRibbonButtonBarButtonInstance& instance = layout->buttons.Item(btn_i);
        wxRibbonButtonBarButtonSizeInfo& size = instance.base->sizes[instance.size];
        wxRect btn_rect;
        btn_rect.SetTopLeft(m_layout_offset + instance.position);
        btn_rect.SetSize(size.size);
        if(btn_rect.Contains(cursor))
        {
            if((instance.base->state & wxRIBBON_BUTTONBAR_BUTTON_DISABLED) == 0)
            {
                tooltipButton = &instance;
                new_hovered = &instance;
                new_hovered_state = instance.base->state;
                new_hovered_state &= ~wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK;
                wxPoint offset(cursor);
                offset -= btn_rect.GetTopLeft();
                if(size.normal_region.Contains(offset))
                {
                    new_hovered_state |= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_HOVERED;
                }
                if(size.dropdown_region.Contains(offset))
                {
                    new_hovered_state |= wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED;
                }
                break;
            }
            else if (m_show_tooltips_for_disabled)
            {
                tooltipButton = &instance;
            }
        }
    }

#if wxUSE_TOOLTIPS
    if(tooltipButton == NULL && GetToolTip())
    {
        UnsetToolTip();
    }
    if(tooltipButton)
    {
        SetToolTip(tooltipButton->base->help_string);
    }
#endif

    if(new_hovered != m_hovered_button || (m_hovered_button != NULL &&
        new_hovered_state != m_hovered_button->base->state))
    {
        if(m_hovered_button != NULL)
        {
            m_hovered_button->base->state &= ~wxRIBBON_BUTTONBAR_BUTTON_HOVER_MASK;
        }
        m_hovered_button = new_hovered;
        if(m_hovered_button != NULL)
        {
            m_hovered_button->base->state = new_hovered_state;
        }
        Refresh(false);
    }

    if(m_active_button && !m_lock_active_state)
    {
        long new_active_state = m_active_button->base->state;
        new_active_state &= ~wxRIBBON_BUTTONBAR_BUTTON_ACTIVE_MASK;
        wxRibbonButtonBarButtonSizeInfo& size =
            m_active_button->base->sizes[m_active_button->size];
        wxRect btn_rect;
        btn_rect.SetTopLeft(m_layout_offset + m_active_button->position);
        btn_rect.SetSize(size.size);
        if(btn_rect.Contains(cursor))
        {
            wxPoint offset(cursor);
            offset -= btn_rect.GetTopLeft();
            if(size.normal_region.Contains(offset))
            {
                new_active_state |= wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE;
            }
            if(size.dropdown_region.Contains(offset))
            {
                new_active_state |= wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE;
            }
        }
        if(new_active_state != m_active_button->base->state)
        {
            m_active_button->base->state = new_active_state;
            Refresh(false);
        }
    }
}
Example #17
0
void wxTabbedCtrl::OnMouse(wxMouseEvent &ev) {
    wxPoint mouse = ev.GetPosition();
    int page = HitTest(ev.GetPosition());
    if(ev.GetEventType()==wxEVT_MOTION) {
        bool xhover = mouse.x >= x_rect.x && mouse.x <= x_rect.x+x_rect.width && mouse.y >= x_rect.y && mouse.y <= x_rect.y+x_rect.height;
        bool nhover = (mouse.x >= Next_rect.x && mouse.x <= Next_rect.x + Next_rect.width && mouse.y >= Next_rect.y && mouse.y <= Next_rect.y + Next_rect.height ) &&
                      ( m_intLastPage < ( GetPageCount() - 1 ) );
        bool phover = (mouse.x >= Prev_rect.x && mouse.x <= Prev_rect.x + Prev_rect.width && mouse.y >= Prev_rect.y && mouse.y <= Prev_rect.y + Prev_rect.height ) &&
                      ( m_intStartPage > 0 );
        bool mhover = (mouse.x >= Menu_rect.x && mouse.x <= Menu_rect.x + Menu_rect.width && mouse.y >= Menu_rect.y && mouse.y <= Menu_rect.y + Menu_rect.height );
        if(hover != xhover) {
            hover = xhover;
            wxClientDC dc(this);
            DrawX(hover, dc);
        }
        else if(hover_next != nhover) {
            hover_next = nhover;
            wxClientDC dc(this);
            DrawNext(hover_next, dc);
        }
        else if(hover_prev != phover) {
            hover_prev = phover;
            wxClientDC dc(this);
            DrawPrev(hover_prev, dc);
        }
        else if ( hover_menu != mhover ) {
            hover_menu = mhover;
            wxClientDC dc(this);
            DrawMenu(hover_menu, dc);
        }
        else {
            wxToolTip * tooltip = GetToolTip();
            if ( page != wxNOT_FOUND ) {
                if ( tipTab != page ) {
                    tipTab = page;
                    tooltip->Enable( true );
                    wxString info;
                    int pg = page + 1;
                    info << pg << " of " << GetPageCount() << " - " << GetPageText( page );
                    tooltip->SetTip( info );
                }
            }
            else {
                tipTab = -1;
                tooltip->Enable( false );
            }
        }
    }
    else if( ev.GetEventType()==wxEVT_LEFT_UP ) {
        if(hover ) {
            wxClientDC dc(this);
            DrawX(false, dc);
            SetVisible( active );
            wxCommandEvent event( wxEVT_COMMAND_MENU_SELECTED, Menu_Close );
            GetEventHandler()->ProcessEvent( event );
        }
        else if( hover_next ) {
            wxClientDC dc(this);
            DrawNext(false, dc);
            if( GetPageCount() > ( m_intStartPage + 1 ) && ( m_intLastPage + 1 ) < GetPageCount() ) {
                m_intStartPage++;
                Refresh();
            }
        }
        else if( hover_prev ) {
            wxClientDC dc(this);
            DrawPrev(false, dc);
            if( m_intStartPage > 0 ) {
                m_intStartPage--;
                Refresh();
            }
        }
        else if( hover_menu ) {
            hover_menu = false;
            wxClientDC dc(this);
            DrawMenu(false, dc);
            GenerateConextMenu( mouse );
        }
        else {
            if(page != wxNOT_FOUND)
                SetSelection(page);
        }
    }
    else if( ev.GetEventType() == wxEVT_RIGHT_UP && page == wxNOT_FOUND ) {
        GenerateConextMenu( mouse );
    }
}