Last active
August 29, 2015 14:27
-
-
Save ydm/b142f56f57929ae97ecd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Append element to the end of array. | |
| // | |
| proc append(string $ary[], string $elem) | |
| { | |
| $ary[size($ary)] = $elem; | |
| } | |
| // | |
| // Return a list of all layouts that are direct children of $wnd. | |
| // | |
| proc string[] findWindowLayouts(string $wnd) | |
| { | |
| string $controls[] = `lsUI -l -controlLayouts`; | |
| string $pattern = "^" + $wnd + "|[^|]+"; | |
| string $uniques[] = {}; | |
| for ($c in $controls) | |
| { | |
| string $child = `match $pattern $c`; | |
| if (size($child) > 0) | |
| { | |
| if (!stringArrayContains($child, $uniques)) | |
| { | |
| append($uniques, $child); | |
| } | |
| } | |
| } | |
| return $uniques; | |
| } | |
| // | |
| // Return the first child layout of $wnd matched. | |
| // | |
| proc string findWindowLayout(string $wnd) | |
| { | |
| // Get a list of all controls. | |
| // | |
| string $controls[] = `lsUI -l -controlLayouts`; | |
| string $pattern = "^" + $wnd + "|[^|]+"; | |
| string $uniques[] = {}; | |
| for ($c in $controls) | |
| { | |
| // Check them if they're actually children of $wnd. | |
| // | |
| string $child = `match $pattern $c`; | |
| if (size($child) > 0) | |
| { | |
| return $child; | |
| } | |
| } | |
| return ""; | |
| } | |
| proc string getShortName(string $layout) | |
| { | |
| // Erase the parent's window name for the given layout. | |
| // | |
| return `substitute "^([^|]*|)+" $layout ""`; | |
| } | |
| proc printWidget(string $widget) | |
| { | |
| print (getShortName($widget) + " (" + objectTypeUI($widget) + ")\n"); | |
| } | |
| proc printLayoutHierarchyImpl(string $layout, int $level) | |
| { | |
| // Print the initial offset and the widget name. | |
| // | |
| int $i = 0; | |
| for ($i = 0; $i < $level; $i++) | |
| { | |
| print "| "; | |
| } | |
| print "+ "; | |
| printWidget($layout); | |
| // Now check if this widget is another layout. | |
| // If yes, it's traversed too. | |
| // | |
| if (`layout -query -exists $layout` == 0) | |
| { | |
| return; | |
| } | |
| // Traverse the layout's children and recurse. | |
| // | |
| string $children[] = `layout -query -childArray $layout`; | |
| for ($child in $children) | |
| { | |
| printLayoutHierarchyImpl($layout + "|" + $child, $level + 1); | |
| } | |
| } | |
| proc printWindowHierarchy(string $wnd) | |
| { | |
| printWidget($wnd); | |
| string $layouts[] = findWindowLayouts($wnd); | |
| for ($layout in $layouts) | |
| { | |
| printLayoutHierarchyImpl($layout, 0); | |
| } | |
| } | |
| // printWindowHierarchy("vrayLLWindow"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment