<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TitleHandle &#8211; Undocumented Matlab</title>
	<atom:link href="https://undocumentedmatlab.com/articles/tag/titlehandle/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Wed, 24 Nov 2010 18:00:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>Panel-level uicontrols</title>
		<link>https://undocumentedmatlab.com/articles/panel-level-uicontrols?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=panel-level-uicontrols</link>
					<comments>https://undocumentedmatlab.com/articles/panel-level-uicontrols#comments</comments>
		
		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 24 Nov 2010 18:00:53 +0000</pubDate>
				<category><![CDATA[GUI]]></category>
		<category><![CDATA[Handle graphics]]></category>
		<category><![CDATA[Hidden property]]></category>
		<category><![CDATA[Low risk of breaking in future versions]]></category>
		<category><![CDATA[Stock Matlab function]]></category>
		<category><![CDATA[UI controls]]></category>
		<category><![CDATA[Pure Matlab]]></category>
		<category><![CDATA[TitleHandle]]></category>
		<category><![CDATA[uicontrol]]></category>
		<category><![CDATA[Undocumented property]]></category>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=1976</guid>

					<description><![CDATA[<p>Matlab's uipanel contains a hidden handle to the title label, which can be modified into a checkbox or radio-button control</p>
<p>The post <a rel="nofollow" href="https://undocumentedmatlab.com/articles/panel-level-uicontrols">Panel-level uicontrols</a> appeared first on <a rel="nofollow" href="https://undocumentedmatlab.com">Undocumented Matlab</a>.</p>
<div class='yarpp-related-rss'>
<h3>Related posts:</h3><ol>
<li><a href="https://undocumentedmatlab.com/articles/rich-contents-log-panel" rel="bookmark" title="Rich-contents log panel">Rich-contents log panel </a> <small>Matlab listboxes and editboxes can be used to display rich-contents HTML-formatted strings, which is ideal for log panels. ...</small></li>
<li><a href="https://undocumentedmatlab.com/articles/gui-integrated-html-panel" rel="bookmark" title="GUI integrated HTML panel">GUI integrated HTML panel </a> <small>Simple HTML can be presented in a Java component integrated in Matlab GUI, without requiring the heavy browser control....</small></li>
<li><a href="https://undocumentedmatlab.com/articles/images-in-matlab-uicontrols-and-labels" rel="bookmark" title="Images in Matlab uicontrols &amp; labels">Images in Matlab uicontrols &amp; labels </a> <small>Images can be added to Matlab controls and labels in a variety of manners, documented and undocumented. ...</small></li>
<li><a href="https://undocumentedmatlab.com/articles/icon-images-in-matlab-uicontrols" rel="bookmark" title="Icon images &amp; text in Matlab uicontrols">Icon images &amp; text in Matlab uicontrols </a> <small>HTML can be used to add image icons to Matlab listbox and popup (drop-down) controls. ...</small></li>
</ol>
</div>
]]></description>
										<content:encoded><![CDATA[<p>In one of my larger Matlab applications &#8211; <em>Integration-lab Debriefing System</em> (IDS, which shall be described in a future dedicated article) &#8211; I wanted to present a panel-level checkbox that applies to the entire panel contents. In my particular case, the IDS <i><b>uipanel</b></i> contained a Java table (another future topic) with multiple selectable rows, and I needed a global checkbox that selects all (or none) of them at once:<br />
<center><figure style="width: 128px" class="wp-caption aligncenter"><img decoding="async" alt='Panel-level ("Objects") checkbox' src="https://undocumentedmatlab.com/images/IDS_Main_Tabs.png" title='Panel-level ("Objects") checkbox' width="128" height="107" /><figcaption class="wp-caption-text">Panel-level ("Objects") checkbox</figcaption></figure></center><br />
One way to do this is to calculate the checkbox&#8217;s desired position relative to the <i><b>uipanel</b></i> and place a regular checkbox-style <i><b>uicontrol</b></i> there. The checkbox can even be made a child of the <i><b>uipanel</b></i> with &#8216;normalized&#8217; units, thereby moving and resizing it together with its <i><b>uipanel</b></i> parent when the later is moved or resized.<br />
But there&#8217;s a much simpler method that want to share. It relies on the undocumented fact that the <i><b>uipanel</b></i>&#8216;s title label is a simple hidden <i><b>uicontrol</b></i> child of the <i><b>uipanel</b></i> handle. This <i><b>uicontrol</b></i> handle can be found and simply transformed from a &#8216;style&#8217;=&#8217;text&#8217; control into a &#8216;style&#8217;=&#8217;checkbox&#8217; control, as follows:</p>
<pre lang="matlab">
% Prepare the panel
hPanel = uipanel('position',[0.2,0.2,0.4,0.4], 'title','Objects');
% Get the title label's handle
warning off MATLAB:Uipanel:HiddenImplementation  % turn off warning
hTitle = setdiff(findall(hPanel),hPanel);  % retrieve title handle
hTitle = get(hPanel,'TitleHandle');  % alternative, uses hidden prop
% Modify the uicontrol style; add 20 pixel space for the checkbox
newPos = get(hTitle,'position') + [0,0,20,0];  % in pixels
set(hTitle, 'style','checkbox', 'value',1, 'pos',newPos);
</pre>
<p><center><figure style="width: 120px" class="wp-caption aligncenter"><img decoding="async" alt="Panel-level checkbox" src="https://undocumentedmatlab.com/images/IDS_Main_Checkbox.png" title="Panel-level checkbox" width="120" height="70" /><figcaption class="wp-caption-text">Panel-level checkbox</figcaption></figure></center><br />
Note that we can retrieve the title handle using either the <i><b>uipanel</b></i>&#8216;s hidden property <b>TitleHandle</b>, or by scanning the panel&#8217;s children using <i><b>findall</b></i>. I prefer the <b>TitleHandle</b> approach because it does not require modification (minor as it might be) when the panel already contains other children.<br />
The down-side is that since <b>TitleHandle</b> is an undocumented hidden property, it may change its name, its behavior or even be removed in some future Matlab release. In fact, there&#8217;s even a Matlab warning about this, unless you turn it off using:</p>
<pre lang="matlab">warning off MATLAB:Uipanel:HiddenImplementation</pre>
<p>We can use this approach for more complex options panels, as the following example illustrates. Here, we set radio-button controls rather than a checkbox control, and also modify the title color to blue:</p>
<pre lang="matlab">
% Main panel and basic alternative control
hPanelMain = uipanel('pos',[.1,.1,.8,.8], 'Title','Main', 'units','norm');
hAlt1 = uicontrol('parent',hPanelMain, 'units','norm', 'pos',[.1,.8,.5,.1], 'style','radio', 'string','Alternative #1');
% Alternative options panel #2
hAlt2 = uipanel('parent',hPanelMain, 'units','norm', 'pos',[.07,.4,.5,.35], 'title','Alternative #2');
hAlt2Title = get(hAlt2, 'TitleHandle');
newPos = get(hAlt2Title,'position') + [0,0,20,0];  % in pixels
set(hAlt2Title, 'style','radio', 'pos',newPos);
hAlt2a = uicontrol('parent',hAlt2, 'units','norm', 'pos',[.2,.6,.7,.3], 'style','checkbox', 'string','Option 1');
hAlt2b = uicontrol('parent',hAlt2, 'units','norm', 'pos',[.2,.2,.7,.3], 'style','checkbox', 'string','Option 2');
% Alternative options panel #3
hAlt3 = uipanel('parent',hPanelMain, 'units','norm', 'pos',[.07,.05,.5,.3], 'title','Alternative #3');
hAlt3Title = get(hAlt3, 'TitleHandle');
newPos = get(hAlt3Title,'position') + [0,0,20,0];  % in pixels
set(hAlt3Title, 'style','radio', 'pos',newPos, 'ForegroundColor','blue');
hAlt3a = uicontrol('parent',hAlt3, 'units','norm', 'pos',[.2,.5,.7,.3], 'style','popup', 'string',{'Option 3a','Option 3b','Option 3c'});
</pre>
<p><center><figure style="width: 421px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" alt="Advanced panel-level controls" src="https://undocumentedmatlab.com/images/Panel_Controls.png" title="Advanced panel-level controls" width="421" height="373" /><figcaption class="wp-caption-text">Advanced panel-level controls</figcaption></figure></center><br />
Note that since the hAlt2Title and hAlt3Title radio-buttons are children of their respective <i><b>uipanel</b></i> parents, we cannot use a simple <i><b>uibuttongroup</b></i> to group them in a mutual-exclusion group. Instead, we must use a dedicated callback function. This is actually quite easy:</p>
<pre lang="matlab">
% Set the callback for all relevant radio-buttons
hButtonGroup = [hAlt1, hAlt2Title, hAlt3Title];
set(hButtonGroup, 'Callback', {@SelectionCb, hButtonGroup});
% This is the callback function that manages mutual exclusion
function SelectionCb(hSrc,hEvent,hButtonGroup)
   otherButtons = setdiff(hButtonGroup,hSrc);
   set(otherButtons,'value',0);
   set(hSrc,'value',1);  % needed to prevent de-selection
end
</pre>
<p>The post <a rel="nofollow" href="https://undocumentedmatlab.com/articles/panel-level-uicontrols">Panel-level uicontrols</a> appeared first on <a rel="nofollow" href="https://undocumentedmatlab.com">Undocumented Matlab</a>.</p>
<div class='yarpp-related-rss'>
<h3>Related posts:</h3><ol>
<li><a href="https://undocumentedmatlab.com/articles/rich-contents-log-panel" rel="bookmark" title="Rich-contents log panel">Rich-contents log panel </a> <small>Matlab listboxes and editboxes can be used to display rich-contents HTML-formatted strings, which is ideal for log panels. ...</small></li>
<li><a href="https://undocumentedmatlab.com/articles/gui-integrated-html-panel" rel="bookmark" title="GUI integrated HTML panel">GUI integrated HTML panel </a> <small>Simple HTML can be presented in a Java component integrated in Matlab GUI, without requiring the heavy browser control....</small></li>
<li><a href="https://undocumentedmatlab.com/articles/images-in-matlab-uicontrols-and-labels" rel="bookmark" title="Images in Matlab uicontrols &amp; labels">Images in Matlab uicontrols &amp; labels </a> <small>Images can be added to Matlab controls and labels in a variety of manners, documented and undocumented. ...</small></li>
<li><a href="https://undocumentedmatlab.com/articles/icon-images-in-matlab-uicontrols" rel="bookmark" title="Icon images &amp; text in Matlab uicontrols">Icon images &amp; text in Matlab uicontrols </a> <small>HTML can be used to add image icons to Matlab listbox and popup (drop-down) controls. ...</small></li>
</ol>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://undocumentedmatlab.com/articles/panel-level-uicontrols/feed</wfw:commentRss>
			<slash:comments>17</slash:comments>
		
		
			</item>
	</channel>
</rss>
