/* * This file illustrates a simple monthly calendar view, built with Frames, * Messages, TextEditors, HBoxes, and VBoxes. */ #include #include #include #include #include #include #include #include #include #include class CaretModifiableTextEditor; /* * A DayCellView is a Frame containing a VBox containing a 15-char message and * 5x15 text editor. Its Handle function should be specialized to allow double * clicking to bring up a day view expansion. */ class DayCellView : public Frame { public: DayCellView(char* date); InsertText(char* text); protected: CaretModifiableTextEditor* ed; }; /* * A CaretModifiableTextEditor is simply a standard InterViews TextEditor with * a new public function that allows the caret style of the underlying * TextDisplay to be changed. */ class CaretModifiableTextEditor : public TextEditor { public: CaretModifiableTextEditor(int rows, int cols, int tabsize, int highlight); void CaretStyle(int style); }; DayCellView::DayCellView(char* date) { Insert(new VBox( new Message(date), ed = new CaretModifiableTextEditor(5, 15, 8, Reversed))); ed->Edit(new TextBuffer(new char[5*15], 0, 5*15)); ed->CaretStyle(NoCaret); } DayCellView::InsertText(char* text) { ed->InsertText(text, strlen(text)+1); } CaretModifiableTextEditor::CaretModifiableTextEditor( int rows, int cols, int tabsize, int highlight) : TextEditor(rows, cols, tabsize, highlight) {} void CaretModifiableTextEditor::CaretStyle(int style) { display->CaretStyle(style); } main () { World* w = new World; DayCellView* days[32]; int d; char dstr[3]; for (d=1; d<=31; d++) { sprintf(dstr, "%d", d); days[d] = new DayCellView(dstr); } HBox* week1 = new HBox(new HGlue(), days[1], days[2]); week1->Align(Right); HBox* week2 = new HBox( days[3], days[4], days[5], days[6], days[7], days[8], days[9]); HBox* week3 = new HBox( days[10], days[11], days[12], days[13], days[14], days[15], days[16]); HBox* week4 = new HBox( days[17], days[18], days[19], days[20], days[21], days[22], days[23]); HBox* week5 = new HBox( days[24], days[25], days[26], days[27], days[28], days[29], days[30]); HBox* week6 = new HBox(days[31]); week6->Align(Left); days[8]->InsertText("Snr Project"); w->InsertApplication(new Tray(new HBox(new VBox( week1, week2, week3, week4, week5, week6)))); w->Run(); }