Index: wtabbed.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wtabbed.png =================================================================== --- wtabbed.png (revision 34886) +++ wtabbed.png (nonexistent) Property changes on: wtabbed.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wbutton.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wbutton.png =================================================================== --- wbutton.png (revision 34886) +++ wbutton.png (nonexistent) Property changes on: wbutton.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: TEMPLATE.c =================================================================== --- TEMPLATE.c (revision 34886) +++ TEMPLATE.c (nonexistent) @@ -1,94 +0,0 @@ -/* - HOW TO USE THE TEMPLATE: - 1. decide about the name of your dialog box, e.g. foo in this example - 2. svn copy this file to dlg_foo.c - do not use plain fs copy, use svn copy! - 3. rename functions in this file to - 4. add '#include "dlg_foo.c"' in dialogs.c at the end of the list where - all the other dlg_*.c files are included - 5. add an action to pcb_act*_Foo in dialogs.c - 6. edit the parts marked with '<<<- edit this' or 'EDIT THIS' - do not - yet add the implementation - 7. run 'make dep' in src/ - 8. remove this comment block so copyright is on top - 9. edit the copyright message: year and author - 10. test compile - 11. in trunk/: 'svn commit src_plugins/dialogs src/Makefile.dep' - 12. start implementing the dialog box - - This simplistic example is a single-instance non-modal dialog; - there should be only one global variable, created out of the - context struct. This ensures it is easy to convert the dialog - to multi-instance in the future, if needed. - - If you need a multi-instance dialog, there should be no global variable - at all and the context struct should be allocated. A good example - on this is the shape dialog in ../shape/shape_dialog.c -*/ - -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * Copyright (C) 2018 Tibor 'Igor2' Palinkas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: http://repo.hu/projects/pcb-rnd/contact.html - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - */ - -#include "core headers this file depends on (even if other dialogs include them)" - -typedef struct{ - RND_DAD_DECL_NOINIT(dlg) - int active; /* already open - allow only one instance */ - int whatever; -} foo_ctx_t; <<<- rename this - -foo_ctx_t foo_ctx; - -static void foo_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) <<<- rename this -{ - foo_ctx_t *ctx = caller_data; - RND_DAD_FREE(ctx->dlg); - memset(ctx, 0, sizeof(foo_ctx_t)); /* reset all states to the initial - includes ctx->active = 0; */ -} - -static void pcb_dlg_foo(whatever args) <<<- edit this -{ - rnd_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; - if (foo_ctx.active) - return; /* do not open another */ - - RND_DAD_BEGIN_VBOX(foo_ctx.dlg); - RND_DAD_COMPFLAG(foo_ctx.dlg, RND_HATF_EXPFILL); - RND_DAD_LABEL(foo_ctx.dlg, "foo"); - RND_DAD_BUTTON_CLOSES(foo_ctx.dlg, clbtn); - RND_DAD_END(foo_ctx.dlg); - - /* set up the context */ - foo_ctx.active = 1; - - RND_DAD_NEW("EDIT_THIS_ID", foo_ctx.dlg, "EDIT THIS: title", &foo_ctx, rnd_false, foo_close_cb); -} - -static const char pcb_acts_Foo[] = "Foo(object)\n"; <<<- edit this -static const char pcb_acth_Foo[] = ""; <<<- edit this -static fgw_error_t pcb_act_Foo(fgw_arg_t *res, int argc, fgw_arg_t *argv) <<<- edit this -{ - return 0; -} Index: text.html =================================================================== --- text.html (revision 34886) +++ text.html (nonexistent) @@ -1,21 +0,0 @@ - -
- --The text widget is a text viewer/editor that operates on a string -that may contain multiple lines. - -
-PCB_DAD_TEXT(table, user_ctx) -creates a new text widget and installs user context. - -
-The only callback the user may provide is user_free_cb which is called -when the text widget is destroyed. Other than this, DAD caller code can not -react on events happening in the text. - - - Index: widgets.html =================================================================== --- widgets.html (revision 34886) +++ widgets.html (nonexistent) @@ -1,275 +0,0 @@ - -
- --Input widgets are leaf widgets in the widget tree that typically -implement a field where user input takes place. Available -input widgets are: -
creation call | screenshot (gtk2) | description - |
---|---|---|
PCB_DAD_LABEL | single line or multi line of plain text, from a string - | |
PCB_DAD_LABELF | single line or multi line of plain text, using printf formatting - | |
PCB_DAD_ENUM | select one value from a fixed set (typical implementation is a combo box) - | |
PCB_DAD_BOOL | checkbox - | |
PCB_DAD_INTEGER | set an integer value - | |
PCB_DAD_REAL | set a real (floating point) value - | |
PCB_DAD_COORD | set a coordinate value - | |
PCB_DAD_STRING | input single line string value (plain text) - | |
PCB_DAD_BUTTON | clickable push button - | |
PCB_DAD_PROGRESS | progress bar - | |
PCB_DAD_TREE | a list, table or tree of text data - | |
PCB_DAD_PREVIEW | drawing area - | |
PCB_DAD_PICTURE | static bitmap image - | |
PCB_DAD_PICBUTTON | static bitmap button - | |
PCB_DAD_COLOR | color button and selector - | |
PCB_DAD_TEXT | text box (text editor) - |
-Draw a label, which is not an input field (unmodifiable by the user). -text is copied by the call into a new allocation. The only -control text accepts is '\n', which is line break. - -
-Same as PCB_DAD_LABEL() but the text is rendered using printf. Note: -printf args, including the format string, shall be in parenthesis, e.g. -
-PCB_DAD_LABELF(dlg, ("Cats: %d", num_cats)) -- -
-The user can choose one value out of an ordered list of strings. The list -is passed as a NULL terminalte char * array. The value -of the enum is an integer index into that array, 0 being the first string. -
-Typical GUI implementation is a combo box, without text editing. - -
-Ask the user about a boolean value, typically using a checkbox. The value -of the bool is an integer which is either 0 or 1. - -
-Ask for an integer value, between a minval and a maxval. -The value is an int, which is not guaranteed to be wider than a -16 bit signed value. -
-Typical GUI implementation is a text entry, often upgraded with small buttons -to increase or decrease the value ("spinbox"). - -
-Ask for a REAL (double precision floating point value), between a minval -and a maxval. -
-Typical GUI implementation is a text entry, often upgraded with small buttons -to increase or decrease the value ("spinbox"). - - -
-Ask for a coordinate value, between a minval and a maxval. -The value is pcb_coord_t. -
-Typical GUI implementation is a text entry that understands unit suffix, -often upgraded with small buttons to increase or decrease the value ("spinbox"). - - -
-Ask for a single line of plain text input. -
-The value is a dynamically allocated string. - -
-A push button the user can click on. text is not allocated or copied -(shall be a static const string or allocated/free'd by the user). -
-There is no value, the only interface is the change callback. - - -
-Present a progress bar which is not an user input. value is a -REAL value between 0.0 and 1.0. When the code changes the value, the -GUI makes sure the dialog box is drawn and flushed, because typical use -is in a busy loop calculation. - -
-Present a tree-table with cols columns of text objects. When -first_col_is_tree is 1, the first column works as a tree, with -indentation and/or tree graphics and logics for collapsing/expanding subtrees. -If opt_header is not NULL, it is a NULL terminated static const -array of header strings describing the table header to be displayed, in as -many strings as cols specified. -
-A special cases: -
-
case | parameters - |
---|---|
plain flat list | cols=1, first_col_is_tree=0 - |
tree-only | cols=1, first_col_is_tree=1 - |
table-only | cols>1, first_col_is_tree=0 - |
-Manipulating the data and the view are both done using - special tree-table macros. - -
-Present a drawing area with callbacks to the host code to handle drawing: -
argument | meaning - |
---|---|
expose_cb | called when (parts of) the preview needs to be redrawn - |
mouse_cb | called on mouse events - |
free_cb | called before the widget is destroyed - |
initial_view_box | set the initial zoom/pan to match the view box specified in drawing units - |
min_sizex_px | widget minimum size in x direction (width), in pixels - |
min_sizey_px | widget minimum size in y direction (height), in pixels - |
user_ctx | opaque pointer that is passed to every callback - |
-The pointer to a static xpm image is stored in the enumerations field. The image -is displayed in a widget without any other decoration. - -
-The pointer to a static xpm image is stored in the enumerations field. The image -is displayed in a button tat behaves exaclty as a normal BUTTON in all other -regards. - -
-A button that has a solid region of the color specified in value. Unless -read-only (PCB_HATF_CLR_STATIC), when the user clicks the button a -HID-specific color selector dialog is popped up where the user can -specify a new color. - -
-Free form multiline text string, edited using a HID-builtin text editor. Line -terminator is \n. -
-TODO: accessor macros - -
creation call | screenshot (gtk2) | description - |
---|---|---|
PCB_DAD_BEGIN_HBOX | arrange children widgets in a horizontal list - | |
PCB_DAD_BEGIN_VBOX | arrange children widgets in a vertical list - | |
PCB_DAD_BEGIN_HPANE | split the parent box horizontally into two sections; the split ratio is adjustable Note: "left" and "right" are the first and second children (left and right sibling) of the widget tree - | |
PCB_DAD_BEGIN_VPANE | split the parent box vertically into two sections; the split ratio is adjustable Note: on the screenshot "left" and "right" are the first and second children (left and right sibling) of the widget tree - | |
PCB_DAD_BEGIN_TABLE | arrange children widgets into a n*m matrix, allocate each cell the same size Note: on the screenshot the table is set up to have 3 columns - | |
PCB_DAD_BEGIN_TABBED | create a "tabbed notebook" view, each children is a new tab - |
-hbox, vbox and table share a few common compflags, that are defined in -hid_attrib.h, pcb_hatt_compflags_t. The explanation of what each flag does -can be found there. The most commonly used ones are PCB_HATF_FRAME, -PCB_HATF_SCROLL, PCB_HATF_EXPFILL. -
-If PCB_HATF_EXPFILL is set, the given box tries to expannd and fill, using -up all available space in its parent widget. If multiple sibling boxes -have this flag set the behaviour is unspecified; some HIDs may prefer -to grow only one box, others may evenly distribute the avaialble space -among boxes. If this flag is not set, the box uses only as much space -as its children widgets require. - - -
-Arrange children widgets in a horizontal or vertical row. - -
-Expect exactly two child widgets. Arrange them horizontally, with -a widget in between them that allows the user to change the space allocation -between the sides. - -
-Expect exactly two child widgets. Arrange them vertically, with -a widget in between them that allows the user to change the space allocation -between the sides. - -
-Place children widgets in a table with cols columns. Widgets are -placed by filling up rows first. If there are not enough widget to finish -the last row, rightmost columns are left empty. -
-The table is homogenous, which means the cell size is the same for all cells -and is either determined by the size of the smallest cell content or if -the table fills in a larger widget space than its minimal size, then cell -space is evenly distributed. - -
-Creates a "tabbed notebook": each child widget ends up on a new -page, there is only one page shown at a time and there is a GUI way -to switch page (the tab). The list of tab names is passed as tabs, -as a NULL terminalte char * array. The number of tab names must match -the number of children widgets. The value -of is an integer index into that array, 0 being the first tab. -
-If compflag includes PCB_HATF_HIDE_TABLAB, the tab graphics are hidden - -no tab labels printed and the user can not click to switch tab. This is -useful for dialog boxes where the code needs to present different tabs -using the same screen estate. -
-If compflag PCB_HATF_LEFT_TAB is set, tab labels are presented in a vertical -row on the left side of the widget. This is useful if there are a lot of -tabs with short names. - -
-Create a new widget by duplicating an existing one. attr is the -widget ID of the existing widget. If the widget being duplicated is a -BEGIN*, it will need a corresponding PCB_DAD_END. - - -
-The raw macro call is PCB_DAD_SET_VALUE, which can change (overwrite) a named -field of the current (last created) widget. The following table lists high -level macros that usually call PCB_DAD_SET_VALUE on a specific field. -
-
name | description - |
---|---|
PCB_DAD_COMPFLAG(table, val) | set all compflags - |
PCB_DAD_MINVAL(table, val) | change the minimal value for numeric input - |
PCB_DAD_MAXVAL(table, val) | change the maximal value for numeric input - |
PCB_DAD_DEFAULT_NUM(table, val) | set the default (initial) value for numeric fields (integers, coords, bools, floats) - |
PCB_DAD_DEFAULT_PTR(table, val) | set the default (initial) value for pointer fields (e.g. strings) - |
PCB_DAD_MINMAX(table, min, max) | hange both the minimal and the maximal value for numeric input - |
PCB_DAD_CHANGE_CB(table, cb) | cb is a function that shall be called upon any change to the widget value - |
PCB_DAD_HELP(table, val) | set the help text (typically presented as a tooltip) - |
-There is a dad() action in the dialogd plugin that exposes all the above macros. -The dialog table ID is am arbitrary unique string and commands are the macro -names without PCB_DAD, written in lowercase. -
-Please refer to scripting rosetta -project for examples. An example of a typical small dialog box is the -unit conveter -script. - Index: run.html =================================================================== --- run.html (revision 34886) +++ run.html (nonexistent) @@ -1,75 +0,0 @@ - -
- --Dialog box data is created in memory using either PCB_DAD_DECL(table) or -PCB_DAD_DECL_NOINIT(table). The first call declares and initializes all -variables and is suitable for when the dialog box is hosted directly in -(static) global variables or as local variables of a function. The _NOINIT -version omits the initialization and is suitable for declaring the dialog box -as part of a struct. In the latter case the caller needs to make sure all -dialog box fields are initialized to zero. -
-How user attached data and memory allocation is managed is described in -the DAD closing sequence document. - -
-The typical sequence of running a non-modal dialog is: -
-(declaration) -(filling in with widgets) -PCB_DAD_NEW(); --
-The modal argument of PCB_DAD_NEW() is pcb_false. The dialog box -is created in the PCB_DAD_NEW() call, which returns immediately, leaving -the dialog box running in the background. -
-The typical sequence of running a modal dialog is: -
-(declaration) -(filling in with widgets) -PCB_DAD_NEW(); -PCB_DAD_RUN(); -(process the return value of PCB_DAD_RUN()) -PCB_DAD_FREE(); --
-The modal argument of PCB_DAD_NEW() is pcb_true. PCB_DAD_RUN() -will not return until the user gets the modal dialog box closed (either -by the VM or by the code). -
-There is an alternative sequence using PCB_DAD_AUTORUN() but it saves -only one line compared to the above code and makes handling the return -value somewhat more complicated. Thus the above sequence should be -preferred. - - -
-After creating the dialog box widgets in memory, the actual GUI can be -started up by a call to action dad(dialog_name, run, title) or -dad(dlgname, run_modal, title). -
-The difference between run and run_modal is when the -call returns: -
-There are two ways a DAD can be closed: -
-There are four sets of structures/allocations associated with a DAD: -
- -There is only one allocation sequence: -
-In other words, one PCB_DAD_NEW() needs to have exactly one PCB_DAD_FREE() -pair. If PCB_DAD_FREE() is called while the dialog is on (code close), -the dialog is closed and the callback function is called (unless it is -already running). The [caller] can access DAD widget states and values -only between PCB_DAD_NEW() and PCB_DAD_FREE(). - Index: wreal.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wreal.png =================================================================== --- wreal.png (revision 34886) +++ wreal.png (nonexistent) Property changes on: wreal.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wtree.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wtree.png =================================================================== --- wtree.png (revision 34886) +++ wtree.png (nonexistent) Property changes on: wtree.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wlabel.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wlabel.png =================================================================== --- wlabel.png (revision 34886) +++ wlabel.png (nonexistent) Property changes on: wlabel.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wbool.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wbool.png =================================================================== --- wbool.png (revision 34886) +++ wbool.png (nonexistent) Property changes on: wbool.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wenum.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wenum.png =================================================================== --- wenum.png (revision 34886) +++ wenum.png (nonexistent) Property changes on: wenum.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: tree.html =================================================================== --- tree.html (revision 34886) +++ tree.html (nonexistent) @@ -1,32 +0,0 @@ - -
- --The table tree widget is a table containint cells arranged in a -fixed number of columns. Each cell is a dynamically allocated -char * string. - -
-These macros, defined in hid_dad.h, are used to fill up the last -created (tree) widget with initial data. They return a row pointer. If the -row pointer is NULL, root is used - in this case insert means inserting at -the beginning of the row list, append means append at the end of the row list. -
-When the tree widget is already created, typically when the dialog box -is already running, the code can use hid_dad_tree.h for reading or -changing cells or rows of the tree. Any change is immediately reflected -on the GUI. Please refer to the comments in hid_dad_tree.h for details -on the functions and arguments. - - - Index: wprogress.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wprogress.png =================================================================== --- wprogress.png (revision 34886) +++ wprogress.png (nonexistent) Property changes on: wprogress.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wpicture.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wpicture.png =================================================================== --- wpicture.png (revision 34886) +++ wpicture.png (nonexistent) Property changes on: wpicture.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: whbox.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: whbox.png =================================================================== --- whbox.png (revision 34886) +++ whbox.png (nonexistent) Property changes on: whbox.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: intro.html =================================================================== --- intro.html (revision 34886) +++ intro.html (nonexistent) @@ -1,56 +0,0 @@ - -
- --Attribute Dialogs were originally invented around the early/mid 2000s for export -HIDs to store a static, flat list of options that are then presented both -as command line options and as the GUI dialog box for export parameters. - -
-DAD is the dyamically allocated version, extended with new widget types for -providing tools for building more complex dialog boxes. It is not connected -with command line options in any way at the moment. -
-The list of widgets is still a flat, growing C array, often called the -table. But inside the table, widgets build as a logical tree -structure. Widgets with name that includes "BEGIN" will open a new -logical layout level that has to be closed with a PCB_DAD_END(). - -
-A table is always built incrementally and sequentially. In this sense -the dialog box is static: once build and created, the number and -type of widgets can not be modified. The dynamic aspect is that the code -may create (and destroy) arbitrary DAD boxes, even with loops and -runtime conditions on what widgets end up in the box. -
-There are two kind of widget calls: widget creation and property set. -Property set calls always change the last created widget. This, by -convention, is often indicated by code indentation as well. For example: -
- PCB_DAD_INTEGER(dlg, "foo"); - PCB_DAD_MINVAL(dlg, 1); - PCB_DAD_MAXVAL(dlg, 10); - PCB_DAD_DEFAULT_NUM(dlg, 3); - widget_id_foo = PCB_DAD_CURRENT(dlg); - PCB_DAD_BUTTON(dlg, "update!"); - PCB_DAD_CHANGE_CB(dlg, pcb_act_attr_chg); --
-PCB_DAD_INTEGER() and PCB_DAD_BUTTON() are (macro) calls to create -new widgets (an integer entry and a button), the rest of the calls -change the last created widget's properties. -
-The main widget of the box, the root widget of the widget tree is -any widget. It is practical to make it a container widget (e.g. a HBOX, VBOX, -TABLE, PANE, or TABBED) so that it can host children widgets. -
-After each creation, the caller can query and store the integer widget -identifier using the PCB_DAD_CURRENT() macro. The widget identifier can -be used, together with the table, to query or change widget properties -and current value any time the dialog box is active. - Index: wtable.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wtable.png =================================================================== --- wtable.png (revision 34886) +++ wtable.png (nonexistent) Property changes on: wtable.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: wvbox.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: wvbox.png =================================================================== --- wvbox.png (revision 34886) +++ wvbox.png (nonexistent) Property changes on: wvbox.png ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -application/octet-stream \ No newline at end of property Index: index.html =================================================================== --- index.html (revision 34886) +++ index.html (revision 34887) @@ -1,14 +1,5 @@
- -