Update of /cvsroot/eas-dev/clip-ui In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv3248 Added Files: AUTHORS ChangeLog LICENSE Makefile.in TODO button.prg checkbox.prg clip-ui.ch color.prg combobox.prg configure edit.prg font.prg form.prg frame.prg grid.prg image.prg label.prg layout.prg menu.prg progressbar.prg project.kateproject radiobutton.prg slider.prg special.prg table.prg timer.prg toolbar.prg tree.prg utils.prg window.prg workspace.prg Log Message: Add files --- NEW FILE: AUTHORS --- Andrey (Skull) Cherepanov <sk...@ea...> Igor Satsyuk <sa...@tu...> --- NEW FILE: ChangeLog --- 2006-06-02 - UIGrid: add expand flags to pos (+ at axes end) - small fixes in UIForm - UIFont now supports font size in form +XX or -XX 2006-04-06 clip-ui 0.1.2.4 - configure stript - remove XMLTag() and use clip-xml for XML parsing 2005-11-14 clip-ui 0.1.2.3 - new methods: UIButton: setText() UITable: savePosition(), restorePosition() UITree: savePosition(), restorePosition() - new function: getMainWindow() - fix alignment for UIGrid - UIForm support "Image" widget class (UIImage) 2005-07-01 - FIX: put in scrolled window by gtk_ScrolledWindowAddWithViewport() 2005-04-04 - new classes: UIEditColor, UIEditDate, UIEditFileName - methods: setFocus() [UIChildWindow,UIDocument], setAction() [UIWorkSpace] - support signal names in setAction() methods 2005-03-18 - new predefined icons: IMG_WARNING, IMG_QUESTION - new classes: UILayout, UIProgressBar, UIRadioGroup, UIRadioButton, UISlider, UITableItem, UITreeItem - new methods: appendText() [UIEdit,UIEditText], setCaption() [UIChildWindow] 2005-02-25 clip-ui 0.1.2.2 - new function useDriver() for driver choose - new driver: gtk2 (GTK+ 2.xx driver) 2005-02-03 - fix Makefile 2005-02-01 - new method setAction() for UIEdit/UIEditText (on changed) 2005-01-31 - new method clear() in UIMenuBar/UIPopupMenu/UIToolBar --- NEW FILE: LICENSE --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS --- NEW FILE: Makefile.in --- # This is a part of CLIP-UI library # # Copyright (C) 2003 by E/AS Software Foundation # Author: Andrey Cherepanov <sk...@ea...> ifndef CLIPROOT CLIPROOT=$(shell cd ../../../; pwd)/cliproot endif include $(CLIPROOT)/include/Makefile.inc DRIVERSDIR = $(DESTDIR)$(CLIPROOT)/lib/drivers CLIPINCLUDE = -I$(CLIPROOT)/include CLIP = $(CLIPROOT)/bin/clip .SUFFIXES: .prg .o .po # Here you can define appropriate compile settings #C_FLAGS=-Wall -g -I. $(CLIPINCLUDE) #CC=gcc TARGET = libclip-ui$(DLLSUFF) RTARGET = libclip-ui$(DLLREALSUFF) OBJS = button.o checkbox.o color.o combobox.o edit.o font.o form.o \ frame.o grid.o image.o label.o layout.o menu.o \ progressbar.o radiobutton.o slider.o special.o table.o timer.o \ toolbar.o tree.o utils.o window.o workspace.o .PHONY: all clean uninstall distclean all: var.ch driver $(TARGET) var.ch: echo "#define DRIVERSDIR \"$(DRIVERSDIR)\"" >var.ch driver: cd drivers && $(MAKE) all $(TARGET): $(OBJS) $(CLIPROOT)/bin/clip_makeslib $(TARGET) $(OBJS) clean: cd drivers && $(MAKE) clean cd example && $(MAKE) clean rm -f Makefile $(OBJS) $(TARGET) var.ch *.bak *.nm *.ex *.ppo *.dll.a *.log *.dll clear: clean install: all cd drivers && $(MAKE) install mkdir -p $(DESTDIR)$(CLIPROOT)/lib mkdir -p $(DESTDIR)$(CLIPROOT)/include $(CLIPROOT)/bin/clip_cp $(TARGET) $(DESTDIR)$(CLIPROOT)/lib $(CLIPROOT)/bin/clip_cp $(RTARGET) $(DESTDIR)$(CLIPROOT)/lib $(CLIPROOT)/bin/clip_cp clip-ui.ch $(DESTDIR)$(CLIPROOT)/include mkdir -p $(DESTDIR)$(CLIPROOT)/doc/example/clip-ui cp -R example/* $(DESTDIR)$(CLIPROOT)/doc/example/clip-ui/ uninstall: cd drivers && $(MAKE) uninstall rm -rf $(CLIPROOT)/lib/$(TARGET) $(CLIPROOT)/lib/$(RTARGET) $(CLIPROOT)/doc/example/clip-ui/ rm -f $(CLIPROOT)/include/clip-ui.ch distclean: clean dist: distclean cd .. && tar cvfz clip-ui.tgz clip-ui .prg.o: clip-ui.ch $(CLIP) -w $(CLIPINCLUDE) $< commit: _cvs commit update: _cvs update -dP ucommit: _cvs update -dP && _cvs commit shell: sh --- NEW FILE: TODO --- TODO ==== Last change: 06 Apr 2006 CLIP-UI ------- - Debug function for UIForm and debug lebel for library (possible, CLIP-wide) - Spreadsheet widget - Set slot functions for window open, activation, close - New widgets: - UIChoice (for select object) - UITab - DnD methods for UITable/UITree - Deletion of widget from comtainers - Disallow editing in UIComboBox field - Using ID in UIComboBox - gtk_ScrolledWindowNew() make child widget too small - sent command line parameters to gtk_Init() - Default selection needed for UIComboBox in forms - usablity issues for UISlider: value should be step multiple, step indication under slider - icons for UIChildWindow - wrong setFocus() behaviour for widgets in UIChildWindow/UIDocument - UIEditDate should display calendar in popup window - UIEditDate: date should be selected by keyboard - add method setProperty() for each widget - calendar for UIDateEdit should be placed in popup window with buttons 'select' and 'close' FORM ---- - debug unclosed tags (<form /></form>) - "alignment.vertical" and "alignment.horizonal" widget properties - program for test form (include child window too) - fix bug in HTTP parser with unknown locales (C, ru_RU.UTF-8) - empty tag names GTK --- - Input numero sign or typographic quotes - unscrollable position of column header (GTK/GTK2) Documentation ------------- - separate section "CLIP-UI" in CLIP documentation - XFL format description - list support (and any other Docbook tags) in .txt class/funcs description files - UIDriver class - full attribute list of window classes ------------------------------------------------------------------------------- See TODOs on web-site: http://eas.lrn.ru/index.php?module=request (on Russian) ------------------------------------------------------------------------------- --- NEW FILE: button.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* Button class */ function UIButton( label, action, val ) local obj := driver:createButton(label, action) obj:className := "UIButton" obj:val := val _recover_UIBUTTON(obj) return obj function _recover_UIBUTTON( obj ) obj:setText := @ui_setText() obj:setAction := @ui_setAction() obj:setPadding := @ui_setPadding() obj:setValue := @ui_setValue() obj:getValue := @ui_getValue() return obj /* Button bar class */ function UIButtonBar() local obj := UIHBox(, 5, 3 ) obj:className := "UIButtonBar" obj:setEqualSize( .T. ) obj:setAlignment( 0 ) return obj /* Change button label */ static function ui_setText(self, text) driver:setButtonText(self, text) return NIL /* Connect action to button */ static function ui_setAction(self, signal, action) if signal=='clicked' .and. valtype(action)=='B' driver:setAction( self, "clicked", action) driver:enableWidget( self, .T. ) endif return NIL /* Set button padding */ static function ui_setPadding(self, padding) driver:setPadding( self, padding ) return NIL /* Set value */ static function ui_setValue(self, value) self:val := value return NIL /* Get value */ static function ui_getValue(self) return self:val --- NEW FILE: checkbox.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* Checkbox class */ function UICheckBox( value, label ) local obj := driver:createCheckBox(value, label) obj:className := "UICheckBox" _recover_UICHECKBOX(obj) return obj function _recover_UICHECKBOX( obj ) obj:setValue := @ui_setValue() obj:getValue := @ui_getValue() return obj /* Set value */ static function ui_setValue(self, value) driver:setValue( self, value ) return NIL /* Get value */ static function ui_getValue(self) return driver:getValue( self ) --- NEW FILE: clip-ui.ch --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ /* Header file for common CLIP-UI definition */ #define lib_version "0.1.2.4" /* Default driver name */ #define DEFAULT_DRIVER "gtk" /* Page settings for UIPrinter. TODO: need to move in client sources */ /* Measurement units */ #define PRINT_PT 0 #define PRINT_CM 1 #define PRINT_MM 2 #define PRINT_INCH 3 /* Page orientation */ #define PAGE_PORTRAIT 0 #define PAGE_LANDSCAPE 1 /* Page size */ #define PAGE_A4 0 /* Cell anchoring */ #define CELL_ABOVE 0 #define CELL_BELOW 1 #define CELL_LEFT 2 #define CELL_RIGHT 3 /* Cell align */ #define ALIGN_LEFT 0 #define ALIGN_CENTER 1 #define ALIGN_RIGHT 2 #define ALIGN_JUSTIFY 3 #define ALIGN_TOP 0 #define ALIGN_MIDDLE 1 #define ALIGN_BOTTOM 2 /* Cell side anchoring */ #define CELL_SIDE_BOTTOM 0 #define CELL_SIDE_LEFT 1 /* Points in mm */ /* Note: if you use ps2pdf command for covert to PDF PT_IN_MM is equal 2.946 */ /* PT_MARGIN is 12 */ #define PT_IN_MM 2.83465 #define PT_MARGIN 0 /* COLOR */ #define ALT_TABLE_ROW_COLOR "#eef6ff" /* Preview programs */ #define WINDOWS_PRINT_PREVIEW "start" #define UNIX_PRINT_PREVIEW "ggv" /* SPLITTER DIRECTION */ #define SPLITTER_HORIZONTAL 0 #define SPLITTER_VERTICAL 1 /* IMAGES */ #define IMG_EMPTY 1 // Empty transparent pixmap #define IMG_OK 2 // i #define IMG_ERROR 3 // Error (cross on red field) #define IMG_WARNING 4 // Exclamation mark #define IMG_QUESTION 5 // ? /* FRAME TYPES */ #define FRAME_PLAIN 0 #define FRAME_SUNKEN 1 #define FRAME_RAISED 2 #define FRAME_IN 3 #define FRAME_OUT 4 --- NEW FILE: color.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* UIColor class */ function UIColor( color, opacity ) local r, g, b, o local obj := map() color := iif(empty(color),"#000000",color) if left(color,1) != '#' obj = driver:colorParse(color) else o := iif(empty(opacity),255,opacity) r := cton(substr(color,2,2),16) g := cton(substr(color,4,2),16) b := cton(substr(color,6,2),16) obj:red := iif(r==0,0,(r+1)*256-1) obj:green := iif(g==0,0,(g+1)*256-1) obj:blue := iif(b==0,0,(b+1)*256-1) obj:opacity := iif(o==0,0,(o+1)*256-1) endif obj:className := "UIColor" return obj --- NEW FILE: combobox.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* Combobox class */ function UIComboBox( values, defaultItem ) local obj := driver:createComboBox( values ) obj:className := "UIComboBox" obj:list := values _recover_UICOMBOBOX(obj) if .not. empty( defaultItem ) driver:setValue( obj, defaultItem ) endif return obj function _recover_UICOMBOBOX( obj ) obj:setList := @ui_setList() obj:setValue := @ui_setValue() obj:getValue := @ui_getValue() obj:setValueInList := @ui_setValueInList() return obj /* Set list of strings */ static function ui_setList(self, values) self:list := values driver:setComboBoxList( self, values ) return NIL /* Set value */ static function ui_setValue(self, value) driver:setValue( self, value ) return NIL /* Get value */ static function ui_getValue(self) return driver:getValue( self ) /* Value entered in the text entry field must match one of the values in the list */ static function ui_setValueInList(self, flag) return driver:setComboBoxValueInList(self, flag) --- NEW FILE: configure --- #!/bin/sh libdir="$CLIPROOT/lib" if [ ! -f "$libdir/libclip-xml.so" ] then echo "Warning: library clip-xml does not installed on your system" exit 1 fi cp Makefile.in Makefile exit 0 --- NEW FILE: edit.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* TODO: control wordwrap for UIEditText */ /* EditText class */ function UIEdit(value) local obj := driver:createEdit() obj:className := "UIEdit" _recover_UIEDIT(obj) obj:setValue( value ) obj:setPassword := @ui_editSetPassword() return obj /* EditText class */ function UIEditText(value) local obj := driver:createEditText(value) obj:className := "UIEditText" if .not. empty(value) ui_setValue(obj, value) endif _recover_UIEDIT(obj) return obj function _recover_UIEDIT( obj ) obj:getGeometry := @ui_getGeometry() obj:setGeometry := @ui_setGeometry() obj:setValue := @ui_setValue() obj:getValue := @ui_getValue() obj:readOnly := @ui_setReadOnly() obj:setAction := @ui_setEditAction() obj:appendText := @ui_appendText() return obj /* Get widget geometry: position and size */ static function ui_getGeometry( self ) local geom geom := driver:getGeometry( self ) return( geom ) /* Set widget geometry: position and size */ static function ui_setGeometry( self, geom ) driver:setGeometry( self, geom ) return NIL /* Set value */ static function ui_setValue(self, value) driver:setValue( self, val2str(value) ) return NIL /* Get value */ static function ui_getValue(self) return driver:getValue( self ) /* Set state to read-only */ static function ui_setReadOnly(self, flag) if empty(flag) flag := .T. endif driver:editSetReadOnly(self,flag) return /* Set state to password mode (if TRUE) */ static function ui_editSetPassword(self, flag) flag := iif(valtype(flag)=="U",.T.,flag) driver:editSetPassword(self,flag) return /* Set action for edit entry */ static function ui_setEditAction(self, signal, action) if signal=='changed' .and. valtype(action)=='B' driver:setAction( self, "changed", action) endif return .T. /* Append text to the end of current text */ static function ui_appendText(self, text) driver:setValue( self, val2str(text), .T.) return .T. /* EditDate class */ function UIEditDate(value, caption) local button, obj obj := UIEdit(value) caption := iif(empty(caption),"Select Date",caption) button := UIButton("...", {|| driver:showCalendar(caption, obj:getValue(), obj) }) obj:stick := map() obj:stick:right := button return obj /* EditFileName class */ function UIEditFileName(value, caption) local button, obj obj := UIEdit(value) caption := iif(empty(caption),"Select File",caption) button := UIButton("...", {|| driver:selectFileName(caption, obj:getValue(), obj) }) obj:stick := map() obj:stick:right := button return obj /* EditColor class */ function UIEditColor(value, caption) local button, obj obj := UIEdit(value) caption := iif(empty(caption),"Select Color",caption) button := UIButton("...", {|| driver:selectColor(caption, obj:getValue(), obj) }) obj:stick := map() obj:stick:right := button return obj /* EditNumber class */ /*????*/ /* EditReference class */ /*????*/ --- NEW FILE: font.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2004-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* UIFont class */ function UIFont( family, style, size, encoding ) local obj := map() obj:className := "UIFont" obj:font := "" obj:family := family obj:style := style obj:size := size obj:encoding := encoding _recover_UIFONT(obj) if driver:driver == "gtk" if left(family,1) == '-' obj:font := obj:parseFont( family ) else obj:font := obj:parseFont() endif else if style == NIL .and. size == NIL obj:font := obj:parseFont2( family ) else obj:font := obj:parseFont2() endif endif return obj function _recover_UIFONT( obj ) obj:setProperty := @ui_setProperty() obj:parseFont := @ui_parseFont() obj:parseFont2 := @ui_parseFont2() return obj /* Set property for font */ static function ui_setProperty(self, property, value) switch upper(property) case 'FAMILY' self:family := value case 'STYLE' self:style := value case 'SIZE' //?? "Size before:", valtype(self:size), self:size,chr(10) if empty(self:size) self:size := 10 endif if valtype( value ) == 'C' if left( value, 1 ) == '+' value := self:size + val(substr(value,2))*2 elseif left( value, 1 ) == '-' value := self:size - val(substr(value,2))*2 else value := val( value ) endif endif self:size := value case 'ENCODING' self:encoding := value endswitch if driver:driver == "gtk" self:font := self:parseFont() else self:font := self:parseFont2() endif //?? "NEW FONT:", self:font,chr(10) return /* Parse font (XWindow font name) */ static function ui_parseFont(self, string) local a, ff, fn, fs, fe, lang if .not. empty(string) // Font string like -monotype-arial-medium-r-normal--12-0-0-0-p-0-koi8-r a = split(string,'-') self:family := a[3] if a[4] == 'bold' self:style := 'bold' if a[5] == 'i' self:style := 'bolditalic' endif elseif a[5] == 'i' self:style := 'italic' else self:style := 'normal' endif self:size := val(a[9])/10 self:encoding := a[14]+'-'+a[15] return string else // Composite font ff := iif( empty(self:family), 'helvetica', self:family ) fn := iif( empty(self:style), 'normal', lower(self:style) ) fs := iif( empty(self:size), '', alltrim(str(self:size)) ) lang := split(getenv("LANG"),'\.') if len(lang) > 1 fe := lower(lang[2]) else fe := 'iso8859-1' endif string := '-*-'+ff+'-'+iif(left(fn,4)=='bold','bold','medium') string += '-'+iif(right(fn,6)=='italic','i','r')+'-'+'normal'+'-' string += '-'+fs+'-*-*-*-*-*-'+fe return string endif return /* Parse font (GTK2 font name) */ static function ui_parseFont2(self, string) local a, l, i, ff, fn, fs, fe if .not. empty(string) // Font string like "Sans Medium 10" a = split(string,' ') l := len(a) if l == 2 // Only family and size self:style := "Medium" else self:style := a[l-1] adel(a, l-1) l := l-1 endif self:size := val(a[l]) l := l-1 self:family := "" for i:=1 to l self:family += " "+a[i] next self:family := alltrim(self:family) return string else // Composite font ff := iif( empty(self:family), 'Sans', self:family ) fn := iif( empty(self:style) .or. upper(self:style)=="NORMAL", 'Medium', lower(self:style) ) fs := iif( empty(self:size), '10', alltrim(str(self:size)) ) string := ff+" "+fn+" "+fs return string endif return --- NEW FILE: form.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2006 by E/AS Software Foundation */ /* Authors: */ /* Andrey Cherepanov <sk...@ea...> */ /* Igor Satsyuk <sa...@tu...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ #include "clip-ui.ch" #define DEBUG .F. static driver := getDriver() /* Interface form class */ function UIForm( fileName, parent ) local obj := map() obj:parent := parent obj:className := "UIForm" obj:fileName := fileName obj:oXml := NIL obj:widgets := map() obj:names := array(0) obj:actions := array(0) obj:src := NIL obj:locale := map() _recover_UIFORM(obj) return obj function _recover_UIFORM( obj ) obj:parseFile := @ui_parseFile() obj:parseString := @ui_parseString() obj:parse := @ui_parse() obj:createWidget := @ui_createWidget() obj:setProperty := @ui_setProperty() obj:getPropertyValue := @ui_getPropertyValue() obj:setAction := @ui_setAction() obj:setPreAction := @ui_setPreAction() obj:actionHandler := @ui_actionHandler() obj:subActionHandler := @ui_subActionHandler() obj:i18n := @ui_form_i18n() return obj /* Parse form from file */ static function ui_parseFile(self) local fileName fileName := self:fileName set translate path off if DEBUG ?? "UIForm: file parsing...&\n" endif // Parse file self:oXml := XMLTree() if .not. self:oXml:parseFile( fileName ) ?? "ERROR: Cannot open form file '"+fileName+"': "+self:oXml:getError()+chr(10) return NIL endif if DEBUG ?? "UIForm: file parsing complete&\n" endif return self:parse() /* Parse form from string */ static function ui_parseString(self, str) if DEBUG ?? "UIForm: string parsing...&\n" endif // Parse string self:oXml := XMLTree() if .not. self:oXml:parseString( str ) ?? "ERROR: Cannot open form file: "+self:oXml:getError()+chr(10) return NIL endif if DEBUG ?? "UIForm: string parsing complete&\n" endif return self:parse() /* Parse form */ static function ui_parse(self) local win := NIL, res, t, i if DEBUG ?? "UIForm: form parsing...&\n" endif if self:oXml:getRoot() == NIL ?? "ERROR: there isn't root element.&\n" return win else self:root := self:oXml:getRoot() endif /* Locale */ self:locale := getLocaleStrings(self:root) /* Root widget */ res := self:oXml:XPath("/interface/widget") if empty(res) .or. len(res) == 0 ?? "ERROR: no root widget!&\n" return NIL endif t := res[1] //?? "PARENT window for form: ",valtype(self:parent),chr(10) if DEBUG ?? "UIForm: create widgets...&\n" endif win := ui_createWidget(self, t, self:parent) if empty(win) return NIL endif if DEBUG ?? "UIForm: set properties...&\n" endif /* Set properties */ t := self:oXml:XPath("/style/*") for i in t ui_setProperty(self, i, NIL) next if DEBUG ?? "UIForm: set actions...&\n" endif /* Set actions */ t := self:oXml:XPath("/actions/*") for i in t ui_setAction(self, i, NIL) next if DEBUG ?? "UIForm: set preliminary actions...&\n" endif /* Set pre actions */ res := self:oXml:XPath("/head") if empty(res) .or. len(res) == 0 ?? "ERROR: no <head> tag!&\n" return NIL endif self:setPreAction(res[1], NIL) if DEBUG ?? "UIForm: form parsing complete&\n" endif return win /* Return created widget from tag */ static function ui_createWidget(self, tag, parent ) local o:=NIL, class, name, label, c, i, a, e, w, box, t:=tag local add:=.F., gCol:=1, gRow:=1, gClass, rule class := t:attribute("class","") name := t:attribute("name","") label := self:i18n( t:attribute("label","") ) rule := t:attribute("rule",NIL) switch upper(class) /* Grid */ case "HBOX" o := UIHBox() add := .T. case "VBOX" o := UIVBox() add := .T. case "HSPLITTER" o := UISplitter(SPLITTER_HORIZONTAL) add := .T. case "VSPLITTER" o := UISplitter(SPLITTER_VERTICAL) add := .T. case "GRID" gCol := val(getProperty(self:root, t, "cols")) gRow := val(getProperty(self:root, t, "rows")) o := UIGrid(, gRow, gCol) add := .T. case "LAYOUT" o := UILayout() add := .T. /* Widgets */ case "MAINWINDOW" o := UIMainWindow(label,name) self:w := o if empty(o) return NIL endif case "WINDOW" o := UIWindow(label,parent,name,.F.) self:w := o if empty(o) return NIL endif case "CHILDWINDOW" o := UIChildWindow(label,parent,name) self:w := o if empty(o) return NIL endif case "DOCUMENT" o := UIDocument(label,parent,name) self:w := o if empty(o) return NIL endif case "MENUBAR" o := UIMenu() parent:setPanels(o,,) case "MENUITEM" if ascan(t:childs,{|e| e:getName() == "widget" }) == 0 i := parent:add(,label,) o := parent:elem[i] endif case "MENUCHECKEDITEM" i := parent:addChecked(,label,NIL) o := parent:elem[i] case "POPUPMENU" o := UIPopupMenu() parent:add(,label,o) case "MENUSEPARATOR" parent:addSeparator() return NIL case "TOOLBAR" o := UIToolBar() parent:setPanels(,o,) case "TOOLBUTTON" i := parent:addButton(NIL,label,NIL) o := parent:elem[i] case "STATUSBAR" o := UIStatusBar() parent:setPanels(,,o) o:setText(label) case "TABLE" a := array(0) for e in t:getChilds() if e:getName() == "column" aadd( a, self:i18n(e:attribute("title",""))) endif next if len(a) > 0 o := UITable( a ) add = .T. else ?? "No defined columns for Table widget&\n" endif case "TREE" a := array(0) for e in t:getChilds() if e:getName() == "column" aadd( a, self:i18n(e:attribute("title",""))) endif next if len(a) > 0 o := UITree( 1, a ) add = .T. else ?? "No defined columns for Tree widget&\n" endif /* case "SHEET" a := array(0) for e in t:childs if e:name == "COLUMN" aadd( a, self:i18n(e:attr["TITLE"])) endif next o := UISheet( a ) add = .T. */ case "BUTTONBAR" if "ACTIONS" $ parent o := parent:actions else o := UIButtonBar( parent ) add = .T. endif case "BUTTON" o := UIButton( label, NIL) add = .T. case "LABEL" o := UILabel(label) add = .T. case "EDIT" o := UIEdit() add = .T. case "EDITTEXT" o := UIEditText() add = .T. case "EDITDATE" o := UIEditDate() add = .T. case "EDITFILENAME" o := UIEditFileName() add = .T. case "EDITCOLOR" o := UIEditColor() add = .T. case "CHECKBOX" o := UICheckBox(,label) add = .T. case "COMBOBOX" o := UIComboBox() add = .T. case "IMAGE" o := UIImage( iif(isfunction("GETRESOURCE"), ; clip("GETRESOURCE", label), label) ) add = .T. case "RADIOGROUP" o := UIRadioGroup() o:box := parent case "RADIOBUTTON" if parent:className == "UIRadioGroup" o := parent:addButton(label) parent := parent:box add = .T. else ?? "WARNING: radiobutton must be placed into radiogroup&\n" endif case "FRAME" o := UIFrame(label) add = .T. case "PROGRESSBAR" o := UIProgressBar(label) add = .T. case "SLIDER" o := UISlider() add = .T. otherwise ?? "WARNING: Unknown class:",class,chr(10) endswitch if .not. empty(name) aadd(self:names,name) self:widgets[name] := o if "W" $ self w := self:w w:setName(name,o) w:valueTypes[name] := t:attribute("type",NIL) endif endif if .not. empty(rule) .and. .not. empty(self:w) .and. "SYSMENUS" $ self:w self:w:sysMenus[rule] := o // ?? "SYSMENU:",rule,"=",valtype(o),chr(10) endif /* Add to grid */ if add == .T. gClass := iif("O" $ parent, parent:o, parent) box := iif("USERSPACE" $ parent,parent:userSpace,parent) if gClass:className == "UIGrid" .or. gClass:className == "UILayout" gRow := t:attribute("pos","") parent:add( o, gRow ) elseif gClass:className == "UISplitter" if empty( parent:first ) parent:add( o ) else parent:addEnd( o ) endif else if class=="table" .or. o:className=="UISplitter" .or. o:className=="UIEditText" box:add( o, .T., .T. ) else box:add( o, .F., iif(box:className=="UIButtonBar",.T.,.F.) ) endif endif endif t:o := o /* Loop child widgets */ if o == NIL o := parent endif for c in t:getChilds() if c:getName() == "widget" ui_createWidget(self, c, o) elseif c:getName() == "property" ui_setProperty(self, c, o) elseif c:getName() == "rule" ui_setAction(self, c, o) elseif ascan({"column"},{|ev| ev==c:getName()}) != 0 // Nothing do else ?? "WARNING: tag "+c:getName()+" is ignored&\n" endif next return o /* Set property for widget */ static function ui_setProperty(self, tag, obj, value) local class, name, widget, row, block, t:=tag, elem, node, nName, nParent, nSibling, nArr if t != NIL class := t:attribute("class","") name := t:attribute("name","") widget := t:attribute("widget","") value := iif(value==NIL,t:attribute("value",""),value) //?? name, value, chr(10) if ascan({"rows","cols"},{|ev| ev==name}) > 0 return .F. endif endif if DEBUG ?? "UIForm: setProperty() for "+widget+':'+name+' = '+value,chr(10) endif obj := iif(obj==NIL,mapget(self:widgets,widget,NIL),obj) if obj == NIL return .F. endif switch name case "altColor" if .not. "SETALTROWCOLOR" $ obj; return .F.; endif obj:setAltRowColor(value) case "label" if .not. "SETTEXT" $ obj; return .F.; endif obj:setText(value) case "value" if .not. "SETVALUE" $ obj; return .F.; endif if obj:className == "UICheckBox" if ascan({"YES","TRUE"}, {|ev| ev==upper(value)}) > 0 value := .T. elseif ascan({"NO","FALSE"}, {|ev| ev==upper(value)}) > 0 value := .F. else return .F. endif endif obj:setValue(value) case "geometry" if .not. "SETGEOMETRY" $ obj; return .F.; endif obj:setGeometry(splitGeom(value,4)) case "geometry.width" if .not. "SETGEOMETRY" $ obj; return .F.; endif obj:setGeometry(val(value)) case "geometry.height" if .not. "SETGEOMETRY" $ obj; return .F.; endif obj:setGeometry({,val(value)}) case "MDI" if .not. "SETMDI" $ obj; return .F.; endif if value == "true" obj:setMDI() endif case "spacing" if .not. "SETSPACING" $ obj; return .F.; endif obj:setSpacing(val(value)) case "padding" if .not. "SETPADDING" $ obj; return .F.; endif obj:setPadding(val(value)) case "position" if .not. "SETPLACEMENT" $ obj; return .F.; endif if value == "center" obj:setPlacement( .T. ) endif case "readOnly" if .not. "READONLY" $ obj; return .F.; endif if value == "true" obj:readOnly( .T. ) endif case "values" if .not. "SETLIST" $ obj; return .F.; endif block := "{|| {"+value+"} }" row := eval(&block) obj:setList( row ) case "selection" if obj:className != "UIComboBox"; return .F.; endif obj:setValue( val(value) ) case "type" if obj:className != "UIFrame"; return .F.; endif switch upper(value) case "PLAIN" obj:setType(FRAME_PLAIN) case "RAISED" obj:setType(FRAME_RAISED) case "SUNKEN" obj:setType(FRAME_SUNKEN) case "IN" obj:setType(FRAME_IN) case "OUT" obj:setType(FRAME_OUT) endswitch case "icon" if .not. "SETICON" $ obj; return .F.; endif obj:setIcon(UIImage( iif(isfunction("GETRESOURCE"), ; clip("GETRESOURCE", value), value) ) ) case "row" if obj:className != 'UITable' .and. obj:className != 'UITree'; return .F.; endif block := "{|| {"+value+"} }" row := eval(&block) elem := t:attribute("element",NIL) if obj:className == 'UITable' obj:addRow( row, elem ) else if .not. 'NODENAMES' $ obj obj:nodeNames := map() endif nArr := split(elem, "\.") nName := '' nParent := NIL nSibling := NIL switch len(nArr) case 1 nName := nArr[1] case 2 nName := nArr[1] nParent := mapget(obj:nodeNames,nArr[2],NIL) case 3 nName := nArr[1] nParent := mapget(obj:nodeNames,nArr[2],NIL) nSibling := mapget(obj:nodeNames,nArr[3],NIL) endswitch //?? nArr, nName, nParent, nSibling,chr(10) obj:nodeNames[nName] := obj:addNode (row, nName, nParent, nSibling) // (columns,id,parent,sibling) endif case "range" if obj:className != "UISlider"; return .F.; endif obj:setRange(value) case "step" if obj:className != "UISlider"; return .F.; endif obj:setStep(value) otherwise driver:setStyle(obj, name, value, t:attribute("element",NIL)) endswitch return .T. /* Get property value. Lookup under current tag and style */ static function getProperty(tree, obj, name, def) local e, widget, class, ret:=def if valtype(obj) != "O" .or. obj:className != "XMLTag" ?? "ERROR: object is broken&\n" return def endif // Child properties widget := obj:attribute("name","") for e in obj:getChilds() if e:attribute("name","")==name ret := e:attribute("value",def) endif next return ret /* Return widget property value */ static function ui_getPropertyValue(self, tagObj) local val:=NIL, widget, prop, obj if valtype(tagObj) != "O" .or. tagObj:className != "XMLTag" ?? "ERROR: object is broken&\n" return NIL endif widget := tagObj:attribute("widget","") prop := tagObj:attribute("name","") obj := mapget(self:widgets,widget,NIL) if empty(obj) ?? "ERROR get property for widget '"+widget+"': widget not found&\n" return NIL endif if prop == "object" return obj endif if obj:className == "UIMenuItem" .and. prop == "isChecked" return driver:isCheckedMenuItem( obj ) endif return val /* Set action for widget */ static function ui_setAction(self, tag, lObj) local e, obj, widget, signal, events, actions, j, id, labelRule, t:=tag local cWidget if t:getName() != "rule" ?? "WARNING: rule tag must be <rule>. Rule is ignored.&\n" return .F. endif if len(t:getChilds()) == 0 ?? "WARNING: rule is empty. Ignored.&\n" return .F. endif // TODO: labelled form rule support on menu labelRule := self:i18n( t:attribute("label",NIL) ) if .not. empty(labelRule) // ?? "Action:",labelRule,chr(10) endif // Retrieve data events := array(0) actions := array(0) for e in t:getChilds() if e:getName() == "event" // Event condition widget := e:attribute("widget","") signal := e:attribute("signal","") obj := iif(lObj==NIL,mapget(self:widgets,widget,NIL),lObj) if obj == NIL .or. empty(widget) .or. empty(signal) ?? "WARNING: widget '"+widget+"' is not found. Ignored&\n" return .F. endif aadd(events,{ obj, signal }) elseif e:getName() == "action" // Actions if len(events) == 0 ?? "WARNING: condition is not found. Ignored&\n" return .F. endif for j in e:getChilds() widget := j:attribute("widget",NIL) /*if valtype(widget) == 'C' cWidget := widget elseif valtype(widget) == 'O' cWidget := '{'+widget:className+'}' else cWidget := '<unknown>' endif //?? "set action for widget "+cWidget,chr(10) if .not. empty(widget) j:setAttribute( "widget", mapget(self:widgets,widget,NIL) ) endif*/ aadd(actions, j) next else ?? "WARNING: unknown tag "+e:getName()+" in '"+self:fileName+"'. Ignored&\n" endif next // Set actions aadd(self:actions, actions) id := len(self:actions) for e in events obj := e[1] signal := e[2] if "SETACTION" $ obj obj:setAction(signal,{|| self:actionHandler( id ) }) else ?? "WARNING: cannot link action to widget class '",obj,"'&\n" endif next return .T. /* Set pre action for form */ static function ui_setPreAction(self, tag, lObj) local e, widget, actions, id, t:=tag, cWidget // Retrieve data actions := array(0) for e in t:getChilds() if e:getName() == "call" widget := e:attribute("widget",NIL) /*if valtype(widget) == 'C' cWidget := widget elseif valtype(widget) == 'O' cWidget := '{'+widget:className+'}' else cWidget := '<unknown>' endif //?? "set pre action for widget "+cWidget,chr(10) if .not. empty(widget) e:setAttribute( "widget", mapget(self:widgets,widget,NIL) ) endif*/ //?? "post widget:",valtype(e:attribute("widget")),chr(10) aadd(actions, e) endif next aadd(self:actions, actions) id := len(self:actions) self:actionHandler( id ) return .T. /* Form action handler */ static function ui_actionHandler(self, id, addVal) local i, acts /* DEBUG print if valtype(id) != "O" ?? "Action handler:",valtype(id), id, addVal,chr(10) else ?? "Action handler:",valtype(id), id:name, addVal,chr(10) endif */ if valtype(id) == "N" acts := self:actions[id] else acts := id:getChilds() //?? "returned:",addVal,chr(10) endif for i in acts self:subActionHandler(i, addVal) next return NIL /* Recursive action execution */ static function ui_subActionHandler(self, tag, addVal) local widget, method, ret, subItem, retAction, value, i, condVal, chkVal local iArr local e, c, p, params:=array(0) if tag:getName() == "returnedvalue" // ?? "returned value:", addVal, chr(10) return addVal endif if tag:getName() == "property" if len(tag:getChilds()) > 0 // ?? "val ->",addVal,chr(10) value := self:subActionHandler(tag:getChild(1),addVal) // ?? "SET PROPERTY", valtype(value), chr(10) self:setProperty(tag, NIL, value) return NIL else return self:getPropertyValue( tag ) endif endif if tag:getName() == "condition" // Form condition condVal := NIL iArr := tag:getChilds() // ?? "CONDITION CHECK...&\n" for i=1 to len(iArr) e := iArr[i] if e:getName() == "param" .and. len(e:getChilds()) == 1 condVal := self:subActionHandler(e:getChild(1), addVal) // ?? "checked value:",condVal,chr(10) endif if e:getName() == "case" chkVal := e:attribute("value", NIL) if valtype(condVal) == "L" chkVal := iif(ascan({"TRUE",".T.","YES"},upper(chkVal))>0,.T.,.F.) endif // ?? "case value:",condVal,"?",chkVal,chr(10) if chkVal == condVal // ?? "CASE:",chkVal,"executing...&\n" return self:actionHandler(e,addVal) endif endif next return NIL endif widget := tag:attribute("widget","") method := upper(tag:attribute("method","")) //?? "call "+iif(valtype(widget)=='C',widget,"")+":"+method+"()",tag:getAttributes(),"&\n" c := tag:getChilds() for p in c switch p:getName() case "param" if p:attribute("value") != NIL // Constant value aadd(params,p:attribute("value")) else // Recursive call if len(p:getChilds()) > 0 aadd(params, self:subActionHandler(p:getChild(1),addVal)) else ?? "WARNING: parameter has no value&\n" aadd(params, NIL) endif endif case "return" // Bind action on form creation // ?? "SET RETURN HANDLER", self:fileName, ret, chr(10) retAction := {|ret| self:actionHandler(p,ret)} if method == "OPEN" asize(params, 2) endif if method == "DIALOGBOX" asize(params, 4) endif aadd(params, retAction) otherwise ?? "WARNING: unknown tag",p:name,"&\n" endswitch next outlog("CALL", method, "...") if valtype(widget) == "C" widget := mapget(self:widgets, widget, NIL) endif //?? "call widget: ", valtype(widget), iif(valtype(widget)=='O',widget:className,""),chr(10) if widget != NIL .and. valtype(widget) == "O" if method $ widget .and. valtype(widget[method]) == "B" /* TODO: use clipa() or similar function aadd( params, NIL ) ains( params, 1 ) params[1] := widget ret := clipa("func", params) */ switch len(params) case 1 ret := eval(widget[method], widget, params[1]) case 2 ret := eval(widget[method], widget, params[1], params[2]) case 3 ret := eval(widget[method], widget, params[1], params[2], params[3]) case 4 ret := eval(widget[method], widget, params[1], params[2], params[3], params[4]) case 5 ret := eval(widget[method], widget, params[1], params[2], params[3], params[4], params[5]) case 6 ret := eval(widget[method], widget, params[1], params[2], params[3], params[4], params[5], params[6]) otherwise ret := eval(widget[method], widget) endswitch else ?? "ERROR: no method '"+method+"'&\n" return NIL endif else if isfunction( method ) ret := clipA( method, params ) else ?? "ERROR: no function '"+method+"'&\n" return NIL endif endif // ?? "RETURN:",iif(valtype(ret)=="O","<OBJECT>",ret),chr(10) return ret /* Try to localize current string */ static function ui_form_i18n(self, str) local lstr:="" if str == NIL return NIL endif if valtype(self:locale)=="O" .and. str $ self:locale lstr := self:locale[str] elseif .not. empty(str) // TODO: show untranslated string in debug mode //?? self:fileName+": untranslated '"+str+"'&\n" lstr := str endif // ?? "i18n:",str,"=>",lstr,chr(10) return lstr --- NEW FILE: frame.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* 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. */ /*-------------------------------------------------------------------------*/ static driver := getDriver() /* Frame class */ function UIFrame(caption, type) local obj := driver:createFrame(caption, type) obj:className := "UIFrame" _recover_UIFRAME(obj) return obj function _recover_UIFRAME( obj ) obj:add := @ui_add() obj:setLabel := @ui_setLabel() obj:setType := @ui_setType() return obj /* Set grid for frame */ static function ui_add(self, grid) driver:setFrameGrid(self, grid) return NIL /* Set label for frame */ static function ui_setLabel(self, label) driver:setFrameLabel(self, label) return NIL /* Set frame type */ static function ui_setType(self, type) driver:setFrameType(self, type) return NIL --- NEW FILE: grid.prg --- /*-------------------------------------------------------------------------*/ /* This is a part of CLIP-UI library */ /* */ /* Copyright (C) 2003-2005 by E/AS Software Foundation */ /* Author: Andrey Cherepanov <sk...@ea...> */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* ... [truncated message content] |