I ALWAYS WANTED TO BE A COWBOY. As a child, I perched on the arm of my grandmother’s sofa and rode the range while watching “Gun Smoke” or “Bonanza” on television. I assumed at some point in my life, I would graduate from the red straw children’s cowboy hat my parents bought me to the real item. But wearing a cowboy hat is a complicated gesture. History, culture, attitude reside in its brim. And to tell the truth, I’m still trying to find a cowboy hat that feels right on my head.

I bought my first adult cowboy hat when I was 17. I had a summer job on a road construction crew. It was backbreaking, dusty work in the broiling sun. I built muscle and learned profanity that would have broken my mother’s heart had she heard me use it. So I thought I was ready.

I still remember the way it looked. It was black felt with a braided leather band and vent holes just above the brim. I spent hours bending the brim and crumpling it up so that it looked as if I had ridden the range in it. I pulled it low over my eyes and went to work.

Within a week a bulldozer driver burst my bubble. He was everything I wasn’t — hard-living, visibly muscular, hung-over most days from long nights with wild women at the local honky-tonk — our version of a saloon. He didn’t ride a horse, but he drove a machine that could have easily turned me into a grease spot on the road we were building. He called me over during lunch and asked to borrow my hat.

Five minutes later, he handed it back. He had taken the razor-sharp, 5-inch blade of his pocketknife and cut the crown out.

The whole crew roared with laughter as I examined my newly shorn hat. I threw it away and went back to the baseball cap I had been wearing. Nobody ever said anything, but I got the point. I wasn’t ready for a cowboy hat. I didn’t have the chutzpah to pull it off.

Still, despite the emasculation of my first cowboy hat, I had gotten one detail right: I wore it to work. That is how and why the cowboy hat came into being. Cowboys had to protect themselves from the elements — sun, dust, rain, hail, snow. The first pivotal moment in the development of the cowboy hat occurred in the 1860s during the big cattle drives along the Goodnight-Loving Trail and the Chisholm Trail. The brims on the hats that the men wore would collapse under the stress of wind, rain, hail and snow. Then John B. Stetson came along and made the now famous “Boss of the Plains,” a hat that could withstand the elements for years and still stand up straight and tall, brim and all. But at this point the story gets complicated.

Cowboys and the hats they wore soon became much bigger than life. Little wonder those of us who came later would have trouble measuring up. The real cowboys were small, agile men who herded wild longhorns from Texas and other parts of the Southwest to cow towns, such as Dodge City or Wichita to be shipped to slaughter yards in the Midwest. They were prisoners of dust, an all-beef diet and low wages — $30 a month in most cases. They faced more than the daily onslaught of unpredictable weather or the dust of the arid regions where they herded the cows. As any rancher knows, cattle are cantankerous and unpredictable. Many a cowboy lost his life by being quite literally flattened in a stampede that just came out of nowhere.

But the expansion of the American West coincided perfectly with two events in the history of photography: the improvement in photographic resolution and the first photography studios that began to appear in France in the 1850s. During the era of the great cattle drives, photography studios began appearing in cattle towns, catering to cowboys who were between runs, flush with their meager wages, and ready to drink, carouse and be photographed. The studios sometimes provided the clothes, the hats, even the guns. And thus, the pictures are left to haunt all the would-be cowboys who came later.

You don’t see the dust or the low wages or the stampeding cattle. You see young men with guns and holsters, sometimes rifles too. Their clothes are rough-hewn and the hats are wide-brimmed and commanding. And always their eyes peering out from under the brims are resolute and determined — even menacing in such a way as is required for a life on the very edge of civilization. Those eyes haunt me to this day, calling me to freedom, danger, adventure — a life lived on the edge of the world.

But as I learned in my encounter with the bulldozer driver, wearing a cowboy hat is a complicated gesture. Even if you leave out the color of the hat, these pictures show an array of hat styles. The crown can be round or flat. Even if it is round, it can be pushed up or creased through the middle or along the crest. The brim can be flat and wide or it can be rolled or pushed up at the edges. The band at the top of the brim can be a braid made of leather or cloth, festooned with a feather or a playing card. You can wear the hat low over your eyes or tilted back on your head or cocked to the side. With each style, with each twist of the hat, your persona, your character, your attitude changes — all of this after you have decided that you have what it takes to wear the hat in the first place.

