stlab.adobe.com Adobe Systems Incorporated

platform_edit_text.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /****************************************************************************************************/
00008 
00009 #ifndef ADOBE_WIDGET_EDIT_TEXT_HPP
00010 #define ADOBE_WIDGET_EDIT_TEXT_HPP
00011 
00012 /****************************************************************************************************/
00013 
00014 #include <boost/operators.hpp>
00015 
00016 #include <adobe/future/macintosh_events.hpp>
00017 
00018 #include <adobe/config.hpp>
00019 #include <adobe/extents.hpp>
00020 #include <adobe/layout_attributes.hpp>
00021 #include <adobe/widget_attributes.hpp>
00022 
00023 #include <adobe/future/widgets/headers/macintosh_focus_handler.hpp>
00024 #include <adobe/future/widgets/headers/platform_label.hpp>
00025 #include <adobe/future/widgets/headers/edit_text_common.hpp>
00026 
00027 /****************************************************************************************************/
00028 
00029 namespace adobe {
00030 
00031 /****************************************************************************************************/
00032 #ifndef ADOBE_NO_DOCUMENTATION
00033 struct edit_text_t;
00034 
00035 typedef std::string                                                edit_text_model_type;
00036 typedef boost::function<void (const edit_text_model_type&, bool&)> edit_text_pre_edit_proc_t;
00037 typedef boost::function<void (const edit_text_model_type&)>        edit_text_post_edit_proc_t;
00038 
00039 /****************************************************************************************************/
00040 
00041 struct edit_text_handler_t
00042 {
00043     explicit edit_text_handler_t(edit_text_t& widget) :
00044         widget_m(widget)
00045     {
00046         handler_m.insert(kEventClassCommand, kHICommandFromMenu);
00047         handler_m.insert(kEventClassTextInput, kEventTextInputUnicodeForKeyEvent);
00048 
00049         handler_m.monitor_proc_m = boost::bind(&edit_text_handler_t::handle_event,
00050                                                boost::ref(*this), _1, _2);
00051     }
00052 
00053     ::OSStatus handle_event(::EventHandlerCallRef next,
00054                             ::EventRef            event);
00055 
00056     event_handler_t handler_m;
00057     edit_text_t&    widget_m;
00058 };
00059 #endif
00060 /****************************************************************************************************/
00061 
00067 struct edit_text_t : boost::equality_comparable<edit_text_t>
00068 {
00070     typedef edit_text_model_type       model_type;
00071 
00073     typedef edit_text_post_edit_proc_t setter_type;
00074 
00076     explicit edit_text_t(const edit_text_ctor_block_t& block);
00077 
00084     void measure(extents_t& result);
00085 
00086     void place(const place_data_t& place_data);
00088 
00095     void display(const model_type& text);
00097 
00104     void monitor(const setter_type& proc);
00105 
00106     void enable(bool make_active);
00108 
00109 #ifndef ADOBE_NO_DOCUMENTATION
00110     void        set_selection(long start_char, long end_char);
00111     void        signal_pre_edit(const edit_text_pre_edit_proc_t& proc);
00112 
00113     label_t&       get_label()       { assert(name_m.get()); return *name_m; }
00114     const label_t& get_label() const { assert(name_m.get()); return *name_m; }
00115 
00116     ::ControlRef                 control_m;
00117     ::HIViewRef                  scroll_control_m;
00118     boost::scoped_ptr<label_t>   name_m;
00119     std::string                  alt_text_m;
00120     theme_t                      theme_m;
00121     mutable metric_extractor_t   metrics_m;
00122     bool                         type_2_debounce_m;
00123     model_type                   type_1_debounce_m;
00124     bool                         using_label_m;
00125     bool                         scrollable_m;
00126     bool                         password_m;
00127     long                         rows_m;
00128     long                         cols_m;
00129     long                         max_cols_m;
00130     long                         static_width_m;
00131     long                         static_height_m;
00132     long                         static_baseline_m;
00133     long                         edit_height_m;
00134     long                         edit_baseline_m;
00135     mouse_in_out_event_handler_t mouse_handler_m;
00136     edit_text_handler_t          edit_text_handler_m;
00137     edit_text_pre_edit_proc_t    pre_edit_proc_m;
00138     edit_text_post_edit_proc_t   post_edit_proc_m;
00139     focus_handler_t              focus_handler_m;
00140 #endif
00141 };
00142 
00143 /****************************************************************************************************/
00144 #ifndef ADOBE_NO_DOCUMENTATION
00145 inline ::HIViewRef get_display(const edit_text_t& widget)
00146     { return widget.scrollable_m ? widget.scroll_control_m : widget.control_m; }
00147 #endif
00148 /****************************************************************************************************/
00149 
00150 } // namespace adobe
00151 
00152 /****************************************************************************************************/
00153 
00154 //ADOBE_WIDGET_EDIT_TEXT_HPP
00155 #endif
00156 
00157 /****************************************************************************************************/
00158 

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google