;+ ;NAME: ; thm_ui_text__define ; ;PURPOSE: ; generic object for character strings ; ;CALLING SEQUENCE: ; text = Obj_New("THM_UI_TEXT") ; ;INPUT: ; none ; ;KEYWORDS: ;value what's contained in the string ;font font names ('Time New Roman', etc...) ;format font formats ('bold', 'italic', etc..) ;color name of color for text ;size character size ;thickness character thickness ;show flag to display text ;OUTPUT: ; text object reference ; ;METHODS: ; GetProperty ; GetAll ; SetProperty ; GetFonts ; GetFont ; GetFontIndex ; GetFormats ; GetFormat ; GetFormatIndex ; ;HISTORY: ; ;$LastChangedBy: pcruce $ ;$LastChangedDate: 2009-04-02 17:57:49 -0700 (Thu, 02 Apr 2009) $ ;$LastChangedRevision: 5532 $ ;$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/tags/tdas_5_11/idl/themis/thm_ui_new/objects/thm_ui_text__define.pro $ ;----------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::Copy out = Obj_New('THM_UI_TEXT') selfClass = Obj_Class(self) outClass = Obj_Class(out) IF selfClass NE outClass THEN BEGIN Print, 'Object classes not identical' RETURN, -1 END Struct_Assign, self, out RETURN, out END ;-------------------------------------------------------------------------------- ;functional copy constructor has simpler syntax function THM_UI_TEXT::Copy out = obj_new('thm_ui_text') selfClass = Obj_Class(self) outClass = Obj_Class(out) Struct_Assign, self, out return,out END ;-------------------------------------------------------------------------------- PRO THM_UI_TEXT::SetProperty, $ Value=value, $ ; what's contained in the string Font=font, $ ; font names ('Time New Roman', etc...) Format=format, $ ; font formats ('bold', 'italic', etc..) Color=color, $ ; name of color for text Size=size, $ ; character size Thickness=thickness, $ ; character thickness Show=show ; flag to display text Catch, theError IF theError NE 0 THEN BEGIN Catch, /Cancel ok = Error_Message(Traceback=1) RETURN ENDIF IF N_Elements(value) NE 0 THEN self.value = value IF N_Elements(font) NE 0 THEN self.font = font IF N_Elements(format) NE 0 THEN self.format = format IF N_Elements(color) NE 0 THEN begin if is_string(color) then self.color = getcolor(color) else self.color=color endif IF N_Elements(size) NE 0 THEN self.size = size IF N_Elements(thickness) NE 0 THEN self.thickness = thickness IF n_elements(show) THEN self.show = show RETURN END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::GetFormats formats = [ $ 'Bold', $ 'Italic', $ 'Bold*Italic', $ 'No Format'] RETURN, formats END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::GetFormat, Index=index IF N_Elements(index) EQ 0 THEN index = self.format IF NOT Is_Numeric(index) THEN RETURN, -1 IF index LT 0 OR index GT 5 THEN RETURN, -1 ELSE formats = self->GetFormats() font = self->GetFont() if font eq 'Symbol' || font eq 'Monospace Symbol' then return,-1 RETURN, formats[index] END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::GetFormatIndex, FormatName=formatname IF N_Elements(formatname) EQ 0 THEN RETURN, self.format IF Is_Numeric(formatname) THEN RETURN, -1 formats = self->GetFormats() formatIndex = where(formats EQ formatname) RETURN, formatIndex END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::GetFonts fonts = ['Times', $ 'Courier', $ 'Helvetica', $ 'Symbol', $ 'Monospace Symbol'] RETURN, fonts END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::GetFont, Index=index IF N_Elements(index) EQ 0 THEN index = self.font IF NOT Is_Numeric(index) THEN RETURN, -1 IF index LT 0 OR index GT 12 THEN RETURN, -1 fonts = self->GetFonts() RETURN, fonts(index) END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::GetFontIndex, FontName=fontname IF N_Elements(fontname) EQ 0 THEN RETURN, self.font IF Is_Numeric(fontname) THEN RETURN, -1 fonts = self->GetFonts() fontIndex = where(fonts EQ fontname) RETURN, fontIndex END ;-------------------------------------------------------------------------------- ;returns an IDLgrFont object which is used for Fonts in IDL object graphics ;This routine should guarantee appropriate font format. FUNCTION THM_UI_TEXT::getGrFont font = self->getFont() format = self->getFormat() if is_string(format[0]) && format ne 'No Format' then grFont = font + '*' + format else grFont = font if self.size gt 0 then grSize = self.size if self.thickness gt 0 then grThick = self.thickness return,obj_new('IDLgrFont',grFont,size=grSize,thick=grThick) end ;returns the text from the object, but with the appropriate ;values replaced in %strings FUNCTION THM_UI_TEXT::GetValue return,self.value end FUNCTION THM_UI_TEXT::GetAll all=create_struct(name="THM_UI_TEXT") struct_assign,self,all RETURN, all END ;-------------------------------------------------------------------------------- PRO THM_UI_TEXT::SetAll, in struct_assign,in,self END ;-------------------------------------------------------------------------------- PRO THM_UI_TEXT::GetProperty, $ Value=value, $ ; what's contained in the string Font=font, $ ; font names ('Time New Roman', etc...) Format=format, $ ; font formats ('bold', 'italic', etc..) Color=color, $ ; name of color for text Size=size, $ ; character size Thickness=thickness, $ ; character thickness Show=show ; flag to display text Catch, theError IF theError NE 0 THEN BEGIN Catch, /Cancel ok = Error_Message(Traceback=1) RETURN ENDIF IF Arg_Present(value) THEN value = self.value IF Arg_Present(font) THEN font = self.font IF Arg_Present(format) THEN format = self.format IF Arg_Present(color) THEN color = self.color IF Arg_Present(size) THEN size = self.size IF Arg_Present(thickness) THEN thickness = self.thickness IF Arg_Present(show) THEN show = self.show RETURN END ;-------------------------------------------------------------------------------- FUNCTION THM_UI_TEXT::Init, $ ; The INIT method of the line style object Value=value, $ ; what's contained in the string Font=font, $ ; font names ('Time New Roman', etc...) Format=format, $ ; font formats ('bold', 'italic', etc..) Color=color, $ ; name of color for text Size=size, $ ; character size Thickness=thickness, $ ; character thickness Show=show, $ ; flag to display text Debug=debug ; flag to debug Catch, theError IF theError NE 0 THEN BEGIN Catch, /Cancel ok = Error_Message(Traceback=Keyword_Set(debug)) RETURN, 0 ENDIF ; Check that all parameters have values IF N_Elements(value) EQ 0 THEN value = '' IF N_Elements(font) EQ 0 THEN font = 2 IF N_Elements(format) EQ 0 THEN format = -1 IF N_Elements(color)EQ 0 THEN color = [0,0,0] IF N_Elements(size)EQ 0 THEN size = 12. IF N_Elements(thickness) EQ 0 THEN thickness = 1 IF N_Elements(show)EQ 0 THEN show = 1 ; Set all parameters self.value = value self.font = font self.format = format self.color = color self.size = size self.thickness = thickness self.show = show RETURN, 1 END ;-------------------------------------------------------------------------------- PRO THM_UI_TEXT__DEFINE struct = { THM_UI_TEXT, $ value : '', $ ; what's contained in the string font : 0, $ ; font names ('Time New Roman', etc...) format : -1, $ ; font formats ('bold', 'italic', etc..) color : [0,0,0], $ ; name of color for text size : 0, $ ; character size thickness : 0, $ ; character thickness show : 0, $ ; flag to display text INHERITS thm_ui_readwrite $ ; use generalize read/write methods } END