// @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; }
// @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=▭ } 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; }
// @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; }
// @pymethod |PyCDialogBar|CreateWindow|Creates the window for the <o PyCDialogBar> object. static PyObject *PyCDialogBar_CreateWindow(PyObject *self, PyObject *args) { TCHAR *szTemplate; UINT style, id; PyObject *obParent, *obTemplate; // @pyparm <o PyCWnd>|parent||The parent window // @pyparm <o PyResourceId>|template||Template name or integer resource id // @pyparm int|style||The style for the window // @pyparm int|id||The ID of the window if (!PyArg_ParseTuple(args, "OOii", &obParent, &obTemplate, &style, &id)) return NULL; CDialogBar *pDialog = PyCDialogBar::GetDialogBar(self); if (pDialog==NULL) return NULL; CWnd *pParent = NULL; if (obParent != Py_None) { pParent = PyCWnd::GetPythonGenericWnd(obParent, &PyCWnd::type); if (pParent==NULL) RETURN_TYPE_ERR("The parent window is not a valid PyCWnd"); } if (!PyWinObject_AsResourceId(obTemplate, &szTemplate, FALSE)) return NULL; BOOL rc; GUI_BGN_SAVE; if (IS_INTRESOURCE(szTemplate)) rc=pDialog->Create(pParent, MAKEINTRESOURCE(szTemplate), style, id); else rc=pDialog->Create(pParent, szTemplate, style, id); GUI_END_SAVE; PyWinObject_FreeResourceId(szTemplate); if (!rc) RETURN_ERR("CDialogBar::Create failed"); RETURN_NONE; }
// @pymethod |PyCWinApp|AddDocTemplate|Adds a template to the application list. static PyObject * ui_app_add_doc_template(PyObject *self, PyObject *args) { PyObject *obTemplate; if (!PyArg_ParseTuple(args,"O:AddDocTemplate", &obTemplate)) // @pyparm <o PyCDocTemplate>|template||The template to be added. return NULL; if (!ui_base_class::is_uiobject(obTemplate, &PyCDocTemplate::type)) RETURN_TYPE_ERR("The parameter must be a template object"); CDocTemplate *pTempl = PyCDocTemplate::GetTemplate(obTemplate); if (pTempl==NULL) return NULL; CWinApp *pApp = GetApp(); if (!pApp) return NULL; // walk all templates in the application looking for it. CDocTemplate* pTemplate; POSITION pos = pApp->m_pDocManager ? pApp->m_pDocManager->GetFirstDocTemplatePosition() : NULL; while (pos != NULL) { pTemplate = pApp->m_pDocManager->GetNextDocTemplate(pos); if (pTemplate==pTempl) RETURN_ERR("The template is already in the application list"); } GUI_BGN_SAVE; pApp->AddDocTemplate(pTempl); GUI_END_SAVE; RETURN_NONE; }
// @pymethod |PyCPropertySheet|RemovePage|Removes the specified page from the sheet. PyObject *ui_propsheet_remove_page( PyObject *self, PyObject *args ) { CPropertySheet *pPS; if (!(pPS=GetPropSheet(self))) return NULL; PyObject *ob; // @pyparm int|offset||The page number to remove // @pyparmalt1 <o PyCPropertyPage>|page||The page to remove if (!PyArg_ParseTuple( args, "O", &ob)) return NULL; if (PyInt_Check(ob)) { int id = (int)PyInt_AsLong(ob); GUI_BGN_SAVE; pPS->RemovePage(id); GUI_END_SAVE; } else if (ui_base_class::is_uiobject(ob, &PyCPropertyPage::type)) { CPythonPropertyPage * pPage = GetPropPage(ob); if (!pPage) return NULL; GUI_BGN_SAVE; pPS->RemovePage(pPage); GUI_END_SAVE; } else RETURN_TYPE_ERR("passed object must be an integer or PyCPropertyPage object"); RETURN_NONE; }
// @pymethod |PyCEdit|CreateWindow|Creates the window for a new Edit object. static PyObject * PyCEdit_create_window(PyObject *self, PyObject *args) { int style, id; PyObject *obParent; RECT rect; if (!PyArg_ParseTuple(args, "i(iiii)Oi:CreateWindow", &style, // @pyparm int|style||The style for the Edit. Use any of the win32con.BS_* constants. &rect.left,&rect.top,&rect.right,&rect.bottom, // @pyparm (left, top, right, bottom)|rect||The size and position of the Edit. &obParent, // @pyparm <o PyCWnd>|parent||The parent window of the Edit. Usually a <o PyCDialog>. &id )) // @pyparm int|id||The Edits control ID. 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; CEdit *pEdit = GetEditCtrl(self); if (!pEdit) return NULL; BOOL ok; GUI_BGN_SAVE; ok = pEdit->Create(style, rect, pParent, id ); GUI_END_SAVE; if (!ok) RETURN_ERR("CEdit::Create"); RETURN_NONE; }
// @pymethod <o PyCPropertySheet>|win32ui|CreatePropertySheet|Creates a property sheet object. PyObject *PyCPropertySheet::create( PyObject *self, PyObject *args ) { PyObject *obParent = NULL, *obCaption; TCHAR *Caption; CWnd *pParent = NULL; int iSelect = 0; if (!PyArg_ParseTuple(args,"O|Oi", &obCaption, // @pyparm <o PyResourceId>|caption||The caption for the property sheet, or id of the caption &obParent, // @pyparm <o PyCWnd>|parent|None|The parent window of the property sheet. &iSelect)) // @pyparm int|select|0|The index of the first page to be selected. return NULL; if (obParent) { if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type)) RETURN_TYPE_ERR("parameter 2 must be a PyCWnd object"); pParent = (CWnd *)PyCWnd::GetPythonGenericWnd(obParent); } CPythonPropertySheet *pPS; if (!PyWinObject_AsResourceId(obCaption, &Caption, FALSE)) return NULL; if (IS_INTRESOURCE(Caption)){ GUI_BGN_SAVE; pPS = new CPythonPropertySheet(MAKEINTRESOURCE(Caption), pParent, iSelect); GUI_END_SAVE; } else{ GUI_BGN_SAVE; pPS = new CPythonPropertySheet(Caption, pParent, iSelect); GUI_END_SAVE; } PyWinObject_FreeResourceId(Caption); PyCPropertySheet *ret = (PyCPropertySheet *)ui_assoc_object::make( PyCPropertySheet::type, pPS); return ret; }
CPythonPropertySheet *GetPythonPropSheet(PyObject *self) { CPythonPropertySheet *ret = (CPythonPropertySheet *)PyCWnd::GetPythonGenericWnd(self, &PyCPropertySheet::type); if (!ret->IsKindOf(RUNTIME_CLASS(CPythonPropertySheet))) RETURN_TYPE_ERR("Object is not of the correct type"); return ret; }
// @pymethod |PyCWinApp|RemoveDocTemplate|Removes a template to the application list. static PyObject * ui_app_remove_doc_template(PyObject *self, PyObject *args) { // @comm Note that MFC does not provide an equivilent function. PyObject *obTemplate; if (!PyArg_ParseTuple(args,"O:RemoveDocTemplate", &obTemplate)) // @pyparm <o PyCDocTemplate>|template||The template to be removed. Must have previously been added by <om PyCWinApp.AddDocTemplate>. return NULL; if (!ui_base_class::is_uiobject(obTemplate, &PyCDocTemplate::type)) RETURN_TYPE_ERR("The parameter must be a template object"); CDocTemplate *pTempl = PyCDocTemplate::GetTemplate(obTemplate); if (pTempl==NULL) return NULL; GUI_BGN_SAVE; BOOL ok = PyCDocTemplate::RemoveDocTemplateFromApp( pTempl ); GUI_END_SAVE; if (!ok) RETURN_ERR("The template is not in the application template list"); RETURN_NONE; }
// @pymethod <o PyCMenu>|win32ui|LoadMenu|Creates and loads a menu resource from a DLL. PyObject *PyCMenu::load_menu(PyObject *self, PyObject *args) { int id; PyObject *dllObj = NULL; HMODULE hMod = NULL; // @pyparm int|id||The Id of the menu to load. // @pyparm <o PyDLL>|dll|None|The DLL to load from. if (!PyArg_ParseTuple(args, "i|O", &id, &dllObj)) return NULL; if (dllObj && dllObj!=Py_None) { // passed a DLL object. if (!is_uiobject(dllObj, &dll_object::type)) RETURN_TYPE_ERR("passed object must be a PyDLL object"); hMod = ((dll_object *)dllObj)->GetDll(); } else hMod = AfxFindResourceHandle( MAKEINTRESOURCE(id), RT_MENU ); HMENU hMenu = ::LoadMenu(hMod, MAKEINTRESOURCE(id)); if (!hMenu) RETURN_API_ERR("LoadMenu"); return ui_assoc_object::make(PyCMenu::type, hMenu); }
// @pymethod |PyCPropertySheet|CreateWindow|Displays the property sheet as a modeless dialog. PyObject *ui_propsheet_create_window( PyObject *self, PyObject *args ) { PyObject *obParent = NULL; int dwStyle = WS_SYSMENU | WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_VISIBLE; int dwExStyle = WS_EX_DLGMODALFRAME; CWnd *pParent = NULL; // @pyparm <o PyCWnd>|parent|None|The parent of the dialog. // @pyparm int|style|WS_SYSMENU\|WS_POPUP\|WS_CAPTION\|DS_MODALFRAME\|WS_VISIBLE|The style for the window. // @pyparm int|exStyle|WS_EX_DLGMODALFRAME|The extended style for the window. if (!PyArg_ParseTuple(args,"|Oll", &obParent, &dwStyle, &dwExStyle)) return NULL; if (obParent && obParent!=Py_None) { if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type)) RETURN_TYPE_ERR("parameter 1 must be a PyCWnd object"); pParent = (CWnd *)PyCWnd::GetPythonGenericWnd(obParent); if (!pParent) return NULL; } CPythonPropertySheet *pPS; if (!(pPS=GetPythonPropSheet(self))) return NULL; if (!PropSheetCheckForDisplay(pPS)) return NULL; int rc; const char *failMsg = "Create() failed"; GUI_BGN_SAVE; try { rc=pPS->Create(pParent, dwStyle, dwExStyle ); } catch (...) { rc = NULL; failMsg = "Create() caused an exception - it is likely that the specified template can not be located"; } GUI_END_SAVE; if (!rc) RETURN_ERR((char *)failMsg); RETURN_NONE; }
/////////////////////////////////////// // // PropSheet Methods // // @pymethod |PyCPropertySheet|AddPage|Adds the supplied page with the rightmost tab in the property sheet. PyObject *ui_propsheet_add_page( PyObject *self, PyObject *args ) { PyObject *obPage; CPythonPropertyPage *pPage; if (!PyArg_ParseTuple(args,"O", &obPage)) // @pyparm <o PyCPropertyPage>|page||The page to be added. return NULL; if (!ui_base_class::is_uiobject(obPage, &PyCPropertyPage::type)) { RETURN_TYPE_ERR("passed object must be a PyCPropertyPage object"); } pPage = GetPropPage(obPage); if (!pPage) return NULL; CPythonPropertySheet *pPS; if (!(pPS=GetPythonPropSheet(self))) return NULL; GUI_BGN_SAVE; pPS->AddPage(pPage); // @pyseemfc PyCPropertySheet|AddPage GUI_END_SAVE; // @comm Add pages to the property sheet in the left-to-right order you want them to appear. RETURN_NONE; }