Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format Painter

Status
Not open for further replies.

ameedoo3000

IS-IT--Management
Sep 20, 2016
233
EG
hi all friends
I have a question
Is there in Visual Fox Pro property format Painter
 
No. The usual way to get multiple properties the same across multiple controls is to set the properies in a class, and then subclass it or create instances of it.
 
ameedoo3000

Actually, it is possible to do something like paint and even more complex tricks, well beyond.

Build two forms. One form will be used as a palette of buttons which can have various painting functions. You can associate a regular CommandButton with each function.

Something goofy like this:
Painter2_jx17fu.png



And here is a sample of code you can put inside each button. Of course, you decide what the button will do. The nice thing is that you can modify a whole bunch of objects on your form all at once with anything you want to sprinkle them with. The Paint feature is just an apprentice to what you can do with this.


Code:
*  Place this code in the MouseDown event of your button!
LPARAMETERS nButton, nShift, nXCoord, nYCoord

Local i, n, laObjects[50], UU 
n = aselobj(laObjects) 
IF n > 0 
	For i=1 to n 
		DO CASE 
		CASE UPPER(laObjects[i].Class) = "COMMANDBUTTON" 
			
			With laObjects[i]
				DO CASE 
				CASE nShift=0
					.picture	= This.picture
					.picturePosition = 12
					.fontBold	= .F.
					.FontItalic = .F.
				CASE nShift=1
					.picture	= ""
					.picturePosition = 13
					.fontBold	= .F.
					.FontItalic = .F.
				CASE nShift=2
					.picture	= ""
					.picturePosition = 13
					.fontBold	= .T.
					.FontItalic = .T.
				CASE nShift=4
					.Width = This.Width
					.Height = This.Height
					IF i>1
						lao2 = laObjects[i-1]
						.top = lao2.top+lao2.height+4
						.left = lao2.left
					ENDIF 
				CASE nShift=5
					IF i>1
						lao2 = laObjects[i-1]
						.Width = lao2.Width
						.Height = lao2.Height
						.top = lao2.top+lao2.height+4
						.left = lao2.left
					ENDIF 
				CASE nShift=6
					IF i>1
						lao2 = laObjects[i-1]
						*.Width = lao2.Width
						*.Height = lao2.Height
						.top = lao2.top+lao2.height+4
						.left = lao2.left
					ENDIF 
				ENDCASE 
			ENDWITH 
		CASE UPPER(laObjects[i].Class) = "TEXTBOX" 
			With laObjects[i]
				IF i>1
					lao2 = laObjects[i-1]
					.top = lao2.top+lao2.height+4
					.left = lao2.left
				ENDIF 
			ENDWITH 
		OTHERWISE 
			fn.sound("huhugh1")
		ENDCASE 
	NEXT 
ENDIF 
	
ThisForm.Refresh


The Second form could have a variety of buttons and other elements and you can manipulate as many of them as you wish at a time to paint a style across an entire form, formatting them all in your preferred style.

Here is an example of what you may have on the 2nd form. The code will allow you to do 6 modifications depending on the combination of the Shift, Ctrl and Alt buttons you press on the keyboard. Each will do something else.

Here is a silly example of a test form to see how you can order everything with just one click of your button on the first form.

coco1_qtyadh.png


With compliments of the Chef...



Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Dennis Kean, I don't think this is what's asked for. Format Painter:
Dan has understood this term already and yes, inheritance is the way to go about that. To go one step further than using hard wired layout settings let parent/base classes have a dynamic setting, you need to define them with either expressions, eg have the master template of properties in goApp.oMasterLayout and let base classes have their Fontname as "=goApp.oMasterLayout.FontName", their FontSize as "=goApp.oMasterLayout.FontSize", etc. and any control based on such base controls will inherit that. Where you need exceptions from the rule you can override the inherited values.

One other way is to make use of .SetAll(), but it's rather a kludge to use it for that matter. It's the strength of OOP to let inheritance do this for you and have a central single master/base class to define the layout of all child and grandchild controls.