And cowboy character was similar. The men posing for these pictures were between runs. And when they were not in the photography studio looking noble and determined, they were having one hell of a good time. Cow towns such as Dodge City or Wichita were notorious for cowboys who drank and gambled and shot holes in the ceilings of the saloons they frequented. Sometimes they shot holes in one another. And then of course there were the women who were for sale. We all know that in real life Miss Kitty from “Gun Smoke” was providing much more than good advice to Marshal Dillon.

People back East were scandalized by cow towns and cowboys. A writer in Washington’s Evening Star wrote of Dodge City on January 1, 1878:

“Dodge City is a wicked little town. … Here those nomads in regions remote from the restraints of moral, civil, social, and law enforcing life, the Texas cattle drovers … the embodiment of waywardness and wantonness, end the journey with their herds, and here they loiter and dissipate, sometimes for months and share the boughten dalliances of fallen women.”

The cowboy and his hat quickly came to symbolize more than hard work, low pay, or even adventure or courage. Cowboys were wild, prone to unpredictable forays outside the bounds of the prim and proper world of civilized men and women back East. They were risk-takers on the range and in town.

To complicate matters more, these historical cowboys and the photographic images they left us are only one set of cowboys. There were others. The shootout at the O. K. Corral in Tombstone on October 26, 1881 — arguably the most famous 30 seconds in the history of the American West — involved a completely different group of cowboys. On that fateful day — a Wednesday to be exact — Wyatt Earp, his brothers Morgan and Virgil and his friend Doc Holliday, had a shootout with a Tombstone gang of miscreants called “the cowboys.” These cowboys were not drovers or cattle herders. They were a gang that reputedly rustled cattle, held up stagecoaches, and did other nefarious acts. According to Wyatt Earp biographer Casey Tefertiller, Curley Bill Brocious, one of their number, made an entire dance hall full of men and women strip naked and dance at gunpoint for his entertainment.

Despite their troublesome natures, the “cowboys” had quite a following in Tombstone. Their cattle rustling kept the price of beef low, and they could always be counted on to patronize the local saloons. Furthermore, they were brave. Tefertiller tells us that Tom Thornton, a hotel owner, said of them, “in my 20 years’ intercourse with them I never knew one of them to whine and squeal when he knew he had to die. They will run away from death, but when cornered will look into the muzzle of a six-shooter with defiant indifference.”

The shootout at the O. K. Corral was a complicated event. The right and wrong of what the Earps and Holliday did was debated back then in a court of law as well as in the local and national press. Since then it has become the subject of countless debates among historians as well as more than countless reenactments. More importantly, it is the basis of most of the Westerns that have spread the legend of the cowboys and their hats throughout the world. Every time Marshal Dillon faced down an outlaw in “Gun Smoke,” he was reenacting what Wyatt Earp and company did to the “cowboys” at the O. K. Corral. And you guessed it — the Earp group and the cowboys were wearing hats — maybe even the same style of cowboy hats.

And I suspect that is why we have made this event such a pivotal moment. We need Wyatt Earp to get rid of the cowboys who dropped off the edge of civilization and brought chaos into the picture. After all, having fun between runs — even shooting holes in the ceiling of the saloon — are forgivable offenses in men who lived on the edge of civilization and sucked dust every day to bring steak to people back East. Cattle rustling, holding up stagecoaches and forcing people to dance nude are not. Without Wyatt Earp and his descendants, the hat that has come down to us would be too big and heavy for anybody’s head.

My current cowboy hat is made by Filson Garment Company in Seattle. The cloth of the hat is impregnated with paraffin so that it can withstand rain, sleet, snow. It even has a leather chin strap so that the wind can’t blow it off. I bought it in Montana at a fly fishing shop. I was heading out on a camping and fishing trip in spring and the weather had turned cold and threatening. Before I wore it out the door, I asked my brother to tell me if the hat had too much attitude. I was still afraid of bulldozer drivers and sharp knives — real cowboys between runs, you might say. He said no. I looked as boring as ever.

My Filson hat has been wonderful. It has protected me from wind and snow and rain — even hail. I firmly believe that it has made me a better fisherman. It also looks good and feels almost right on my head. Still, I think that someday I might get something with a little more attitude — a black felt Stetson maybe. Something like my old hat, the one emasculated by the bulldozer driver. My current hat conveys the message that I’m ready for all sorts of weather, not that I’m ready for saloons and all that they entail. Still, until I know who is in those saloons, I won’t know if I’m up to the challenge.

Until then, I can dream of life on the edge of civilization while I fish with my Filson hat on my head.