示例#1
0
void wxToolTip::DoSetTip(WXHWND hWnd)
{
    // update the tip text shown by the control
    wxToolInfo ti((HWND)hWnd, m_id, m_rect);

    // for some reason, changing the tooltip text directly results in
    // repaint of the controls under it, see #10520 -- but this doesn't
    // happen if we reset it first
    ti.lpszText = const_cast<wxChar *>(wxT(""));
    (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti);

    ti.lpszText = wxMSW_CONV_LPTSTR(m_text);
    (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti);
}
示例#2
0
// @pymethod |PyCToolTipCtrl|CreateWindow|Creates the actual control.
static PyObject *
PyCToolTipCtrl_create_window(PyObject *self, PyObject *args)
{
	int style;
	PyObject *obParent;
	if (!PyArg_ParseTuple(args, "Oi:CreateWindow", 
			   &obParent, // @pyparm <o PyCWnd>|parent||The parent window of the control.
			   &style)) // @pyparm int|style||The style for the control.
		return NULL;

	if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type))
		RETURN_TYPE_ERR("parent argument must be a window object");
	CWnd *pParent = GetWndPtr( obParent );
	if (pParent==NULL)
		return NULL;
	CToolTipCtrl *pTTC = GetToolTipCtrl(self);
	if (!pTTC)
		return NULL;

	BOOL ok;
	GUI_BGN_SAVE;
	ok = pTTC->Create(pParent,style);
	GUI_END_SAVE;
	if (!ok)
		RETURN_ERR("CToolTipCtrl::Create");
	RETURN_NONE;
}
示例#3
0
void wxToolTip::Enable(bool flag)
{
    // Make sure the tooltip has been created
    (void) GetToolTipCtrl();

    SendTooltipMessageToAll(ms_hwndTT, TTM_ACTIVATE, flag, 0);
}
示例#4
0
BOOL COptionsPage::OnInitDialog(void)
{
	// invoke inherited handler
	BOOL fResult = __super::OnInitDialog();

	// setup controls as needed
	m_dtpWrite.SetFormat(_T("dd.MM.yyyy   HH:mm:ss"));
	long tz_delta = _timezone / 3600;
	CTime timeMin(1970, 1, 1, 0 - tz_delta, 0, 0);
	CTime timeMax(2038, 1, 18, 0 - tz_delta, 0, 0);
	m_dtpWrite.SetRange(&timeMin, &timeMax);
	if (m_timeWrite != -1)
	{
		m_dtpWrite.SetTime(&m_timeWrite);
	}

	// assign tool tips
	CToolTipCtrl& tipWnd = GetToolTipCtrl();
	tipWnd.AddTool(GetDlgItem(IDC_EDIT_SOURCE));
	tipWnd.AddTool(GetDlgItem(IDC_BUTTON_SOURCE));
	tipWnd.AddTool(GetDlgItem(IDC_CHECK_RECURSE));
	tipWnd.AddTool(GetDlgItem(IDC_EDIT_EXCLUDE));
	tipWnd.AddTool(GetDlgItem(IDC_EDIT_TARGET));
	tipWnd.AddTool(GetDlgItem(IDC_BUTTON_TARGET));
	tipWnd.AddTool(GetDlgItem(IDC_CHECK_CLEANUP));
	tipWnd.AddTool(GetDlgItem(IDC_CHECK_RECYCLE));
	tipWnd.AddTool(GetDlgItem(IDC_DTP_WRITE));
	tipWnd.AddTool(GetDlgItem(IDC_CHECK_COMPARE));
	tipWnd.Activate(TRUE);

	// initialized
	return (fResult);
}
示例#5
0
// @pymethod |PyCToolTipCtrl|UpdateTipText|Update the tool tip text for a control's tools
static PyObject *
PyCToolTipCtrl_update_tip_text(PyObject *self, PyObject *args)
	{
	PyObject *obWnd;
	TCHAR *pszText;
	PyObject *obText;
	UINT nIDTool;
	if (!PyArg_ParseTuple(args, "OOi:UpdateTipText", 
			   &obText,// @pyparm string|text||The text for the tool.
			   &obWnd, // @pyparm <o PyCWnd>|wnd||The window of the tool.
			   &nIDTool// @pyparm int|id||The id of the tool
			   )) 
		return NULL;

	CWnd *pWndToolOwner = NULL;
	if (obWnd != Py_None) 
		{
		if (!ui_base_class::is_uiobject(obWnd,&PyCWnd::type))
			RETURN_TYPE_ERR("wnd argument must be a window object");
		pWndToolOwner = GetWndPtr(obWnd);
		if (pWndToolOwner==NULL)
			RETURN_TYPE_ERR("The window is not a valid PyCWnd");
		}

	CToolTipCtrl *pTTC = GetToolTipCtrl(self);
	if (!pTTC)return NULL;
	if (!PyWinObject_AsTCHAR(obText, &pszText, FALSE))
		return NULL;
	GUI_BGN_SAVE;
	pTTC->UpdateTipText(pszText,pWndToolOwner,nIDTool);
	GUI_END_SAVE;
	PyWinObject_FreeTCHAR(pszText);
	RETURN_NONE;
	}
