From c93081b8074617a6e66fec94012f4e6d184cb046 Mon Sep 17 00:00:00 2001 From: Miguel de Benito Date: Mon, 28 May 2012 22:17:09 +0000 Subject: [PATCH] Features and fixes (Qt): Support for widgets: texmacs-output, texmacs-input, resize, popup (for help balloons), buttons in dialogs, tweaks here and there. Fixes to layouts and sizing, scroll widgets are dummy for most widgets. Support for side tools as another (floatable) QToolBar. Would a QDockWidget be better? Consistent (albeit partial) support for TeXmacs' widget styles. Support for some more widgets as menu items (i.e. as QActions for QToolBar). Fix placement of context menus. New management of ownership of QWidgets. Cleanup and maintenance (Qt): Comments. Many, many comments. Removed unnecessary files. Grouped common method definitions. Shifting around of code for consistency. Documentation regarding widgets and extension of the UI. XCode: update project for XCode4, new xcconfig for MOC objects fixes linker warnings. To do (Qt): Fine-tune the presentation of QWidgets: remove unnecessary spacing, provide default alignment policies, add better support for widgets in QToolBars (see as_qaction()). Finish the popup widget (timeout, etc.) Why are texmacs widgets so often wrapped into vertical widgets? This messes with scrollable_widget. Understand why QPainter is not properly initialized for output widgets, then remove the hack in Texmacs/Window/tm_button.cpp. --- devel/scheme/gui/scheme-gui-advanced.en.tm | 26 +-- devel/scheme/gui/scheme-gui-intro.en.tm | 49 +++-- devel/scheme/gui/scheme-gui-reference.en.tm | 187 ++++++++++++++++++++ 3 files changed, 235 insertions(+), 27 deletions(-) diff --git a/devel/scheme/gui/scheme-gui-advanced.en.tm b/devel/scheme/gui/scheme-gui-advanced.en.tm index d7df1a9..41851c1 100644 --- a/devel/scheme/gui/scheme-gui-advanced.en.tm +++ b/devel/scheme/gui/scheme-gui-advanced.en.tm @@ -5,23 +5,25 @@ <\body> + + + Setting attributes of widgets is achieved by enclosing them in the + following special widgets: + + , , , ...\ + - + You can arrange widgets horizontally or vertically, or in two column mode + as in forms. When running the QT version the latter will default to the OS + standard for arranging labels and their associated input widgets in + dialogs. - <\scm> - aligned - - - - - - - + , , , , ... - From the definitions... + Shifting of widgets... From the definitions: <\verbatim> ((== x '---) '$---) @@ -51,4 +53,6 @@ \; + + \; \ No newline at end of file diff --git a/devel/scheme/gui/scheme-gui-intro.en.tm b/devel/scheme/gui/scheme-gui-intro.en.tm index da3c60a..406bc25 100644 --- a/devel/scheme/gui/scheme-gui-intro.en.tm +++ b/devel/scheme/gui/scheme-gui-intro.en.tm @@ -3,23 +3,28 @@ <\body> - + - In you create visual interfaces using . This word - means either the basic building blocks you have at your disposal, like - buttons, popup lists, etc. or the collections of those into dialogs, menus - or whatever. This rather loose concept might be confusing, especially when - we refer to what usually are know as dialogs as widgets, but it makes sense - because all sorts of widgets can be aggregated to build more complicated - ones as well.<\footnote> + In you create and extend the visual interface using . + This word means either the basic building blocks you have at your disposal, + like buttons, popup lists, etc. or the collections of those into dialogs, + menu bars or whatever. This rather loose concept might be confusing, + especially when we refer to what usually are know as dialogs as widgets, + but it makes sense because all sorts of widgets can be aggregated to build + more complicated ones as well.<\footnote> If you miss some particular ``building block'' from your OS, you might see whether it's feasible as an aggregation of simpler ones or try and play with the UI interface code in C++ (but you'll have to add it for every supported platform!). + However, it must be kept in mind that items intended to be inserted in a + menu bar won't necessarily display as they do in a separate window: + complicated aggregations of widgets might be better placed in a separate + window or dialogue. + A complete reference with all the available widgets is , some more examples are here and here. @@ -67,8 +72,8 @@ The next step is to add some text next to the button, i.e. a label. This is done with the keyword, as in , but in order - to have both widgets sit side by side, you'll need a - >, such as : + to have both widgets sit side by side, you'll need a , such as : <\session|scheme|default> <\unfolded-io|Scheme] > @@ -115,6 +120,13 @@ The special symbol \\> is just one of the predefined .\ + + + As we said before, menus are special collections of widgets: + + + Let's see how you create a dialog. To get started here is one little @@ -188,11 +200,18 @@ - - is one of the several available container or . + management widgets|scheme-gui-container.en.tm>. It accepts two sorts of + arguments. Either one sets a fixed size for the widget with two strings, as + in the example above, or one passes two lists, the first for widths, the + second for heights, with the minimum, default and maximum values in that + order, like this:\ + + + + This sets to have a default square size of 200x200 + pixels. If you want to add the usual buttons you use like in the following example. Notice that the widget now accepts one parameter @@ -322,8 +341,6 @@ A complete list of the widgets you can embed in a form is in the table inside . - \; - team.> , as of SVN + revision 5238: + + <\scm> + \; + + (define-table gui-make-table + + \ \ (eval ,gui-make-eval) + + \ \ (dynamic ,gui-make-dynamic) + + \ \ (former ,gui-make-former) + + \ \ (link ,gui-make-link) + + \ \ (let ,gui-make-let) + + \ \ (let* ,gui-make-let) + + \ \ (with ,gui-make-with) + + \ \ (receive ,gui-make-with) + + \ \ (for ,gui-make-for) + + \ \ (cond ,gui-make-cond) + + \ \ (refresh ,gui-make-refresh) + + \ \ (group ,gui-make-group) + + \ \ (text ,gui-make-text) + + \ \ (glue ,gui-make-glue) + + \ \ (color ,gui-make-color) + + \ \ (texmacs-output ,gui-make-texmacs-output) + + \ \ (texmacs-input ,gui-make-texmacs-input) + + \ \ (input ,gui-make-input) + + \ \ (enum ,gui-make-enum) + + \ \ (choice ,gui-make-choice) + + \ \ (choices ,gui-make-choices) + + \ \ (toggle ,gui-make-toggle) + + \ \ (icon ,gui-make-icon) + + \ \ (concat ,gui-make-concat) + + \ \ (verbatim ,gui-make-verbatim) + + \ \ (check ,gui-make-check) + + \ \ (balloon ,gui-make-balloon) + + \ \ (-\ ,gui-make-submenu) + + \ \ (=\ ,gui-make-top-submenu) + + \ \ (horizontal ,gui-make-horizontal) + + \ \ (vertical ,gui-make-vertical) + + \ \ (hlist ,gui-make-hlist) + + \ \ (vlist ,gui-make-vlist) + + \ \ (aligned ,gui-make-aligned) + + \ \ (item ,gui-make-item) + + \ \ (meti ,gui-make-meti) + + \ \ (tabs ,gui-make-tabs) + + \ \ (tab ,gui-make-tab) + + \ \ (inert ,gui-make-inert) + + \ \ (explicit-buttons ,gui-make-explicit-buttons) + + \ \ (bold ,gui-make-bold) + + \ \ (tile ,gui-make-tile) + + \ \ (scrollable ,gui-make-scrollable) + + \ \ (resize ,gui-make-resize) + + \ \ (hsplit ,gui-make-hsplit) + + \ \ (vsplit ,gui-make-vsplit) + + \ \ (minibar ,gui-make-minibar) + + \ \ (extend ,gui-make-extend) + + \ \ (padded ,gui-make-padded) + + \ \ (centered ,gui-make-centered) + + \ \ (bottom-buttons ,gui-make-bottom-buttons) + + \ \ (assuming ,gui-make-assuming) + + \ \ (if ,gui-make-if) + + \ \ (when ,gui-make-when) + + \ \ (mini ,gui-make-mini) + + \ \ (symbol ,gui-make-symbol) + + \ \ (promise ,gui-make-promise) + + \ \ (ink ,gui-make-ink) + + \ \ (form ,gui-make-form) + + \ \ (form-input ,gui-make-form-input) + + \ \ (form-enum ,gui-make-form-enum) + + \ \ (form-choice ,gui-make-form-choice) + + \ \ (form-choices ,gui-make-form-choices)) + + \; + + (tm-define (gui-make x) + + \ \ ;;(display* "x= " x "\\n") + + \ \ (cond ((symbol? x) + + \ \ \ \ \ \ \ \ \ (cond ((== x '---) '$---) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '===) (gui-make '(glue #f #f 0 5))) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '======) (gui-make '(glue #f #f 0 + 15))) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '/) '$/) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '//) (gui-make '(glue #f #f 5 0))) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '///) (gui-make '(glue #f #f 15 0))) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '\\) (gui-make '(glue #t + #f 5 0))) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x '\\\) (gui-make + '(glue #t #f 15 0))) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ((== x (string-\symbol "\|")) '$/) + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (else + + \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (texmacs-error "gui-make" "invalid menu + item ~S" x)))) + + \ \ \ \ \ \ \ \ ((string? x) x) + + \ \ \ \ \ \ \ \ ((and (pair? x) (ahash-ref gui-make-table (car x))) + + \ \ \ \ \ \ \ \ \ (apply (car (ahash-ref gui-make-table (car x))) (list + x))) + + \ \ \ \ \ \ \ \ ((and (pair? x) (or (string? (car x)) (pair? (car x)))) + + \ \ \ \ \ \ \ \ \ \0($\ ,(gui-make (car x)) ,@(cdr x))) + + \ \ \ \ \ \ \ \ (else + + \ \ \ \ \ \ \ \ \ \ (texmacs-error "gui-make" "invalid menu item ~S" + x)))) + + \; + + \; team.>