From: <mie...@us...> - 2013-12-21 20:18:33
|
Revision: 9742 http://sourceforge.net/p/oorexx/code-0/9742 Author: miesfeld Date: 2013-12-21 20:18:29 +0000 (Sat, 21 Dec 2013) Log Message: ----------- [#553] Add the StatusBar control to ooDialog [#550] Add the ReBar dialog control to ooDialog [#552] Add the ToolBar control to ooDialog [#569] Allow direct creation of dialog control windows. Modified Paths: -------------- ooDialog/branches/4.2.3/trunk/doc/oodguide.pdf ooDialog/branches/4.2.3/trunk/doc/oodialog.pdf ooDialog/trunk/ooDialog/BaseDialog.cls ooDialog/trunk/ooDialog/ooDialog.cpp ooDialog/trunk/ooDialog/ooDialog.hpp ooDialog/trunk/ooDialog/oodBaseDialog.cpp ooDialog/trunk/ooDialog/oodCommon.hpp ooDialog/trunk/ooDialog/oodPackageEntry.cpp ooDialog/trunk/ooDialog/oodUser.cpp ooDialog/trunk/ooDialog/oodUser.hpp Modified: ooDialog/branches/4.2.3/trunk/doc/oodguide.pdf =================================================================== (Binary files differ) Modified: ooDialog/branches/4.2.3/trunk/doc/oodialog.pdf =================================================================== (Binary files differ) Modified: ooDialog/trunk/ooDialog/BaseDialog.cls =================================================================== --- ooDialog/trunk/ooDialog/BaseDialog.cls 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/BaseDialog.cls 2013-12-21 20:18:29 UTC (rev 9742) @@ -198,6 +198,15 @@ ::method removeAll external "LIBRARY oodialog il_removeAll" +::class 'CreateWindows' public mixinclass Object + +::method initCreateWindows external "LIBRARY oodialog cw_initCreateWindows" +::method createReBarWindow external "LIBRARY oodialog cw_createReBarWindow" +::method createStatusBarWindow external "LIBRARY oodialog cw_createStatusBarWindow" +::method createToolBarWindow external "LIBRARY oodialog cw_createToolBarWindow" + + + ::class 'CustomDraw' public mixinclass EventNotification ::constant CDRF_DODEFAULT 0 -- 0x00000000 Modified: ooDialog/trunk/ooDialog/ooDialog.cpp =================================================================== --- ooDialog/trunk/ooDialog/ooDialog.cpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/ooDialog.cpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -3232,6 +3232,14 @@ pcpbd->autoDetect = (pcpbd->isPropSheetDlg ? FALSE : TRUE); pcpbd->rexxSelf = self; + if ( context->IsOfType(self, "CREATEWINDOWS") ) + { + if ( ! initCreateWindows(context, self, pcpbd) ) + { + goto terminate_out; + } + } + // Set our default font to the PlainBaseDialog class default font. pCPlainBaseDialogClass pcpbdc = dlgToClassCSelf(context); strcpy(pcpbd->fontName, pcpbdc->fontName); Modified: ooDialog/trunk/ooDialog/ooDialog.hpp =================================================================== --- ooDialog/trunk/ooDialog/ooDialog.hpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/ooDialog.hpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -663,6 +663,15 @@ } CWindowExtensions; typedef CWindowExtensions *pCWindowExtensions; +/* Struct for the CreateWindows object CSelf. */ +typedef struct _cwCSelf { + HINSTANCE hinst; + pCWindowBase wndBase; + HWND hDlg; + RexxObjectPtr rexxDlg; +} CCreateWindows; +typedef CCreateWindows *pCCreateWindows; + /* Struct for the PlainBaseDialog object CSelf. The struct itself is * allocated using interpreter memory and therefore garbage collected by the * interpreter. But, there are still things like the table allocated externally Modified: ooDialog/trunk/ooDialog/oodBaseDialog.cpp =================================================================== --- ooDialog/trunk/ooDialog/oodBaseDialog.cpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/oodBaseDialog.cpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -56,6 +56,7 @@ #include "oodMessaging.hpp" #include "oodDeviceGraphics.hpp" #include "oodResizableDialog.hpp" +#include "oodUser.hpp" class LoopThreadArgs @@ -2241,6 +2242,276 @@ /** + * Methods for the .CreateWindow class. + */ +#define CREATEWINDOW_CLASS "CreateWindow" + + +static pCCreateWindows validateCwCSelf(RexxMethodContext *c, void *pCSelf) +{ + pCCreateWindows pccw = (pCCreateWindows)pCSelf; + if ( pccw == NULL ) + { + baseClassInitializationException(c, "CreateWindow"); + } + else + { + if ( pccw->hDlg == NULL ) + { + if ( pccw->wndBase->hwnd == NULL ) + { + noWindowsDialogException(c, pccw->rexxDlg); + } + else + { + pccw->hDlg = pccw->wndBase->hwnd; + } + } + } + + return pccw; +} + + +bool initCreateWindows(RexxMethodContext *c, RexxObjectPtr self, pCPlainBaseDialog pcpbd) +{ + RexxBufferObject obj = c->NewBuffer(sizeof(CCreateWindows)); + if ( obj == NULLOBJECT ) + { + return false; + } + + pCCreateWindows pccw = (pCCreateWindows)c->BufferData(obj); + pccw->rexxDlg = self; + pccw->wndBase = pcpbd->wndBase;; + pccw->hDlg = NULL; + pccw->hinst = MyInstance; + + c->SendMessage1(self, "INITCREATEWINDOWS", obj); + + return true; +} + + +/** CreateWindows::initCreateWindows() + * + */ +RexxMethod1(logical_t, cw_initCreateWindows, RexxObjectPtr, cSelf) +{ + if ( ! context->IsBuffer(cSelf) ) + { + wrongClassException(context->threadContext, 1, "Buffer"); + return FALSE; + } + + context->SetObjectVariable("CSELF", cSelf); + return TRUE; +} + + +/** CreateWindows::createReBarWindow() + * + * Creates a Windows rebar and returns the Rexx ReBar object. + * + * @param id [required] The resource ID of the rebar. + * + * @param sytle [optional] Style keywords. If omitted the rebar uses the + * default rebar style of visible, tabstop, variable height, band + * borders, and common control no divider style. + * + * @notes Sets the .SystemErrorCode + * + * rebars ignore the position and size co-ordinates, so there is no + * arguments for them. + * + * @remarks The rebar control seems to remove the WS_BORDER style when it is + * created. The WS_TABSTOP style seems to have no effect, behavior + * is the same with or without it. However, tabbing does *not* work + * if the control does not have the WS_EX_CONTROLPARENT styles. The + * WS_EX_TOOLWINDOW style is used here because several of the MSDN + * samples use it. But, not sure if it is really needed or + * appropriate. + */ +RexxMethod3(RexxObjectPtr, cw_createReBarWindow, RexxObjectPtr, rxID, OPTIONAL_CSTRING, _style, CSELF, pCSelf) +{ + oodResetSysErrCode(context->threadContext); + + RexxObjectPtr result = TheNilObj; + pCCreateWindows pccw = validateCwCSelf(context, pCSelf); + if ( pccw == NULL ) + { + goto done_out; + } + + uint32_t id = oodResolveSymbolicID(context, pccw->rexxDlg, rxID, -1, 1, true); + if ( id == OOD_ID_EXCEPTION ) + { + goto done_out; + } + + uint32_t style = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN ; + if ( argumentExists(2) ) + { + style |= getControlStyle(winReBar, _style); + } + else + { + style |= WS_VISIBLE | WS_TABSTOP | RBS_VARHEIGHT | RBS_BANDBORDERS | CCS_NODIVIDER; + } + + HWND hRebar = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT, REBARCLASSNAME, NULL, style, + 0, 0, 0, 0, pccw->hDlg, (HMENU)id, pccw->hinst, NULL); + if ( hRebar == NULL ) + { + oodSetSysErrCode(context->threadContext); + goto done_out; + } + + RexxClassObject rxClass = oodClass4controlType(winReBar, context); + if ( rxClass == NULLOBJECT ) + { + goto done_out; + } + + result = createRexxControl(context->threadContext, hRebar, pccw->hDlg, id, winReBar, pccw->rexxDlg, + rxClass, false, true); + +done_out: + return result; +} + + +/** CreateWindows::createStatusBarWindow() + * + * Creates a Windows status bar and returns the Rexx StatusBar object. + * + * @param id [required] The resource ID of the status bar. + * + * @param sytle [optional] Style keywords. If omitted the status bar uses + * the default status bar style of visible, sizing grep, tool + * tips enabled. + * + * @notes Sets the .SystemErrorCode + * + * Status bars ignore the position and size co-ordinates, so there is + * no arguments for them. + */ +RexxMethod3(RexxObjectPtr, cw_createStatusBarWindow, RexxObjectPtr, rxID, OPTIONAL_CSTRING, _style, CSELF, pCSelf) +{ + oodResetSysErrCode(context->threadContext); + + RexxObjectPtr result = TheNilObj; + pCCreateWindows pccw = validateCwCSelf(context, pCSelf); + if ( pccw == NULL ) + { + goto done_out; + } + + uint32_t id = oodResolveSymbolicID(context, pccw->rexxDlg, rxID, -1, 1, true); + if ( id == OOD_ID_EXCEPTION ) + { + goto done_out; + } + + uint32_t style = WS_CHILD; + if ( argumentExists(2) ) + { + style |= getControlStyle(winStatusBar, _style); + } + else + { + style |= SBARS_SIZEGRIP | SBARS_TOOLTIPS | WS_VISIBLE; + } + + HWND hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, style, 0, 0, 0, 0, pccw->hDlg, + (HMENU)id, pccw->hinst, NULL); + if ( hStatus == NULL ) + { + oodSetSysErrCode(context->threadContext); + goto done_out; + } + + RexxClassObject rxClass = oodClass4controlType(winStatusBar, context); + if ( rxClass == NULLOBJECT ) + { + goto done_out; + } + + result = createRexxControl(context->threadContext, hStatus, pccw->hDlg, id, winStatusBar, pccw->rexxDlg, + rxClass, false, true); + +done_out: + return result; +} + + +/** CreateWindows::createToolBarWindow() + * + * Creates a Windows toolbar and returns the Rexx ToolBar object. + * + * @param id [required] The resource ID of the toolbar. + * + * @param sytle [optional] Style keywords. If omitted the toolbar uses the + * default toolbar style of visible, border, tabstop, and + * wrappable. + * + * @notes Sets the .SystemErrorCode + * + * @remarks Originally we were going to have the size and position arguments. + * However, after testing that, the size and position arguments are + * ignored just like they are are in status bars and rebars. + */ +RexxMethod3(RexxObjectPtr, cw_createToolBarWindow, RexxObjectPtr, rxID, OPTIONAL_CSTRING, _style, CSELF, pCSelf) +{ + oodResetSysErrCode(context->threadContext); + + RexxObjectPtr result = TheNilObj; + pCCreateWindows pccw = validateCwCSelf(context, pCSelf); + if ( pccw == NULL ) + { + goto done_out; + } + + uint32_t id = oodResolveSymbolicID(context, pccw->rexxDlg, rxID, -1, 1, true); + if ( id == OOD_ID_EXCEPTION ) + { + goto done_out; + } + + uint32_t style = WS_CHILD; + if ( argumentExists(2) ) + { + style |= getControlStyle(winToolBar, _style); + } + else + { + style |= WS_VISIBLE | WS_BORDER | WS_TABSTOP | TBSTYLE_WRAPABLE; + } + + HWND hToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, style, 0, 0, 0, 0, pccw->hDlg, + (HMENU)id, pccw->hinst, NULL); + if ( hToolbar == NULL ) + { + oodSetSysErrCode(context->threadContext); + goto done_out; + } + + RexxClassObject rxClass = oodClass4controlType(winToolBar, context); + if ( rxClass == NULLOBJECT ) + { + goto done_out; + } + + result = createRexxControl(context->threadContext, hToolbar, pccw->hDlg, id, winToolBar, pccw->rexxDlg, + rxClass, false, true); + +done_out: + return result; +} + + + +/** * Methods for the .CustomDraw class. */ #define CUSTOMDRAW_CLASS "CustomDraw" Modified: ooDialog/trunk/ooDialog/oodCommon.hpp =================================================================== --- ooDialog/trunk/ooDialog/oodCommon.hpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/oodCommon.hpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -205,6 +205,7 @@ // These functions are defined in oodBaseDialog.cpp extern bool initWindowExtensions(RexxMethodContext *, RexxObjectPtr, HWND, pCWindowBase, pCPlainBaseDialog); +extern bool initCreateWindows(RexxMethodContext *c, RexxObjectPtr self, pCPlainBaseDialog pcpbd); extern bool validControlDlg(RexxMethodContext *c, pCPlainBaseDialog pcpbd); extern bool processOwnedDialog(RexxMethodContext *c, pCPlainBaseDialog pcpbd); extern void setFontAttrib(RexxThreadContext *c, pCPlainBaseDialog pcpbd); Modified: ooDialog/trunk/ooDialog/oodPackageEntry.cpp =================================================================== --- ooDialog/trunk/ooDialog/oodPackageEntry.cpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/oodPackageEntry.cpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -1780,6 +1780,12 @@ REXX_METHOD_PROTOTYPE(kb_getAsyncKeyState_cls); +// CreateWindows +REXX_METHOD_PROTOTYPE(cw_initCreateWindows); +REXX_METHOD_PROTOTYPE(cw_createReBarWindow); +REXX_METHOD_PROTOTYPE(cw_createStatusBarWindow); +REXX_METHOD_PROTOTYPE(cw_createToolBarWindow); + // CustomDraw REXX_METHOD_PROTOTYPE(cd_init); REXX_METHOD_PROTOTYPE(cd_customDrawControl); @@ -3148,6 +3154,12 @@ // Keyboard REXX_METHOD(kb_getAsyncKeyState_cls, kb_getAsyncKeyState_cls), +// CreateWindows + REXX_METHOD(cw_initCreateWindows, cw_initCreateWindows), + REXX_METHOD(cw_createReBarWindow, cw_createReBarWindow), + REXX_METHOD(cw_createStatusBarWindow, cw_createStatusBarWindow), + REXX_METHOD(cw_createToolBarWindow, cw_createToolBarWindow), + // CustomDraw REXX_METHOD(cd_init, cd_init), REXX_METHOD(cd_customDrawControl, cd_customDrawControl), Modified: ooDialog/trunk/ooDialog/oodUser.cpp =================================================================== --- ooDialog/trunk/ooDialog/oodUser.cpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/oodUser.cpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -458,6 +458,11 @@ * null is needed for txt. On the other hand className must be checked * because that is how we determine if the control is being identified * by the control atom or by the class name. + * + * @TOOO We have enhanced this to use the extended dialog template, but we need + * to add an extra arg so that the user can specify the extended styles. + * The rebar control does not behave correctly without the + * WS_EX_CONTROLPARENT style. So, for now, we add that manually. */ bool addToDialogTemplate(RexxMethodContext *c, pCDynamicDialog pcdd, SHORT kind, const char *className, int id, int x, int y, int cx, int cy, const char * txt, uint32_t style) @@ -493,6 +498,10 @@ } else { + if ( strcmp(className, REBARCLASSNAME) == 0 ) + { + pItem->exStyle = WS_EX_CONTROLPARENT; + } p += putUnicodeText(p, className); } @@ -912,7 +921,7 @@ } -uint32_t getControlStyle(oodControl_t ctrl, CSTRING opts) +extern uint32_t getControlStyle(oodControl_t ctrl, CSTRING opts) { uint32_t style = WS_CHILD; @@ -939,12 +948,12 @@ break; case winReBar : - style |= getCommonWindowStyles(opts, false, true); + style |= getCommonWindowStyles(opts, false, false); style = reBarStyle(opts, style); break; case winStatusBar : - style |= getCommonWindowStyles(opts, false, true); + style |= getCommonWindowStyles(opts, false, false); style = statusBarStyle(opts, style); break; @@ -954,7 +963,7 @@ break; case winToolBar : - style |= getCommonWindowStyles(opts, false, true); + style |= getCommonWindowStyles(opts, true, true); style = toolBarStyle(opts, style); break; Modified: ooDialog/trunk/ooDialog/oodUser.hpp =================================================================== --- ooDialog/trunk/ooDialog/oodUser.hpp 2013-12-21 17:57:24 UTC (rev 9741) +++ ooDialog/trunk/ooDialog/oodUser.hpp 2013-12-21 20:18:29 UTC (rev 9742) @@ -55,6 +55,9 @@ int x, int y, int cx, int cy, const char *dlgClass, const char *title, const char *fontName, int fontSize, uint32_t style, uint32_t exStyle); +extern void cleanUpDialogTemplate(void *pDlgTemplate, pCDynamicDialog pcdd); -extern void cleanUpDialogTemplate(void *pDlgTemplate, pCDynamicDialog pcdd); +// Style parsing functions +extern uint32_t getControlStyle(oodControl_t ctrl, CSTRING opts); + #endif |