Mercurial > octave
comparison libinterp/corefcn/graphics.in.h @ 18735:28eab2d84190
Add callbacks for root properties format and formatspacing (bug #42135).
* graphics.in.h (root format and formatspacing properties) define custom get and set methods
* graphics.in.h (root format property) replace allowed value "rationale" (not supported by Fformat) by "rat"
* pr-output.cc: new static variable format_string
* pr-output.cc (set_format_style): store the actual current format in format_string
* pr-output.cc (F__compactformat__): new defun to set/get the current Vcompactformat state
* pr-output.cc (F__formatstring__): new defun to set/get the current format string
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Mon, 21 Apr 2014 17:17:15 +0200 |
parents | e42843ceff48 |
children | 333901476119 |
comparison
equal
deleted
inserted
replaced
18734:adb948d7fae4 | 18735:28eab2d84190 |
---|---|
43 #include "oct-map.h" | 43 #include "oct-map.h" |
44 #include "oct-mutex.h" | 44 #include "oct-mutex.h" |
45 #include "oct-refcount.h" | 45 #include "oct-refcount.h" |
46 #include "ov.h" | 46 #include "ov.h" |
47 #include "txt-eng-ft.h" | 47 #include "txt-eng-ft.h" |
48 #include "builtin-defun-decls.h" | |
48 | 49 |
49 // FIXME: maybe this should be a configure option? | 50 // FIXME: maybe this should be a configure option? |
50 // Matlab defaults to "Helvetica", but that causes problems for many | 51 // Matlab defaults to "Helvetica", but that causes problems for many |
51 // gnuplot users. | 52 // gnuplot users. |
52 #if !defined (OCTAVE_DEFAULT_FONTNAME) | 53 #if !defined (OCTAVE_DEFAULT_FONTNAME) |
3105 const Matrix& parent_pix_size = Matrix ()) const; | 3106 const Matrix& parent_pix_size = Matrix ()) const; |
3106 | 3107 |
3107 // See the genprops.awk script for an explanation of the | 3108 // See the genprops.awk script for an explanation of the |
3108 // properties declarations. | 3109 // properties declarations. |
3109 | 3110 |
3110 // FIXME: it seems strange to me that the diary, diaryfile, | 3111 // FIXME: Matlab defines some root properties and uses them in |
3111 // echo, errormessage, format, formatspacing, language, and | 3112 // the same way that Octave uses an internal static variable to |
3112 // recursionlimit properties are here. | 3113 // keep track of state. set (0, "echo", "on") is equivalent |
3113 // WTF do they have to do with graphics? | 3114 // to Octave's echo ("on"). Properties that still dont have callbacks |
3114 // Also note that these properties (and the monitorpositions, | 3115 // are : diary, diaryfileecho, errormessage, language, and recursionlimit. |
3116 // Note that these properties (and the monitorpositions, | |
3115 // pointerlocation, and pointerwindow properties) are not yet used | 3117 // pointerlocation, and pointerwindow properties) are not yet used |
3116 // by Octave, so setting them will have no effect, and changes | 3118 // by Octave, so setting them will have no effect, and changes |
3117 // made elswhere (say, the diary or format functions) will not | 3119 // made elswhere (say, the diary or format functions) will not |
3118 // cause these properties to be updated. | 3120 // cause these properties to be updated. |
3119 // ANSWER: Matlab defines these properties and uses them in | |
3120 // the same way that Octave uses an internal static variable to | |
3121 // keep track of state. set (0, "echo", "on") is equivalent | |
3122 // to Octave's echo ("on"). Maybe someday we can connect callbacks | |
3123 // that actually call Octave's own functions for this. | |
3124 | 3121 |
3125 // Programming note: Keep property list sorted if new ones are added. | 3122 // Programming note: Keep property list sorted if new ones are added. |
3126 | 3123 |
3127 BEGIN_PROPERTIES (root_figure, root) | 3124 BEGIN_PROPERTIES (root_figure, root) |
3128 handle_property callbackobject Sr , graphics_handle () | 3125 handle_property callbackobject Sr , graphics_handle () |
3131 bool_property diary , "off" | 3128 bool_property diary , "off" |
3132 string_property diaryfile , "diary" | 3129 string_property diaryfile , "diary" |
3133 bool_property echo , "off" | 3130 bool_property echo , "off" |
3134 string_property errormessage , "" | 3131 string_property errormessage , "" |
3135 string_property fixedwidthfontname , "Courier" | 3132 string_property fixedwidthfontname , "Courier" |
3136 radio_property format , "+|bank|bit|hex|long|longe|longeng|longg|native-bit|native-hex|none|rational|{short}|shorte|shorteng|shortg" | 3133 radio_property format gs , "+|bank|bit|hex|long|longe|longeng|longg|native-bit|native-hex|none|rat|{short}|shorte|shorteng|shortg" |
3137 radio_property formatspacing , "compact|{loose}" | 3134 radio_property formatspacing gs , "compact|{loose}" |
3138 string_property language , "ascii" | 3135 string_property language , "ascii" |
3139 array_property monitorpositions , Matrix (1, 4, 0) | 3136 array_property monitorpositions , Matrix (1, 4, 0) |
3140 array_property pointerlocation , Matrix (1, 2, 0) | 3137 array_property pointerlocation , Matrix (1, 2, 0) |
3141 double_property pointerwindow r , 0.0 | 3138 double_property pointerwindow r , 0.0 |
3142 double_property recursionlimit , 256.0 | 3139 double_property recursionlimit , 256.0 |
3147 radio_property units U , "inches|centimeters|normalized|points|{pixels}" | 3144 radio_property units U , "inches|centimeters|normalized|points|{pixels}" |
3148 END_PROPERTIES | 3145 END_PROPERTIES |
3149 | 3146 |
3150 private: | 3147 private: |
3151 std::list<graphics_handle> cbo_stack; | 3148 std::list<graphics_handle> cbo_stack; |
3149 | |
3150 std::string get_formatspacing (void) const | |
3151 { | |
3152 bool iscompact = F__compactformat__ ()(0).bool_value (); | |
3153 if (iscompact) | |
3154 return std::string ("compact"); | |
3155 else | |
3156 return std::string ("loose"); | |
3157 } | |
3158 | |
3159 void set_formatspacing (const octave_value& val) | |
3160 { | |
3161 if (! error_state) | |
3162 { | |
3163 // Input checking and abrev. matching | |
3164 formatspacing.set (val, false); | |
3165 | |
3166 if (! error_state) | |
3167 { | |
3168 std::string strval = formatspacing.current_value (); | |
3169 | |
3170 if (strval == "compact") | |
3171 F__compactformat__ (ovl (true)); | |
3172 else | |
3173 F__compactformat__ (ovl (false)); | |
3174 | |
3175 formatspacing.run_listeners (); | |
3176 } | |
3177 } | |
3178 } | |
3179 | |
3180 std::string get_format (void) const | |
3181 { | |
3182 return F__formatstring__ ()(0).string_value (); | |
3183 } | |
3184 | |
3185 void set_format (const octave_value& val) | |
3186 { | |
3187 if (! error_state) | |
3188 { | |
3189 // Input checking and abrev. matching | |
3190 format.set (val, false); | |
3191 | |
3192 if (! error_state) | |
3193 { | |
3194 Fformat (ovl (format.current_value ())); | |
3195 | |
3196 format.run_listeners (); | |
3197 } | |
3198 } | |
3199 } | |
3200 | |
3152 }; | 3201 }; |
3153 | 3202 |
3154 private: | 3203 private: |
3155 properties xproperties; | 3204 properties xproperties; |
3156 | 3205 |