function setcolours(bg,fg,root)
% setuicolours - set default foreground and background colours for UI elements
%
% setuicolours :: colour ~'background', colour ~'foreground' -> action.
% setuicolours :: colour ~'background', colour ~'foreground', handle ~'root' -> action.
%
% colour ::= [[1,3]] | {'k','r','g','b','c','m','y','w'}.
%
% The 3-argument form takes the handle of the object to which properties will be attached.

if nargin<3, root=0; end

classes1={'Control','Panel'};
classes2={'Container','FlowContainer','GridContainer'};

set(root,'DefaultFigureColor',bg);
foreach(@(c)set(root,dc(c,'Foreground'),fg,dc(c,'Background'),bg),classes1);
foreach(@(c)set(root,dc(c,'Background'),bg),classes2);
set(root,dc('Menu','Foreground'),fg);
set(root,dc('Panel','Shadow'),0.7*bg,dc('Panel','Highlight'),min(1.3*bg,1));

function p=dc(c,fb), p=['DefaultUI' c fb 'Color']; 
