/*---------------------------------------------*/ /* $VER: MUItxtRotator V4.07 (20 Dec 1998) */ /* ©1996-98 Michael Merkel */ /*---------------------------------------------*/ /* Application partially created with MUIBuild */ /*---------------------------------------------*/ /* ** TRACE ALL */ debug = 1 /* Make sure rexx support is opened */ IF ~SHOW('L','rexxsupport.library') THEN CALL ADDLIB('rexxsupport.library',0,-30) IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN CALL ADDLIB('softlogik:libs/slarexxsupport.library',0,-30) IF ~SHOW('L','rexxmathlib.library') THEN CALL ADDLIB('rexxmathlib.library',0,-30) ADDRESS TXTROTATOR OPTIONS RESULTS trversion = 'V4.07' trLVer = '4.02' trLVerN = '4.06' trdate = '20 Dec 1998' trcopy = '©1996-98 Michael Merkel' this = 'T:MUItxtRotator.rexx' thisPIC = 'T:MUItxtRotator' TRUE = 1 FALSE = 0 Application_AboutMUI = 0x8042d21d Application_OpenConfigWindow = 0x804299ba Application_Iconified = 0x8042a07f ASLFR_DrawersOnly = 0x8008002F MUIA_Application_Author = 0x80424842 MUIA_Application_Copyright = 0x8042ef4d MUIA_Application_Version = 0x8042b33f MUIA_Background = 0x8042545b MUIA_Cycle_Active = 0x80421788 MUIA_CycleChain = 0x80421ce7 MUIA_Disabled = 0x80423661 MUIA_Frame = 0x8042ac64 MUIA_Gauge_Max = 0x8042bcdb MUIA_Gauge_Current = 0x8042f0dd MUIA_Gauge_Horiz = 0x804232dd MUIA_Gauge_InfoText = 0x8042bf15 MUIA_Group_Columns = 0x8042f416 MUIA_Group_Rows = 0x8042b68f MUIA_Menu_Enabled = 0x8042ed48 MUIA_Menuitem_Checked = 0x8042562a MUIA_Menuitem_Checkit = 0x80425ace MUIA_Menuitem_Enabled = 0x8042ae0f MUIA_Menuitem_Shortcut = 0x80422030 Menuitem_Title = 0x804218be MUIA_Pressed = 0x80423535 MUIA_Selected = 0x8042654b MUIA_Slider_Level = 0x8042ae3a MUIA_Slider_Min = 0x8042e404 MUIA_Slider_Max = 0x8042d78a MUIA_Text_SetMin = 0x80424e10 MUIA_Weight = 0x80421d1f MUIA_Window_ActiveObject = 0x80427925 MUIA_Window_CloseGadget = 0x8042a110 MUIA_Window_Open = 0x80428aa0 MUIA_Window_SizeGadget = 0x8042e33d MUIA_Window_Sleep = 0x8042e7db MUII_FILLBACK = 135 MUII_GroupBack = 35 MUIV_EveryTime = 0x49893131 MUIV_Frame_Group = 9 MUIV_Frame_None = 0 Notify = 0x8042c9cb Set = 0x8042549a Window_Open = 0x80428aa0 tRotAction = '' prefsOld = 1 prefsTooOld = 2 prefsOK = 3 g_startAngle = 'SLD11' /* start angle */ g_endAngle = 'SLD12' /* end angle */ g_fontSize = 'STR11' /* size of the used font */ g_fontStyle = 'STR12' /* style of the used font */ g_fontSizeSlider = 'SLD2' /* slider for the font size */ g_placedText = 'STR20' /* the placed text */ g_textPosition = 'CYC20' /* position to the line */ g_textDirection = 'CYC21' /* direction of printing */ g_textFile = 'CHK20' /* use ascii file */ g_textFileName = 'ASL20' /* filename for the text file */ g_spiralCheck = 'CHK30' /* draw as spiral? */ g_sizeFactor = 'STR30' /* size factor of the spiral */ g_surrNum = 'STR31' /* number of times to go 'round the spiral */ g_winOffOn = 'SWT00' /* switch to turn on or off the window */ g_drawEx = 'BUT40' /* draw example button */ g_drawExSeg = 'STR40' /* example segment number */ g_doit1 = 'STR91' /* info line 1 */ g_doit2 = 'STR92' /* info line 2 */ g_saveOnExit = 'MEN01' /* save prefs when starting */ PARSE ARG tRotAction SELECT WHEN Upper(tRotAction) = '' THEN DO IF ~SHOW('PORTS','PAGESTREAM') THEN DO Call ErrorWin('Please start PageStream3 first!') ADDRESS TXTROTATOR 'quit' EXIT END ELSE DO ADDRESS PAGESTREAM "LOCKINTERFACE TRUE" Call GetStyleTags Call InitWindow Call GetMUIGadgets Call LoadPrefs Call SetMUIGadgets IF (CheckConstraints() = 1) THEN DO 'REFRESH CONTINUE' 'REFRESHWINDOW' ADDRESS PAGESTREAM "LOCKINTERFACE FALSE" ADDRESS TXTROTATOR 'quit' EXIT END SLIDER ID g_startAngle ATTRS MUIA_Slider_Level startA SLIDER ID g_endAngle ATTRS MUIA_Slider_Level endA WINDOW ID g_TRW ATTRS MUIA_Window_ActiveObject OK END END WHEN Upper(tRotAction) = 'LOADPREFS' THEN DO Call GetMUIGadgets Call LoadPrefs("") Call SetMUIGadgets END WHEN Upper(tRotAction) = 'LOADPREFSAS' THEN DO Call GetMUIGadgets ADDRESS PAGESTREAM 'GETFILE TITLE "Please choose the preference file" PATH "PageStream3:Scripts" FILE "MUItxtRotator.prefs"' IF (RC=0) THEN name = result ELSE RETURN Call LoadPrefs(name) Call SetMUIGadgets END WHEN Upper(tRotAction) = 'SAVEPREFS' THEN DO Call GetMUIGadgets Call WritePrefs("") RETURN END WHEN Upper(tRotAction) = 'SAVEPREFSAS' THEN DO ADDRESS PAGESTREAM 'GETFILE TITLE "Please choose the preference file" PATH "PageStream3:Scripts" FILE "MUItxtRotator.prefs"' IF (RC=0) THEN name = result ELSE RETURN Call GetMUIGadgets Call WritePrefs(name) RETURN END WHEN Upper(tRotAction) = 'DOIT' THEN DO ITEM ID g_saveOnExit ATTRS MUIA_Menuitem_Checked soe = RESULT Call GetMUIGadgets /* ** Remember the preferences in a temporary file */ Call WriteTempPrefs IF (soe = 1) THEN Call WritePrefs("") Call DoIt Call txtRotator END WHEN Upper(tRotAction) = 'CANCEL' THEN DO Call DeleteExampleArc ADDRESS PAGESTREAM "LOCKINTERFACE FALSE" Call CancelWin END WHEN Upper(tRotAction) = 'QUIT' THEN DO Call DeleteExampleArc ADDRESS PAGESTREAM "LOCKINTERFACE FALSE" ADDRESS TXTROTATOR "quit" END WHEN Upper(tRotAction) = 'ABOUTWIN' THEN Call AboutWin WHEN Upper(tRotAction) = 'WINDOW' THEN DO SWITCH ID g_SWT00 ATTRS MUIA_Selected pressed = RESULT getvar trWin; winName = RESULT IF (pressed = True) THEN ADDRESS PAGESTREAM 'HIDEWINDOW' IF (pressed = False) THEN ADDRESS PAGESTREAM 'REVEALWINDOW WINDOW "'winName'"' END WHEN Upper(tRotAction) = 'EXAMPLE' THEN DO Call GetMUIGadgets WINDOW ID g_TRW ATTRS MUIA_Window_Sleep TRUE Call DrawExampleArc WINDOW ID g_TRW ATTRS MUIA_Window_Sleep FALSE END OTHERWISE Say '????' END EXIT InitWindow: application ATTRS ''MUIA_Application_Author "Michael Merkel" MUIA_Application_Copyright ""||trcopy||"" MUIA_Application_Version "$VER: MUItxtRotator "||trversion||" ("||trdate||")"'' window ID g_TRW COMMAND """"this" QUIT""" TITLE 'MUItxtRotator '||trversion||' (||'trdate'||)' ATTRS ''MUIA_Window_CloseGadget TRUE MUIA_Window_SizeGadget TRUE'' MENU LABEL "MUItxtRotator" ITEM COMMAND """"this" aboutwin""" LABEL 'About' ITEM COMMAND """method "Application_AboutMUI" 0""" PORT TXTROTATOR LABEL 'About MUI' ITEM ATTRS Menuitem_Title "-1" ITEM COMMAND """method "Application_OpenConfigWindow"""" PORT TXTROTATOR LABEL 'MUI Settings...' ITEM ATTRS Menuitem_Title "-1" ITEM COMMAND """"this" QUIT""" ATTRS MUIA_Menuitem_Shortcut "q" LABEL 'Quit' ENDMENU MENU LABEL "Prefs" ITEM COMMAND """"this" loadprefsas""" LABEL 'Load Prefs...' ITEM ATTRS Menuitem_Title "-1" ITEM COMMAND """"this" saveprefs""" LABEL 'Save Prefs' ITEM COMMAND """"this" saveprefsas""" LABEL 'Save Prefs as...' ITEM ATTRS Menuitem_Title "-1" ITEM ID g_saveOnExit ATTRS MUIA_Menuitem_Checkit TRUE LABEL 'Save at end' ENDMENU group group HORIZ ATTRS MUIA_Background MUII_FILLBACK MUIA_Frame MUIV_Frame_Group space HORIZ button ICON thisPIC text ATTRS MUIA_Text_SetMin TRUE MUIA_Background MUII_FILLBACK MUIA_Frame MUIV_Frame_None LABEL "\033c\033b\0338MUI txtRotator "|| trversion ||" ("||trdate||")\033n\n"||trcopy||"" space HORIZ endgroup group /******************/ /* page 1 - sizes */ /******************/ group space group HORIZ space group label "\033c\0338Start and end angle\033n" group ATTRS MUIA_Group_Columns 2 label "start °" SLIDER ID g_startAngle ATTRS ''MUIA_Weight 50 MUIA_Slider_Min 0 MUIA_Slider_Max 360 MUIA_Slider_Level 0'' HELP '"Angle to start with on the curve."' label "end °" SLIDER ID g_endAngle ATTRS ''MUIA_Weight 50 MUIA_Slider_Min 0 MUIA_Slider_Max 360 MUIA_Slider_Level 360'' HELP '"Angle to end with on the curve."' endgroup endgroup space endgroup space space BAR HORIZ space group HORIZ space HORIZ 20 group label "\033c\0338Font settings\033n" group ATTRS MUIA_Group_Columns 3 label "basic font size:" string ID g_fontSize HELP '"Size of the rotated text font."' CONTENT "12pt" SLIDER ID g_fontSizeSlider COMMAND """STRING ID "g_fontSize" CONTENT %spt""" PORT TXTROTATOR ATTRS ''MUIA_Slider_Min 1 MUIA_Slider_Max 100 MUIA_Slider_Level 12'' HELP '"Select here or type in."' label "basic font style:" POPLIST ID g_fontStyle LABELS '"'styleString'"' HELP '"Textstyle for the rotated text font."' CONTENT "None" space endgroup endgroup space HORIZ 20 endgroup space space BAR HORIZ space GROUP HORIZ GROUP LABEL "\033c\0338Text settings\033n" GROUP GROUP ID g_tOUT HORIZ STRING ID g_placedText HELP '"Insert your text here."' CONTENT "This text will be rotated around the ellipse." ENDGROUP GROUP HORIZ CHECK ID g_textFile HELP '"Load text from ASCII file instead of entering it."' GROUP ID g_tIN HORIZ ATTRS ''MUIA_Disabled TRUE'' POPASL ID g_textFileName HELP '"Filename for the ASCII file\nto load text from."' SPEC "6:20" CONTENT "PageStream3:Text/txtRotator.txt" ENDGROUP ENDGROUP GROUP HORIZ CYCLE ID g_textPosition ATTRS MUIA_Cycle_Active 0 HELP '"Where to place the text to the curve?"' LABELS 'below line,on line, above line' CYCLE ID g_textDirection ATTRS MUIA_Cycle_Active 0 HELP '"The direction to place the text on the curve."' LABELS 'clockwise,counterclockwise' ENDGROUP ENDGROUP ENDGROUP ENDGROUP space space BAR HORIZ space group HORIZ group label '\033c\0338Spiral settings\033n' GROUP HORIZ CHECK ID g_spiralCheck HELP '"Check if you want a spiral to be drawn."' GROUP ID g_spON ATTRS MUIA_Group_Columns 2 MUIA_Disabled TRUE LABEL "\033c\0338Inner circle factor\033n" STRING ID g_sizeFactor HELP '"Factor fo the size of the end of the Spiral.\n(0.5 means that the end radius of the Spiral\n will be halve the size of the start radius)"' CONTENT "0.3" LABEL "\033c\0338# of surroundings\033n" STRING ID g_surrNum HELP '"Times to go around the spiral."' CONTENT "2" ENDGROUP ENDGROUP endgroup endgroup space endgroup /*********************/ /* go/cancel buttons */ /*********************/ GROUP HORIZ BUTTON ID g_drawEx PRESS COMMAND """"this" EXAMPLE""" HELP '"Click here to see the example arc."' LABEL 'Show Example Arc' LABEL "\033c\0338Segments:\033n" STRING ID g_DrawExSeg HELP '"Number of segments to draw the example.\nThe more, the longer it takes."' CONTENT "20" ENDGROUP group HORIZ button ID g_OK HELP '"Click here to start the Catalog generation."' LABEL 'Generate rotated text' button ID g_NOK HELP '"Click here to cancel the action."' LABEL 'Cancel' endgroup endgroup endgroup endwindow /***********/ /* methods */ /***********/ method ID g_spiralCheck Notify MUIA_Selected TRUE @g_spON 3 Set MUIA_Disabled FALSE method ID g_spiralCheck Notify MUIA_Selected FALSE @g_spON 3 Set MUIA_Disabled TRUE method ID g_textFile Notify MUIA_Selected TRUE @g_tIN 3 Set MUIA_Disabled FALSE method ID g_textFile Notify MUIA_Selected TRUE @g_tOUT 3 Set MUIA_Disabled TRUE method ID g_textFile Notify MUIA_Selected FALSE @g_tIN 3 Set MUIA_Disabled TRUE method ID g_textFile Notify MUIA_Selected FALSE @g_tOUT 3 Set MUIA_Disabled FALSE callhook ID g_OK PRESS COMMAND """"this" DOIT""" callhook ID g_NOK PRESS COMMAND """"this" QUIT""" /* define all input string to the cycle chain (TAB) */ SLIDER ID g_startAngle ATTRS MUIA_CycleChain TRUE SLIDER ID g_endAngle ATTRS MUIA_CycleChain TRUE SLIDER ID g_fontSizeSlider ATTRS MUIA_CycleChain TRUE STRING ID g_fontSize ATTRS MUIA_CycleChain TRUE POPLIST ID g_fontStyle ATTRS MUIA_CycleChain TRUE STRING ID g_placedText ATTRS MUIA_CycleChain TRUE STRING ID g_sizeFactor ATTRS MUIA_CycleChain TRUE STRING ID g_surrNum ATTRS MUIA_CycleChain TRUE STRING ID g_drawExSeg ATTRS MUIA_CycleChain TRUE CYCLE ID g_textPosition ATTRS MUIA_CycleChain TRUE CYCLE ID g_textDirection ATTRS MUIA_CycleChain TRUE CHECK ID g_spiralCheck ATTRS MUIA_CycleChain TRUE CHECK ID g_textFile ATTRS MUIA_CycleChain TRUE BUTTON ID g_drawEx ATTRS MUIA_CycleChain TRUE BUTTON ID g_OK ATTRS MUIA_CycleChain TRUE BUTTON ID g_NOK ATTRS MUIA_CycleChain TRUE POPASL ID g_textFileName ATTRS MUIA_CycleChain TRUE SETVAR trEID 0 RETURN /************/ /* ErrorWin */ /************/ ErrorWin: PARSE ARG errtext Say errtext ADDRESS TXTROTATOR 'request ID g_FONTW TITLE "MUI txtRotator '||trversion||'" GADGETS "OK" STRING '||errtext RETURN /************/ /* AboutWin */ /************/ AboutWin: ADDRESS 'TXTROTATOR' request ID g_FONW TITLE """About MUI txtRotator "||trversion||" ("||trdate||")""" GADGETS '_OK' STRING "\033c\033bMUItxtRotator is "||trcopy||"\033n\nMui is © by Stefan Stuntz\nMuiRexx is © by Russ Leighton\nPageStream is © by SoftLogik\n\nThanks to SoftLogik for this wonderful program!" RETURN /*********/ /* DoIt! */ /*********/ DoIt: /* close prefs window and open the busy window */ ADDRESS PAGESTREAM 'GETELLIPSE ANGLES angle' type = angle.type WINDOW ID g_TRW CLOSE WINDOW ID g_TRDO COMMAND """"this" CANCEL""" ATTRS ''MUIA_Window_CloseGadget TRUE'' TITLE 'MUItxtRotator '||trversion'' GROUP FRAME TEXT ID g_doit1 ATTRS MUIA_Frame MUIV_Frame_None MUIA_Background MUII_GroupBack LABEL "\033ctext is placed around "||type||"..." TEXT ID g_doit2 ATTRS MUIA_Frame MUIV_Frame_None MUIA_Background MUII_GroupBack LABEL "\033c..." GAUGE ID g_GAG01 ATTRS MUIA_Gauge_Max 100 MUIA_Gauge_Current 0 MUIA_Gauge_Horiz TRUE MUIA_Gauge_InfoText """generating rotated text...""" OBJECT CLASS "Busy.mcc" GROUP HORIZ SPACE HORIZ SWITCH ID g_SWT00 COMMAND """"this" WINDOW""" HELP '"Turn Window on or off"' LABEL "hide window" SPACE HORIZ ENDGROUP BUTTON ID g_QUIT PRESS COMMAND """"this" CANCEL""" HELP '"Click to cancel rotating"' LABEL "CANCEL" ENDGROUP ENDWINDOW SETVAR UserWantsQuit 0 RETURN /****************/ /* cancelwindow */ /****************/ CancelWin: setvar UserWantsQuit 1 RETURN /*******************/ /* Window Canceled */ /*******************/ WindowCanceled: ADDRESS 'TXTROTATOR' getvar trWin winName = RESULT SWITCH ID g_SWT00 ATTRS MUIA_Selected pressed = RESULT IF (pressed = True) THEN ADDRESS PAGESTREAM 'REVEALWINDOW WINDOW "'winName'"' window ID g_TRDO CLOSE quit RETURN /* ** load the preferences file ** ------------------------- */ LoadPrefs: PARSE ARG fileName IF (fileName = "") THEN fileName = 'PageStream3:Scripts/MUItxtRotator.prefs' /* ** Check the version of the prefs file */ cp = CheckPrefsVersion(fileName) SELECT WHEN (cp = prefsOld) THEN DO /* ** Load old prefs file */ Call LoadPrefsOld(fileName) /* ** Convert it on the fly to new format */ Call GetMUIGadgets Call WritePrefs(fileName) Return END WHEN (cp = prefsOK) THEN DO /* ** Prefs file is ok. Just go on. ** ... */ END WHEN (cp = prefsTooOld) THEN DO /* ** Prefs file is too old. */ Call ErrorWin('Prefs file too old to read! Using defaults.') Return END OTHERWISE DO Call ErrorWin('Prefsfile not found! Using defaults.') Return END END ok = Open('Prefs',fileName,'R') IF (ok = 1) THEN DO dummy = ReadLN('Prefs') DO xx = 1 to 100 command = ReadLn('Prefs') INTERPRET command IF EOF('Prefs') THEN LEAVE END cl = Close('Prefs') END RETURN /* ** save the preferences file ** ------------------------- */ WritePrefs: PARSE ARG filename IF (fileName = "") THEN fileName = 'PageStream3:Scripts/MUItxtRotator.prefs' ADDRESS 'TXTROTATOR' ok = Open('Prefs', fileName, 'W') IF (ok = 1) THEN DO OPTIONS FAILAT 11 Say 'writing prefs "'|| fileName ||'"...' WriteLN('Prefs', 'TRP'|| trVersion) Call WritePrefsNameValue('Prefs', 'startAngle', startAngle) Call WritePrefsNameValue('Prefs', 'endAngle', endAngle) Call WritePrefsNameValue('Prefs', 'saveOnExit', saveOnExit) Call WritePrefsNameValue('Prefs', 'fontSize', fontSize) Call WritePrefsNameValue('Prefs', 'textFile', textFile) Call WritePrefsNameValue('Prefs', 'textPosition', textPosition) Call WritePrefsNameValue('Prefs', 'textDirection', textDirection) Call WritePrefsNameValue('Prefs', 'spiralCheck', spiralCheck) Call WritePrefsNameValue('Prefs', 'sizeFactor', sizeFactor) Call WritePrefsNameValue('Prefs', 'surrNum', surrNum) Call WritePrefsNameValue('Prefs', 'drawExSeg', drawExSeg) Call WritePrefsNameValue('Prefs', 'fontStyle', fontStyle) Call WritePrefsNameValue('Prefs', 'placedText', placedText) Call WritePrefsNameValue('Prefs', 'textFileName', textFileName) WriteLN('Prefs', '/* END OF Prefsfile for MUItxtRotator '||trversion||' ('||trdate||') */') OPTIONS FAILAT 10 cl = Close('Prefs') END ELSE DO Say 'Error writing prefs file "'||fileName||'"' Call ErrorWin('ERROR writing prefs file '|| fileName) END RETURN /* ** write the temporary preferences file ** ------------------------------------ */ WriteTempPrefs: Call WritePrefs('T:MUItxtRotator.tmp') RETURN /* ** load the temporary preferences file ** ----------------------------------- */ LoadTempPrefs: Call LoadPrefs('T:MUItxtRotator.tmp') RETURN /* ** the real thing */ txtRotator: ADDRESS 'PAGESTREAM' defmeasure = GetDefaultMeasurementSystem() measure = 'pt' degree = '°' tf.0 = 'FALSE' tf.1 = 'TRUE' /* ** Get temp prefs */ Call LoadTempPrefs endA = endAngle startA = startAngle IF (spiralCheck = 0) THEN DO sizeFactor = 1 surrNum = 1 END 'GETELLIPSE POSITION arcPos' arcID = result mx = arcPos.centerx my = arcPos.centery rx = arcPos.radiusx ry = arcPos.radiusy posiFactor = textPosition - 1 IF (endA < startA) THEN endA = endA + 360 endA = endA + 360*(surrNum - 1) IF (textDirection = 1) THEN DO dirFactor = -1 dummy = startA startA = endA endA = dummy END ELSE dirFactor = 1 /* ** convert FontSize to points */ fontSize = p2d(fontSize, measure) r = radius mx = mx my = my rx = rx ry = ry IF (textFile = True) THEN DO l = ReadTextToBePlaced() specialCount = 0 END ELSE DO l = Length(placedText) END IF (l = 0) THEN DO Call CleanUp(1) Exit END /* ---------------------------------------------------------------- */ 'REFRESH OFF' 'CURRENTWINDOWPATH' winName = RESULT ADDRESS 'TXTROTATOR' setvar trWin winName highAngle = -3.1415 * 0.5 + endA*3.1415/180 lowAngle = -3.1415 * 0.5 + startA*3.1415/180 oldRx = rx OldRy = ry deltaRadiusX = rx - (rx*sizeFactor) deltaRadiusY = ry - (ry*sizeFactor) deltaRadiusRoundX = deltaRadiusX / surrNum deltaRadiusRoundY = deltaRadiusY / surrNum deltaLetter = l / surrNum deltaMinusX = deltaRadiusRoundX / deltaLetter deltaMinusY = deltaRadiusRoundY / deltaLetter /* ** define the gauge maximum */ ADDRESS 'TXTROTATOR' GAUGE ID g_GAG01 ATTRS MUIA_Gauge_Max l MUIA_Gauge_Current 0 DO num = 0 TO (l-1) ADDRESS 'TXTROTATOR' GAUGE ID g_GAG01 ATTRS MUIA_Gauge_Current num IF (textFile = True) THEN DO character = back.num END ELSE DO character = SUBSTR(placedText, num+1, 1) END Call GetBusy('please hold on...', character) 'DRAWTEXTOBJ '||mx my||' INFRONT' textID = RESULT 'SELECTTEXT INOBJECT '||textID 'BEGINCOMMANDCAPTURE' 'SETTYPESIZE '||fontSize 'SETTYPEWIDTH 100%' 'SETTRACKING NONE' 'SETLEADING RELATIVE 100%' 'SETPARAGRAPHSTYLE '||fontStyle 'ENDCOMMANDCAPTURE' IF (character = 'SPEC') THEN DO /* ** insert special character */ 'INSERTCHAR UNICODE '||specialChar.specialCount specialCount = specialCount + 1 END ELSE DO 'INSERT "'||character||'"' END 'ROTATE 0'||degree 'GETTEXTOBJ POSITION txtPos2 OBJECTID '|| textID IF (sizeFactor ~= 1) THEN txtPos2 = SCALEOBJECT(txtPos2, textID, (rx/oldRx)) txtHeight = txtPos2.bottom - txtPos2.top txtWidth = txtPos2.right - txtPos2.left IF (l>1) THEN sinus = (highAngle-lowAngle) / (l-1) * num + lowAngle ELSE sinus = (highAngle-lowAngle) * num + lowAngle rot = sinus * 180 / 3.1415 sinusResult = Sin(sinus) cosinusResult = Cos(sinus) nrx = rx + (txtHeight/2)*posiFactor nry = ry + (txtHeight/2)*posiFactor xx2 = mx + cosinusResult * nrx yy2 = my + sinusResult * nry movx = (xx2-mx-(txtWidth/2)) movy = (yy2-my-(txtHeight/2)) 'MOVE OFFSET '||movx movy||' OBJECTID '|| textID /* calculate the rotation angle for the letter */ x0 = cosinusResult * rx y0 = sinusResult * ry IF (y0 = 0) THEN rot = -3.1415 / 2 ELSE DO rot = (x0*ry*ry)/(y0*rx*rx) rot = atan(rot) END rot = 180 + rot * 180 / 3.1415 IF (y0 * dirFactor) > 0 THEN 'ROTATE '||rot degree ELSE 'ROTATE '||180+rot degree /* ** spaces will be deleted after they are drawn */ IF (character = ' ') THEN 'DELETEOBJECT OBJECTID '|| textID rx = rx - deltaMinusx ry = ry - deltaMinusy END Call CleanUp(1) RETURN /* ** Scale a text object */ ScaleObject: ARG txtpos2,objectidnew,factor txt_x = txtpos2.left txt_y = txtpos2.top txt_xx = txtpos2.right txt_yy = txtpos2.bottom txtheight = txt_yy - txt_y txtwidth = txt_xx - txt_x newtxt_x = txt_x + txtwidth * factor newtxt_y = txt_y + txtheight * factor 'EDITTEXTOBJ POSITION '|| txt_x txt_y newtxt_x newtxt_y ||' OBJECTID 'objectidnew 'GETTEXTOBJ POSITION txtpos2 OBJECTID '|| textID RETURN txtpos2 /* ** Get busy requester */ GetBusy: PARSE ARG mess,mess2 Call SetBusyMessage(mess,mess2) ADDRESS 'TXTROTATOR' getvar UserWantsQuit uwq = result ADDRESS 'PAGESTREAM' IF (uwq = 1) THEN DO Call CLEANUP END RETURN /* ** Clean up everything */ CleanUp: Call DeleteExampleArc /* reset the measurementsystem to the saved one!! */ ''defmeasure'' Call SetBusyMessage('Refreshing display...','...') Call WindowCanceled 'REFRESH CONTINUE' 'REFRESHWINDOW' ADDRESS PAGESTREAM "LOCKINTERFACE FALSE" EXIT /* ** Get the default measurement system */ GetDefaultMeasurementSystem: PROCEDURE 'GETMEASUREMENTS COORDINATE stemc RELATIVE rel TEXT tex FROM fro' st = 'SETMEASUREMENTS COORDINATE 'stemc.horizontal stemc.vertical' RELATIVE 'rel' TEXT 'tex' FROM 'fro 'SETMEASUREMENTS COORDINATE POINTS SAMEAS RELATIVE SAMEAS TEXT POINTS FROM PAGE' RETURN st /* ** ERORR -> Exit */ ErrorExit: Call ErrorWin('An ERROR occured! Please restart and try again!') Call CleanUp EXIT /* ** Set the busy window */ SetBusyMessage: PARSE ARG BMess1,BMess2 IF BMess1 ~= '' THEN ADDRESS 'TXTROTATOR' 'TEXT ID STR91 LABEL \033c'BMess1 IF BMess2 ~= '' THEN ADDRESS 'TXTROTATOR' 'TEXT ID STR92 LABEL \033c'BMess2 RETURN /* ** Check and prepare angles */ CheckConstraints: ADDRESS PAGESTREAM /* ** get the objecttype. must be an ellipse/circle or an arc/pie */ 'GETOBJECT TYPE typ' ret = RESULT IF ( (typ ~= 7) | (ret = 10) ) THEN DO /* ** selected nothing or not an ellipse/circle/arc/pie */ Call ErrorWin('Please select an Ellipse first!') RETURN 1 END /* ** get the start and end angles if the object is an arc/pie */ 'GETELLIPSE ANGLES angle' type = angle.type startA = 0 endA = 360 IF type ~= 'ELLIPSE' THEN DO /* ** 0 degrees are 90 math. degrees ** 90 degrees are 0 math. degrees ** 180 degrees are 270 math. degrees ** 270 degrees are 180 math. degrees ** ... */ endA = (450 - (angle.begin)) // 360 startA = (450 - (angle.end)) // 360 END ADDRESS TXTROTATOR RETURN 0 /* ** Read text from file */ ReadTextToBePlaced: /* ** check if filename is correct */ IF ~Exists(textFileName) THEN DO Say 'File "'|| textFileName ||'" not found!' Call ErrorWin('\033cTextfile \n\033b'|| textFileName ||'\033n\n\033c cannot be opened!') Return(0) END Open('inTxt', textFileName, 'R') rMode = 0 specialCount = 0 back = '' backCount = 0 /* ** read in complete text! */ DO UNTIL (EOF('inTxt') = 1) t = ReadCH('inTxt') /* ** special character detected (/1234) */ IF (t = '\') THEN DO /* ** read the next four characters */ t1 = ReadCH('inTxt') /* ** if t1 is also a '\' use '\' as character and not a special one! */ IF (t1 = '\') THEN DO back.backCount = '\\\\' END ELSE DO /* ** really a special character! if an error occurs now -> BAD IDEA! */ t2 = ReadCH('inTxt') t3 = ReadCH('inTxt') t4 = ReadCH('inTxt') specialChar.specialCount = t1 || t2 || t3 || t4 specialCount = specialCount + 1 back.backCount = 'SPEC' END END ELSE DO back.backCount = t END backCount = backCount + 1 END Close('inTxt') Return backCount /* ** Draw the example arc */ DrawExampleArc: Call DeleteExampleArc endA = endAngle startA = startAngle IF (spiralCheck = 0) THEN DO sizeFactor = 1 surrNum = 1 END ADDRESS PAGESTREAM defmeasure = GetDefaultMeasurementSystem() measure = 'pt' degree = '°' tf.0 = 'FALSE' tf.1 = 'TRUE' fontSize = p2d(fontSize, measure) 'GETELLIPSE POSITION arcPos' arcID = result mx = arcPos.centerx my = arcPos.centery rx = arcPos.radiusx ry = arcPos.radiusy 'CREATEPATH '|| mX mY mX mY nEID = RESULT posiFactor = textPosition - 1 IF (endA < startA) THEN endA = endA + 360 endA = endA + 360*(surrNum - 1) IF (textDirection = 1) THEN DO dirFactor = -1 dummy = startA startA = endA endA = dummy END ELSE dirFactor = 1 highAngle = -3.1415 * 0.5 + endA*3.1415/180 lowAngle = -3.1415 * 0.5 + startA*3.1415/180 oldRx = rx oldRy = ry deltaRadiusX = rx - (rx*sizeFactor) deltaRadiusY = ry - (ry*sizeFactor) deltaRadiusRoundX = deltaRadiusX / surrNum deltaRadiusRoundY = deltaRadiusY / surrNum l = drawExSeg deltaLetter = l / surrNum deltaMinusX = deltaRadiusRoundX / deltaLetter deltaMinusY = deltaRadiusRoundY / deltaLetter DO num = 0 TO (l-1) IF (l > 1) THEN sinus = (highAngle-lowAngle) / (l-1) * num + lowAngle ELSE sinus = (highAngle-lowAngle) * num + lowAngle sinusResult = Sin(sinus) cosinusResult = Cos(sinus) xx2 = mx + cosinusResult * (rx + 0.5*posiFactor*fontSize) yy2 = my + sinusResult * (ry + 0.5*posiFactor*fontSize) IF (num = 0) THEN 'ADDPOINT MOVETO '|| xx2 yy2 ||' OBJECTID '||nEID ELSE 'ADDPOINT LINETO '|| xx2 yy2 ||' OBJECTID '||nEID rx = rx - deltaMinusx ry = ry - deltaMinusy END 'SETFPATTERN NONE FILL OBJECT OBJECTID '|| nEID 'STROKED ON OBJECT OBJECTID '|| nEID 'SETSTROKE PATTERN 1111111100000000 STROKENUMBER 0 OBJECT OBJECTID '|| nEID 'SETSTROKEWEIGHT 5pt STROKENUMBER 0 OBJECT OBJECTID '|| nEID 'SETSTROKEBEGIN FLAT STROKENUMBER 0 OBJECT OBJECTID '|| nEID 'SETSTROKEEND ARROW STROKENUMBER 0 OBJECT OBJECTID '|| nEID 'SETCOLORSTYLE Green COLORNUMBER 0 STROKENUMBER 0 OBJECT OBJECTID '|| nEID 'SELECTOBJECT OBJECTID '|| arcID ''defmeasure'' ADDRESS TXTROTATOR SETVAR trEID nEID Return /* ** Delete the example arc */ DeleteExampleArc: ADDRESS TXTROTATOR GETVAR trEID oEID = RESULT IF (oEID ~= 0) THEN DO ADDRESS PAGESTREAM 'DELETEOBJECT OBJECTID '|| oEID SETVAR trEID 0 END Return /* ** Get the style tags from PageStream */ GetStyleTags: ADDRESS PAGESTREAM 'GETSTYLETAGS styles TEXT' stylecount = RESULT styleString = '' DO k=0 TO stylecount-1 styleString = styleString || styles.k || ',' END styleString = Left(styleString, Length(styleString)-1) Return /* ** write parameter with value in file ** ---------------------------------- */ WritePrefsNameValue: PARSE ARG file,name,value WriteLN(file, name || ' = "' || value || '"') Return /* ** load the preferences file of OLD version ** and update the preferences window. ** ---------------------------------------- */ LoadPrefsOLD: PARSE ARG filename IF (fileName = "") THEN fileName = 'PageStream3:Scripts/MUItxtRotator.prefs' ok = Open('Prefs',fileName,'R') IF (ok = 1) THEN DO dummy = ReadLn('Prefs') IF ( (Left(dummy,3) = 'TRP' ) & (right(dummy,4) >= trlver) ) THEN DO Say 'correct version! reading old prefs...' /* format of mui-variables | | tr1 (startAngle endAngle saveOnExit) | tr2 (fontSize textFile textPosition textDirection spiralCheck sizeFactor surrNum drawExSeg) | tr3 (fontStyle) | tr4 (placedText) | tr5 (textFileName) \*/ tr1 = ReadLN('Prefs') SLIDER ID g_startAngle ATTRS MUIA_Slider_Level WORD(tr1,1) SLIDER ID g_endAngle ATTRS MUIA_Slider_Level WORD(tr1,2) ITEM ID g_saveOnExit ATTRS MUIA_Menuitem_Checked WORD(tr2,3) tr2 = ReadLN('Prefs') STRING ID g_fontSize CONTENT WORD(tr2,1) CHECK ID g_textFile ATTRS MUIA_Selected WORD(tr2,2) CYCLE ID g_textPosition ATTRS MUIA_Cycle_Active WORD(tr2,3) CYCLE ID g_textDirection ATTRS MUIA_Cycle_Active WORD(tr2,4) CHECK ID g_spiralCheck ATTRS MUIA_Selected WORD(tr2,5) STRING ID g_sizeFactor CONTENT WORD(tr2,6) STRING ID g_surrNum CONTENT WORD(tr2,7) STRING ID g_drawExSeg CONTENT WORD(tr2,8) tr3 = ReadLN('Prefs') POPLIST ID g_fontStyle CONTENT tr3 tr4 = ReadLN('Prefs') STRING ID g_placedText CONTENT tr4 tr5 = ReadLN('Prefs') POPASL ID g_textFileName CONTENT tr5 END ELSE DO Call ErrorWin('Incompatible prefsfile') END cl = Close('Prefs') END ELSE DO Call ErrorWin('Prefsfile not found!') END RETURN /* ** Check if prefsfile is compatible ** -------------------------------- */ CheckPrefsVersion: PARSE ARG fileName IF (fileName = "") THEN fileName = 'PageStream3:Scripts/MUItxtRotator.prefs' ok = Open('Prefs', fileName, 'R') IF (ok = 1) THEN DO dummy = ReadLn('Prefs') cl = Close('Prefs') IF ( (Left(dummy,3) = 'TRP' ) & (right(dummy,4) >= trlver) ) THEN DO IF (right(dummy,4) >= trLVerN) THEN RETURN prefsOK ELSE RETURN prefsOld END ELSE RETURN prefsTooOld END RETURN 0 /* ** Set the window gadgets according to the prefs ** --------------------------------------------- */ SetMUIGadgets: ADDRESS 'TXTROTATOR' SLIDER ID g_startAngle ATTRS MUIA_Slider_Level startAngle SLIDER ID g_endAngle ATTRS MUIA_Slider_Level endAngle ITEM ID g_saveOnExit ATTRS MUIA_Menuitem_Checked saveOnExit STRING ID g_fontSize CONTENT fontSize CHECK ID g_textFile ATTRS MUIA_Selected textFile CYCLE ID g_textPosition ATTRS MUIA_Cycle_Active textPosition CYCLE ID g_textDirection ATTRS MUIA_Cycle_Active textDirection CHECK ID g_spiralCheck ATTRS MUIA_Selected spiralCheck STRING ID g_sizeFactor CONTENT sizeFactor STRING ID g_surrNum CONTENT surrNum STRING ID g_drawExSeg CONTENT drawExSeg POPLIST ID g_fontStyle CONTENT fontStyle STRING ID g_placedText CONTENT placedText POPASL ID g_textFileName CONTENT textFileName Return /* ** Get the prefs from the window gadgets ** ------------------------------------- */ GetMUIGadgets: ADDRESS 'TXTROTATOR' SLIDER ID g_startAngle ATTRS MUIA_Slider_Level; startAngle = RESULT SLIDER ID g_endAngle ATTRS MUIA_Slider_Level; endAngle = RESULT ITEM ID g_saveOnExit ATTRS MUIA_Menuitem_Checked; saveOnExit = RESULT STRING ID g_fontSize; fontSize = RESULT CHECK ID g_textFile ATTRS MUIA_Selected; textFile = RESULT CYCLE ID g_textPosition ATTRS MUIA_Cycle_Active; textPosition = RESULT CYCLE ID g_textDirection ATTRS MUIA_Cycle_Active; textDirection = RESULT CHECK ID g_spiralCheck ATTRS MUIA_Selected; spiralCheck = RESULT STRING ID g_sizeFactor; sizeFactor = RESULT STRING ID g_surrNum; surrNum = RESULT STRING ID g_drawExSeg; drawExSeg = RESULT POPLIST ID g_fontStyle; fontStyle = RESULT STRING ID g_placedText; placedText = RESULT POPASL ID g_textFileName; textFileName = RESULT Return