www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@itemList/pSetColumnWidths.m
function pSetColumnWidths(obj) %PSETCOLUMNWIDTHS Set correct widths for columns % % PSETCOLUMNWIDTHS(OBJ) sets the columns of the list to be the correct % width. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. % Work out available width for headers W = obj.Position(3); H = obj.Position(4); if strcmpi( obj.BorderStyle, 'single' ) W = W - 2; H = H - 2; end % Check for a scrollbar being present nItems = length(obj.Items); if obj.DisplayHeaderRow nItems = nItems+1; end if (nItems*17) > H SCROLLBAR_WIDTH = javax.swing.UIManager.get('ScrollBar.width'); % Make room for the vertical scrollbar W = W - SCROLLBAR_WIDTH; end if obj.DisplayTypeColumn col1width = floor(W*obj.ItemColumnWidth); obj.Display.Peer.setColumnWidths( [max(0, col1width), max(0, W-col1width)] ); else obj.Display.Peer.setColumnWidths( max(0, W) ); end