We need two navigation buttons, one each on either side of the month/year label at the top of our popup. We'll start by presenting the arrow images that we'll use for these buttons. They are a double left and single left pointing arrow head (and their accompanying masks):
The images here are simple enough that even an artistic deficient like myself was able to create them with Image Editor in Wrapper's UIPainter. The only thing of interest in these methods are that they are on the CalendarArtist class. This is just a convention we use in Pollock. Image resources are always on the Artist. As before with the image on the Calendar action button, I don't expect you to really hand code these... They are here for completeness, and are published in today's updated "Pollock-Calendar" package on the Cincom public repository
To use these images in a button, we have to bundle them in a Pollock DisplayImage. We'll create an accessor for each DisplayImage for each of the buttons:
Only little bits of interesting code here. We take a DisplayImage, and give it an image and a mask, then give it an AlignmentFrame. A DisplayImage is the Pollock Pane that holds Images (or CachedImages or Pixmaps or Masks) and displays them. It has the ability to hold an image and a mask, as well as a disabledImage and a disabledMask. Thus, they can be shown enabled and disabled. Thus the DisplayImage plays the role that both an OpaqueImage and OpaqueImageWithEnablement play in the Wrapper framework.
A final note is how we just "flipped" the images, using reflectedInX. To do so, we had to get our hands on the Image inside the CachedImage that is defined in the left and right arrow(s) methods.
Next we'll write a method that adds the navigation buttons to the form:
Again, there isn't a lot going on here. We create a button, give it a frame, give the button an image/icon and add it to the form. You will note that I factored out the "left" and "right" base frames for the buttons, here is the code for those:
One might note in the #addNavigationButtonsTo: method I basically gave these buttons a size of 18x18. Why? I could come up with some complex answer that says I calculated the sizes of the buttons and their internal decorations and then added some padding. But in fact, I just played with it a bit till I found a size I liked. One small note is that I place the inner buttons one pixel further inset from the outside of the outer buttons.
The Last Detail
Now that we have all the setup work done, let's finally add the buttons to the code that creates our form:
CalendarAgent>>calendarForm
| form label |
form := Form new.
form frame: (FractionalFrame fractionLeft: 0 right: 1 top: 0 bottom: 1).
label := DisplayLabel string: self currentMonthYear.
label frame: AlignmentFrame topCentered.
form addComponent: label.
self addNavigationButtonsTo: form.
^form
If we open our tester now (CalendarTest new openWindowWithCalendar), we have our calendar popup with the four buttons, right where we want them, and today's month/year.
The above is published as version 1.11 in the Package named "Pollock-Calendar" on the Cincom public repository.
Well, today was mostly a lot of boring code. Next time we'll be more interesting and add a working object to hold on to the date we'll be manipulating with the popup, as well as write the code to increment or decrement the month or year with our buttons, and also update the month/year display label.