J6/Splitter/Class

From J Wiki
Jump to navigation Jump to search

Splitter/Navigator

The code that paints the splitter is in class jsplitter..

Load the splitter by loading the class, for example:

load 'jsplitter'

A splitter is drawn in an isigraph control on a J form. The verb that creates the form should also create an instance of the splitter class, and set values in the instance to define the splitter. Nouns ID, LC and RC are required:

  • noun ID is the splitter control id, where an 'h' suffix indicates a horizontal splitter
  • nouns LC and RC are lists of left/top controls and right/bottom controls respectively.

The verb show shows the splitter, or refreshes the splitter if it is already displayed. The argument specifies splitter options, either as:

  • a character string of names that can be read from the form locale.
  • a 2 column boxed matrix of names and corresponding values.

Options are listed in Options. Option names are always uppercase in splitter, and are converted if necessary.

The following example is the splitter demo in the system:

NB. splitter demo

require 'jsplitter'
coclass 'jsplitdemo'

DEMO=: 0 : 0
pc demo;pn "Splitter Demo";
xywh 6 6 50 61;cc ok button bottommove;cn "OK";
xywh 7 73 48 10;cc real checkbox topmove bottommove;cn "Real Time";
xywh 7 87 50 50;cc style combodrop topmove bottommove;
xywh 57 6 3 94;cc splitv isigraph bottommove;
xywh 61 6 86 28;cc b1 button rightmove;
xywh 150 6 31 28;cc b2 button leftmove rightmove;
xywh 61 35 121 3;cc splith isigraph rightmove;
xywh 61 39 120 62;cc cancel button rightmove bottommove;cn "Cancel";
pas 4 4;pcenter;
rem form end;
)

demo_run=: 3 : 0
wd DEMO
wd 'set style hidden default line'
wd 'setselect style 1'
wd 'set real 1'
wd 'setfocus ok'

spv=: '' conew 'jsplitter'
show__spv 'id';'splitv';'lc';'ok real style';'rc';'splith b1 cancel'

sph=: '' conew 'jsplitter'
show__sph 'id';'splith';'lc';'b1 b2';'rc';'cancel'

wd 'pshow;'
)

demo_real_button=: 3 : 0
demo_setreal 0 ". real
)

demo_style_select=: 3 : 0
demo_setstyle 0 ". style_select
)

demo_setreal=: 3 : 0
REAL__spv=: REAL__sph=: y
wd 'set real ',":y
)

demo_setstyle=: 3 : 0
wd 'setselect style ',":y
show__spv ,: 'style';y
show__sph ,: 'style';y
)

demo_close=: 3 : 0
destroy__spv''
destroy__sph''
wd'pclose'
)

NB. uncomment lines to see move events
splitv_splithandler=: 3 : 0
select. y
case. 'move' do.
NB.   smoutput 'vertical move'
case. 'moved' do.
NB.   smoutput 'vertical moved'
end.
)

demo_run''