📄 framedview
字号:
#..........................................................................# # L a s t W a v e P a c k a g e 'disp' 2.0.3## Author Emmanuel Bacry # #..........................................................................## Some default values for the FramedView class## The default margin values between the border of the FramedView and the axisgclass.FramedView.default.viewMargin={60 20 25 50}# The default view background colorgclass.FramedView.default.viewbg='white'# The default box background colorgclass.FramedView.default.boxbg=gclass.FramedView.default.viewbg# The default margin between the axis and the View (same value in all directions)gclass.FramedView.default.axisMargin=6# A flag to know whether the ticks of the axis are in or outgclass.FramedView.default.ticksIn=0# A flag to know whether it should draw axis (=> 2 axis are drawn)gclass.FramedView.default.axis=1# A flag to know whether it should frame the view with axis (=> 4 axis are drawn)gclass.FramedView.default.axisFrame=0# Default value to know whether the x or the y axis should be reversedgclass.FramedView.default.reverse='y'# Default background colorgclass.FramedView.default.bg=gclass.FramedView.default.viewbg# Default font for labelsgclass.FramedView.default.labelFont="10"# Default font for titleif ([font exist "10-bold"]) { gclass.FramedView.default.titleFont="10-bold"} else { gclass.FramedView.default.titleFont="10"}# Default font for axisgclass.FramedView.default.axisFont=[font default]## Try These values you might like them better##gclass.FramedView.default.axisMargin=0#gclass.FramedView.default.ticksIn=1#gclass.FramedView.default.axis=1#gclass.FramedView.default.axisFrame=1#gclass.FramedView.default.bg='darkgrey'#gclass.FramedView.default.viewbg='grey'#gclass.FramedView.default.boxbg='darkgrey'### Now we create the FramedView class ## it consists basically in an EView along with axis and a text line at the bottom## ## Answering the messages for FramedViews #setproc _GFramedViewMsge {obj message .l} { # The help if (obj == "?") { return "{{{clear} {Clears the FramedView.}}}" } id=[msge $obj id] if (message == "init") { global gclass.FramedView.default # Set all the default fields of the FramedView {left top right bottom}=default.viewMargin setg $obj -mn 1 1 -margin left top right bottom -axisMargin default.axisMargin -bg default.bg -axis default.axis -ticksIn default.ticksIn -axisFrame default.ticksIn -axisFont default.axisFont # Add the EView and reverse it if necessary msge $obj add 'view' EView -grid 1 1 1 1 -bg default.viewbg setg $obj -reverse default.reverse # Add the box at the bottom of the FramedView and sets its vertical size msge $obj add 'box' Box -bg default.boxbg {asc desc inter}=[font info [setg ${obj}.box -font]] setg ${obj}.box -size 1 asc+desc # Sets the default size of thr FramedView setg $obj -size 200 200 setv gclass.FramedView.${id}.n 0 -l 1 return 1 } if (message == "delete") { var delete 1 gclass.FramedView.$id return 1 } if (message == "deleteNotify") { if (l[0] == "view" || l[0] == "box") { return 0 } return 1 } if (message == "clear") { setv gclass.FramedView.${id}.n 0 -l 1 msge ${obj}.view remove '*' return 1 } } ## Setting or Getting the fields of FramedViews#setproc _GFramedViewSet {obj field .l} { if (obj == "?") { return "{{{graph <exprString>} {Sets the graph corresponding to <exprString> that will be displayed in the FramedView.}} \{{graph+ <exprString>} {Adds the graph corresponding to expression <exprString> to be displayed in the FramedView on top of the other ones.}} \{{graph1 <exprString>} {Same as graph but do not update the boundaries of the FramedView.}} \{{graph1+ <exprString>} {Same as graph+ but do not update the boundaries of the FramedView.}} \{{boundNoSync <xMin> <xMax> <yMin> <yMax>} {Just send the message to the '-bound' field of the View class of the \EView inside the FramedView. It thus changes the boundaries without synchronization of other views.}} \{{bound [<xMin> <xMax> <yMin> <yMax>]} {Just send the message to the '-bound' field of the EView inside the FramedView.}} \{{string [<string>]} {Works exactly the same way as '-string' field for the Box inside the FramedView.}} \{{axisFrame [<flagOn>]} {Sets/Gets the flag that allows that four axis (instead of 2) are displayed around the view.}} \{{ticksIn [<flagOn>]} {Sets/Gets the flag that allows the ticks on the axis to be inside the view instead of outside.}} \{{axis [<flagOn>]} {Sets/Gets the flag that allows the axis to be displayed or not.}} \{{xLabel [<string>]} {Sets/Gets the label string for the x-axis. Let us note that it creates a Text object named 'xlabel' that you can adress/move direcly.}} \{{yLabel [<string>]} {Sets/Gets the label string for the y-axis. Let us note that it creates a Text object named 'ylabel' that you can adress/move direcly.}} \{{title [<string>]} {Sets/Gets the title string. Let us note that it creates a Text object named 'title' that you can adress/move direcly.}} \{{axisFont [<font>]} {Sets/Gets the font used for axis.}} \{{reverse [x | y | xy | none]} {Gets/Sets the state that indicates which axis are reversed compared to the regular global axis. \If it is 'y' (the default FramedView value at initialization) then the y-axis will be going from bottom of the window to top, if 'x' the x-axis \will be going from right to left, if 'xy' both will be combined and if 'none' the y-axis will be top to bottom and the x-axis left to right \(as for GLists).}}}" } # Get the fields structure associated to the FramedView id=[msge $obj id] import args 1 &array `gclass.FramedView.$id struct` # # Some basic field behavior # if ((field == "reverse") || (field == "ticksIn") || (field == "axisFont") || (field == "axisMargin") || (field == "axisFrame") || (field == "axis")) { # Get case if (l.length == 0) { return struct.$field } # Set case if ([var exist struct.$field]) { if (struct.$field==l[0]) {return -1} } struct.$field=l[0] if ("reverse" == field) {setg ${obj}.view -reverse l[0]} return 1 } # # The 'xLabel' field # if (field == "xLabel") { # Get case : just check whether the gobject xlabel exists if (l.length==0) { if ([msge ${obj}.xlabel exist]) { return [setg ${obj}.xlabel -string] } else { return "" } } # Set case : create the xlabel gobject if it does not exist yet if (![msge ${obj}.xlabel exist]) { if (l[0]=="") {return -1} import args 1 `gclass.FramedView.default.labelFont font` msge $obj add 'xlabel' Text -font font # Sets the position of the label {m1 m2 m3 m4}=[setg ${obj} -margin] {w h}=[setg ${obj} -size] if (struct.reverse == 'y') { if (struct.ticksIn == 0) { setg ${obj}.xlabel -posMode 'right' 'up' -pos w-m3-30 h-m4+22 } else { setg ${obj}.xlabel -posMode 'right' up -pos w-m3-30 h-m4+4 } } elseif (struct.reverse == 'xy') { setg ${obj}.xlabel -posMode 'left' 'up' -pos m1 h-m4+22 } elseif (struct.reverse == 'none') { setg ${obj}.xlabel -posMode 'right' 'down' -pos w-m3 m2-12 } else { setg ${obj}.xlabel -posMode 'left' 'down' -pos m1 m2-12 } } setg ${obj}.xlabel -string l[0] return -1 } # # The 'yLabel' field # if (field == "yLabel") { # Get case : just check whether the gobject ylabel exists if (l.length==0) { if ([msge ${obj}.ylabel exist]) { return [setg ${obj}.ylabel -string] } else { return "" } } # Set case : create the ylabel gobject if it does not exist yet if (![msge ${obj}.ylabel exist]) { if (l[0]=="") {return -1} import args 1 `gclass.FramedView.default.labelFont font` msge $obj add 'ylabel' Text -font font # Sets the position of the label {m1 m2 m3 m4}=[setg ${obj} -margin] {w h}=[setg ${obj} -size] if (struct.reverse == 'y') { if (struct.ticksIn == 0) { setg ${obj}.ylabel -posMode 'right' 'up' -pos m1-20 m2+10 } else { setg ${obj}.ylabel -posMode 'right' 'up' -pos m1-15 m2+10 } } elseif (struct.reverse == 'xy') { setg ${obj}.ylabel -posMode 'left' 'up' -pos w-m3+20 m2 } elseif (struct.reverse == 'none') { setg ${obj}.ylabel -posMode 'right' 'down' -pos m1-20 h-m4 } else { setg ${obj}.ylabel -posMode 'left' 'down' -pos w-m3+20 h-m4 } } setg ${obj}.ylabel -string l[0] return -1 } # # The 'title' field # if (field == "title") { # Get case : just check whether the gobject title exists if (l.length == 0) { if ([msge ${obj}.title exist]) { return [setg ${obj}.title -string] } else { return "" } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -