function dlgstruct = udtGetLeafWidgetBaseID(type, messageID, tag, sync, prop)
%udtGetLeafWidgetBaseID Dynamic Dialog block helper function.
%
%   udtGetLeafWidgetBaseID(type,messageID,tag,prop)
%   Returns a MATLAB structure for use with Dynamic Dialogs
%   The structure has several common fields filled out:
%
%    type : Type
%    name : Message catalog lookup of argument messageID
%    tag  : Tag
%    sync : whether or not to set MatlabMethod/MatlabArgs for syncing
%           input the controller source to set
%           input 0 to ignore
%    prop : ObjectProperty (optional)
%
%   Also, the struct has Mode set to 1, and Tunability set to 0
%

% Copyright 2012 The MathWorks, Inc.

narginchk(4,5);

dlgstruct.Type = type;
dlgstruct.Tag = tag;
dlgstruct.Tunable = 0;

% Don't even create a Name field if the string is blank
if ~isempty(messageID)
    dlgstruct.Name = DAStudio.message(messageID);
end

% The mode should be true for all objects except those of type text.
if strcmp(type, 'text')
    dlgstruct.Mode  = false;
else
    dlgstruct.Mode  = true;
end

% The objectProperty (optional)
if nargin >= 5
    dlgstruct.ObjectProperty = prop;
end

% Fill in fields necessary to synchronize the widgets.
if sync ~= 0
    dlgstruct.MatlabMethod = 'udtDDGSync';
    dlgstruct.MatlabArgs = {sync, '%dialog', '%tag'};
end

