FUNCTION SPD_UI_PAGE_SETTINGS::Copy
out = Obj_New("SPD_UI_PAGE_SETTINGS",/nosave)
Struct_Assign, self, out
newTitle=Obj_New("SPD_UI_TEXT")
IF Obj_Valid(self.title) THEN newTitle=self.title->Copy() ELSE $
newTitle=Obj_New()
out->SetProperty, Title=newTitle
newLabel=Obj_New("SPD_UI_TEXT")
IF Obj_Valid(self.labels) THEN newLabel=self.labels->Copy() ELSE $
newLabel=Obj_New()
out->SetProperty, Labels=newLabel
newVariables=Obj_New("SPD_UI_TEXT")
IF Obj_Valid(self.variables) THEN newVariables=self.variables->Copy() ELSE $
newVariables=Obj_New()
out->SetProperty, Variables=newVariables
newFooter=Obj_New("SPD_UI_TEXT")
IF Obj_Valid(self.footer) THEN newFooter=self.footer->Copy() ELSE $
newFooter=Obj_New()
out->SetProperty, Footer=newFooter
newMarker=Obj_New("SPD_UI_TEXT")
IF Obj_Valid(self.Marker) THEN newMarker=self.Marker->Copy() ELSE $
newMarker=Obj_New()
out->SetProperty, Marker=newMarker
RETURN, out
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetTokenNames
tokenNames = ['Time', 'Date', 'Year', 'Day of Year']
RETURN, tokenNames
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetTokenName, index
IF index LT 0 OR index GT 7 THEN RETURN, -1 ELSE tokenNames=self->GetTokenNames()
RETURN, tokenNames[index]
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetTokenCommands
tokenCommands= ['%time', '%date', '%year', '%doy']
RETURN, tokenCommands
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetTokenCommand, index
IF index LT 0 OR index GT 7 THEN RETURN, -1 ELSE tokenCommands=self->GetTokenCommands()
RETURN, tokenCommands[index]
END
function spd_ui_page_settings::EvaluateToken ,$
value, $
result, $
inittoken, $
token
compile_opt idl2, hidden
stringLength = StrLen(value)
tokenlength = strlen(token)
inittokenlength = strlen(inittoken)
case 1 of
inittokenlength eq stringlength: title = token
result eq 0: title = token + strmid(value, inittokenlength, stringlength - inittokenlength)
result gt 0 && result lt stringlength-inittokenlength: $
title = strmid(value, 0, result) + token + strmid(value, result+inittokenlength, stringlength-inittokenlength-result)
result eq stringlength-inittokenlength: title = strmid(value, 0, stringlength-inittokenlength) + token
endcase
return,title
end
FUNCTION SPD_UI_PAGE_SETTINGS::GetTitleString
compile_opt idl2
self->GetProperty, title=title
title->GetProperty, Value=value
value = self->interpolateTitle(value)
out = title->copy()
out->setProperty,value=value
RETURN,out
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFooterString
compile_opt idl2
self->GetProperty, footer=footer
footer->GetProperty, Value=value
value = self->interpolateTitle(value)
out = footer->copy()
out->setProperty,value=value
RETURN,out
END
function spd_ui_page_settings::interpolateTitle,value
compile_opt idl2
WHILE stregex(value, '%',/boolean) DO BEGIN
IF stregex(value, '%time',/boolean) THEN BEGIN
result = stregex(value, '%time')
token = self->GetTokenValue(0)
text = self->EvaluateToken(value, result, '%time', token)
value = text
ENDIF ELSE IF stregex(value, '%date',/boolean) then begin
result = stregex(value, '%date')
token = self->GetTokenValue(1)
text = self->EvaluateToken(value, result, '%date', token)
value = StrCompress(text)
ENDIF ELSE IF stregex(value, '%year',/boolean) then begin
result = stregex(value, '%year')
token = self->GetTokenValue(2)
text = self->EvaluateToken(value, result, '%year', token)
value = text
ENDIF else if stregex(value, '%doy',/boolean) then begin
result = stregex(value, '%doy')
token = self->GetTokenValue(3)
text = self->EvaluateToken(value, result, '%doy', token)
value = StrCompress(text)
ENDIF ELSE BEGIN
break
endelse
ENDWHILE
return,value
end
FUNCTION SPD_UI_PAGE_SETTINGS::GetTokenValue, index
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /Cancel
ok = Error_Message(Traceback=1)
RETURN, -1
ENDIF
timeObj = Obj_New("SPD_UI_TIME")
timeObj->GetProperty, TString=timeString
timeStruc = timeObj->GetStructure()
CASE index OF
0: titleValue = StrMid(timeString, 11, 8)
1: titleValue = StrMid(timeString, 0, 10)
2: titleValue = StrTrim(String(timeStruc.year),2)
3: titleValue = StrTrim(String(timeStruc.doy),2)
ELSE:
ENDCASE
RETURN, titleValue
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFormatNames
textObj = Obj_New("SPD_UI_TEXT")
formatNames = textObj->GetFormats()
Obj_Destroy, textObj
RETURN, formatNames
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFormatName, index
FormatNames=self->GetFormatNames()
IF index LT 0 OR index GE n_elements(FormatNames) THEN RETURN, -1 ELSE RETURN, FormatNames[index]
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFormatCommands
formatCommands= ['\B', '\I', '\U', '\D', '\L']
RETURN, formatCommands
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFormatCommand, index
formatCommands=self->GetFormatCommands()
IF index LT 0 OR index GE n_elements(formatCommands) THEN RETURN, -1 ELSE RETURN, formatCommands[index]
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetUnitNames
RETURN, ['hours', 'minutes', 'seconds', 'days', '<none>']
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetUnitName, index
IF index LT 0 OR index GT 4 THEN RETURN, -1 ELSE unitNames=self->GetUnitNames()
RETURN, unitNames(index)
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFontNames
textObj = Obj_New("SPD_UI_TEXT")
fontNames = textObj->GetFonts()
Obj_Destroy, textObj
RETURN, fontNames
END
FUNCTION SPD_UI_PAGE_SETTINGS::GetFontName, index
IF index LT 0 OR index GT 7 THEN RETURN, -1 ELSE fontNames=self->GetFontNames()
RETURN, fontNames(index)
END
PRO SPD_UI_PAGE_SETTINGS::Save
obj = self->copy()
if ptr_valid(self.origSettings) then ptr_free,self.origSettings
self.origSettings = ptr_new(obj->getall())
RETURN
END
pro spd_ui_page_settings::setProperty,ypanelspacing=ypanelspacing,_extra=ex
self->spd_ui_getset::setProperty,_extra=ex
if n_elements(ypanelspacing) gt 0 then begin
if self.parentlocked ge 0 then begin
self.lockedypanelspacing = ypanelspacing
endif else begin
self.unlockedypanelspacing = ypanelspacing
endelse
endif
end
pro spd_ui_page_settings::getProperty,ypanelspacing=ypanelspacing,_ref_extra=ex
self->spd_ui_getset::getProperty,_extra=ex
if arg_present(ypanelspacing) then begin
if self.parentlocked ge 0 then begin
ypanelspacing = self.lockedypanelspacing
endif else begin
ypanelspacing = self.unlockedypanelspacing
endelse
endif
end
PRO SPD_UI_PAGE_SETTINGS::Reset
if ptr_valid(self.origSettings) then begin
self->setall,*self.origSettings
self->save
endif
RETURN
END
FUNCTION SPD_UI_PAGE_SETTINGS::Init, $
Title=title, $
Labels=labels, $
Variables=variables, $
Footer=footer, $
Marker=marker, $
Token=token, $
ifootertoken=ifootertoken, $
DefMarkerTitle=defmarkertitle, $
maintainRead=maintainread, $
ShowTraceNames=showtracenames, $
xPanelSpacing=xpanelspacing, $
yPanelSpacing=ypanelspacing, $
HeightProp=heightprop, $
GutterWidth=gutterwidth, $
DisplayOnScreen=displayonscreen, $
AltTopBottom=alttopbottom, $
OffsetFirstPage=offsetfirstpage, $
Orientation=orientation, $
BackgroundColor=backgroundcolor, $
LeftPrintMargin=leftprintmargin, $
RightPrintMargin=rightprintmargin, $
TopPrintMargin=topprintmargin, $
BottomPrintMargin=bottomprintmargin, $
CanvasSize=canvassize, $
OverlapMajorTicks=overlapmajorticks, $
ShowValues=showvalues, $
CloserThanValue=closerthanvalue, $
CloserThanUnits=closerthanunits, $
UseSameYRange=usesameyrange, $
NumMajorTicks=nummajorticks, $
NumMinorTicks=numminorticks, $
SkipBlanks=skipblanks, $
Debug=debug, $
nosave=nosave
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /Cancel
ok = Error_Message(Traceback=Keyword_Set(debug))
RETURN, 0
ENDIF
IF NOT Obj_Valid(title) THEN title = Obj_New('SPD_UI_TEXT')
IF NOT Obj_Valid(labels) THEN labels = Obj_New('SPD_UI_TEXT')
IF NOT Obj_Valid(variables) THEN variables = Obj_New('SPD_UI_TEXT',size=8)
IF NOT Obj_Valid(footer) THEN footer = Obj_New('SPD_UI_TEXT')
IF NOT Obj_Valid(marker) THEN marker = Obj_New('SPD_UI_TEXT')
IF N_Elements(token) EQ 0 THEN token = 0
IF N_Elements(ifootertoken) EQ 0 THEN ifootertoken = 0
IF N_Elements(defmarkertitle) EQ 0 THEN defmarkertitle = ''
IF N_Elements(xpanelspacing) EQ 0 THEN xpanelspacing = 130
IF N_Elements(ypanelspacing) EQ 0 THEN unlockedypanelspacing = 60 else unlockedypanelspacing = ypanelspacing
IF N_Elements(gutterwidth) EQ 0 THEN gutterwidth = 50
IF N_Elements(orientation) EQ 0 THEN orientation = 0
IF N_Elements(backgroundcolor) EQ 0 THEN backgroundcolor = [255,255,255]
IF N_Elements(leftprintmargin) EQ 0 THEN leftprintmargin =1.25
IF N_Elements(rightprintmargin) EQ 0 THEN rightprintmargin = 1.
IF N_Elements(topprintmargin) EQ 0 THEN topprintmargin = 1.
IF N_Elements(bottomprintmargin) EQ 0 THEN bottomprintmargin = 1.
IF N_Elements(canvassize) EQ 0 THEN canvassize = [8.5, 11.0]
IF N_Elements(overlapmajorticks) EQ 0 THEN overlapmajorticks = 0
IF N_Elements(closerthanvalue) EQ 0 THEN closerthanvalue = 0
IF N_Elements(closerthanunits) EQ 0 THEN closerthanunits = 0
IF N_Elements(nummajorticks) EQ 0 THEN nummajorticks = 5
IF N_Elements(numminorticks) EQ 0 THEN numminorticks = 12
IF N_Elements(maintainread) EQ 0 THEN maintainread = 1
IF N_Elements(showtracenames) EQ 0 THEN showtracenames = 0
IF N_Elements(heightprop) EQ 0 THEN heightprop = 1
IF N_Elements(displayonscreen) EQ 0 THEN displayonscreen = 1
IF N_Elements(alttopbottom) EQ 0 THEN alttopbottom = 0
IF N_Elements(offsetfirstpage) EQ 0 THEN offsetfirstpage = 0
IF N_Elements(showvalues) EQ 0 THEN showvalues = 0
IF N_Elements(usesameyrange) EQ 0 THEN usesameyrange = 1
IF N_Elements(skipblanks) EQ 0 THEN skipblanks = 0
lockedypanelspacing = 5
self.title = title
self.labels = labels
self.variables = variables
self.footer = footer
self.marker = marker
self.token = token
self.ifootertoken = ifootertoken
self.defMarkerTitle = defmarkertitle
self.maintainRead = maintainread
self.showTraceNames = showtracenames
self.xpanelSpacing = xpanelspacing
self.unlockedypanelSpacing = unlockedypanelspacing
self.lockedypanelspacing = lockedypanelspacing
self.heightProp = heightprop
self.gutterWidth = gutterwidth
self.displayOnScreen = displayonscreen
self.altTopBottom = alttopbottom
self.offsetFirstPage = offsetfirstpage
self.orientation = orientation
self.backgroundColor = backgroundcolor
self.leftPrintMargin = leftprintmargin
self.rightPrintMargin = rightprintmargin
self.topPrintMargin = topprintmargin
self.bottomPrintMargin = bottomprintmargin
self.canvasSize = canvassize
self.overlapMajorTicks = overlapmajorticks
self.showValues = showvalues
self.closerThanValue = closerthanvalue
self.closerThanUnits = closerthanunits
self.useSameYRange = usesameyrange
self.numMajorTicks = nummajorticks
self.numMinorTicks = numminorticks
self.skipBlanks = skipblanks
if ~keyword_set(nosave) then self->save
RETURN, 1
END
PRO SPD_UI_PAGE_SETTINGS__DEFINE
struct = { SPD_UI_PAGE_SETTINGS, $
title : Obj_New(), $
labels : Obj_New(), $
variables : Obj_New(), $
footer : Obj_New(), $
marker : Obj_New(), $
token : 0, $
ifootertoken : 0, $
defMarkerTitle : '', $
maintainRead: 0, $
showTraceNames : 0, $
xpanelSpacing : 0, $
heightProp : 0, $
gutterWidth : 0, $
displayOnScreen : 0, $
altTopBottom : 0, $
offsetFirstPage : 0, $
orientation : 0, $
backgroundColor : [255,255,255], $
leftPrintMargin : 0., $
rightPrintMargin : 0., $
topPrintMargin : 0., $
bottomPrintMargin : 0., $
canvasSize : [0.D, 0.D], $
overlapMajorTicks : 0, $
showValues : 0, $
closerThanValue : 0, $
closerThanUnits : 0, $
useSameYRange : 0, $
numMajorTicks : 0, $
numMinorTicks : 0, $
skipBlanks : 0, $
parentlocked:-1, $
lockedypanelspacing:0, $
unlockedypanelspacing:0, $
origSettings : Ptr_New(), $
INHERITS SPD_UI_READWRITE, $
INHERITS spd_ui_getset $
}
END