示例#6
0
void wxToolTip::SetDelay(long milliseconds)
{
    // Make sure the tooltip has been created
    (void) GetToolTipCtrl();

    SendTooltipMessageToAll(ms_hwndTT, TTM_SETDELAYTIME,
                            TTDT_INITIAL, milliseconds);
}
示例#7
0
文件: tooltip.cpp 项目: Duion/Torsion
void wxToolTip::Remove()
{
    // remove this tool from the tooltip control
    if ( m_window )
    {
        wxToolInfo ti(GetHwndOf(m_window));
        (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti);
    }
}
示例#8
0
void wxToolTip::SetTip(const wxString& tip)
{
    m_text = tip;

    if ( m_window )
    {
        // update the tip text shown by the control
        wxToolInfo ti(GetHwndOf(m_window), m_id, m_rect);

        // for some reason, changing the tooltip text directly results in
        // repaint of the controls under it, see #10520 -- but this doesn't
        // happen if we reset it first
        ti.lpszText = const_cast<wxChar *>(wxT(""));
        (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti);

        ti.lpszText = const_cast<wxChar *>(m_text.wx_str());
        (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti);
    }
}
示例#9
0
void wxToolTip::SetRect(const wxRect& rc)
{
    m_rect = rc;

    if ( m_window )
    {
        wxToolInfo ti(GetHwndOf(m_window), m_id, m_rect);
        (void)SendTooltipMessage(GetToolTipCtrl(), TTM_NEWTOOLRECT, &ti);
    }
}
示例#10
0
文件: tooltip.cpp 项目: Duion/Torsion
void wxToolTip::SetTip(const wxString& tip)
{
    m_text = tip;

    if ( m_window )
    {
        // update the tip text shown by the control
        wxToolInfo ti(GetHwndOf(m_window));
        ti.lpszText = (wxChar *)m_text.c_str();

        (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
    }
}
示例#11
0
// @pymethod |PyCToolTipCtrl|AddTool|Adds a tool to tooltip control.
static PyObject *
PyCToolTipCtrl_add_tool(PyObject *self, PyObject *args)
	{
	PyObject *obWnd,*obRect;
	TCHAR *pszText;
	PyObject *obText;
	UINT nIDTool;
	if (!PyArg_ParseTuple(args, "OOOi:CreateWindow", 
			   &obWnd, // @pyparm <o PyCWnd>|wnd||The window of the tool.
			   &obText,// @pyparm string|text||The text for the tool.
			   &obRect, // @pyparm int, int, int, int|rect|None|The default rectangle
			   &nIDTool// @pyparm int|id||The id of the tool
			   )) 
		return NULL;

	CWnd *pWnd = NULL;
	if (obWnd != Py_None) 
		{
		if (!ui_base_class::is_uiobject(obWnd,&PyCWnd::type))
			RETURN_TYPE_ERR("wnd argument must be a window object");
		pWnd = GetWndPtr(obWnd);
		if (pWnd==NULL)
			RETURN_TYPE_ERR("The window is not a valid PyCWnd");
		}

	RECT rect;
	RECT *pRectTool=NULL;
	if (obRect != Py_None) 
		{
		if (!PyArg_ParseTuple(obRect, "iiii", &rect.left,  &rect.top,  &rect.right,&rect.bottom)) 
			{
			PyErr_Clear();
			RETURN_TYPE_ERR("Rect must be None or a tuple of (iiii)");
			}
		pRectTool=&rect;
		}


	CToolTipCtrl *pTTC = GetToolTipCtrl(self);
	if (!pTTC)return NULL;
	if (!PyWinObject_AsTCHAR(obText, &pszText, FALSE))
		return NULL;
	GUI_BGN_SAVE;
	BOOL ok=pTTC->AddTool(pWnd,pszText,pRectTool,nIDTool);
	GUI_END_SAVE;
	PyWinObject_FreeTCHAR(pszText);
	if (!ok)
		RETURN_ERR("CToolTipCtrl::AddTool");
	RETURN_NONE;
	}
示例#12
0
void wxToolTip::DoAddHWND(WXHWND hWnd)
{
    HWND hwnd = (HWND)hWnd;

    wxToolInfo ti(hwnd, m_id, m_rect);

    // another possibility would be to specify LPSTR_TEXTCALLBACK here as we
    // store the tooltip text ourselves anyhow, and provide it in response to
    // TTN_NEEDTEXT (sent via WM_NOTIFY), but then we would be limited to 79
    // character tooltips as this is the size of the szText buffer in
    // NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips
    // of any length
    ti.hwnd = hwnd;
    ti.lpszText = wxMSW_CONV_LPTSTR(m_text);

    if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
    {
        wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str());

        return;
    }

#ifdef TTM_SETMAXTIPWIDTH
    if ( !AdjustMaxWidth() )
#endif // TTM_SETMAXTIPWIDTH
    {
        // replace the '\n's with spaces because otherwise they appear as
        // unprintable characters in the tooltip string
        m_text.Replace(wxT("\n"), wxT(" "));
        ti.lpszText = wxMSW_CONV_LPTSTR(m_text);

        if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
        {
            wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str());
        }
    }
}
示例#13
0
void wxToolTip::SetTip( const wxString &tip )
{
    m_text = tip;

    if ( m_window )
    {
#if 0
    // update it immediately
    wxToolInfo ti(GetHwndOf(m_window));
    ti.lpszText = (wxChar *)m_text.c_str();

    (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
#endif
    }
}
示例#14
0
// @pymethod int|PyCToolTipCtrl|SetMaxTipWidth|
static PyObject *
PyCToolTipCtrl_set_max_tip_width(PyObject *self, PyObject *args)
	{
	int width;
	if (!PyArg_ParseTuple(args, "i:SetMaxTipWidth", 
			   &width)) // @pyparm int|width||The new width
		return NULL;

	CToolTipCtrl *pTTC = GetToolTipCtrl(self);
	if (!pTTC)return NULL;

	GUI_BGN_SAVE;
	int rc = pTTC->SetMaxTipWidth(width);
	GUI_END_SAVE;
	return PyInt_FromLong(rc);
}
示例#15
0
void wxToolTip::Add(WXHWND hWnd)
{
    HWND hwnd = (HWND)hWnd;

    wxToolInfo ti(hwnd, m_id, m_rect);

    // another possibility would be to specify LPSTR_TEXTCALLBACK here as we
    // store the tooltip text ourselves anyhow, and provide it in response to
    // TTN_NEEDTEXT (sent via WM_NOTIFY), but then we would be limited to 79
    // character tooltips as this is the size of the szText buffer in
    // NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips
    // of any length
    ti.hwnd = hwnd;
    ti.lpszText = const_cast<wxChar *>(m_text.wx_str());

    if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
    {
        wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str());

        return;
    }

#ifdef TTM_SETMAXTIPWIDTH
    if ( wxApp::GetComCtl32Version() >= 470 )
    {
        // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the
        // extent of its first line as max value
        HFONT hfont = (HFONT)
            SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);

        if ( !hfont )
        {
            hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            if ( !hfont )
            {
                wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));
            }
        }

        MemoryHDC hdc;
        if ( !hdc )
        {
            wxLogLastError(wxT("CreateCompatibleDC(NULL)"));
        }

        if ( !SelectObject(hdc, hfont) )
        {
            wxLogLastError(wxT("SelectObject(hfont)"));
        }

        // find the width of the widest line
        int maxWidth = 0;
        wxStringTokenizer tokenizer(m_text, wxT("\n"));
        while ( tokenizer.HasMoreTokens() )
        {
            const wxString token = tokenizer.GetNextToken();

            SIZE sz;
            if ( !::GetTextExtentPoint32(hdc, token.wx_str(),
                                         token.length(), &sz) )
            {
                wxLogLastError(wxT("GetTextExtentPoint32"));
            }

            if ( sz.cx > maxWidth )
                maxWidth = sz.cx;
        }

        // limit size to ms_maxWidth, if set
        if ( ms_maxWidth == 0 )
        {
            // this is more or less arbitrary but seems to work well
            static const int DEFAULT_MAX_WIDTH = 400;

            ms_maxWidth = wxGetClientDisplayRect().width / 2;

            if ( ms_maxWidth > DEFAULT_MAX_WIDTH )
                ms_maxWidth = DEFAULT_MAX_WIDTH;
        }

        if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth )
            maxWidth = ms_maxWidth;

        // only set a new width if it is bigger than the current setting:
        // otherwise adding a tooltip with shorter line(s) than a previous
        // one would result in breaking the longer lines unnecessarily as
        // all our tooltips share the same maximal width
        if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(),
                                           TTM_GETMAXTIPWIDTH, 0) )
        {
            SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
                               wxUIntToPtr(maxWidth));
        }
    }
    else
