diff --git a/@HorizontalLineGridDraw/HorizontalLineGridDraw.m b/@HorizontalLineGridDraw/HorizontalLineGridDraw.m new file mode 100644 index 0000000000000000000000000000000000000000..29a99bb23956e1b1d0ce06c10964141063e84542 --- /dev/null +++ b/@HorizontalLineGridDraw/HorizontalLineGridDraw.m @@ -0,0 +1,17 @@ +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 + diff --git a/@HorizontalLineGridDraw/draw_onto.m b/@HorizontalLineGridDraw/draw_onto.m new file mode 100644 index 0000000000000000000000000000000000000000..21c07374f4c01d7cf923eb28e4e84cd67b5c89ee --- /dev/null +++ b/@HorizontalLineGridDraw/draw_onto.m @@ -0,0 +1,40 @@ +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 + diff --git a/@HorizontalLineGridDraw/get_bounding_box.m b/@HorizontalLineGridDraw/get_bounding_box.m new file mode 100644 index 0000000000000000000000000000000000000000..d3f815ae7570bebc79a543ee3159b3a2d63aeb93 --- /dev/null +++ b/@HorizontalLineGridDraw/get_bounding_box.m @@ -0,0 +1,11 @@ +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 +