Purpose |
This sub changes the style of the objects contained in a selection
|
Author | Date of code (original) | Updated on | Date of page (original) | Updated on |
Jacques Paris jakes.paris@sympatico.ca |
20Feb2001
|
|
20Feb2001
|
|
Restrictions on use |
This module is distributed under the terms of the Lesser GNU General Public License. Restrictions on the use of this work in a commercial application or derivative work is described in the Lesser GNU General Public License page at: http://www.fsf.org/copyleft/lesser.html
|
Description |
This sub changes the styles of the objects contained in the current selection. All the objects of the same type receive the same style. Objects in the selection can be of different types. If a new style is not specified for some object type, the defaut style will be used. The size of text objects is not modified even though a point size is specified.
|
External resources |
|
Declare statement of sub_function. Include in your program. Copy/Paste if needed. |
declare sub ChangeSelStyle
|
Returned value(s) (function only) |
|
Other required declare statement(s). Include in your program. Copy/Paste if needed. |
If not already required by program: include "mapbasic.def" |
MapBasic Code. Copy/Paste if needed.
|
sub ChangeSelStyle dim nobj,npts,npli,nreg,ntxt,i as integer dim ob as object dim nusym as symbol dim nupen, nuper as pen dim nubru as brush dim nufon as font nobj=selectioninfo(sel_info_nrows) if nobj=0 then exit sub end if for i=1 to nobj fetch rec i from selection ob=selection.obj do case objectinfo(ob,obj_info_type) case obj_type_arc, obj_type_line, obj_type_pline npli=npli+1 case obj_type_ellipse, obj_type_region, obj_type_rect, obj_type_roundrect nreg=nreg+1 case obj_type_point npts=npts+1 case obj_type_text ntxt=ntxt+1 end case next dialog title +"Setting styles for the objects in the selection" control statictext title "You must set a style for each type that has been found in the"  +chr$(10)+"selection (see check boxes) or the current styles will be used" height 20 width 190 position 15,5 control symbolpicker position 15,30 value currentsymbol() into nusym control penpicker position 59,30 value currentpen() into nupen control brushpicker position 106,30 value currentbrush() into nubru control penpicker position 126,30 value currentpen() into nuper control fontpicker position 174,30 value currentfont() into nufon control checkbox position 22,52 value npts disable control checkbox position 66,52 value npli disable control checkbox position 123,52 value nreg disable control checkbox position 181,52 value ntxt disable control statictext position 16,60 title "Points" control statictext position 61,60 title "Lines" control statictext position 114,60 title "Regions" control statictext position 177,60 title "Text" control okbutton position 30,77 control cancelbutton position 140,77 if not commandinfo(cmd_info_dlg_ok) then exit sub end if for i=1 to nobj fetch rec i from selection ob=selection.obj do case objectinfo(ob,obj_info_type) case obj_type_arc, obj_type_line, obj_type_pline alter object ob info obj_info_pen, nupen case obj_type_ellipse, obj_type_region, obj_type_rect, obj_type_roundrect alter object ob info obj_info_brush, nubru alter object ob info obj_info_pen, nuper case obj_type_point alter object ob info obj_info_symbol, nusym case obj_type_text alter object ob info obj_info_textfont, nufon end case update selection set obj=ob where rowid=i next end sub |
Availability for download |
Varia.zip |
Example |
include "mapbasic.def" declare sub main declare sub ChangeSelStyle sub main ' a selection must exist select * from whatever_open_table_name into sel call ChangeSelStyle end sub |
Comments |
|
See also |