Loading @HorizontalLineGridDraw/HorizontalLineGridDraw.m 0 → 100644 +17 −0 Original line number Diff line number Diff line classdef HorizontalLineGridDraw < handle %TABLEGRIDDRAW Draw a TableGrid into a uipanel % Draws a 2D Grid inside a uipanel (Yay!) properties my_grid = [] controls = {} end methods function object = HorizontalLineGridDraw(my_grid) object.my_grid = my_grid; end end end @HorizontalLineGridDraw/draw_onto.m 0 → 100644 +40 −0 Original line number Diff line number Diff line function [height, grid_controls] = draw_onto( object, parent_handle, grid, grid_controls, depth, start_height, x, y ) %DRAW_ONTO Draws the controls onto the parent_handle. This function needs to be called everytime an update happens. % This function draws the entire handle onto the handle. This function % needs to be called everytime the back table is updated. The class will % notify when its necessary. if nargin == 2 %Need to invert y, so need total size [x, y] = object.get_bounding_box(); draw_onto(object, parent_handle, object.my_grid.grid, object.controls, 0, 0, x, y); return ; end % First delete an extra controls assert( ~(size(grid_controls, 2) > size(grid, 2)), 'Implment delete when necessary.'); height = 0; for i = 1:size(grid, 2) if size(grid_controls, 2) >= i assert( false, 'Deal with existing controls' ); else grid_controls{i} = struct(); grid_controls{i}.subgrid = {}; %[new_height, grid_controls{i}.subgrid] = draw_onto( object, parent_handle, grid{i}.grid, grid_controls{i}.subgrid, depth+1, height, x, y); new_height = 1; %max([new_height 1]); height = height + new_height; %Standardize this uicontrol(parent_handle, 'Style', 'edit', 'Position', [(height-1)*125, 0, 120, 80], 'String', ['' num2str(depth) ', ' num2str(i) ]); end end end @HorizontalLineGridDraw/get_bounding_box.m 0 → 100644 +11 −0 Original line number Diff line number Diff line function [x, y] = get_bounding_box( object ) %GET_BOUNDING_BOX Gets the size in pixels of the grid. %Returns the size of the grid (as a box) for layout purposes. x = size(object.my_grid.grid, 2); %Store maximum width x = 120*x + 5*(x-1); %Then calculate the pixels. y = 1; %We have one row. y = 80*y + 5*(y-1); %Same here. end Loading
@HorizontalLineGridDraw/HorizontalLineGridDraw.m 0 → 100644 +17 −0 Original line number Diff line number Diff line classdef HorizontalLineGridDraw < handle %TABLEGRIDDRAW Draw a TableGrid into a uipanel % Draws a 2D Grid inside a uipanel (Yay!) properties my_grid = [] controls = {} end methods function object = HorizontalLineGridDraw(my_grid) object.my_grid = my_grid; end end end
@HorizontalLineGridDraw/draw_onto.m 0 → 100644 +40 −0 Original line number Diff line number Diff line function [height, grid_controls] = draw_onto( object, parent_handle, grid, grid_controls, depth, start_height, x, y ) %DRAW_ONTO Draws the controls onto the parent_handle. This function needs to be called everytime an update happens. % This function draws the entire handle onto the handle. This function % needs to be called everytime the back table is updated. The class will % notify when its necessary. if nargin == 2 %Need to invert y, so need total size [x, y] = object.get_bounding_box(); draw_onto(object, parent_handle, object.my_grid.grid, object.controls, 0, 0, x, y); return ; end % First delete an extra controls assert( ~(size(grid_controls, 2) > size(grid, 2)), 'Implment delete when necessary.'); height = 0; for i = 1:size(grid, 2) if size(grid_controls, 2) >= i assert( false, 'Deal with existing controls' ); else grid_controls{i} = struct(); grid_controls{i}.subgrid = {}; %[new_height, grid_controls{i}.subgrid] = draw_onto( object, parent_handle, grid{i}.grid, grid_controls{i}.subgrid, depth+1, height, x, y); new_height = 1; %max([new_height 1]); height = height + new_height; %Standardize this uicontrol(parent_handle, 'Style', 'edit', 'Position', [(height-1)*125, 0, 120, 80], 'String', ['' num2str(depth) ', ' num2str(i) ]); end end end
@HorizontalLineGridDraw/get_bounding_box.m 0 → 100644 +11 −0 Original line number Diff line number Diff line function [x, y] = get_bounding_box( object ) %GET_BOUNDING_BOX Gets the size in pixels of the grid. %Returns the size of the grid (as a box) for layout purposes. x = size(object.my_grid.grid, 2); %Store maximum width x = 120*x + 5*(x-1); %Then calculate the pixels. y = 1; %We have one row. y = 80*y + 5*(y-1); %Same here. end