Bye, Olaf.
 
It should be feasible to create your own format painter - with a bit of effort.

Use GETPEM() to interrogate the relevant properties (ForeColor, BackColor, FontName, etc) of a given control. Then let the user (that is, the developer) multi-select the controls that are to be painted. Apply the relevant property values to those controls.

The tool would be used within the form or class designer, not in an EXE. You could run it from the command window, or via a custom toolbar button or menu option. Or you could register it as a builder, and run it from the control's context menu.

Whether it would be worth the effort is up to you.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Olaf's link to the Office format painter is what I was thinking. And, frankly, in Word it's the WORST possible way to do formatting. It's far more effective (and, in the long term, easier) to rely on styles for all formatting in Word. Styles are Word's version of classes.

Word super-users have been doing object-oriented (document) development since the earliest days of Word for DOS but they don't know it.
 
Yes, the comparison of format styles to layout properties of objects is very descriptive.
When a document uses the formats (like heading level1,2,3...) it's quite like CSS is for HTML tags H1, H2,...
To compare that with the inheritance of classes is a bit misleading, but the behaviour of CSS or Word Formats is based upon object oriented inheritance in some way or the other.

In regard of Word Documents, this has troubled me from times to times, even though you can choose how to paste in clipboard contents with or without formatting. There is a mode missing, in which you can copy the intent (eg main heading, sub heading) of the copied text/snippet and get it formatted as in the current word doc format styles. Just like HTML and CSS would do that, when you just copy over HTML and get it formatted per current CSS.

Bye, Olaf.
 
One aspect of VFP is bad about the layout properties: Even when you define your library of the very basic base classes to have that single point of changing a font or fontsize and other layout properties, there is no font base class of which all controls displaying text inherit, you have base settings for labels, textbox, combobox, etc. My Idea of a oMasterTemplate object is addressing that. If you don't understand this hint, I may expand on the idea.

Of course, things like font size changes are still not simply done with changing some base setting of some root class, bigger fonts don't autoadjust control positions and sizes for no overlap etc. That's a topic on it's own again and the root problem about the base OS font size setting and dpi and why so many application layouts suck or even are disfunctional, when you change the OS for big fonts.

In the end that means I wouldn't dare (like Windows itself does) to make it an option for the user to freely choose looks of an application, especially sizes are a topic of UI design as we recently made clear about anchoring and zooming as different aspects of enlarging forms and their content. It's easier to make such settings in the core document section of a word processor than in forms with input controls and a certain layout. HTMLs concept of floating tags also isn't very intuitive and doesn't have the greatest results. The topic of device types changed this a bit for the better with responsive webdesign, but that goes a bit too off topic, perhaps.

Bye, Olaf.
 
OlafDoschke,

I do all of that with code based on what I showed above. I have designed an armada of tools, some specifically for Grids, others to rearrange all elements and line them up. You can resize any Object's font size, font, alignment, dimensions spaces between objects. There is no limit to what you can do. With VFP all you have to do is touch one or more elements and click on the proper button to do magic. It is like CSS on steroids. With WEB tools you have to run the site to see it. With VFP you can see everything changing before your eyes without running the form. I have been using this idea for the last 20 years.

Here is what you can do with VFP my friend:

This is just a personal app to figure out food mixtures to get highly efficiency protein.
The sliders allow you to change the food quantity by Click-Slide or just click on the slider... Does it look like VFP???
protein_dudupv.jpg


Here is another goofy look in an app used for comparing and storing files in repositories.

compare_xy2kyf.jpg



To me this is better than CSS3, Less and all of the WEB tools put together. And I have not touched on some deeper subjects, yet.

Let me warn you, however, that I have redesigned most of my base classes to extend features. But if I can do it so can other guys. There is no limit with VFP. You just have to put on your Robinson Crusoe Explorer hat and hack away! It is like discovering America anew...









Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
I wouldn't like that, but even considering the looks can be changed to whatever style one likes, this type of skinning an application goes too far for my taste. I like to have control about aplication looks with Windows and don't want to maintain a theme per application. The only skinned application I have installed is Winamp, but it's not even my main audio player.

