Commits

Jason McKesson committed 9f0c8f3

Added scrolling windows to LuaGUI. Also allowed panels to be non-moveable.

Comments (0)

Files changed (3)

                 center panel is designated by the setting the <literal>centerpane</literal>
                 attribute to <quote>true.</quote> This will override the
                     <literal>direction</literal> attribute.</para>
-            <para>Panels can have a title, defined by the <literal>title</literal> attribute.
-                Whether they have a title or not, all panels are "tearaway"; you can grab them by
-                their title bar, pull them off of the side of the window, and attach them to a
-                different side. A panel can even be made a free-standing window. There is no way to
-                remove or prevent this behavior. The only panel that cannot be pulled away is the
-                single panel designated the center panel.</para>
-            <para>Toolbars <emphasis>can</emphasis> have this ability, but it is optional. It is set
-                by the <classname>toolbar</classname>-only <literal>gripper</literal> attribute.
-                This attribute defaults to <quote><literal>true</literal></quote>; if it is
-                        <quote><literal>false</literal>,</quote> then the toolbar will be fixed in
-                place and cannot move.</para>
+            <para>Panels can have a title, defined by the <literal>title</literal> attribute. By
+                default, panes are "tearaway"; you can grab them by their title bar, pull them off
+                of the side of the window, and attach them to a different side. A panel can even be
+                made a free-standing window. Toolbars also have a tearaway strip that allows you to
+                move them.</para>
+            <para>If you want to position panels or toolbars, you may use the
+                    <literal>gripper</literal> attribute. This attribute defaults to
+                        <quote><literal>true</literal></quote>; if it is
+                        <quote><literal>false</literal>,</quote> then the panel or toolbar will be
+                fixed in place and cannot move. You can still resize panels (but not
+                toolbars).</para>
             <note>
-                <title>Gripper Bug</title>
-                <para>Toolbars with a gripper can be made into free-standing windows. When they are,
-                    they have a close button that can cause the toolbar to be removed. There is no
-                    LuaGUI API to detect this as of yet, so you will have to use wxLua APIs to
-                    prevent it from happening or restore the toolbar when it does.</para>
+                <title>Gripper Issue</title>
+                <para>Toolbars or panels with a gripper can be made into free-standing windows. When
+                    they are, they have a close button that can cause the toolbar or panels to be
+                    removed. There is no LuaGUI API to detect this as of yet, so you will have to
+                    use wxLua APIs to prevent it from happening or restore the toolbar when it
+                    does.</para>
             </note>
             <para>Another important difference between panels and toolbars is that panels are
                 resizeable. Two panels adjacent to each other will have a resizing bar between them.
                 of that size. Any empty space will be the window's background color.</para>
             <para>Panels can have a maximize button. This button causes the panel to take up all of
                 the available area, including the center pane (but not covering any toolbars). To
-                allow a panel to have this button, use the <literal>maximizebutton</literal>; it
-                defaults to <quote><literal>false</literal></quote>. If it is
+                allow a panel to have this button, use the <literal>maximizebutton</literal>
+                attribute; it defaults to <quote><literal>false</literal></quote>. If it is
                         <quote><literal>true</literal>,</quote> then the panel will have a maximize
                 button. Toolbars cannot have this.</para>
+            <para>By default panels will have a bar for resizing them and toolbars will not. You can
+                use the <literal>resizable</literal> attribute to change these defaults. When it is
+                        <quote><literal>true</literal>,</quote> the toolbar or panel will be
+                resizable. Note that resizing works in both directions; non-resizable objects have a
+                fixed width and height. There is no way to set a panel or toolbar to fill the
+                width/height perpendicular to the anchor direction, but still not be resizable in
+                the other.</para>
             <para>Other than these features, panels and toolbars behave like any other container
                 control. They can contain any container control or leaf control. However, panels and
                 toolbars cannot be contained by anything except the <classname>appWnd</classname>
         lg.containers | lg.controls
         
     lg.containers =
-        lg.tabs | lg.collpane | lg.box | lg.sizer
+        lg.tabs | lg.collpane | lg.scrollpane | lg.box | lg.sizer
         
     lg.dialog.containers =
         lg.tabs | lg.collpane | lg.box | lg.sizer
         ## A container that can be collapsed.
         element collpane { lg.collpane.attlist, lg.windows* }
         
+    lg.scrollpane =
+        ## A container that can be collapsed.
+        element scrollpane { lg.scrollpane.attlist, lg.windows* }
+        
     lg.sizer =
         ## A container for controls that has no visuals for it.
         element sizer { lg.sizer.elem.attlist, lg.windows* }
         lg.text.attribute?,
         lg.collpane.collapsed.attribute?,
         lg.sizer.attlist
+        
+    lg.scrollpane.attlist =
+        lg.std.window.attlist,
+        lg.size,
+        lg.positioning.attlist,
+        lg.sizer.attlist,
+        lg.scrollpane.hscroll.attribute?,
+        lg.scrollpane.vscroll.attribute?
+        
     
     lg.sizer.elem.attlist =
         lg.size,
         lg.size,
         lg.positioning.attlist,
         lg.sizer.attlist,
-        lg.aui.attlist
+        lg.aui.attlist,
+        lg.gripper.attribute?
     
     lg.toolbar.attlist =
         lg.std.window.attlist,
         lg.id.attribute?,
         lg.size,
         lg.positioning.attlist,
