Oberon Community Platform Forum
November 20, 2019, 07:50:41 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: FormDesigner  (Read 5025 times)
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« on: March 24, 2008, 02:57:31 PM »

I want to make a simple formdesigner.
How do adding the visual component to the form, when form working?

simple call:
  MyDesignPanel.AddContent (MyComponent);
adding component, but it does not work (only draws)

if I'm call SetContent() his working, but after several calling - form is trap.
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #1 on: March 24, 2008, 03:35:57 PM »

Set the content of a window (WMComponents.FormWindow.SetContent()) to a WMStandardComponents.Panel that is WMComponents.AlignClient aligned (panel.alignment.Set(WMComponents.AlignClient)) and use panel.AddContent() then to add visual components to this panel.
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #2 on: March 25, 2008, 11:28:33 AM »

When click button add:  TRAP 8 PL 3 8  ASSERT failed WinAos Kernel 070801

MODULE DesignTest;
IMPORT   
   Modules, WM := WMWindowManager, WMGraphics, WMEvents, WMComponents, WSC:=WMStandardComponents; (* A *)
CONST
   (* Window position relative to the upper left display corner. *)
   Width=240;   Height=240;      Toleft = 140;   Fromtop=150;
   AlignNone=WMComponents.AlignNone;
   AlignLeft=WMComponents.AlignLeft;
   AlignClient=WMComponents.AlignClient;
TYPE
   Window* = OBJECT(WMComponents.FormWindow);   (* B *)
   VAR
      panel : WSC.Panel;
   PROCEDURE &New ;   (* C *)
   BEGIN
      panel:=NewPanel(WMGraphics.Cyan, AlignClient,0,0,0,0);
      panel.AddContent(NewButton("Add", AlignNone, 0,0,80, 30,AddComponent));

      Init (Width , Height , TRUE);      (* F1 *)
      SetContent (panel);   (* G *)
      manager := WM.GetDefaultManager ();
      manager.Add (Toleft, Fromtop, SELF, {WM.FlagStayOnTop, WM.FlagFrame});
      SetTitle (WM.NewString ("BohMenuTest - Empty window"));   (* I *)
   END New;
   
      PROCEDURE AddComponent(sender, data : ANY);
      BEGIN
            panel.AddContent (NewButton("NewButton", AlignNone, 160,40,80, 32,NIL));      
            SetContent   (panel);
      END AddComponent;      
END Window;
VAR
   winstance : Window;
PROCEDURE Open*;
BEGIN
   NEW (winstance);
END Open;
PROCEDURE Cleanup;   (* K *)
BEGIN
   winstance.Close ();
   winstance := NIL
END Cleanup;
(** Helper procedures *)
PROCEDURE NewButton*(CONST caption : ARRAY OF CHAR; alignment, left,top,width, height : LONGINT;observer :WMEvents. EventListener) : WSC.Button;
VAR button: WSC.Button;
BEGIN
   NEW (button); button.caption.SetAOC (caption); button.alignment.Set (alignment);   
   button.bounds.SetTop(top);      button.bounds.SetLeft(left);   button.bounds.SetHeight(height );   button.bounds.SetWidth(width);
   button.onClick.Add (observer );
   RETURN button;
END NewButton;

PROCEDURE NewPanel*(fillColor, alignment, left,top,width, height : LONGINT) : WSC.Panel;
VAR panel : WSC.Panel;
BEGIN
   NEW(panel); panel.alignment.Set(alignment);
   panel.bounds.SetLeft(left);panel.bounds.SetTop(top);panel.bounds.SetExtents(width, height);
   panel.fillColor.Set(fillColor);
   RETURN panel;
END NewPanel;
BEGIN   (* L *)
   Modules.InstallTermHandler(Cleanup)
END DesignTest.Open ~
« Last Edit: March 25, 2008, 11:32:00 AM by BohdanT » Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #3 on: March 25, 2008, 02:10:29 PM »

Grin I'm find nice demo : MenuEdit.Mod
This worked:
      PROCEDURE AddComponent(sender, data : ANY);
      VAR
       but:WSC.Button;
      BEGIN
            but:=NewButton("NewButton", AlignNone, 160,40,80, 32,NIL);
            panel.AddContent (but);      
            but.Reset(NIL, NIL);
            panel.Invalidate;
      END AddComponent;      
« Last Edit: March 25, 2008, 02:12:00 PM by BohdanT » Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #4 on: April 04, 2008, 07:59:21 PM »

I'm stopped with the next problem:
I try add components and install them with a handle, but it not transmit "sender" parameter:
HandlePointerDown (x, y: LONGINT; keys: SET; VAR handled: BOOLEAN);
I can not determine what component clicked.
When I (for testing) adding buttons, I'm install onclick handler, and all working good.
But when I began to add other components (for example label), I pulled into a wall.
I tried to write a special component with click event, and insert it into the label, but that does not give the desired effect.

I just started studying Aos, on this I do not know how to circumvent this problem. Give me please pull to the right direction ...
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #5 on: April 11, 2008, 12:50:48 PM »

I partialy bypassed this problems (problems  left with components as GroupPanel, Scrollbar. Bat better IMHO add onClick  property to the VisualComponent) by the writing of the make mirror of necessary components:
example:
Code:

DImagePanel* = OBJECT(WSC.ImagePanel);
VAR onClick- :WMEvents.EventSource;
PROCEDURE &Init;
BEGIN Init^; NEW(onClick, SELF, NIL, NIL, SELF.StringToCompCommand); events.Add(onClick); END Init;
PROCEDURE PointerUp(x, y: LONGINT; keys: SET);
VAR value : LONGINT; BEGIN onClick.Call(NIL) END PointerUp;
END DImagePanel;

   
The next question:
Can I open for reading in module WMProperties.Mod in object PropertyList properties?
Code:
VAR
properties -: PropertyArray;
nofProperties-: LONGINT;
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!