Bye, Olaf.
 
Yeah, these are extreme, but It shows how far you can push the VFP skins. Most people are not aware of this flexibility in VFP. Everything is monochromatic and forms all look like one another. For some, it takes a while to get a taste for this, but my colleagues rave about it. The buttons on the forms have 5 states and they are fully animated... also supplemented with subtle sounds. The old skins of 1993 are passe in my book... Unlike you, I am so way over the MS theme and monochromatics. I suppress it most of the time and replace the sliders.

But like they say, to each his own.

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Back to the spinning labels of the '80s LOL

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

Did you mean Blinking labels? Ha ha ha... Yeah, a lot of people are allergic to innovative UX design. It is hard enough to design with the default MS theme and get a wholesome look. To venture outside, is like starting a hurricane. The role of the Architect/UX leader is a harsh one. Development is hard enough for his team of UIs. Who wants a slick UI? I guess we will have to wait for the 22nd century, where objects can negotiate with one another and the UI does not have to bleed from his eyeballs...

Of course, I was doing that in 1998. With VFP all things are possible. I just love VFP, Mike. [pipe]

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
You might consider looking at your own signature in these messages.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thanks, Mike.... Let's see if it works in this reply...

Looks good... in the preview

Merci Monsieur



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Just to get back on topic about the format painter: Of course being able to change looks of whole forms via skinning using some theme like layouting would help with the need to apply coherent looks to a form or whole application. It's an extreme, the opposite extreme is doing nothing on the layout of controls and keep them at the default, which will let Windows themes change their looks by OS version. MS changed theme styling from XP to Vista and then again in Win10, base VFP controls also changed along. Using the same font throughout all controls is a thing you unfortunately don't have in control with a single setting, but you can and should define a class library of all VFP base classes including labels and all controls having captions themselves like options of optiongroups, checkboxes and buttons, so at least it's a limited number of base classes you can set to another font, if you base all further controls and forms on these classes than using the native controls.

A thing, which struck the Themed Controls VFPX project is, that MS also changed the look of office applications very rapidly. People having used this for their VFP apps now look like 2007 Office/Outlook, today we have flat designs and while it's a step back in my eyes, it gives clarity and it gives every developer not having much design skills the chance to create icons in line with Windows and not only Windows. Flat icons only haven't arrived on Linux Desktops. Maybe because of too low userbase. Developers using Linux rather concentrate on a bash anyway.

Bye, Olaf.
 
laf,

Olaf said:
today we have flat designs and while it's a step back in my eyes,

I am with you about the flat look. But I am also against conventional development, where MS dictates the style at large and all bow to a standard because they have no inspiration. Who cares what MS and their cheesy UX designers peddle. Windows 10 UX is an abomination to me. Let's make wooden cubes and sit on the floor to play like kids. To me, any application which does not have a distinct individuality is unstimulating. Users react the same way. It was a surprise to me to discover that with FoxPro 2.5. I jumped on graphics as soon as it came out and my users were tickled to joy. Many resisted and later said "I do like it, actually."

While it is difficult to please the eyes of every user and it is just as difficult to move away from the norm due to the developer's resistance, UX is proving to be a major factor and obviously at odds with the UI developers. The WEB is a witness of it. CSS3 has opened a new highway, but UX designers are still afraid of style and revert to standards for fear of meeting doom and disapproval from a few fickle users who clamor more than their rank allows. To me it is comical. The power is there and no one dares to use it. The great thing with VFP is, that door opened way back with VFP 3.0. After the contortions of making FoxPro 2.5 display in graphics, VFP 3.0 and OOPS exceeded and remained so until CSS3. The speed of rendering graphics in VFP is abysmal and the alpha layer is not available to the VFP platform.

