www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@toGVColumnHeader/toGVColumnHeader.m

    function obj = toGVColumnHeader(varargin)
%TOGVCOLUMNHEADER Constructor for toGVRowHeader
%
%  OUT = TOGVCOLUMNHEADER(PROP, VAL) creates a new instance of a
%  toGVColumnHeader.  This object is designed to be used as the column
%  header in the tradeoff grid of graphs.

%  Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.


if nargin && isa(varargin{1}, 'cgtradeoffgui.toGVColumnHeader')
   obj = varargin{1};
   varargin(1) = [];
else
   obj = cgtradeoffgui.toGVColumnHeader;
end

% Call the inherited constructor
abstractlayoutcomponent(obj, varargin{:});

obj.hBorder = mbcgui.container.layoutpanel(...
    'Parent', obj.Parent,...
    'Visible', obj.Visible, ...
    'Position', obj.Position, ...
    'BorderType','beveledout');

obj.hAxis = xregGui.axisslider('parent', obj.hBorder, ...
    'orientation', 'horizontal');

obj.hValueEditor = mbcgui.widget.Spinner('Parent', obj.hBorder, ...
    'Callback', {@i_editvalue, obj});

obj.hLabel = xregGui.labelcontrol('parent', obj.hBorder, ...
    'LabelAlignment', 'Right', ...
    'BaselineOffsetMode', 'manual', ...
    'BaselineOffsetZero', 'middle', ...
    'BaselineOffset', -4, ...
    'Gap', 7, ...
    'ControlSize', 84, ...
    'Control', obj.hValueEditor); 

obj.hLabelGrid = xreggridbaglayout(obj.hBorder, ...
    'dimension', [1 3], ...
    'colsizes', [-1 80 -1], ...
    'mergeblock', {[1 1] [1 3]}, ...
    'elements', {[], obj.hLabel});
    
if obj.DisplayYAxisTickMarks
    LeftBorder = 30;
else
    LeftBorder = 10;
end
grid = xreggridbaglayout(obj.hBorder, ...
    'dimension', [3 3], ...
    'rowsizes', [1 -1 18], ...
    'colsizes', [LeftBorder -1 10], ....
    'border', [4 6 4 7], ...
    'mergeblock', {[3 3], [1 3]}, ...
    'elements', {[], [], obj.hLabelGrid, obj.hAxis});
obj.pSetupWideMode;

set(obj.hBorder, 'LayoutComponent', {grid});
obj.Display = obj.hBorder;

obj.addPropertyListeners( ...
    {'DisplayYAxisTickMarks', ...
    'WideHeaderMode'}, ...
    {{@i_switchdisplayyaxis, grid}, ...
    @i_switchwidemode});



function i_switchdisplayyaxis(~, evt, grid)
if evt.NewValue
    set(grid, 'colsizes', [30 -1 10]);
else
    set(grid, 'colsizes', [10 -1 10]);
end

function i_switchwidemode(~, evt)
% Don't need to worry about getting strings right - the setTableData does
% this anyway
obj = evt.AffectedObject;
obj.pSetupWideMode;

function i_editvalue(src, ~, obj)
if ~isempty(obj.GraphView)
    obj.GraphView.pSetValue(obj.CurrentColumn, src.Value); 
end