123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899(*
* lTerm_widget_base_impl.ml
* ---------------------
* Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org>
* Licence : BSD3
*
* This file is a part of Lambda-Term.
*)openLTerm_widget_callbacksopenLTerm_geomclasstinitial_resource_class:objectmethodchildren:tlistmethodparent:toptionmethodset_parent:toption->unitmethodcan_focus:boolmethodfocus:toptionLTerm_geom.directionsmethodset_focus:toptionLTerm_geom.directions->unitmethodqueue_draw:unitmethodset_queue_draw:(unit->unit)->unitmethoddraw:LTerm_draw.context->t->unitmethodcursor_position:coordoptionmethodallocation:rectmethodset_allocation:rect->unitmethodsend_event:LTerm_event.t->unitmethodon_event:?switch:switch->(LTerm_event.t->bool)->unitmethodsize_request:sizemethodresources:LTerm_resources.tmethodset_resources:LTerm_resources.t->unitmethodresource_class:stringmethodset_resource_class:string->unitmethodupdate_resources:unitend=object(self)methodchildren:tlist=[]methodcan_focus=falsevalmutablefocus=LTerm_geom.({left=None;right=None;up=None;down=None})methodfocus=focusmethodset_focusf=letcheck=functionNone->()|Some(x)->ifnot((x:t)#can_focus)thenfailwith"set_focus: target widget must have can_focus=true"incheckf.left;checkf.right;checkf.up;checkf.down;focus<-fvalmutableparent:toption=Nonemethodparent=parentmethodset_parentopt=parent<-optvalmutablequeue_draw=ignoremethodqueue_draw=queue_draw()methodset_queue_drawf=queue_draw<-f;List.iter(funw->w#set_queue_drawf)self#childrenmethoddraw(_:LTerm_draw.context)(_focused:t)=()methodcursor_position=Nonevalmutableallocation={row1=0;col1=0;row2=0;col2=0}methodallocation=allocationmethodset_allocationrect=allocation<-rectvalevent_filters=LTerm_widget_callbacks.create()methodsend_eventev=ifnot(exec_filtersevent_filtersev)thenmatchparentwith|Somewidget->widget#send_eventev|None->()methodon_event?switchf=registerswitchevent_filtersfvalsize_request={rows=0;cols=0}methodsize_request=size_requestvalmutableresource_class=initial_resource_classmethodresource_class=resource_classmethodset_resource_classrc=resource_class<-rc;self#update_resourcesvalmutableresources=LTerm_resources.emptymethodresources=resourcesmethodset_resourcesres=resources<-res;self#update_resources;List.iter(funw->w#set_resourcesres)self#childrenmethodupdate_resources=()end