Update of /cvsroot/pywin32/pywin32/Pythonwin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11255
Modified Files:
win32assoc.cpp win32assoc.h win32toolbar.cpp
Log Message:
A couple of new toolbar methods, and prevent us looking for an existing
toolbar object - we may get the wrong one when MFC pulls its tricks of
reusing the underlying control as the MFC class.
Index: win32assoc.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32assoc.h 1 Sep 1999 23:33:00 -0000 1.1
--- win32assoc.h 7 Sep 2004 02:26:20 -0000 1.2
***************
*** 44,48 ****
public: // some probably shouldnt be, but...
PyObject *GetGoodRet();
! static ui_assoc_object *make( ui_type &makeType, void * search );
// Given a C++ object, return a PyObject associated (map lookup)
--- 44,48 ----
public: // some probably shouldnt be, but...
PyObject *GetGoodRet();
! static ui_assoc_object *make( ui_type &makeType, void * search, bool skipLookup=false );
// Given a C++ object, return a PyObject associated (map lookup)
Index: win32assoc.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** win32assoc.cpp 26 Apr 2004 01:19:07 -0000 1.5
--- win32assoc.cpp 7 Sep 2004 02:26:20 -0000 1.6
***************
*** 260,267 ****
}
! /*static*/ ui_assoc_object *ui_assoc_object::make( ui_type &makeType, void *search )
{
ASSERT(search); // really only a C++ problem.
! ui_assoc_object* ret = (ui_assoc_object*)handleMgr.GetAssocObject(search);
if (ret) {
if (!ret->is_uiobject(&makeType))
--- 260,269 ----
}
! /*static*/ ui_assoc_object *ui_assoc_object::make( ui_type &makeType, void *search, bool skipLookup )
{
ASSERT(search); // really only a C++ problem.
! ui_assoc_object* ret=NULL;
! if (!skipLookup)
! ret = (ui_assoc_object*) handleMgr.GetAssocObject(search);
if (ret) {
if (!ret->is_uiobject(&makeType))
Index: win32toolbar.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32toolbar.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** win32toolbar.cpp 1 Sep 1999 23:33:02 -0000 1.1
--- win32toolbar.cpp 7 Sep 2004 02:26:20 -0000 1.2
***************
*** 821,826 ****
if (!pToolBar) return NULL;
! CToolBarCtrl &pTBC = pToolBar->GetToolBarCtrl();
! return ui_assoc_object::make (PyCToolBarCtrl::type, pTBC)->GetGoodRet();
}
--- 821,831 ----
if (!pToolBar) return NULL;
! CToolBarCtrl &rTBC = pToolBar->GetToolBarCtrl();
! // Note that below we take the address of rTBC because it's a reference and not a pointer
! // and ui_assoc_object::make expects a pointer.
! // We need to create a new class and not do a map lookup because in MFC CToolBarCtrl is
! // simply a casted CToolBarCtrl (afxext.inl) so the lookup will return the PyCToolBar object
! // which will fail the type tests.
! return ui_assoc_object::make (PyCToolBarCtrl::type, &rTBC, true)->GetGoodRet();
}
***************
*** 913,917 ****
/* static */ CToolBarCtrl *GetToolBarCtrl (PyObject *self)
{
! return (CToolBarCtrl *)ui_assoc_CObject::GetGoodCppObject( self, &PyCToolBarCtrl::type);
}
--- 918,925 ----
/* static */ CToolBarCtrl *GetToolBarCtrl (PyObject *self)
{
! // note we can only ask for a CWnd since the same object can be both
! // a PyCToolBar and a PyCToolBarCtrl instance and their only common
! // base class is PyCWnd. Otherwise the RTTI call will fail
! return (CToolBarCtrl *)PyCWnd::GetPythonGenericWnd(self);
}
***************
*** 1474,1481 ****
int style = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM;
int id = AFX_IDW_STATUS_BAR;
! if (!PyArg_ParseTuple (args,"O|ii:CreateStatusBar",
! &parent, // @pyparm <o PyCWnd>|parent||The parent window for the status bar.
&style, // @pyparm int|style|afxres.WS_CHILD \| afxres.WS_VISIBLE \| afxres.CBRS_BOTTOM|The style for the status bar.
! &id)) // @pyparm int|windowId|afxres.AFX_IDW_STATUS_BAR|The child window ID.
return NULL;
if (!ui_base_class::is_uiobject (parent, &PyCWnd::type))
--- 1482,1495 ----
int style = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM;
int id = AFX_IDW_STATUS_BAR;
! int ctrlStyle = 0;
! if (!PyArg_ParseTuple (args,"O|iii:CreateStatusBar",
! &parent, // @pyparm <o PyCWnd>|parent||The parent window for the status bar.
&style, // @pyparm int|style|afxres.WS_CHILD \| afxres.WS_VISIBLE \| afxres.CBRS_BOTTOM|The style for the status bar.
! &id, // @pyparm int|windowId|afxres.AFX_IDW_STATUS_BAR|The child window ID.
! &ctrlStyle)) // @pyparm int|ctrlStype|0|Additional styles for the creation of the embedded <o PyCStatusBarCtrl> object.
! // <nl>Status bar styles supported are:<nl>commctrl.SBARS_SIZEGRIP - The status bar control includes a
! // sizing grip at the right end of the status bar. A sizing grip is similar to a sizing border;
! // it is a rectangular area that the user can click and drag to resize the parent window.
! // <nl>commctrl.SBT_TOOLTIPS - The status bar supports tooltips.
return NULL;
if (!ui_base_class::is_uiobject (parent, &PyCWnd::type))
***************
*** 1494,1502 ****
BOOL ok;
GUI_BGN_SAVE;
! ok = sb->Create (frame, style, id);
GUI_END_SAVE;
if (!ok) {
delete sb;
! RETURN_API_ERR("CStatusBar.Create");
}
sb->m_bAutoDelete = TRUE; // let MFC handle deletion??? really?? Cloned from toolbar - not so sure about status bar!!
--- 1508,1516 ----
BOOL ok;
GUI_BGN_SAVE;
! ok = sb->CreateEx (frame, ctrlStyle, style, id); // @pyseemfc CStatusBar|CreateEx
GUI_END_SAVE;
if (!ok) {
delete sb;
! RETURN_API_ERR("CStatusBar.CreateEx");
}
sb->m_bAutoDelete = TRUE; // let MFC handle deletion??? really?? Cloned from toolbar - not so sure about status bar!!
***************
*** 1504,1507 ****
--- 1518,1561 ----
}
+ // @pymethod (id, style, width)|PyCStatusBar|GetPaneInfo|Returns the id, style, and width of the indicator pane at the location specified by index.
+ PyObject *
+ PyCStatusBar_GetPaneInfo( PyObject *self, PyObject *args )
+ {
+ CStatusBar *pStatusBar = PyCStatusBar::GetStatusBar(self);
+ if (!pStatusBar) return NULL;
+
+ UINT nIndex;
+ if (!PyArg_ParseTuple (args,"i:GetPaneInfo",
+ &nIndex)) // @pyparm int|index||Index of the pane whose information is to be retrieved.
+ return NULL;
+
+ UINT nID;
+ UINT nStyle;
+ int cxWidth;
+
+ GUI_BGN_SAVE;
+ pStatusBar->GetPaneInfo(nIndex, nID, nStyle, cxWidth); // @pyseemfc CStatusBar|GetPaneInfo
+ GUI_END_SAVE;
+
+ return Py_BuildValue ("(iii)", nID, nStyle, cxWidth);
+ }
+
+ // @pymethod <o PyCStatusBarCtrl>|PyCStatusBar|GetStatusBarCtrl|Gets the statusbar control object for the statusbar.
+ PyObject *
+ PyCStatusBar_GetStatusBarCtrl( PyObject *self, PyObject *args )
+ {
+ CHECK_NO_ARGS (args);
+ CStatusBar *pStatusBar = PyCStatusBar::GetStatusBar(self);
+ if (!pStatusBar) return NULL;
+
+ CStatusBarCtrl &rSBC = pStatusBar->GetStatusBarCtrl(); // @pyseemfc CStatusBar|GetStatusBarCtrl
+ // Note that below we take the address of rTBC because it's a reference and not a pointer
+ // and ui_assoc_object::make expects a pointer.
+ // We need to create a new class and not do a map lookup because in MFC CToolBarCtrl is
+ // simply a casted CToolBarCtrl (afxext.inl) so the lookup will return the PyCToolBar object
+ // which will fail the type tests.
+ return ui_assoc_object::make (PyCStatusBarCtrl::type, &rSBC, true)->GetGoodRet();
+ }
+
// @pymethod |PyCStatusBar|SetIndicators|Sets each indicator's ID.
PyObject *
***************
*** 1537,1545 ****
--- 1591,1627 ----
}
+ // @pymethod |PyCStatusBar|SetPaneInfo|Sets the specified indicator pane to a new ID, style, and width.
+ PyObject *
+ PyCStatusBar_SetPaneInfo( PyObject *self, PyObject *args )
+ {
+ CStatusBar *pStatusBar = PyCStatusBar::GetStatusBar(self);
+ if (!pStatusBar) return NULL;
+
+ UINT nIndex;
+ UINT nID;
+ UINT nStyle;
+ int cxWidth;
+ if (!PyArg_ParseTuple (args,"iiii:SetPaneInfo",
+ &nIndex, // @pyparm int|index||Index of the indicator pane whose style is to be set.
+ &nID, // @pyparm int|id||New ID for the indicator pane.
+ &nStyle, // @pyparm int|style||New style for the indicator pane.<nl>The following indicator styles are supported:<nl>afxres.SBPS_NOBORDERS - No 3-D border around the pane.<nl>afxres.SBPS_POPOUT - Reverse border so that text "pops out."<nl>afxres.SBPS_DISABLED - Do not draw text.<nl>afxres.SBPS_STRETCH - Stretch pane to fill unused space. Only one pane per status bar can have this style.<nl>afxres.SBPS_NORMAL - No stretch, borders, or pop-out.
+ &cxWidth)) // @pyparm int|width||New width for the indicator pane.
+ return NULL;
+
+ GUI_BGN_SAVE;
+ pStatusBar->SetPaneInfo(nIndex, nID, nStyle, cxWidth); // @pyseemfc CStatusBar|SetPaneInfo
+ GUI_END_SAVE;
+
+ RETURN_NONE;
+ }
+
// @object PyCStatusBar|A class which encapsulates an MFC <o CStatusBar>. Derived from a <o PyCControlBar> object.
static struct PyMethodDef
PyCStatusBar_methods[] =
{
+ {"GetPaneInfo", PyCStatusBar_GetPaneInfo, 1}, // @pymeth GetPaneInfo|Returns indicator ID, style, and width for a given pane index.
+ {"GetStatusBarCtrl", PyCStatusBar_GetStatusBarCtrl, 1}, // @pymeth GetStatusBarCtrl|Returns the status bar control object associated with the status bar.
{"SetIndicators", PyCStatusBar_SetIndicators, 1}, // @pymeth SetIndicators|Sets each indicator's ID.
+ {"SetPaneInfo", PyCStatusBar_SetPaneInfo, 1}, // @pymeth SetPaneInfo|Sets indicator ID, style, and width for a given pane index.
{ NULL, NULL }
};
|