Ok, what I have so far, having access to a panel handle, I create a list of 'frame' style uicontrol objects. This list is added to the 'handles' argument.
pnl = handles.trackerPanel;
pnlPose = get(pnl, 'Position');
pnlX = pnlPose(1);
pnlY = pnlPose(2);
pnlW = pnlPose(3);
pnlH = pnlPose(4);
panelSidePad = 0.01*pnlW;
% Continuous box space
boxcontW = (pnlW - 2*panelSidePad)/N;
% Visible box: total box space - padding
boxW = boxcontW*0.9;
% Same thing on height
panelTopPad = pnlH*0.01;
boxH = pnlH - 2*panelTopPad;
% Indeces along the X-dimension
boxXIdc = pnlX+panelSidePad:boxcontW:pnlX+panelSidePad + boxcontW*(N-1);
boxYIdc = pnlY + panelSidePad;
trackerObjects = [];
for ii = 1:length(boxXIdc)
objpos = [boxXIdc(ii), boxYIdc, boxW, boxH];
tObj = uicontrol('Parent', pnl,'Style','frame',...
'String','', 'Tag', sprintf('t_%d', ii), ...
'BackgroundColor', 'red',...
'Units','normalized','Position',objpos);
% Register callback function. Use the same function to catch all click
% events.
set(tObj, 'Callback', @tracker_Callback);
trackerObjects = [trackerObjects; tObj];
% For a dramatic loading effect.
drawnow();
end
if(length(boxXIdc) ~= N)
warning('Not all trackers were displayed');
end
handles.trackerObjects = trackerObjects;
But the problem is that frames/text etc. objects do not respond to click events. I have to add buttons for that. Buttons on the other side have thick edges and when there are too many objects, the color disappears. So, does anyone know if 1) add working callbacks to frames/text or 2) make buttons appear without the "popping" edges and make them look flat and boxy. I don't see any such properties in the property inspector for any of the button objects.
EDIT: To obtain clicks on the frame, instead of using 'Callback', use 'ButtonDownFcn' as the click-callback function property, as in the following:
set(tObj, 'ButtonDownFcn', @tracker_Callback);
The callback now will be invoked on mouse clicks.