-        lg.tabs.onselchanged.attribute
+        lg.tabs.onselchanged.attribute?
         
     lg.button.attlist =
         lg.text.attribute,
         lg.aui.title.attribute?,
         (lg.aui.direction.attribute | lg.aui.centerpane.attribute),
         lg.aui.row.attribute?,
-        lg.aui.maximizebutton.attribute?
+        lg.aui.maximizebutton.attribute?,
+        lg.aui.floatable.attribute?,
+        lg.aui.resizable.attribute?
+    
+
 
     lg.aui.toolbar.attlist =
         lg.aui.direction.attribute,
-        lg.aui.row.attribute?
+        lg.aui.row.attribute?,
+        lg.aui.resizable.attribute?
 
     lg.std.window.attlist =
         lg.tip.attribute?, lg.id.attribute?
         ## If true, then the pane starts off initially collapsed.
         [ a:defaultValue = "false" ]
         attribute collapsed { lg.data.boolean }
+        
+    lg.scrollpane.hscroll.attribute =
+        [ a:defaultValue = "0" ]
+        attribute hscroll { xsd:nonNegativeInteger }
+
+    lg.scrollpane.vscroll.attribute =
+        [ a:defaultValue = "0" ]
+        attribute vscroll { xsd:nonNegativeInteger }
     
     lg.tabs.onselchanged.attribute =
         ## A Lua function that gets called whenever the tabs change. It is given a
         ## can use this.
         [ a:defaultValue = "false" ]
         attribute maximizebutton { lg.data.boolean }
+        
+    lg.aui.floatable.attribute =
+        ## If true, then the panel can be floated. If false, it cannot be floated or moved.
+        [ a:defaultValue = "true" ]
+        attribute floatable { lg.data.boolean }
+        
+    lg.aui.resizable.attribute =
+        ## If true, then the panel or toolbar can be resized. If false, it cannot be resized.
+        ## For panels, this is true by default. For toolbars, it is false by default.
+        attribute resizable { lg.data.boolean }
     
     lg.gripper.attribute =
         ## If true, then the toolbar will have a region that the user can use to reposition it.
 LuaGUI.MsgBoxPrint = print;
 print = realPrint;
 
+--Utility for ?: operator
+local function iff(test, valTrue, valFalse)
+	if(test) then return valTrue else return valFalse end
+end
+
 --Utility iterator over all child XML nodes. Nodes of ANY type.
 local function ixmlnodes(parNode)
 	local currNode = parNode:GetChildren();
 			currUnnamedPanel = currUnnamedPanel + 1;
 		end
 	end
+
+	local bIsToolbar = false;
+	if(currNode:GetName() == "toolbar") then
+		info:ToolbarPane();
+		bIsToolbar = true;
+	end
 	
 	bHasProp, prop = currNode:GetPropVal("direction");
 	if(bHasProp) then
 	
 	info:BestSize(GetNodeSize(currNode));
 	info:CloseButton(false);
-	info:Resizable(true);
 	
-	if(currNode:GetName() == "toolbar") then
-		info:ToolbarPane();
+	info:Resizable(GetNodeBoolProp(currNode, "resizable", iff(bIsToolbar, false, true)));
 		
-		if(not GetNodeBoolProp(currNode, "gripper", true)) then info:Gripper(false) end;
-	end
+	if(not GetNodeBoolProp(currNode, "gripper", true)) then
+		if(currNode:GetName() == "toolbar") then
+			info:Gripper(false)
+		else
+			info:CaptionVisible(false)
+		end
+	end;
+
+	if(not GetNodeBoolProp(currNode, "floatable", true)) then info:Floatable(false) end;
+
 
 	return info;
 end
 	return collpane;
 end
 
+function elementJumpTable.scrollpane(parWnd, sizer, currNode, notebook, auiNotebook)
+	local size = GetNodeSize(currNode);
+	
+	local scrollpane = wx.wxScrolledWindow(parWnd, wx.wxID_ANY, 
+		wx.wxDefaultPosition, size);
+		
+	local mySizer = CreateStandardSizer(currNode);
+	scrollpane:SetSizer(mySizer);
+	
+	--Scroll increments.
+	local hScroll = tonumber(currNode:GetPropVal("hscroll", "0"));
+	local vScroll = tonumber(currNode:GetPropVal("vscroll", "0"));
+	scrollpane:SetScrollRate(hScroll, vScroll);
+		
+	ParseChildrenWithCallback(scrollpane, mySizer, currNode, notebook, auiNotebook, nil);
+	
+	AddToSizer(currNode, scrollpane, sizer);
+	FinalizeControl(currNode, scrollpane);
+	
+	return scrollpane;
+end
+
 
 function elementJumpTable.sizer(parWnd, sizer, currNode, notebook, auiNotebook)
 	local size = GetNodeSize(currNode);
 		);
 	end
 
-
 	return tabs;
 end
 
 
 	ParseChildrenWithCallback(page, page:GetSizer(), currNode, nil, nil, nil);
 	
+	FinalizeControl(currNode, page);
 	notebook:AddPage(page, currNode:GetPropVal("text", "tab"));
-	FinalizeControl(currNode, page);
 
 	return page;
 end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.