Folk, I need to extend base object WMDialogs.Dialog and have to copy into my module such procedures as InstantiateButton, FindComponent, FindButton and WireError method because they not exported from module WMDialogs. And will be useful to have ability to read width an height of dialog window for more precise positioning (in center of view, for example). Example of dialog: LoginDlg = OBJECT (WMDialogs.Dialog) VAR editLogin, editPassword: WMEditors.Editor; buttonPanel: WMStandardComponents.Panel; server, ok, abort: WMStandardComponents.Button; content: WMComponents.VisualComponent; width-, height-: LONGINT; serverString-: ARRAY 256 OF CHAR; PROCEDURE &New (serverStr: ARRAY OF CHAR); BEGIN (*serverString := serverStr;*) COPY (serverStr, serverString); errors := FALSE; CreateDialog; WireDialog; width := content.bounds.GetWidth (); height := content.bounds.GetHeight (); Init (width, height, FALSE); SetContent (content); IF editLogin # NIL THEN editLogin.SetFocus; editLogin.SetFocus END END New; PROCEDURE GetServer*(sender, data:PTR); VAR res: LONGINT; BEGIN res := QueryString ("Server", serverString); END GetServer; PROCEDURE CreateDialog; VAR panel: WMStandardComponents.Panel; labelLogin, labelPassword: WMStandardComponents.Label; manager: WM.WindowManager; windowStyle: WM.WindowStyle; CONST width = 12 * 18; height = 12 * 9; BWidth = 12 * 5; BHeight = 20; BEGIN manager := WM.GetDefaultManager (); windowStyle := manager.GetStyle (); NEW (panel); panel.bounds.SetExtents (width, height); panel.fillColor.Set (windowStyle.bgColor); panel.takesFocus.Set (FALSE); NEW (labelLogin); labelLogin.bounds.Set (WMRectangles.MakeRect (12, 12, 12 * 6, 12 + 20)); labelLogin.SetCaption ("UIN:"); labelLogin.alignH.Set (WMGraphics.AlignRight); panel.AddContent (labelLogin); NEW (labelPassword); labelPassword.bounds.Set (WMRectangles.MakeRect (12, 12 * 4, 12 * 6, 12 * 4 + 20)); labelPassword.SetCaption ("Password:"); labelPassword.alignH.Set (WMGraphics.AlignRight); panel.AddContent (labelPassword); NEW (editLogin); editLogin.uid.SetAOC ("Login"); editLogin.tv.defaultTextColor.Set (windowStyle.fgColor); editLogin.tv.defaultTextBgColor.Set (windowStyle.bgColor); editLogin.bounds.Set(WMRectangles.MakeRect (12 * 7, 12, width - 12, 12 + 20)); panel.AddContent (editLogin); editLogin.multiLine.Set (FALSE); editLogin.tv.borders.Set (WMRectangles.MakeRect(5, 2, 3, 2)); editLogin.tv.showBorder.Set (TRUE); NEW (editPassword); editPassword.uid.SetAOC ("Password"); editPassword.tv.defaultTextColor.Set (windowStyle.fgColor); editPassword.tv.defaultTextBgColor.Set (windowStyle.bgColor); editPassword.tv.isPassword.Set (TRUE); editPassword.bounds.Set (WMRectangles.MakeRect (12 * 7, 12 * 4, width - 12, 12 * 4 + 20)); panel.AddContent (editPassword); editPassword.multiLine.Set (FALSE); editPassword.tv.borders.Set (WMRectangles.MakeRect(5, 2, 3, 2)); editPassword.tv.showBorder.Set (TRUE); NEW (buttonPanel); buttonPanel.bounds.SetHeight (BHeight); buttonPanel.alignment.Set (WMComponents.AlignBottom); panel.AddContent (buttonPanel); abort := InstantiateButton (WMDialogs.AbortBtnId, "Abort"); buttonPanel.AddContent (abort); abort.bounds.SetWidth (BWidth); abort.alignment.Set (WMComponents.AlignRight); ok := InstantiateButton (WMDialogs.OkBtnId, "Ok"); buttonPanel.AddContent (ok); ok.bounds.SetWidth (BWidth); ok.alignment.Set (WMComponents.AlignRight); NEW (server); server.caption.SetAOC ("Server..."); buttonPanel.AddContent (server); server.bounds.SetWidth (BWidth); server.alignment.Set (WMComponents.AlignRight); content := panel END CreateDialog; PROCEDURE WireDialog; VAR c: WMComponents.Component; BEGIN c := FindComponent (content, "Login"); IF (c # NIL) & (c IS WMEditors.Editor) THEN editLogin := c (WMEditors.Editor) END; IF editLogin = NIL THEN WireError ("LoginDlg", "Required component 'Login' not found."); RETURN END; c := FindComponent (content, "Password"); IF (c # NIL) & (c IS WMEditors.Editor) THEN editPassword := c (WMEditors.Editor) END; IF editPassword = NIL THEN WireError ("LoginDlg", "Required component 'Password' not found."); RETURN END; ok := FindButton (content, WMDialogs.OkBtnId); abort := FindButton (content, WMDialogs.AbortBtnId); IF ok = NIL THEN WireError ("LoginDlg", "Required component 'Ok' not found."); RETURN END; IF abort = NIL THEN WireError ("LoginDlg", "Required component 'Abort' not found."); RETURN END; ok.onClick.Add (Ok); abort.onClick.Add (Abort); editLogin.onEnter.Add (Ok); editPassword.onEnter.Add (Ok); server.onClick.Add (GetServer); END WireDialog; PROCEDURE WireError(detectedBy, msg: ARRAY OF CHAR); BEGIN errors := TRUE; Out.String ("WMDialogs - Wiring error : "); Out.String(detectedBy); Out.String(" - "); Out.String(msg); Out.Ln; END WireError; END LoginDlg; PROCEDURE QueryLogin*(caption: ARRAY OF CHAR; VAR server, login, password: ARRAY OF CHAR) : LONGINT; VAR ld: LoginDlg; vp: WM.ViewPort; BEGIN NEW(ld, server); IF ~ld.errors THEN ld.SetTitle(Utilities.NewString(caption)); ld.editLogin.SetAsString(login); ld.editLogin.tv.SelectAll(); vp := WM.GetDefaultView (); ld.x := (ENTIER (vp.range.r - vp.range.l) - ld.width) DIV 2; ld.y := (ENTIER (vp.range.b - vp.range.t) - ld.height) DIV 2; ld.Show; IF ld.result = WMDialogs.ResOk THEN ld.editLogin.GetAsString(login); ld.editPassword.GetAsString(password); (*server := ld.serverString;*) COPY (ld.serverString, server); END; RETURN ld.result ELSE RETURN WMDialogs.ResDialogFailure END END QueryLogin; -- Cheers, SAGE http://sage.h15.ru/
Dear SAGE, I've integrated the change below into WMDialogs.Mod. Some questions: - "UID:" sounds kind of cryptical. What about "User:" or "Username:"? - Why do you add this extra server... button? An alternative would be to have three editors (user, password, server). That way, the user could always see to what server he's connecting. What do you think? If that's okay for you, I'll put the changes in WMDialogs.Mod (containing the code provided by you) into the next release. BTW: Utilities.Buffer.Add: Thanks for reporting the bug. Bugfix will be contained in the next release. Best regards, Sven Stauber ________________________________ From: oberon-bounces@lists.inf.ethz.ch on behalf of Yaroslav Romanchenko Sent: Sat 17.03.2007 18:28 To: oberon list Subject: [Oberon] WMDialogs.Mod Folk, I need to extend base object WMDialogs.Dialog and have to copy into my module such procedures as InstantiateButton, FindComponent, FindButton and WireError method because they not exported from module WMDialogs. And will be useful to have ability to read width an height of dialog window for more precise positioning (in center of view, for example). Example of dialog: LoginDlg = OBJECT (WMDialogs.Dialog) VAR editLogin, editPassword: WMEditors.Editor; buttonPanel: WMStandardComponents.Panel; server, ok, abort: WMStandardComponents.Button; content: WMComponents.VisualComponent; width-, height-: LONGINT; serverString-: ARRAY 256 OF CHAR; PROCEDURE &New (serverStr: ARRAY OF CHAR); BEGIN (*serverString := serverStr;*) COPY (serverStr, serverString); errors := FALSE; CreateDialog; WireDialog; width := content.bounds.GetWidth (); height := content.bounds.GetHeight (); Init (width, height, FALSE); SetContent (content); IF editLogin # NIL THEN editLogin.SetFocus; editLogin.SetFocus END END New; PROCEDURE GetServer*(sender, data:PTR); VAR res: LONGINT; BEGIN res := QueryString ("Server", serverString); END GetServer; PROCEDURE CreateDialog; VAR panel: WMStandardComponents.Panel; labelLogin, labelPassword: WMStandardComponents.Label; manager: WM.WindowManager; windowStyle: WM.WindowStyle; CONST width = 12 * 18; height = 12 * 9; BWidth = 12 * 5; BHeight = 20; BEGIN manager := WM.GetDefaultManager (); windowStyle := manager.GetStyle (); NEW (panel); panel.bounds.SetExtents (width, height); panel.fillColor.Set (windowStyle.bgColor); panel.takesFocus.Set (FALSE); NEW (labelLogin); labelLogin.bounds.Set (WMRectangles.MakeRect (12, 12, 12 * 6, 12 + 20)); labelLogin.SetCaption ("UIN:"); labelLogin.alignH.Set (WMGraphics.AlignRight); panel.AddContent (labelLogin); NEW (labelPassword); labelPassword.bounds.Set (WMRectangles.MakeRect (12, 12 * 4, 12 * 6, 12 * 4 + 20)); labelPassword.SetCaption ("Password:"); labelPassword.alignH.Set (WMGraphics.AlignRight); panel.AddContent (labelPassword); NEW (editLogin); editLogin.uid.SetAOC ("Login"); editLogin.tv.defaultTextColor.Set (windowStyle.fgColor); editLogin.tv.defaultTextBgColor.Set (windowStyle.bgColor); editLogin.bounds.Set(WMRectangles.MakeRect (12 * 7, 12, width - 12, 12 + 20)); panel.AddContent (editLogin); editLogin.multiLine.Set (FALSE); editLogin.tv.borders.Set (WMRectangles.MakeRect(5, 2, 3, 2)); editLogin.tv.showBorder.Set (TRUE); NEW (editPassword); editPassword.uid.SetAOC ("Password"); editPassword.tv.defaultTextColor.Set (windowStyle.fgColor); editPassword.tv.defaultTextBgColor.Set (windowStyle.bgColor); editPassword.tv.isPassword.Set (TRUE); editPassword.bounds.Set (WMRectangles.MakeRect (12 * 7, 12 * 4, width - 12, 12 * 4 + 20)); panel.AddContent (editPassword); editPassword.multiLine.Set (FALSE); editPassword.tv.borders.Set (WMRectangles.MakeRect(5, 2, 3, 2)); editPassword.tv.showBorder.Set (TRUE); NEW (buttonPanel); buttonPanel.bounds.SetHeight (BHeight); buttonPanel.alignment.Set (WMComponents.AlignBottom); panel.AddContent (buttonPanel); abort := InstantiateButton (WMDialogs.AbortBtnId, "Abort"); buttonPanel.AddContent (abort); abort.bounds.SetWidth (BWidth); abort.alignment.Set (WMComponents.AlignRight); ok := InstantiateButton (WMDialogs.OkBtnId, "Ok"); buttonPanel.AddContent (ok); ok.bounds.SetWidth (BWidth); ok.alignment.Set (WMComponents.AlignRight); NEW (server); server.caption.SetAOC ("Server..."); buttonPanel.AddContent (server); server.bounds.SetWidth (BWidth); server.alignment.Set (WMComponents.AlignRight); content := panel END CreateDialog; PROCEDURE WireDialog; VAR c: WMComponents.Component; BEGIN c := FindComponent (content, "Login"); IF (c # NIL) & (c IS WMEditors.Editor) THEN editLogin := c (WMEditors.Editor) END; IF editLogin = NIL THEN WireError ("LoginDlg", "Required component 'Login' not found."); RETURN END; c := FindComponent (content, "Password"); IF (c # NIL) & (c IS WMEditors.Editor) THEN editPassword := c (WMEditors.Editor) END; IF editPassword = NIL THEN WireError ("LoginDlg", "Required component 'Password' not found."); RETURN END; ok := FindButton (content, WMDialogs.OkBtnId); abort := FindButton (content, WMDialogs.AbortBtnId); IF ok = NIL THEN WireError ("LoginDlg", "Required component 'Ok' not found."); RETURN END; IF abort = NIL THEN WireError ("LoginDlg", "Required component 'Abort' not found."); RETURN END; ok.onClick.Add (Ok); abort.onClick.Add (Abort); editLogin.onEnter.Add (Ok); editPassword.onEnter.Add (Ok); server.onClick.Add (GetServer); END WireDialog; PROCEDURE WireError(detectedBy, msg: ARRAY OF CHAR); BEGIN errors := TRUE; Out.String ("WMDialogs - Wiring error : "); Out.String(detectedBy); Out.String(" - "); Out.String(msg); Out.Ln; END WireError; END LoginDlg; PROCEDURE QueryLogin*(caption: ARRAY OF CHAR; VAR server, login, password: ARRAY OF CHAR) : LONGINT; VAR ld: LoginDlg; vp: WM.ViewPort; BEGIN NEW(ld, server); IF ~ld.errors THEN ld.SetTitle(Utilities.NewString(caption)); ld.editLogin.SetAsString(login); ld.editLogin.tv.SelectAll(); vp := WM.GetDefaultView (); ld.x := (ENTIER (vp.range.r - vp.range.l) - ld.width) DIV 2; ld.y := (ENTIER (vp.range.b - vp.range.t) - ld.height) DIV 2; ld.Show; IF ld.result = WMDialogs.ResOk THEN ld.editLogin.GetAsString(login); ld.editPassword.GetAsString(password); (*server := ld.serverString;*) COPY (ld.serverString, server); END; RETURN ld.result ELSE RETURN WMDialogs.ResDialogFailure END END QueryLogin; -- Cheers, SAGE http://sage.h15.ru/ -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
I've integrated the change below into WMDialogs.Mod. Some questions: - "UID:" sounds kind of cryptical. What about "User:" or "Username:"? - Why do you add this extra server... button? An alternative would be to have three editors (user, password, server). That way, the user could always see to what server he's connecting. What do you think?
If that's okay for you, I'll put the changes in WMDialogs.Mod (containing the code provided by you) into the next release.
OK, use "User:" or "User ID:"... Because it will be numerical ID rather a name. "Server..." it's like additional configuration option that will be doing not so often. In most cases default value will be used. But if this value must be changed it's better to change it before login-in. I plan to do some new dialogs... It's not good for BB spirit to make big dialogs with ability to enter a several values? How better to make such dialogs as windows with configuration options? How better to check user input before dialog will be closed? And what to do if dialog must NOT be closed before user provided correct values for all fields? -- Cheers, SAGE http://sage.h15.ru/
Dear Stauber Sven Philipp, I've put almost all dialogs I need in WMDialogs.Mod that can be obtained by this link http://sage.siteburg.com/files/Sage.WMDialogs.zip -- Cheers, SAGE http://sage.h15.ru/
participants (2)
-
Stauber Sven Philipp -
Yaroslav Romanchenko