Hi,
For anyone who's interested here is my work in progress for implementing
platform widgets in a buffer. As a side effect I have had to implement
subwindows. Any comments, feedback, criticisms welcome.
Also, I have only implemented the device level stuff for mswindows because
I don't understand / use X so much. If anyone is interested in implementing
the X side I would be really interested to know. I've done a partial
implementation but it needs actual widgets (motif or whatever) which I
don't have access to. It shouldn't be that difficult since most of it is
generalised / platform independent.
ChangeLog follows (this is against 21.2).
andy
1998-11-09 Andy Piper <andy(a)xemacs.org>
* window.h (struct window): add a cache of subwindows on a
per-window basis.
* window.c (mark_window): mark the subwindow_instance_cache.
(allocate_window): initialise the subwindow instance_cache.
* toolbar-x.c (x_output_toolbar): call redisplay_clear_region
instead of the devmeth.
(x_clear_toolbar): ditto.
* redisplay-x.c (x_output_display_block): call
redisplay_output_subwindow for subwindows and widgets.
* redisplay-tty.c (tty_output_display_block): add IMAGE_WIDGET to
types to do nothing for.
* lisp.h: declare new widget/subwindow symbols.
* glyphs.c (image_instantiate): cache subwindows on a per-window
basis.
(subwindow_possible_dest_types): new function for subwindow dest
types.
(subwindow_instantiate): generic instantiation of a
subwindow. specialised by device multi-methods.
(Fsubwindowp): moved from glyphs-x.c. adapted for glyph-based
subwindows.
(Fimage_instance_subwindow_id): ditto.
(Fresize_subwindow): ditto.
(Fforce_subwindow_map): ditto.
* glyphs-x.c (x_print_image_instance): remove subwindow
stuff. Handled genrically in glyphs.c.
(x_image_instance_equal): ditto.
(x_image_instance_hash): ditto.
(x_finalize_image_instance): delete subwindows when required.
(mark_subwindow) (print_subwindow) (finalize_subwindow)
(subwindow_hash) (Fmake_subwindow): deleted because of new,
glyph-based, subwindow implementation.
(Fsubwindow_height) (Fsubwindow_width) (Fsubwindow_xid): aliased
in glyphs.el
(Fsubwindowp) (Fresize_subwindow) (Fforce_subwindow_map): moved to
glyphs.c.
(x_unmap_subwindow): new function to unmap X subwindows.
(x_map_subwindow): new function to map X subwindows.
(x_subwindow_instantiate): new function to instantiate X
subwindows.
(x_resize_subwindow): new function to resize X subwindows.
(console_type_create_glyphs_x): add subwindow functions.
(image_instantiator_format_create_glyphs_x): add device
multi-methods for xpm, xbm and subwindow.
* glyphs.el (subwindow-xid): old alias for new subwindow functions.
(subwindow-width): ditto.
(subwindow-height): ditto.
* glyphs-msw.c (mswindows_widget_instantiate): new function for
generally instantiating ms subwindows. Used by
mswindows_*_instantiate.
(mswindows_edit_instantiate): instantiate an edit field on a
mswindows frame.
1998-11-04 Andy Piper <andy(a)xemacs.org>
* symsinit.h: declare new functions.
* redisplay.h: declare new functions.
* redisplay-x.c (x_output_display_block): call
redisplay_clear_region rather than x_clear_region.
(x_output_string): ditto.
(x_output_pixmap): ditto.
(x_clear_to_window_end): ditto.
(x_output_eol_cursor): ditto.
(x_clear_region): only do X specific things. other duties handled
in redisplay_clear_region.
* redisplay-tty.c (tty_clear_region): do tty specific things - some
duties moved to redisplay_clear_region.
* redisplay-output.c (clear_left_border): use
redisplay_clear_region instead of device method.
(clear_right_border): ditto.
(output_display_line): ditto.
(redisplay_output_subwindow): ditto.
(redisplay_clear_top_of_window): ditto.
(redisplay_clear_region): perform duties previously handled by
device methods. call the appropriate device method at the
end. unmap subwindows if necessary.
* redisplay-msw.c (mswindows_output_string): use
redisplay_clear_region instead of mswindows_clear_region.
(mswindows_clear_to_window_end): ditto.
(mswindows_output_display_block): output subwindows when required.
(mswindows_clear_region): only do mswindows specific things,
everything else is now handled in redisplay_clear_region.
* gui.h: add item id hash defines and declare function prototypes.
* gui.c (mark_gui_item): new function for marking gui_items.
(gui_item_hash): generic hash function for generating command ids
for gui_items.
* gui-msw.c: new file.
(mswindows_handle_gui_wm_command): new function to handle widget
callbacks.
* glyphs.h (MAYBE_IIFORMAT_DEVMETH): new function for device
multi-methods.
(IIFORMAT_HAS_SHARED_METHOD): ditto.
(DEFINE_DEVICE_IIFORMAT): ditto.
(INITIALIZE_DEVICE_IIFORMAT): ditto.
(struct Lisp_Image_Instance): add widget and subwindow data plus
appropriate access functions.
* glyphs.c (decode_device_ii_format): new function for decoding
image instantiator functions based on a device type as well as an
image format.
(decode_image_instantiator_format): just call
decode_device_ii_format with nil device.
(add_entry_to_device_ii_format_list): new function for per device
method instances.
(add_entry_to_image_instantiator_format_list): just call
add_entry_to_device_ii_format_list with nil device.
(check_valid_vector): new function.
(instantiate_image_instantiator): instantiate using per-format
method and then per-format-per-device method (device
multi-methods). signal an error if neither is possible.
(mark_image_instance): cope with subwindows and widgets.
(print_image_instance): ditto.
(image_instance_equal): ditto.
(image_instance_hash): ditto.
(allocate_glyph): ditto.
(glyph_width): ditto.
(glyph_height_internal): ditto.
(xpm_instantiate): removed because of device multi-methods.
(mark_subwindow_cachels): new cachel functions for caching
instantiated subwindows on a per-frame basis. mostly copied from
glyph cachel functions.
(update_subwindow_cachel_data): ditto.
(add_subwindow_cachel): ditto.
(get_subwindow_cachel_index): ditto.
(reset_subwindow_cachels): ditto.
(mark_subwindow_cachels_as_not_updated): ditto.
(unmap_subwindow): generic unmapping of subwindows based on cachel
data.
(map_subwindow): ditto.
(initialize_subwindow_image_instance): generic initialisation of
subwindow data.
(syms_of_glyphs): add widget keywords.
* glyphs-x.h (struct x_subwindow_data): convert Lisp_Subwindow to
x_subwindow_data.
1998-11-04 Andy Piper <andy(a)xemacs.org>
* glyphs-widget.c: new file for instantiating widget type glyphs.
(widget_possible_dest_types): new general dest type function for
widgets.
(widget_validate): ditto.
(initialize_widget_image_instance): ditto
(widget_instantiate): ditto. Sets up fg/bg, gui_item parsing
before handing on control to device multi-methods.
(syms_of_glyphs_widget): new function.
(image_instantiator_format_create_glyphs_widget): new function,
added placeholders for button, edit, combo, scrollbar
(vars_of_glyphs_widget): new function.
* glyphs-msw.h (WIDGET_INSTANCE_MSWINDOWS_HANDLE): new define for
storing window ids of widgets.
* glyphs-msw.c (mswindows_finalize_image_instance): cope with
deletion of widget and subwindow glyphs.
(mswindows_unmap_subwindow): new device function for unmapping
subwindows on a msw frame.
(mswindows_map_subwindow): ditto.
(mswindows_register_image_instance): register instantiated widgets
with the widget hastable.
(mswindows_button_instantiate): instantiate a button type widget
on an msw frame.
(mswindows_subwindow_instantiate): instanttiate a subwindow on a
mswindows frame.
(image_instantiator_format_create_glyphs_mswindows): add device
multi-methods for xbm, xpm, subwindow, edit and button.
* frame.h (struct frame): add subwindow_cachels dynarr for caching
information about subwindows visible on the current frame. used by
redisplay_clear_region to unmap subwindows as required.
* frame.c (mark_frame): mark subwindow_cachels.
(allocate_frame_core): instantiate subwindow_cachels.
* frame-msw.c (mswindows_init_frame_1): instntiate and mark the
widget hashtable.
* event-msw.c (mswindows_wnd_proc): add call to
mswindows_handle_gui_wm_command to handle widget callbacks.
* emacs.c (main_1): add calls to glyphs-widget initialisation
routines.
* console.h (struct console_methods): add
unmap/map_subwindow_method for use be redisplay_clear_region to
map and unmap subwindows. Remove xpm and xbm stuff - now dealt
with by image instantiator multi-methods. Add
resize_subwindow_method.
* console-stream.c (stream_clear_region): change signature to
match new generic clear region function.
* configure.in: add gui-msw.o to msw objects.
* Makefile.in.in: add glyphs-widget.o to list of objects.
* console-msw.h (struct mswindows_frame): add widget hashtable for
wiring command ids to callbacks.
---------------------------------------------------------------------------
" .sigs are like your face - rarely seen by you and uglier than you think"
Dr Andy Piper, Technical Architect, Parallax Solutions Ltd
mail: andyp(a)parallax.co.uk web:
www.parallax.co.uk/~andyp