[M3devel] VBT and up to date desktop styling
Elmar Stellnberger
estellnb at elstel.org
Sun Dec 1 20:26:21 CET 2013
As the VBT standard interface does only offer black and white user
interface styling I would need to use vbtkit to achieve at least a
Windows 3.1 similar user interface. However as I have found out some of
the classes in vbtkit required just for the main menu have not been
completed and do not compile yet. Would someone be ready to invest some
time and affection to complete these classes?
To make MainMenu.m3 look good at least the following tasks would have to
be done:
* AnchorSwitchVBT: to be completed, 3D reflection for the anchors of the
popup menus in the main menu
* ShadowedBarVBT: is here but does not seem to work: it should display a
horizontal bar in one of the popup menus
* ShadowVBT: to be completed: draw a 3D border around popup menus and
other items
* Shadow: have a third color besides background and foreground for the
flat style: eliminate the white borders in non-hover mode
* adjust the vbtkit menu so that the popup menus stays open if the mouse
button is released; this will also be necessary to make sub-menus of
popup-menus work; i.e. let popup menus contain AnchorSwitchVBTs
* evtl.: Shadow: have a horizontal and a vertical width as ShadowVBTs
shadows appear to be larger in their horizontal extent by now compared
to their vertical extent which is not that good to look at
* and likely some other issues I have not discovered yet
Considering all of that if I will not have an extended vbtkit
interfacing with another GUI component like GTK would likely be the way
to go because otherwise there would simply be too much time to be
invested into vbtkit not considering underlying Trestle problems like
Unicode support yet. Though it would be good to have a well working
standard GUI interface for Modula-3 we need to consider now if putting
further work into Trestle/vbtkit is still worth to do. If so I believe
it would require a joint effort.
-------------- next part --------------
MODULE MainMenu EXPORTS Main;
IMPORT TextVBT, RigidVBT, HVSplit, VBT, Split, Axis, Trestle, TrestleComm, Thread;
IMPORT MenuSwitchVBT, (* AnchorSwitchVBT, *) AnchorBtnVBT, ButtonVBT;
IMPORT Shadow, ShadowedFeedbackVBT, ShadowedBarVBT (*, ShadowVBT*), BorderedVBT;
IMPORT Wr,Stdio;
FROM VBTStyle IMPORT gray, black, blackongray, shadow;
<*FATAL TrestleComm.Failure*>
<*FATAL Wr.Failure*>
<*FATAL Thread.Alerted*>
TYPE MenuItemProc = PROCEDURE (v: MenuSwitch; READONLY cd: VBT.MouseRec);
MenuSwitch = MenuSwitchVBT.T OBJECT
callbackproc : MenuItemProc
OVERRIDES
callback := MenuSwitchCallbackWrapper;
END;
PROCEDURE MenuSwitchCallbackWrapper(v: MenuSwitch; READONLY cd:VBT.MouseRec) =
BEGIN v.callbackproc(v,cd) END MenuSwitchCallbackWrapper;
PROCEDURE AddMenuItem( menu: Split.T; item: TEXT; action: MenuItemProc ) =
VAR feedback, menuswitch : VBT.T;
BEGIN
feedback := ShadowedFeedbackVBT.NewMenu( TextVBT.New( item, bgFg:=blackongray ), shadow );
menuswitch := NEW(MenuSwitch, callbackproc:= action).init(feedback);
Split.AddChild(menu,menuswitch);
END AddMenuItem;
PROCEDURE AddHorizontalBar( menu: Split.T ) =
BEGIN
Split.AddChild(menu, NEW(ShadowedBarVBT.T).init( Axis.T.Hor, shadow, Shadow.Style.Chiseled ) );
END AddHorizontalBar;
PROCEDURE AddSubMenu( menu: Split.T; item: TEXT; submenu: HVSplit.T ) =
VAR feedback, anchorbutn : VBT.T;
BEGIN
feedback := NEW(ShadowedFeedbackVBT.T).init( ch:=TextVBT.New( item, bgFg:=blackongray ),
shadow:=shadow, offStyle:=Shadow.Style.Flat, onStyle:=Shadow.Style.Lowered ,onExcitedStyle:=Shadow.Style.Lowered );
(* anchorbutn := AnchorBtnVBT.New( ch:=feedback, menu:= NEW(ShadowVBT.T, submenu, shadow, Shadow.Style.Raised ); *)
anchorbutn := AnchorBtnVBT.New( ch:=feedback, menu:=BorderedVBT.New( submenu, 0.2, black ) );
Split.AddChild( menu, anchorbutn );
END AddSubMenu;
VAR main, menu : VBT.T;
VAR mainmenu, popup1, popup2, popup3 : Split.T;
PROCEDURE Cut (<*UNUSED*>v: MenuSwitch; <*UNUSED*>READONLY cd: VBT.MouseRec) =
BEGIN Wr.PutText(Stdio.stdout, "Cut\n"); Wr.Flush(Stdio.stdout); END Cut;
PROCEDURE Paste (<*UNUSED*>v: MenuSwitch; <*UNUSED*>READONLY cd: VBT.MouseRec) =
BEGIN Wr.PutText(Stdio.stdout, "Paste\n"); Wr.Flush(Stdio.stdout); END Paste;
PROCEDURE Exit (<*UNUSED*>v: MenuSwitch; <*UNUSED*>READONLY cd: VBT.MouseRec) =
BEGIN Trestle.Delete(main); END Exit;
BEGIN
popup1 := HVSplit.New(Axis.T.Ver);
AddMenuItem(popup1, "Open", Cut);
AddHorizontalBar(popup1);
AddMenuItem(popup1, "Exit", Exit);
popup3 := HVSplit.New(Axis.T.Ver);
AddMenuItem(popup3, "SubCut", Cut);
AddMenuItem(popup3, "SubPaste", Paste);
(*popup2 := HVSplit.New(Axis.T.Ver); *)
popup2 := HVSplit.New(Axis.T.Ver);
AddMenuItem(popup2, "Cut", Cut);
AddMenuItem(popup2, "Paste", Paste);
AddSubMenu(popup2, "File", popup3);
(* mainmenu := HVSplit.New(Axis.T.Hor); *)
mainmenu := ButtonVBT.MenuBar( op:=gray );
AddSubMenu(mainmenu, "File", popup1);
AddSubMenu(mainmenu, "Edit", popup2);
AddMenuItem(mainmenu, "Exit", Exit);
Split.AddChild(mainmenu,NEW(VBT.Leaf));
menu := mainmenu;
main := HVSplit.Cons( Axis.T.Ver, menu, RigidVBT.FromHV( TextVBT.New("xxxxxx"), 100.0, 80.0 ) );
Trestle.Install(main);
Trestle.AwaitDelete(main);
END MainMenu.
-------------- next part --------------
INTERFACE VBTStyle;
IMPORT PaintOp, Shadow, Pixmap;
VAR lgray, gray, dgray, black : PaintOp.T;
blackongray : PaintOp.ColorQuad;
shadow : Shadow.T;
graytxt : Pixmap.T;
END VBTStyle.
-------------- next part --------------
MODULE VBTStyle;
IMPORT PaintOp, Shadow;
BEGIN
lgray := PaintOp.FromRGB(0.9, 0.9, 0.9);
gray := PaintOp.FromRGB(0.8, 0.8, 0.8);
dgray := PaintOp.FromRGB(0.7, 0.7, 0.7);
black := PaintOp.FromRGB(0.0, 0.0, 0.0);
blackongray := PaintOp.MakeColorQuad( bg:= gray, fg:= black );
shadow := Shadow.New( size:= 1.0, light:= lgray, dark:= dgray );
END VBTStyle.
More information about the M3devel
mailing list