But VFP is a blast

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
It's not only MS, apple is in the same boat, and everybody likes Apples design and hates MS, though they are converging towards the same principles. That seems to me to be very prejudice driven. The big advantage of monochromatic flat icons is their vector graphic nature, which can make them DPI independent. And that's becoming very important on the different device sizes. While I said it's a step back in design, it's getting a standard, which makes old software stand out as outdated and that's good to drive the need of modernization, jobs for us.

I see my software as a guest system on a host and to make it easier for the user, I stay conform with whatever norm of the OS. Applications, which are the first thing you start on your working day, the last thing you close and what you use throughout the day, are not the norma any more, unless you talk about an author using some word processor or unless you talk about systems like SAP. So instead you typically nowadays have very specialised small apps, also in todays sense of tablet/smartphone apps and connect specialists by using integratable cloud services/solutions. Whatever exactly, but that means you use multiple apps and it would be nice, if they would work similarly and look similarly, so you don't need to learn as many philosohpies about usability as there are developers working out their apps.

And in regard of a general look & feel of internet applications or apps: There are certain trends, but obviously sites want to have individual looks, corporate identity, but again, for an application landscape of a larger corporation this means the wish for one general look&feel in the sense of the company.

By the way, it seems you have a lot of nutritional data there, I could use for something I work on, an app about avoiding allergens.

Bye, Olaf.
 
Olaf,

USDA publishes everything you need on nutrition and food. But they contort it in a way where you have to fight to get it into a DBF format. However, If not for VFP I could never have milked it into data tables. Maybe you know something I don't about converting their Fax format... what not. I only needed some common foods I eat and being a Vegetarian or Vegan it does not include canned or processed foods etc. Just Raw items. Idealist, you know...

[link]https://www.ars.usda.gov/northeast-area/beltsville-md/beltsville-human-nutrition-research-center/nutrient-data-laboratory/docs/sr28-download-files/[/url]

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Olaf,

On the topic of monochromatic, enterprise level UI programming, etc... I know where you are coming from and you are mostly correct, in what you said. Of course, it is much harder to make a soup to satisfy the flavor of 1000s in a single pot. Multiple pots inevitably will end up in the hands of more than one chef, so, flavors will vary. But the more important issue, which you touched on is the approach to solving the exchange of data between user and the App UI. That is a separate issue and it is even more important than monochromatic/pretty coloring of the UI screens. I will leave that for another discussion.

In line with your point, corporate UI needs a UX expert to deliver uniformity of look and functionality. However, the real reasons are far more ephemeral than uniformity which leads to order/cognition. The fickle reason is more for suppressing the critic and suggesting broadness of mind, ideals and ideas. It is similar to wearing jewelry and seeing the hairdresser.

The strange thing is that, by nature, humans are designed to detect differences between comparables. Monochromatic screens or even colorful screens which all have the same look, fail to trigger the "Difference Engine" of the human species mind. The day I decided to break away from the monotony of unified looks I realized that my users were able to work faster on my apps. The simple explanation is that background and/or subtle differences in look trigger cognition way faster than a look alike screen which requires the user to read the header, title etc to orient the mind as to what is next on the plate.

Of course that runs counter to the corporate idealism, which suggests that order is monotone, monochromatic, insipid and devoid of life. Data must be cold, or it will be contaminated, ha ha ha! But humans key off on the subtlest of details to gain cognition. Cloned looks and functionalities, however, put the mind to sleep. The mind thrives on complexity, dislocation and is stimulated by it because it provides little hooks on which it can hang the hat and coat. It is good for every developer to study how people react to his software and how quickly the users perceive what they are doing. Today's offerings are so detached from what stimulates the mind to perform that users fall asleep from the insipid simplicity and overcooked functionality.

I guess that we will have to wait for the 22nd century to recognize how to use the human mind effectively and rapidly. But it is fun to see all the paths of going forward, then backward... and you are right, more work for us.

Cheers,



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top