GUI

From MiniScript Wiki
Jump to navigation Jump to search

This module provides classes and utilities for making GUI (Graphical User Interface) apps, like the desktop demo.

Classes

Name Description
Image9Slice An image wrapper with margins that are not stretched, and a middle that is stretched when drawn to any size.
Scrollbar Base class for other scrollbar classes.
ScrollbarH Horizontal Scrollbar
ScrollbarV Vertical Scrollbar
Window Window class inherits from the events.EventSprite class
Menubar Represents a group of Menus drawn horizontally as a single unit.
Menu Represents a group of MenuItems as a menu or submenu.
MenuItem Represents a single item within a menu.
InputField Numeric input field.

Functions

Name Description
clearScratch(width=256, height=256, color="#FFFFFF") Clear our off-screen "scratch" display, used for drawing or compositing things to create an image or sprite).
drawMenuItem(g, menuText, left, bottom, width=100, highlighted=false, disabled=false) Draw a single menu item.
drawMenuItem(g, menuText, left, bottom, width=100, highlighted=false, disabled=false) A helper function for drawMenuItem.
calcMenuItemWidth(menuText) Calculates the menu item text width in pixels plus padding.
drawMenuBottom(g, left, menuBottom, width=100) Draws the bottom of the menu. Note that the third parameter is the bottom of the bottommost menu item; we actually draw below that (border and shadow).
setupDisplays Setups up the display layers.

Properties

Name Description
gfxSource An image template used to draw certain GUI controls. See /sys/data/desktop/desktopGfx.png for an example.
smallFont A bmfFont. If /usr/fonts/minimicro-pro-12.bmf does not exist, then /sys/fonts/minimicro-pro-12.bmf is used.
medFont A bmfFont. If /usr/fonts/minimicro-pro-16.bmf does not exist, then /sys/fonts/minimicro-pro-16.bmf is used.
largeFont A bmfFont. If /usr/fonts/minimicro-pro-20.bmf does not exist, then /sys/fonts/minimicro-pro-20.bmf is used.
images A map of various control images pulled from the gfxSource image.

Constants

Window.dragMode

Name Description
kDragMove Moving the window
kDragResize Stretching the window
kDragSelect Selecting stuff within the window

Window.partHit

Name Description
kPartTitle Title bar
kPartFrame Frame
kPartResize Resize grip box
kPartContent Content area

Drawing

Name Description
kScrollbarSize Default thickness for any scrollbar
kMenuBarHeight Height of the menu bar at top of screen
kMenuItemHeight Height of one item in a menu

Misc.

Name Description
selectionColor Color string
scrollWheelSpeed Distance to scroll when mouse wheel is turned