Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Sep 27, 2023
1 parent ad760ae commit 152142c
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 75 deletions.
File renamed without changes.
File renamed without changes
2 changes: 1 addition & 1 deletion Documentation/Classes/buttonDelegate.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `button` class is intended to manage button widgets.

> #### 📌 This class inherit from the [`widget`](widget.md) class
> #### 📌 This class inherit from the [`widgetDelegate`](widgetDelegate.md) class
## Properties

Expand Down
23 changes: 10 additions & 13 deletions Documentation/Classes/formDelegate.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# formDelegate

The `formDelegate` class is intended to be called as a delegate by a dialog form class, as in the code example below line 8.
The `formDelegate` class is intended to be called as a delegate by a `form controller class`, as in the code example below line 8.

### <a name="sample">Code sample for a dialog form class</a>

### <a name="sample">Code sample for a `form controller class`</a>

```4d
// Class _myDialog_Controller
Expand Down Expand Up @@ -45,17 +46,19 @@ Function update()
|**.window** | Current form window class object |`cs.windowDelegate`
|**.constraints** | The constraints manager |`cs.constraintsDelegate`

> * To be set up by the dialog form class
> * To be set up by the `form controller class`
**Other properties are described below in the section devoted to them.**

## Form objects instantiation functions
## <a name="objects">Form objects instantiation functions</a>

<img src="mermaid-controller.svg">

In the dialog form class, you instantiate the form objects you wish to manipulate (i.e. activate, deactivate, move, set a value, color, etc.) using the `<class>.new(<name>)` instantiation functions listed in the table below. See the [code sample](#sample) above, lines 16 to 18.
In the `form controller class`, you instantiate the form objects you wish to manipulate (i.e. activate, deactivate, move, set a value, color, etc.) using the `<class>.new(<name>)` instantiation functions listed in the table below. See the [code sample](#sample) above, lines 16 to 18.

| Functions | |
|:-------- |:------ |
|.**static**.*new* (name: `Text`) → `cs.staticDelegate` | for a [static](fstaticDelegate.md) element like a line, a rectangle…|
|.**static**.*new* (name: `Text`) → `cs.staticDelegate` | for a [static](staticDelegate.md) element like a line, a rectangle…|
|.**widget**.*new* (name: `Text`) → `cs.widgetDelegate` | for a [generic widget](widgetDelegate.md) ie. not a static element|
|.**button**.*new* (name: `Text`) → `cs.buttonDelegate` | for a [button widget](buttonDelegate.md)|
|.**comboBox**.*new* (name: `Text`) → `cs.buttonDelegate` | for a [comboBox widget](comboBoxDelegate.md)|
Expand All @@ -77,7 +80,7 @@ Each instantiated form object inherits all the properties and functions of its c

## Standard suite functions

The functions listed in the table below represent the standard suite. **They must be defined in the dialog form class if you need them**, otherwise an alert will be raised.
The functions listed in the table below represent the standard suite. **They must be defined in the `form controller class` if you need them**, otherwise an alert will be raised.

In the [code sample](#sample) above, line 12, the `This.form.init()` call explicitly describes that we want to initialize the form, but the initialization code is specific to the form and must therefore be in the class that drives it. This is the role of the `Function init()` function at line 14.

Expand Down Expand Up @@ -238,9 +241,6 @@ The minimum suite (`init()`, `onLoad()`, `handleEvents()`) is presented in ***DE
|.**setCursor** (cursor: `Integer`\|`Text`)| Sets the mouse cursor to the <a href="https://github.com/vdelachaux/tip-and-tricks/blob/master/docs/Don't%20forget%20the%20cursor.md">cursor type</a> specified in `cursor` by its number or name.|
|.**releaseCursor** ()| Restores the standard mouse cursor|




## Form definition access

|Properties|Description|Type|default|Writable|
Expand All @@ -252,6 +252,3 @@ The minimum suite (`init()`, `onLoad()`, `handleEvents()`) is presented in ***DE
|**.subforms** | All subform form object names | `Collection`
|**.instantiatedWidgets** | All instantiated widgets objects | `Collection`
|**.instantiatedSubforms** | All instantiated subforms objects | `Collection`



Expand Down
31 changes: 29 additions & 2 deletions Documentation/Classes/staticDelegate.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
# staticDelegate

The `staticDelegate` class is the parent class of all form objects classes<img src="static.png">
The `staticDelegate` class is the parent class of all form objects classes.

> 📌 The `group` class can also refer to this class even if it's not inheritance
#### This class is available via the [`formDelegate`](formDelegate.md#objects) class as `static` interface.

```4d
This.form:=cs.formDelegate.new(This)
...
This.myObject:=This.form.static.new("myObject")
...
This.myObject.hide()
```

#### This class can also be instantiated on its own.

```4d
Form.myObject:=cs.staticDelegate.new("myObject")
...
Form.myObject.hide()
```

**Note**: 📌 The `group` class can also refer to this class even if it's not inheritance

## Properties

Expand Down
3 changes: 3 additions & 0 deletions Documentation/Methods/formGetInstance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Description

The `formGetInstance` method returns, if it exists, the instance of the form controller class created by the [formMethod](formMethod.md) method on its first call.
42 changes: 42 additions & 0 deletions Documentation/Methods/formMethod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Description

The purpose of the `formMethod` method is :

* If it hasn't already been done, initialize the form controller class, and store its instance in the `Form.__DIALOG__` property.

* Call the `handleEvents()` function of the controller class, passing it the form event object.

# How do I use it?

Starting with the `DEMO_1` example

## 1️⃣ Create a dialog controller class.

For a `formName` form, create a class named `_<formName>_Controller`.

![Explorer](../../README/explorer.png)

## 2️⃣ Use the method as the dialog's form method.

The `formMethod` method must be defined as the form method.

![Form](../../README/form.png)

## 3️⃣ Instantiate the formDelegate class in the dialog controller class.

In the dialog controller class constructor, the property `.form` is set as `cs.formDelegate.new(This)`.
See the [example](#sample) below.

## 4️⃣ Define the function handleEvents ( \$e ) In the dialog controller class.

The dialog class define, at least one function: `.handleEvents()`
See the [example](#sample) below.

## <a name="sample">Dialog controller class example</a>

```4d
// Class _myDialog_Controller
Class constructor This.isSubform:=False This.toBeInitialized:=False // Instantiate the formDelegate This.form:=cs.formDelegate.new(This) // 3️⃣
This.form.init() // MARK:-[Standard Suite] // === === === === === === === === === === === === === === === === === === === === ===Function init() /* Instantiate the widgets we want to manipulate. • Note that the label is not instantiated, as we don't need to act on it. */ This.pwd:=This.form.input.new("Input") // Bottom buttons This.ok:=This.form.button.new("Button") This.cancel:=This.form.button.new("Button1") // === === === === === === === === === === === === === === === === === === === === ===Function handleEvents($e : cs.evt) // 4️⃣ $e:=$e || cs.evt.new() If ($e.form) // <== FORM METHOD Case of //============================================== : ($e.load) This.form.onLoad() //============================================== End case Else // <== WIDGETS METHOD Case of //============================================== : (This.ok.catch($e; [On Clicked])) // Make some validation then accept or not… If (This.pwd.isEmpty || (This.pwd.value="1234")) ALERT("Invalid pasword!") This.pwd.focus() return End if // All is OK, so we can validate ACCEPT //============================================== : (This.pwd.catch()) This.ok.enable(This.pwd.isNotEmpty) //============================================== End case End if // === === === === === === === === === === === === === === === === === === === === ===Function onLoad() // Create and install a minimal menu bar cs.menuBar.new().defaultMinimalMenuBar().set() // Set window title This.form.window.title:="Passkey" // Set the textbox as password & set a placeholder for it This.pwd.setPlaceholder("Please enter your password...") This.pwd.asPassword:=True // Distribute bottom buttons according to their label This.form.group.new(This.ok; This.cancel).distributeRigthToLeft() This.ok.helpTip:="Click here to validate your password" This.cancel.helpTip:="Click here to abandon" This.ok.disable()
```
Expand Down
55 changes: 38 additions & 17 deletions Project/Sources/Classes/buttonDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ Class constructor($name : Text)

Super:C1705($name)

This:C1470[""]:={}

This:C1470[""].styleNames:=[\
/*00*/"None"; \
/*01*/"Background offset"; \
/*02*/"Push button"; \
/*03*/"Toolbar button"; \
/*04*/"Custom"; \
/*05*/"Circle"; \
/*06*/"Small system square"; \
/*07*/"Office XP"; \
/*08*/"Bevel"; \
/*09*/"Rounded bevel"; \
/*10*/"Collapse/Expand"; \
/*11*/"Help"; \
/*12*/"OS X Textured"; \
/*13*/"OS X Gradient"\
]

//MARK:-[Text & Picture]
// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get linkedPopupMenu() : Boolean
Expand Down Expand Up @@ -175,6 +194,13 @@ Function _proxy($proxy : Text) : Text
//______________________________________________________
End case

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get numStates() : Integer

var $c : Collection
$c:=Split string:C1554(OBJECT Get format:C894(*; This:C1470.name); ";")
return $c.length>=13 ? Num:C11($c[12]) : 4

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set numStates($states : Integer)

Expand All @@ -198,32 +224,27 @@ Function setNumStates($states : Integer) : cs:C1710.buttonDelegate

return This:C1470

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get style() : Integer

var $c : Collection
$c:=Split string:C1554(OBJECT Get format:C894(*; This:C1470.name); ";")
return $c.length>=7 ? Num:C11($c[6]) : 0/*default*/

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set style($style : Integer)

This:C1470.setStyle($style)

// <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <== <==
Function get styleName() : Text

return This:C1470[""].styleNames[This:C1470.style]

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Button style
Function setStyle($style : Integer) : cs:C1710.buttonDelegate

/**
style = 0: None (default)
style = 1: Background offset
style = 2: Push button
style = 3: Toolbar button
style = 4: Custom
style = 5: Circle
style = 6: Small system square
style = 7: Office XP
style = 8: Bevel
style = 9: Rounded bevel
style = 10: Collapse/Expand
style = 11: Help
style = 12: OS X Textured
style = 13: OS X Gradient
**/

This:C1470.setFormat(";;;;;;"+String:C10($style))

return This:C1470
Expand Down
10 changes: 6 additions & 4 deletions Project/Sources/Classes/dropDownDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Class constructor($name : Text; $data : Object)

If (This:C1470.data#Null:C1517) && (This:C1470.data.currentValue#Null:C1517)

This:C1470.data.placeholder:=This:C1470.data.placeholder=Null:C1517\
? This:C1470.data.currentValue\
: This:C1470.data.placeholder
This:C1470.data.placeholder:=This:C1470.data.placeholder#Null:C1517\
? This:C1470.data.placeholder\
: This:C1470.data.currentValue

End if

Expand Down Expand Up @@ -58,8 +58,10 @@ Function set placeholder($placeholder : Text)

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// Reset
Function clear()
Function clear() : cs:C1710.dropDownDelegate

This:C1470.data.index:=-1
This:C1470.data.currentValue:=String:C10(This:C1470.data.placeholder)

return This:C1470

4 changes: 1 addition & 3 deletions Project/Sources/Classes/formDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ Function onLoad()
var $events; $widgets : Collection
var $widget : cs:C1710.widgetDelegate


// Defines the container reference in subform instances
For each ($o; This:C1470.instantiatedSubforms)

Expand All @@ -196,7 +195,6 @@ Function onLoad()

// Add the widgets events that we cannot select in the form properties 😇
// ⚠️ OBJECT GET EVENTS return an empty array if no object method, so we analyze the json form

$widgets:=This:C1470._getInstantiated()

If ($widgets.length>0)
Expand Down Expand Up @@ -479,7 +477,7 @@ Function stopTimer()
/// Gets the associated worker
Function get worker() : Variant

return String:C10(This:C1470._worker)
return This:C1470._worker#Null:C1517 ? This:C1470._worker : ""

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
/// Sets the associated worker
Expand Down
4 changes: 2 additions & 2 deletions Project/Sources/Classes/groupDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ Function show($visible : Boolean) : cs:C1710.groupDelegate
return This:C1470

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function hide : cs:C1710.groupDelegate
Function hide() : cs:C1710.groupDelegate

var $o : cs:C1710.staticDelegate

Expand Down Expand Up @@ -634,7 +634,7 @@ Function enable($enabled : Boolean) : cs:C1710.groupDelegate
return This:C1470

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function disable : cs:C1710.groupDelegate
Function disable() : cs:C1710.groupDelegate

var $o : cs:C1710.staticDelegate

Expand Down
16 changes: 8 additions & 8 deletions Project/Sources/Classes/listboxDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Function get selectionHighlight() : Boolean
return Bool:C1537(LISTBOX Get property:C917(*; This:C1470.name; lk hide selection highlight:K53:41))

// ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==> ==>
Function set selectionHighlight($on : Boolean) : cs:C1710.listboxDelegate
Function set selectionHighlight($on : Boolean)

LISTBOX SET PROPERTY:C1440(*; This:C1470.name; lk hide selection highlight:K53:41; $on ? lk yes:K53:69 : lk no:K53:68)

Expand Down Expand Up @@ -446,13 +446,13 @@ Function resetForegroundColor($target)
End if

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function setRowFontStyle($row : Integer; $tyle : Integer)
Function setRowFontStyle($row : Integer; $style : Integer)

If (This:C1470.isArray(Current method name:C684))

// Default is plain
$tyle:=Count parameters:C259>=2 ? $tyle : Plain:K14:1
LISTBOX SET ROW FONT STYLE:C1268(*; This:C1470.name; $row; $tyle)
$style:=Count parameters:C259>=2 ? $style : Plain:K14:1
LISTBOX SET ROW FONT STYLE:C1268(*; This:C1470.name; $row; $style)

End if

Expand Down Expand Up @@ -497,11 +497,11 @@ Function cellPosition($e : cs:C1710.evt) : Object
}

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
// ⚠️
// ⚠️
Function getCoordinates() : Object

This:C1470.getScrollPosition()
This:C1470.getScrollbars()
This:C1470._getScrollbars()
This:C1470.updateDefinition()
This:C1470.updateCell()

Expand Down Expand Up @@ -720,7 +720,7 @@ Function selectAll() : cs:C1710.listboxDelegate

return This:C1470.select()

// MARK: -
// MARK: -
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function edit($target; $item : Integer)

Expand Down Expand Up @@ -852,7 +852,7 @@ Function updateDefinition() : cs:C1710.listboxDelegate
End for each
End for

This:C1470.getScrollbars()
This:C1470._getScrollbars()

return This:C1470

Expand Down
2 changes: 1 addition & 1 deletion Project/Sources/Classes/pictureDelegate.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Function getCoordinates()->$coordinates : Object

$coordinates:=Super:C1706.getCoordinates()

This:C1470.getScrollbars()
This:C1470._getScrollbars()
This:C1470.getScrollPosition()
This:C1470.getDimensions()

Expand Down
Loading

0 comments on commit 152142c

Please sign in to comment.