-- Libsx v1.1 --
The Simple X library
by
Dominic Giamapolo
dbg@sgi.com
Introduction:
--- What is libsx?
Libsx (the Simple X library) is a library of code that sits on
top of and to the side of the Athena widget set. Its purpose is to
make writing X applications *much* easier. To accomplish this, libsx
encapsulates a large portion of the uglier details that arise while
programming in X and it fills in some gaps that exist with the Athena
Widget set (such as a widget for drawing graphics); libsx tries to
simplify the common case down to a single function call with only a
few arguments.
With libsx, writing a simple program that opens a window, has a
few buttons and draws some graphics (lines, circles, bitmaps, etc) is
a matter of 5-10 lines of code, including the drawing code. Hello
World is 2 lines. More complicated programs that respond to mouse
clicks, have buttons, scrollbars, etc, can be written in 25-50 lines
of code.
Some libraries take the approach of completely hiding whatever
they are layering on top of. In contrast, libsx doesn't drastically
alter the base abstractions of X, it just packages them in the way
they get used most of the time, so that with one function call and a
few arguments you get the effect of 10-20 lines of pure X code.
Access to the underlying X objects (Window id's, Display pointers,
etc) is also possible if necessary, but not required.
With libsx, the simple things are simple and the complex things
are possible (where have I heard that before? :-).
--- Building libsx
1. Edit the libsx_defs file in this directory and set the
compiler you'd like to use and any necessary compiler flags.
It is important that you take a look in this file and
edit things as appropriate. By default it builds for an SGI
system (gee, I wonder why that is? :-) If you are on a
DECstation, their standard compiler will _not_ work as it
is not ANSI compliant (gcc works great though).
2. Type make.
This builds the libsx library in the src directory and all
the demo programs in the other subdirectories.
If you're short on disk space, you can go into any particular
directory and type make there. For anything else to work, the
libsx/src directory must be compiled first.
A word of caution. On some suns that have motif installed from a
third party, you'll get lots of warnings about symbols being
re-defined when compiling libsx. This is because of an
incompatibility in the way the X header files get installed for the
motif product (not sure who makes the one I encountered problems
with). Anyway, the warnings are innocuous but definitely annoying.
Unfortunately I can't seem to make them go away.
The demo program that shows most of the features of the library
is in the src directory (the executable is called `demo'). The other
demo programs demonstrate various aspects of the library. Feel free
to use them as skeletons for your own programs.
The code has been compiled on wide variety of systems and
compilers. It should be mostly clean POSIX code, but I would
appreciate hearing about any difficulties you have while compiling. I
have personally compiled it cleanly on Sun3's and 4's (SunOS 4.1.1
mind you), SGI (Indigo's, PowerSeries, Onyx, etc), and DECstations
3100/5100's. People on the net have told me that they've gotten it to
work on HP-UX, Linux, SVR4.2, AIX 3.2, Sequent/ptx, and numerous other
systems. A while ago I compiled it cleanly on a DG Aviion running a
very strict version of SVR4. I've used gcc to compile it as well as
the native compiler on most of the platforms. The code is ANSI C, so
if you don't have an ANSI compiler, sorry....
Libsx also requires the Athena widget set, which isn't as
omni-present as I once thought. I guess HP doesn't ship it on all of
their systems. I can't help you much there. Bitch at your vendor and
tell them to ship a version of the Athena widgets if you don't have
it.
BTW, there's no Imakefile because I don't understand imake (nor
have I made much of an attempt to understand it). Imake seems like
overkill for libsx. If someone would like to write an Imakefile, I'd
gladly include it in future releases, but it's not likely I'll do it
myself.
--- More details about libsx
The reason I wrote libsx was so that I could whip up simple X
programs in not much time and not lots of X code. Originally it
started because I wanted an easy way to write programs to draw
graphics, but libsx also grew to encapsulate most of the other Athena
widgets making all sorts of GUI programs possible
The essential idea with libsx is that creating the user-interface
should be simple and you should spend your time on the code that
implements the logic of your program. In libsx, the core functions
that control your application are connected to user-interface elements
as callback functions. That is, when the user does something
interesting with your interface, your callback function gets called.
All of the low level management details are handled for you.
Each user interface item (buttons, scrollbars, drawing area's, text
entry, etc) only requires one function call to create it. One of the
arguments to this creation routine is the name of a callback function
that will be called each time an interesting event happens to that
widget. For example, when a button or menu item is clicked on/chosen,
your callback routine gets called. When a drawing area needs to be
redrawn, your callback gets called.
The intent of libsx was to ease the common case. For example,
here is the code to create and manage a single line string entry
with libsx:
void str_callback(Widget w, char *string, void *data)
{
printf("You pressed: %s\n", string);
}
void main()
{
....
MakeStringEntry("preset text", 200, str_callback, NULL);
}
The first function is the callback function that gets called when
the user presses return in the widget (and it just prints what the
user entered). The call to MakeStringEntry() builds the widget and
takes care of setting all the necessary resources and translations for
everything to work. In comparison, the equivalent code in regular X
calls is on the order of 20-25 lines of code (not counting the
callback function which would be the same for both).
Another example is drawing graphics. The plain Athena widget set
does not provide a drawing area widget (like Motif does). Libsx
includes David Nedde's Athena drawing area widget and encapsulates it
so that a simple program to open a window and draw some graphics is
now reduced to only a few lines of code. More complicated programs
build upon the simple model and although creating the user interface
may involve more lines of code, the basic model is the same.
--- What exactly does libsx provide?
Libsx encapsulates the following interface components (all based
on Athena widgets, except for the DrawingArea widget which belongs to
David Nedde):
-- labels
-- buttons
-- radio button groups and toggle buttons
-- single line text entry
-- multi-line text entry (full text-edit box)
-- scrollbars (horizontal or vertical)
-- scrolling lists
-- menu buttons (buttons with pop-up menus)
-- drawing areas (you can draw in these and also receive
mouse/keyboard events if you like)
-- multiple form widgets (more advanced, not normally used)
After creating the interface components you need, you lay-out your
display in a logical fashion. The SetWidgetPos() function lets you
specify what widgets are next-to or underneath (or both) other
widgets. This avoids hard-coding pixel positions and makes setting up
a display pretty simple and quick (though to be fair, some more
complicated displays involving centering and such can be difficult if
not impossible).
You can easily change widget attributes and use different fonts.
There are some simple dialog box routines (for getting yes/no answers
and getting a single string). Libsx can also open multiple windows
(even on different screens) and you can build your own dialog boxes
(modal windows) if you like.
Libsx also supports obtaining, managing and using colors (either
individual colors or an entire 8-bit colormap). Getting specific
named colors or colors based on RGB values is as simple as calling a
single function (no need to worry about colormaps, color cells, or any
of the other junk X makes you worry about). Grabbing the entire
colormap is also very easy.
Effectively, libsx maintains a lot of state for you; it manages all
the grungy X details while providing a cleaner set of routines for
your program to use.
--- Has libsx traded complexity for functionality?
I don't think so. While libsx makes it trivial to write simple
programs (as mentioned before, hello world is 2 lines of code), it's
also been used to write some fairly substantial programs. I've
written 3-D object editors and all sorts of wire-frame/shaded graphics
previewers. This afternoon I got fed up with XLess and wrote an
equivalent replacement with a real file requestor in about an hour.
Most of the time was spent working on the logic of how the program
should behave, not the user interface. A friend used it to write a
complete 3-D modeling/rendering system. I've written tons of small
graphics programs with it (reaction-diffusion and iterated function
system demos, etc). I've used it for a contract application that
required a simulation of a train set on screen (modeled correctly to
scale, etc), and I've been kicking around ideas for some sort of word
processor/editor. Libsx is not some all-singing all-dancing type of
library, but it does make writing common X applications substantially
easier. If you do need the extra confusionality, I mean functionality
that X offers, all the standard X functions are available and you have
access to the Widget id's, Display pointers, etc. The point is that
you don't have to worry about that if you don't want to.
--- Where did libsx come from?
I developed libsx over the course of about 2 years while in
graduate school at Worcester Polytech (in good ole Worcester, Mass.)
It all started when I took the grad course in Computer Graphics. I
wanted a nice library of routines to deal with all the X crap so I
could concentrate on my graphics code. Soon the library started
evolving into a much more sophisticated thing and when I became the TA
for the graphics course, I beefed it up a lot. When you have 65
undergrads beating on a library you've written, it's got to be solid.
The next time that I was TA, I polished up some more rough edges in
the library (the stuff the students complained about) and it went
through the ringer a second time with about 45 more students.
Finally, during the summer of 1993 I added a ton of more functionality
to the library so a friend of mine could write his 3-D editor the way
it should be written and so I could do some stuff I wanted to do.
In September of 1993 I was hired at SGI and I've done a little bit more
work on libsx since I've been here (mainly little cleanups and the
rudimentary OpenGL support). That is effectively what you see today.
I've spent a lot of time deciding how to structure libsx so it
would be easy to use but still be open ended. Libsx doesn't try to
hide all of X, it just tries to make it more digestable. The library
has gotten pretty big at this point, but it should be sufficient to
write most types of GUI programs without lots of fuss.
I've also spent a lot of time deciding what should and shouldn't
be in libsx. It's too easy to throw in everything just because it's
easy to do so. Unfortunately that's almost never the right reason to
include something. I've tried to pare the design down to the
essentials needed to write a useful application. Comments and
critiques of the design/approach are welcome (I'd like to hear what
others have to say about it or how they would have done it).
--- Does libsx hurt performance?
I've never really noticed any problems and most of this code was
developed originally on a Sun3 (so if it ran ok there it's almost
guaranteed to run fine on anything else because a Sun3 is a pretty
damn slow machine nowadays :-).
Seriously though, once you've created the interface and put up
the display, there isn't much libsx code that gets in the way of your
application. Many calls go direct to your application and a few are
routed through libsx code, but nothing fancy happens there. Using
libsx I was able to write programs that interactively manipulated
three dimensional objects of up to several hundred vertices with the
mouse on a Sparc IPC, so I don't consider performance to be a problem.
--- What are the drawbacks to using libsx?
The single biggest drawback that I can think of is that some
layouts of widgets are not possible because of limitations in the
Athena Form widget. For example, it's impossible to create a widget
that is centered in a window (to the best of my knowledge the Form
widget doesn't support this, example code to the contrary would be
greatly appreciated). This is a bit of an annoyance, but usually
isn't too much of a problem.
Libsx also doesn't let you name your widgets individually, so
customization through your .Xdefaults file is possible, but not as
flexible as it could be. For example, within a single program, all
button widgets get called "button", and all label widgets are called
"label" which makes it impossible to invdividually identify widgets in
your .Xdefaults file. This means you can't use your .Xdefaults to
specify that button X has green text with a purple background while
button Y has orange text on a chartruse background with blue
highlights. Either all your buttons are purple with green text or
they are chartruse with orange text, but not both (hopefully none of
them are either :-).
This could be fixed by adding a name argument to the MakeXXX()
functions, but I'd prefer not to add another argument to those
routines. It's also possible to add a SetWidgetName() type of
function which is a nice way to do it, but then it really starts to
make generating an interface a very complicated thing. Maybe I'll add
a SetWidgetName(), but for now I don't think so. The customization
thing hasn't been too much of a big deal for me (you can still
customize, it's just not as infinitely flexible as the underlying X
mechanisms).
Presently libsx doesn't offer much support for detecting double
clicks. This is because of two reasons. First, X doesn't provide any
way for a user to get/set their preferred double-click time (at least
as far as I know, example code to the contrary is welcomed) Second,
getting sub-second timer accuracy in a portable fashion turns out to
be rather problematic. I've just learned that the times() function
can be used in a roundabout way to get sub-second timing, but POSIX
isn't as well and cleanly supported as one might hope.
If you'd like to see code that checks for double-clicks, look in
the freq directory at freq.c. It uses times() and seems to work well.
--- Where do I go from here?
If you haven't already done it, compile libsx. This builds the
library itself and numerous demo programs. Then take a look at the
demo programs and the code behind them. The main demo program is in
the libsx/src directory (and is called `demo'). It demonstrates most
of the features of libsx. The other directories contain demos of
varying complexity and these are your best starting point for building
your own applications. The most complicated application would be
`bezier' which lets you interactively play with bezier curves. It's a
good framework for handling user-interaction and what not, so have a
look at the sources. Feel free to use the demo sources as the basis
for your own programs (but of course I'd appreciate it if you give
credit where credit is due).
The directories freq, creq, and multireq contain code written by
a friend of mine, Allen Martin (amartin@wpi.wpi.edu). Freq contains a
file requestor function based on libsx. Freq provides a single
function GetFile() that lets a user select a file while browsing
through the directory hierarchy. Creq is a color chooser utility that
lets a user select a color using RGB or HSV values (with sliders and
all that jazz). Multi-req is a very nice way to do form-fillout
dialogs. Take a look at the sample code in these directories and you
should be able to figure out how to make use of the functions.
The documentation is always a nice thing to read too (especially
since I put so much time into it :-). The documentation isn't in man
page style format (yet), sorry about that. It was easier to write
this way. The documentation tries to cover all the bases, and with
the example code, it shouldn't be hard to figure out (heck, if second
year college students can do it with little or no help.... :-). If
you have comments/criticism on the docs, let me know. If you'd like
to convert the docs into a man page format, I'd also like to know :-)
The documentation to start reading first is either libsx_intro or
general.libsx.doc. Those introduce you to the basics and then you can
go look at the more specific doc files for each of the various areas
in libsx.
Well, that about sums it up. I hope you find libsx handy and
that you can make some use of it. Any comments, questions or other
communication can be sent to:
Dominic Giampaolo
dbg@sgi.com
Have Fun!
p.s. Oh yeah, I need a disclaimer:
This code was written by me, Dominic Giampaolo, and should not
be taken to represent Silicon Graphics in any way, shape or
form. I've written it on my own time, and for my own purposes.
SGI has nothing to do with it, so don't bother them about it.
(does that sound legal enough? :-)
A much more important factor in the social movement than those already mentioned was the ever-increasing influence of women. This probably stood at the lowest point to which it has ever fallen, during the classic age of Greek life and thought. In the history of Thucydides, so far as it forms a connected series of events, four times only during a period of nearly seventy years does a woman cross the scene. In each instance her apparition only lasts for a moment. In three of the four instances she is a queen or a princess, and belongs either to the half-barbarous kingdoms of northern Hellas or to wholly barbarous Thrace. In the one remaining instance208— that of the woman who helps some of the trapped Thebans to make their escape from Plataea—while her deed of mercy will live for ever, her name is for ever lost.319 But no sooner did philosophy abandon physics for ethics and religion than the importance of those subjects to women was perceived, first by Socrates, and after him by Xenophon and Plato. Women are said to have attended Plato’s lectures disguised as men. Women formed part of the circle which gathered round Epicurus in his suburban retreat. Others aspired not only to learn but to teach. Arêtê, the daughter of Aristippus, handed on the Cyrenaic doctrine to her son, the younger Aristippus. Hipparchia, the wife of Crates the Cynic, earned a place among the representatives of his school. But all these were exceptions; some of them belonged to the class of Hetaerae; and philosophy, although it might address itself to them, remained unaffected by their influence. The case was widely different in Rome, where women were far more highly honoured than in Greece;320 and even if the prominent part assigned to them in the legendary history of the city be a proof, among others, of its untrustworthiness, still that such stories should be thought worth inventing and preserving is an indirect proof of the extent to which feminine influence prevailed. With the loss of political liberty, their importance, as always happens at such a conjuncture, was considerably increased. Under a personal government there is far more scope for intrigue than where law is king; and as intriguers women are at least the209 equals of men. Moreover, they profited fully by the levelling tendencies of the age. One great service of the imperial jurisconsults was to remove some of the disabilities under which women formerly suffered. According to the old law, they were placed under male guardianship through their whole life, but this restraint was first reduced to a legal fiction by compelling the guardian to do what they wished, and at last it was entirely abolished. Their powers both of inheritance and bequest were extended; they frequently possessed immense wealth; and their wealth was sometimes expended for purposes of public munificence. Their social freedom seems to have been unlimited, and they formed combinations among themselves which probably served to increase their general influence.321 The old religions of Greece and Italy were essentially oracular. While inculcating the existence of supernatural beings, and prescribing the modes according to which such beings were to be worshipped, they paid most attention to the interpretation of the signs by which either future events in general, or the consequences of particular actions, were supposed to be divinely revealed. Of these intimations, some were given to the whole world, so that he who ran might read, others were reserved for certain favoured localities, and only communicated through the appointed ministers of the god. The Delphic oracle in particular enjoyed an enormous reputation both among Greeks and barbarians for guidance afforded under the latter conditions; and during a considerable period it may even be said to have directed the course of Hellenic civilisation. It was also under this form that supernatural religion suffered most injury from the great intellectual movement which followed the Persian wars. Men who had learned to study the constant sequences of Nature for themselves, and to shape their conduct according to fixed principles of prudence or of justice, either thought it irreverent to trouble the god about questions on which they were competent to form an opinion for themselves, or did not choose to place a well-considered scheme at the mercy of his possibly interested responses. That such a revolution occurred about the middle of the fifth century B.C., seems proved by the great change of tone in reference to this subject which one perceives on passing from Aeschylus to Sophocles. That anyone should question the veracity of an oracle is a supposition which never crosses the mind of the elder dramatist. A knowledge of augury counts among the greatest benefits222 conferred by Prometheus on mankind, and the Titan brings Zeus himself to terms by his acquaintance with the secrets of destiny. Sophocles, on the other hand, evidently has to deal with a sceptical generation, despising prophecies and needing to be warned of the fearful consequences brought about by neglecting their injunctions. The stranger had a pleasant, round face, with eyes that twinkled in spite of the creases around them that showed worry. No wonder he was worried, Sandy thought: having deserted the craft they had foiled in its attempt to get the gems, the man had returned from some short foray to discover his craft replaced by another. “Thanks,” Dick retorted, without smiling. When they reached him, in the dying glow of the flashlight Dick trained on a body lying in a heap, they identified the man who had been warned by his gypsy fortune teller to “look out for a hidden enemy.” He was lying at full length in the mould and leaves. "But that is sport," she answered carelessly. On the retirement of Townshend, Walpole reigned supreme and without a rival in the Cabinet. Henry Pelham was made Secretary at War; Compton Earl of Wilmington Privy Seal. He left foreign affairs chiefly to Stanhope, now Lord Harrington, and to the Duke of Newcastle, impressing on them by all means to avoid quarrels with foreign Powers, and maintain the blessings of peace. With all the faults of Walpole, this was the praise of his political system, which system, on the meeting of Parliament in the spring of 1731, was violently attacked by Wyndham and Pulteney, on the plea that we were making ruinous treaties, and sacrificing British interests, in order to benefit Hanover, the eternal millstone round the neck of England. Pulteney and Bolingbroke carried the same attack into the pages of The Craftsman, but they failed to move Walpole, or to shake his power. The English Government, instead of treating Wilkes with a dignified indifference, was weak enough to show how deeply it was touched by him, dismissed him from his commission of Colonel of the Buckinghamshire Militia, and treated Lord Temple as an abettor of his, by depriving him of the Lord-Lieutenancy of the same county, and striking his name from the list of Privy Councillors, giving the Lord-Lieutenancy to Dashwood, now Lord Le Despencer. "I tell you what I'll do," said the Deacon, after a little consideration. "I feel as if both Si and you kin stand a little more'n you had yesterday. I'll cook two to-day. We'll send a big cupful over to Capt. McGillicuddy. That'll leave us two for to-morrer. After that we'll have to trust to Providence." "Indeed you won't," said the Surgeon decisively. "You'll go straight home, and stay there until you are well. You won't be fit for duty for at least a month yet, if then. If you went out into camp now you would have a relapse, and be dead inside of a week. The country between here and Chattanooga is dotted with the graves of men who have been sent back to the front too soon." "Adone do wud that—though you sound more as if you wur in a black temper wud me than as if you pitied me." "Wot about this gal he's married?" "Don't come any further." "Davy, it 'ud be cruel of us to go and leave him." "Insolent priest!" interrupted De Boteler, "do you dare to justify what you have done? Now, by my faith, if you had with proper humility acknowledged your fault and sued for pardon—pardon you should have had. But now, you leave this castle instantly. I will teach you that De Boteler will yet be master of his own house, and his own vassals. And here I swear (and the baron of Sudley uttered an imprecation) that, for your meddling knavery, no priest or monk shall ever again abide here. If the varlets want to shrieve, they can go to the Abbey; and if they want to hear mass, a priest can come from Winchcombe. But never shall another of your meddling fraternity abide at Sudley while Roland de Boteler is its lord." "My lord," said Edith, in her defence, "this woman has sworn falsely. The medicine I gave was a sovereign remedy, if given as I ordered. Ten drops would have saved the child's life; but the contents of the phial destroyed it. The words I uttered were prayers for the life of the child. My children, and all who know me, can bear witness that I have a custom of asking His blessing upon all I take in hand. I raised my eyes towards heaven, and muttered words; but, my lord, they were words of prayer—and I looked up as I prayed, to the footstool of the Lord. But it is in vain to contend: the malice of the wicked will triumph, and Edith Holgrave, who even in thought never harmed one of God's creatures, must be sacrificed to cover the guilt, or hide the thoughtlessness of another." "Aye, Sir Treasurer, thou hast reason to sink thy head! Thy odious poll-tax has mingled vengeance—nay, blood—with the cry of the bond." HoME古一级毛片免费观看
ENTER NUMBET 0017
www.daiwo9.com.cn
www.riya8.net.cn
www.sadyal.com.cn
zuban2.com.cn
www.sudai9.net.cn
www.zaoyu7.com.cn
firsco.com.cn
www.zyzrny.com.cn
lezhi7.net.cn
wogao8.net.cn