/*:VRX Main */ /* Main */ Main: /* Process the arguments. Get the parent window. */ parse source . calledAs . parent = "" argCount = arg() argOff = 0 if( calledAs \= "COMMAND" )then do if argCount >= 1 then do parent = arg(1) argCount = argCount - 1 argOff = 1 end end; else do call VROptions 'ImplicitNames' call VROptions 'NoEchoQuit' end InitArgs.0 = argCount if( argCount > 0 )then do i = 1 to argCount InitArgs.i = arg( i + argOff ) end drop calledAs argCount argOff /* Load the windows */ call VRInit parse source . . spec _VREPrimaryWindowPath = , VRParseFileName( spec, "dpn" ) || ".VRW" _VREPrimaryWindow = , VRLoad( parent, _VREPrimaryWindowPath ) drop parent spec if( _VREPrimaryWindow == "" )then do call VRMessage "", "Cannot load window:" VRError(), , "Error!" _VREReturnValue = 32000 signal _VRELeaveMain end /* Process events */ call Init signal on halt do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) _VREEvent = VREvent() interpret _VREEvent end _VREHalt: _VREReturnValue = Fini() call VRDestroy _VREPrimaryWindow _VRELeaveMain: call VRFini exit _VREReturnValue VRLoadSecondary: __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) if __vrlsWait then do call VRFlush end __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) if __vrlsHWnd = '' then signal __vrlsDone if __vrlsWait \= 1 then signal __vrlsDone call VRSet __vrlsHWnd, 'WindowMode', 'Modal' __vrlsTmp = __vrlsWindows.0 if( DataType(__vrlsTmp) \= 'NUM' ) then do __vrlsTmp = 1 end else do __vrlsTmp = __vrlsTmp + 1 end __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) __vrlsWindows.0 = __vrlsTmp do while( VRIsValidObject( VRWindow() ) = 1 ) __vrlsEvent = VREvent() interpret __vrlsEvent end __vrlsTmp = __vrlsWindows.0 __vrlsWindows.0 = __vrlsTmp - 1 call VRWindow __vrlsWindows.__vrlsTmp __vrlsHWnd = '' __vrlsDone: return __vrlsHWnd /*:VRX Fini */ Fini: window = VRWindow() call VRSet window, "Visible", 0 drop window return 0 /*:VRX GetLanguage */ GetLanguage: execPath = VRGet("Application", "Program") execDir = VRParseFileName( execPath, "DP") /* * Figure out what language/message file to use. */ syslanguage = VALUE('LANG',,'OS2ENVIRONMENT') PARSE VAR syslanguage nlv '_' . IF ( STREAM( execDir'\ithm_'nlv'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', 'ithm_'nlv'.msg') \= '') THEN msgfile = 'ithm_'nlv'.msg' ELSE msgfile = 'itheme.msg' CALL RIGetMessage "WN_ReIcon", "Caption", 90 CALL RIGetMessage "DT_1", "Caption", 91 /* * Figure out if we're running on a DBCS system. */ IF VRFileExists( bootdrv'\OS2DBCS') == 1 THEN CALL VRSet 'Win_ITheme', 'Font', '9.WarpSans Combined' RETURN /*:VRX GetScalingFactor */ /* Return the UI scaling factor based on the difference between the specified * font size and the design-default font size. */ GetScalingFactor: PROCEDURE EXPOSE defaultSize PARSE ARG newSize, orgSize IF orgSize == '' THEN orgSize = defaultSize IF newSize < defaultSize THEN newSize = defaultSize scaleFactor = newSize / orgSize RETURN scaleFactor /*:VRX GetSetting */ GetSetting: PROCEDURE EXPOSE wpdll /* * Locate the ITHEME.INI file. */ execPath = VRGet("Application", "Program") execDir = VRParseFileName( execPath, "DP") iniFile = execDir || "\itheme.ini" /* * Get the layout setting. */ lay = TRANSLATE( VRGetIni("Settings", "Layout", iniFile, "NoClose")) SELECT WHEN lay == "1" THEN laystyle = "ECS" WHEN lay == "E" THEN laystyle = "ECS" WHEN lay == "A" THEN laystyle = "AOS" OTHERWISE laystyle = "OS2" END /* * Figure out whether to use ECSWP.DLL (for eCS systems) or AUXWP.DLL (for * other OS/2 systems). */ ecswp = VRGetIni("SysDLLs", "ECSWP_DLL", iniFile ) IF VRFileExists( ecswp ) == 0 THEN DO osdir = VALUE('OSDIR',,'OS2ENVIRONMENT') IF osdir == '' THEN osdir = SysBootDrive() || '\os2' wpdll = Sys2LocateDLL('AUXWP.DLL') If wpdll == '' THEN wpdll = Sys2LocateDLL('ECSWP.DLL') If wpdll == '' THEN wpdll = STREAM( osdir'\DLL\AUXWP.DLL', 'C', 'QUERY EXISTS') If wpdll == '' THEN wpdll = STREAM( osdir'\DLL\ECSWP.DLL', 'C', 'QUERY EXISTS') If wpdll == '' THEN wpdll = execDir'\AUXWP.BIN' END ELSE wpdll = ecswp RETURN laystyle /*:VRX Halt */ Halt: signal _VREHalt return /*:VRX Init */ Init: CALL RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs" CALL SysLoadFuncs CALL RxFuncAdd "Sys2LoadFuncs", "RXUTILEX", "Sys2LoadFuncs" CALL Sys2LoadFuncs CALL GetLanguage window = VRWindow() defaultSize = 9 PARSE VALUE VRGetIni('PM_SystemFonts', 'WindowText') WITH windowText '00'x . IF windowText <> '' THEN DO CALL VRSet window, 'Font', windowText factor = GetScalingFactor( ParseFontSize( windowText )) CALL RescaleObject window, factor, 0 CALL RescaleObject 'DT_1', factor CALL RescaleObject 'PRO_PROGRESS', factor END call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" call VRSet "Console", "WindowListTitle", "" drop window uselayout = GetSetting() CALL UpdateIcons uselayout RETURN /*:VRX logerr */ LogErr: PROCEDURE ARG log, objectid, logopen IF logopen THEN CALL LINEOUT log, "! Could not update object" objectid"." return /*:VRX logupdate */ LogUpdate: PROCEDURE ARG log, objectid, string, logopen IF logopen THEN CALL LINEOUT log, " "objectid "updated with setup string" string"." return /*:VRX ParseFontSize */ ParseFontSize: PROCEDURE EXPOSE defaultSize PARSE ARG font IF font == '' | font == '' THEN RETURN defaultSize PARSE VAR font _pts'.'. IF _pts < defaultSize THEN _pts = defaultSize RETURN _pts /*:VRX Quit */ Quit: CALL SysDestroyObject("") window = VRWindow() call VRSet window, "Shutdown", 1 drop window return /*:VRX RescaleObject */ RescaleObject: PROCEDURE PARSE ARG object, factor, move x = VRGet( object, 'Left') y = VRGet( object, 'Top') w = VRGet( object, 'Width') h = VRGet( object, 'Height') nx = TRUNC( x * factor ) ny = TRUNC( y * factor ) nw = TRUNC( w * factor ) nh = TRUNC( h * factor ) IF move <> 0 THEN DO ok = VRSet( object, 'Left', nx ) ok = VRSet( object, 'Top', ny ) END ok = VRSet( object, 'Width', nw ) ok = VRSet( object, 'Height', nh ) RETURN /*:VRX RIGetMessage */ RIGetMessage: PROCEDURE EXPOSE msgfile ARG control, property, msg msgtxt = SysGetMessage( msg, msgfile ) msgtxt = STRIP( msgtxt, 'T', '0a'x ) msgtxt = STRIP( msgtxt, 'T', '0b'x ) msgtxt = STRIP( msgtxt, 'T', '0d'x ) IF SUBSTR( msgtxt, 1,4 ) = "SYS0" THEN msgfound = 0 ELSE DO msgfound = 1 /* SAY property "=" msgtxt */ call VRSet control, property, msgtxt END return msgfound /*:VRX UpdateIcons */ UpdateIcons: PROCEDURE EXPOSE wpdll ARG uselayout logfile = "reicon.log" logok = VRCreateFile( logfile ) IF logok THEN DO timestamp = DATE()" "TIME() CALL LINEOUT logfile, "*" timestamp "- refreshing desktop icons for layout '"uselayout"'." CALL LINEOUT logfile, "* Additional icons will be loaded from" wpdll END index = 0 AllIcons.0 = index CALL VRSet "WN_ReIcon", "Pointer", "Wait" /* * Read the icon index file. */ listfile = "icons.lst" CALL LINEIN listfile, 1, 0 DO WHILE LINES( listfile ) > 0 entry = LINEIN( listfile ) IF entry \= "" THEN DO IF ( POS(';', entry ) \= 1 ) THEN DO index = index + 1 AllIcons.index = STRIP( entry ) END END END AllIcons.0 = index percentinc = ( 1 / index ) * 100 /* * Now update each icon. */ processed = 0 total = 0 DO index = 1 TO AllIcons.0 processed = processed + 1 CALL VRSet "PRO_PROGRESS", "Percent", TRUNC( processed * percentinc ) entry = AllIcons.index layout = WORD( entry, 1 ) otype = WORD( entry, 2 ) IF otype == "P" THEN DO icon = WORD( entry, 3 ) lib = WORD( entry, 4 ) oid = WORD( entry, 5 ) IF ( lib == 'ECSWP') | ( lib == 'AUXWP') THEN lib = wpdll setupstring = "ICONRESOURCE="icon","lib END ELSE DO icon1 = WORD( entry, 3 ) lib1 = WORD( entry, 4 ) icon2 = WORD( entry, 5 ) lib2 = WORD( entry, 6 ) oid = WORD( entry, 7 ) IF ( lib1 == 'ECSWP') | ( lib1 == 'AUXWP') THEN lib1 = wpdll IF ( lib2 == 'ECSWP') | ( lib2 == 'AUXWP') THEN lib2 = wpdll setupstring = "ICONRESOURCE="icon1","lib1";ICONNRESOURCE=1,"icon2","lib2 END IF ( layout = uselayout ) | ( layout = "ALL") THEN DO ret = SysSetObjectData( oid, setupstring ) IF ret == 0 THEN CALL LogErr logfile, oid, logok ELSE DO CALL LogUpdate logfile, oid, setupstring, logok total = total + 1 END END END CALL VRSet "PRO_PROGRESS", "Percent", 100 IF logok THEN CALL LINEOUT logfile, "*" total "icons were updated." CALL VRSet "WN_ReIcon", "Pointer", "" CALL QUIT RETURN /*:VRX WN_ReIcon_Close */ WN_ReIcon_Close: call Quit return