1 /* 2 ** Copyright 2003, Double Precision Inc. 3 ** 4 ** See COPYING for distribution information. 5 */ 6 7 #ifndef previousscreen_H 8 #define previousscreen_H 9 10 #include "config.h" 11 12 // 13 // Certain functions need to return to the "previous" screen. 14 // 15 // This is done as follows. 16 // 17 // 1) Objects that represent a known screen that qualifies as a "previous" 18 // screen are subclassed from PreviousScreen, and are instantiated with 19 // an argument that points to the main screen function (invoked from 20 // main()'s loop) and the screen function argument. 21 // 22 // 2) A static pointer to the last "previous" screen is set by each 23 // constructor. 24 // 25 // 3) If, by some reason, the original object is destroyed, the destructor 26 // resets the static pointer to a NULL. 27 // 28 // 4) To return to the "previous" screen, first myServer::nextScreen is set 29 // to a default screen function (the folder listing screen is the usual 30 // choice), then PreviousScreen::previousScreen() is invoked. 31 // 32 // 5) If the static ptr is not NULL, myServer::nextScreen+arg is reset. 33 34 class PreviousScreen { 35 36 void (*screenFunction)(void *); 37 void *screenFunctionArg; 38 39 static PreviousScreen *lastScreen; 40 41 public: 42 PreviousScreen( void (*func)(void *), void *funcArg); 43 void screenOpened(); 44 ~PreviousScreen(); 45 46 static void previousScreen(); 47 }; 48 49 #endif 50 51