#endif // TTM_SETMAXTIPWIDTH
    {
        // replace the '\n's with spaces because otherwise they appear as
        // unprintable characters in the tooltip string
        m_text.Replace(wxT("\n"), wxT(" "));
        ti.lpszText = const_cast<wxChar *>(m_text.wx_str());

        if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
        {
            wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str());
        }
    }
}
示例#16
0
/* static */
void wxToolTip::Remove(WXHWND hWnd, unsigned int id, const wxRect& rc)
{
    wxToolInfo ti((HWND)hWnd, id, rc);

    (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, &ti);
}
示例#17
0
/* static */
void wxToolTip::RelayEvent(WXMSG *msg)
{
    (void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, msg);
}
示例#18
0
void wxToolTip::Remove(WXHWND hWnd)
{
    wxToolInfo ti((HWND)hWnd);
    (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, &ti);
}
示例#19
0
bool wxToolTip::AdjustMaxWidth()
{
    // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the
    // extent of its first line as max value
    HFONT hfont = (HFONT)
        SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);

    if ( !hfont )
    {
        hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
        if ( !hfont )
        {
            wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));
        }
    }

    MemoryHDC hdc;
    if ( !hdc )
    {
        wxLogLastError(wxT("CreateCompatibleDC(NULL)"));
    }

    if ( !SelectObject(hdc, hfont) )
    {
        wxLogLastError(wxT("SelectObject(hfont)"));
    }

    // find the width of the widest line
    int maxWidth = 0;
    wxStringTokenizer tokenizer(m_text, wxT("\n"));
    while ( tokenizer.HasMoreTokens() )
    {
        const wxString token = tokenizer.GetNextToken();

        SIZE sz;
        if ( !::GetTextExtentPoint32(hdc, token.t_str(),
                                     token.length(), &sz) )
        {
            wxLogLastError(wxT("GetTextExtentPoint32"));
        }

        if ( sz.cx > maxWidth )
            maxWidth = sz.cx;
    }

    // limit size to ms_maxWidth, if set
    if ( ms_maxWidth == 0 )
    {
        // this is more or less arbitrary but seems to work well
        static const int DEFAULT_MAX_WIDTH = 400;

        ms_maxWidth = wxGetClientDisplayRect().width / 2;

        if ( ms_maxWidth > DEFAULT_MAX_WIDTH )
            ms_maxWidth = DEFAULT_MAX_WIDTH;
    }

    if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth )
        maxWidth = ms_maxWidth;

    // only set a new width if it is bigger than the current setting:
    // otherwise adding a tooltip with shorter line(s) than a previous
    // one would result in breaking the longer lines unnecessarily as
    // all our tooltips share the same maximal width
    if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(),
                                       TTM_GETMAXTIPWIDTH, 0) )
    {
        SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
                           wxUIntToPtr(maxWidth));
    }

    return true;
}
示例#20
0
文件: tooltip.cpp 项目: Duion/Torsion
void wxToolTip::Add(WXHWND hWnd)
{
    HWND hwnd = (HWND)hWnd;

    wxToolInfo ti(hwnd);

    // another possibility would be to specify LPSTR_TEXTCALLBACK here as we
    // store the tooltip text ourselves anyhow, and provide it in response to
    // TTN_NEEDTEXT (sent via WM_NOTIFY), but then we would be limited to 79
    // character tooltips as this is the size of the szText buffer in
    // NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips
    // of any length
    ti.hwnd = hwnd;
    ti.lpszText = (wxChar *)m_text.c_str(); // const_cast

    if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
    {
        wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str());
    }
    else
    {
        // check for multiline toopltip
        int index = m_text.Find(_T('\n'));

        if ( index != wxNOT_FOUND )
        {
#ifdef TTM_SETMAXTIPWIDTH
            if ( wxApp::GetComCtl32Version() >= 470 )
            {
                // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the
                // extent of its first line as max value
                HFONT hfont = (HFONT)SendTooltipMessage(GetToolTipCtrl(),
                                                        WM_GETFONT,
                                                        0, 0);
                if ( !hfont )
                {
                    hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
                    if ( !hfont )
                    {
                        wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)"));
                    }
                }

                MemoryHDC hdc;
                if ( !hdc )
                {
                    wxLogLastError(wxT("CreateCompatibleDC(NULL)"));
                }

                if ( !SelectObject(hdc, hfont) )
                {
                    wxLogLastError(wxT("SelectObject(hfont)"));
                }

                SIZE sz;
                if ( !::GetTextExtentPoint32(hdc, m_text, index, &sz) )
                {
                    wxLogLastError(wxT("GetTextExtentPoint32"));
                }

                SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
                                   0, (void *)sz.cx);
            }
            else
#endif // comctl32.dll >= 4.70
            {
                // replace the '\n's with spaces because otherwise they appear as
                // unprintable characters in the tooltip string
                m_text.Replace(_T("\n"), _T(" "));
                ti.lpszText = (wxChar *)m_text.c_str(); // const_cast

                if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
                {
                    wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str());
                }
            }
        }
    }
}