Aggiornate chiavi relapp anche in modifica (creava problemi in modo multi-maschera)
git-svn-id: svn://10.65.10.50/trunk@1151 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									5ad08f7a90
								
							
						
					
					
						commit
						3e69e38b92
					
				| @ -1,220 +1,220 @@ | ||||
| #include <stdarg.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #ifdef FOXPRO | ||||
| #undef XVT_OS | ||||
| #include <windows.h> | ||||
| #include <pro_ext.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifdef XVT_OS | ||||
| #include <xvt.h> | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
| #include <windows.h> | ||||
| #include <keys.h> | ||||
| #else | ||||
| #include <xvtility.h> | ||||
| #endif | ||||
| #include <applicat.h> | ||||
| #endif /* XVT_OS */ | ||||
| 
 | ||||
| 
 | ||||
| #include <checks.h> | ||||
| 
 | ||||
| #define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr) | ||||
| 
 | ||||
| #ifdef XVT_OS | ||||
| 
 | ||||
| int fatal_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_ICONHAND); | ||||
|   MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL); | ||||
| 
 | ||||
|   if (xvt_running()) | ||||
|     main_app().stop_run(); | ||||
|   else | ||||
|     exit(1); | ||||
| #else | ||||
|   beep(); | ||||
|   if (xvt_running()) xvt_dm_post_fatal_exit("%s", msg); | ||||
|   else | ||||
|   { | ||||
|     fprintf(stderr, "%s\n", msg); | ||||
|     getchar(); | ||||
|     exit(1); | ||||
|   } | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int error_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_ICONEXCLAMATION); | ||||
|   MessageBox(GetFocus(), msg, "ERRORE", MB_OK | MB_ICONEXCLAMATION); | ||||
| #else | ||||
|   beep(); | ||||
|   if (xvt_running()) xvt_dm_post_error("%s", msg); | ||||
|   else | ||||
|   { | ||||
|     fprintf(stderr, "%s\n", msg); | ||||
|     getchar(); | ||||
|   } | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int warning_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_ICONQUESTION); | ||||
|   MessageBox(GetFocus(), msg, "ATTENZIONE", MB_OK | MB_ICONQUESTION); | ||||
| #else | ||||
|   beep(); | ||||
|   xvt_dm_post_note("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int message_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBox(GetFocus(), msg, "INFORMAZIONE", MB_OK | MB_ICONINFORMATION); | ||||
| #else | ||||
|   xvt_dm_post_note("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int sorry_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_OK); | ||||
|   MessageBox(GetFocus(), msg, "SPIACENTE", MB_OK | MB_ICONINFORMATION); | ||||
| #else | ||||
|   xvt_dm_post_note("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int yesno_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNO | MB_ICONQUESTION); | ||||
|   return r == IDYES; | ||||
| #else | ||||
|   ASK_RESPONSE r = xvt_dm_post_ask((char*) "Si", (char*) "No", NULL, "%s", msg); | ||||
|   return r == RESP_DEFAULT; | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int yesnofatal_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #ifdef DBG   | ||||
|   char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg); | ||||
|   const int ret = yesno_box("%s", s); | ||||
|   if (!ret) fatal_box(""); | ||||
| #else | ||||
|   fatal_box("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return FALSE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int yesnocancel_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNOCANCEL | MB_ICONQUESTION); | ||||
|   if (r == IDYES) r = K_YES; | ||||
|   else | ||||
|     if (r == IDNO) r = K_NO; | ||||
|     else | ||||
|       r = K_ESC; | ||||
|   return r; | ||||
| #else | ||||
|   ASK_RESPONSE r = xvt_dm_post_ask((char*) "Si", (char*) "No", (char*) "Annulla", "%s", msg); | ||||
|   if (r == RESP_DEFAULT) r = K_YES; | ||||
|   else | ||||
|     if (r == RESP_2) r = K_NO; | ||||
|     else | ||||
|       r = K_ESC; | ||||
|   return r; | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| int __trace(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   FILE* f = fopen("trace.log", "a"); | ||||
|   if (f != NULL) | ||||
|   { | ||||
|     fprintf(f, "%s\n", msg); | ||||
|     fclose(f); | ||||
|   } | ||||
|    | ||||
|   return f != NULL;   | ||||
| } | ||||
| 
 | ||||
| #endif // XVT_OS
 | ||||
| 
 | ||||
| 
 | ||||
| #ifdef FOXPRO | ||||
| 
 | ||||
| int error_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int fatal_box(const char* fmt, ...) | ||||
| { | ||||
|   MessageBeep(MB_ICONHAND); | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int message_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int yesnofatal_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| #endif // FOXPRO
 | ||||
| 
 | ||||
| #include <stdarg.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| #ifdef FOXPRO | ||||
| #undef XVT_OS | ||||
| #include <windows.h> | ||||
| #include <pro_ext.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifdef XVT_OS | ||||
| #include <xvt.h> | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
| #include <windows.h> | ||||
| #include <keys.h> | ||||
| #else | ||||
| #include <xvtility.h> | ||||
| #endif | ||||
| #include <applicat.h> | ||||
| #endif /* XVT_OS */ | ||||
| 
 | ||||
| 
 | ||||
| #include <checks.h> | ||||
| 
 | ||||
| #define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr) | ||||
| 
 | ||||
| #ifdef XVT_OS | ||||
| 
 | ||||
| int fatal_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_ICONHAND); | ||||
|   MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL); | ||||
| 
 | ||||
|   if (xvt_running()) | ||||
|     main_app().stop_run(); | ||||
|   else | ||||
|     exit(1); | ||||
| #else | ||||
|   beep(); | ||||
|   if (xvt_running()) xvt_dm_post_fatal_exit("%s", msg); | ||||
|   else | ||||
|   { | ||||
|     fprintf(stderr, "%s\n", msg); | ||||
|     getchar(); | ||||
|     exit(1); | ||||
|   } | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int error_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_ICONEXCLAMATION); | ||||
|   MessageBox(GetFocus(), msg, "ERRORE", MB_OK | MB_ICONEXCLAMATION); | ||||
| #else | ||||
|   beep(); | ||||
|   if (xvt_running()) xvt_dm_post_error("%s", msg); | ||||
|   else | ||||
|   { | ||||
|     fprintf(stderr, "%s\n", msg); | ||||
|     getchar(); | ||||
|   } | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int warning_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_ICONQUESTION); | ||||
|   MessageBox(GetFocus(), msg, "ATTENZIONE", MB_OK | MB_ICONQUESTION); | ||||
| #else | ||||
|   beep(); | ||||
|   xvt_dm_post_note("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int message_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBox(GetFocus(), msg, "INFORMAZIONE", MB_OK | MB_ICONINFORMATION); | ||||
| #else | ||||
|   xvt_dm_post_note("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int sorry_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   MessageBeep(MB_OK); | ||||
|   MessageBox(GetFocus(), msg, "SPIACENTE", MB_OK | MB_ICONINFORMATION); | ||||
| #else | ||||
|   xvt_dm_post_note("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int yesno_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNO | MB_ICONQUESTION); | ||||
|   return r == IDYES; | ||||
| #else | ||||
|   ASK_RESPONSE r = xvt_dm_post_ask((char*) "Si", (char*) "No", NULL, "%s", msg); | ||||
|   return r == RESP_DEFAULT; | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int yesnofatal_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #ifdef DBG   | ||||
|   char s[256]; sprintf(s, "%s\nContinuare ugualmente?", msg); | ||||
|   const int ret = yesno_box("%s", s); | ||||
|   if (!ret) fatal_box(""); | ||||
| #else | ||||
|   fatal_box("%s", msg); | ||||
| #endif | ||||
| 
 | ||||
|   return FALSE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int yesnocancel_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
| 
 | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   int r = MessageBox(GetFocus(), msg, "RICHIESTA", MB_YESNOCANCEL | MB_ICONQUESTION); | ||||
|   if (r == IDYES) r = K_YES; | ||||
|   else | ||||
|     if (r == IDNO) r = K_NO; | ||||
|     else | ||||
|       r = K_ESC; | ||||
|   return r; | ||||
| #else | ||||
|   ASK_RESPONSE r = xvt_dm_post_ask((char*) "Si", (char*) "No", (char*) "Annulla", "%s", msg); | ||||
|   if (r == RESP_DEFAULT) r = K_YES; | ||||
|   else | ||||
|     if (r == RESP_2) r = K_NO; | ||||
|     else | ||||
|       r = K_ESC; | ||||
|   return r; | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| int __trace(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   FILE* f = fopen("trace.log", "a"); | ||||
|   if (f != NULL) | ||||
|   { | ||||
|     fprintf(f, "%s\n", msg); | ||||
|     fclose(f); | ||||
|   } | ||||
|    | ||||
|   return f != NULL;   | ||||
| } | ||||
| 
 | ||||
| #endif // XVT_OS
 | ||||
| 
 | ||||
| 
 | ||||
| #ifdef FOXPRO | ||||
| 
 | ||||
| int error_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int fatal_box(const char* fmt, ...) | ||||
| { | ||||
|   MessageBeep(MB_ICONHAND); | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int message_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| 
 | ||||
| int yesnofatal_box(const char* fmt, ...) | ||||
| { | ||||
|   buildmsg(); | ||||
|   _UserError(msg); | ||||
|   return 0; | ||||
| } | ||||
| #endif // FOXPRO
 | ||||
| 
 | ||||
|  | ||||
| @ -1,26 +1,26 @@ | ||||
| #ifndef __KEYS_H | ||||
| #define __KEYS_H | ||||
| 
 | ||||
| #ifndef XVT_INCL_DEFS | ||||
| #include <xvt_defs.h> | ||||
| #endif | ||||
| 
 | ||||
| /* @M */ | ||||
| #define K_BACKSPACE     8 | ||||
| #define K_TAB           9 | ||||
| #define K_ENTER         13 | ||||
| #define K_ESC           27 | ||||
| #define K_SPACE         32 | ||||
| #define K_SHIFT         1000 | ||||
| #define K_CTRL          10000 | ||||
| #define K_CTRL_ENTER    K_CTRL+K_ENTER | ||||
| #define K_AUTO_ENTER    21013 | ||||
| #define K_QUIT          20334 | ||||
| #define K_FORCE_CLOSE   21334 | ||||
| #define K_SAVE          20082 | ||||
| #define K_SHIFT_TAB     K_SHIFT+K_TAB | ||||
| #define K_NO            20000+'N' | ||||
| #define K_YES           20000+'Y' | ||||
| 
 | ||||
| /* @END */ | ||||
| #endif | ||||
| #ifndef __KEYS_H | ||||
| #define __KEYS_H | ||||
| 
 | ||||
| #ifndef XVT_INCL_DEFS | ||||
| #include <xvt_defs.h> | ||||
| #endif | ||||
| 
 | ||||
| /* @M */ | ||||
| #define K_BACKSPACE     8 | ||||
| #define K_TAB           9 | ||||
| #define K_ENTER         13 | ||||
| #define K_ESC           27 | ||||
| #define K_SPACE         32 | ||||
| #define K_SHIFT         1000 | ||||
| #define K_CTRL          10000 | ||||
| #define K_CTRL_ENTER    K_CTRL+K_ENTER | ||||
| #define K_AUTO_ENTER    21013 | ||||
| #define K_QUIT          20334 | ||||
| #define K_FORCE_CLOSE   21334 | ||||
| #define K_SAVE          20082 | ||||
| #define K_SHIFT_TAB     K_SHIFT+K_TAB | ||||
| #define K_NO            20000+'N' | ||||
| #define K_YES           20000+'Y' | ||||
| 
 | ||||
| /* @END */ | ||||
| #endif | ||||
|  | ||||
| @ -30,4 +30,5 @@ | ||||
| #define PART_IMPTOTPAG  "IMPTOTPAG" | ||||
| #define PART_DATARIFPAG  "DATARIFPAG" | ||||
| #define PART_NUMRIFPAG  "NUMRIFPAG" | ||||
| #define PART_NRATA "NRATA" | ||||
| #define PART_CHIUSA "CHIUSA" | ||||
|  | ||||
| @ -1,267 +1,267 @@ | ||||
| //      $Id: progind.cpp,v 1.4 1995-03-22 09:06:23 guy Exp $
 | ||||
| 
 | ||||
| #include <defmask.h> | ||||
| #include <progind.h>   | ||||
| 
 | ||||
| const char* const CANCEL_TEXT = "Annulla"; | ||||
| const char* const TITLE_TEXT  = "Attesa"; | ||||
| 
 | ||||
| word TIndwin::measure_text(TToken_string& s, word& maxlen) const | ||||
| { | ||||
|   word lines = 0; | ||||
|   for(const char* t = s.get(0); t; t = s.get()) | ||||
|   { | ||||
|     const word l = strlen(t); | ||||
|     if (l > maxlen) maxlen = l; | ||||
|     lines++; | ||||
|   } | ||||
|   return lines; | ||||
| } | ||||
| 
 | ||||
| // Certified 70%
 | ||||
| TIndwin::TIndwin(long max, const char* txt, bool cancel,  bool bar, int div) | ||||
| { | ||||
|   _cancel = _bar = _text = NULL_WIN; | ||||
| 
 | ||||
|   _status = 0l; | ||||
|   _max = max; | ||||
|   if (_max <= 0) _max = 1;  | ||||
|   _flags = 0x0; | ||||
| 
 | ||||
|   TToken_string testo(txt, '\n'); | ||||
|   word maxlen = div; | ||||
|   const word lines = measure_text(testo, maxlen); | ||||
|    | ||||
|   int ver = lines+2; | ||||
|    | ||||
|   int hor = maxlen+2; if (hor > 78) hor = 78; | ||||
|    | ||||
|   if (bar)  | ||||
|   { | ||||
|     _bar = ver * CHARY; | ||||
|     ver += 3; | ||||
|   }   | ||||
|   ver += cancel ? 3 : 0; | ||||
| 
 | ||||
|   create(-1, -1, hor, ver, TITLE_TEXT); | ||||
|    | ||||
|   RCT r; r.left = CHARX; r.top = CHARY; r.right = CHARX*(hor-2); r.bottom = r.top + lines*CHARY+4;         | ||||
|   _text = xvt_ctl_create(WC_TEXT, &r, (char*)txt, win(), CTL_FLAG_CENTER_JUST, 0l, DLG_NULL); | ||||
|    | ||||
|   if (cancel) | ||||
|     _cancel = xvt_create_control(WC_PUSHBUTTON, -11, -1, 9, 2, | ||||
|                                  CANCEL_TEXT, win(), 0, 0l, DLG_CANCEL); | ||||
|   open_modal(); | ||||
|   do_events(); | ||||
| }  | ||||
| 
 | ||||
| void TIndwin::set_text(const char* t) | ||||
| { | ||||
|   xvt_vobj_set_title(_text, (char*)t); | ||||
| } | ||||
| 
 | ||||
| TIndwin::~TIndwin() | ||||
| { close_modal(); } | ||||
| 
 | ||||
| bool TIndwin::can_be_closed() const | ||||
| { | ||||
|   const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED); | ||||
|   if (!ok) error_box("Attendere la fine dell'operazione prima di chiudere l'applicazione"); | ||||
|   return ok; | ||||
| } | ||||
| 
 | ||||
| KEY TIndwin::check_stop() | ||||
| { | ||||
|   KEY k = 0; | ||||
|   if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED)) | ||||
|   {         | ||||
|     k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC; | ||||
|     stop_run(k); | ||||
|   }   | ||||
|   return k; | ||||
| } | ||||
| 
 | ||||
| void TIndwin::update_bar() | ||||
| { | ||||
|   if (_status >= _max) | ||||
|   { | ||||
|     _status = _max; | ||||
|     _flags |= IND_FINISHED; | ||||
|   } | ||||
| 
 | ||||
|   const double prc = (double)_status/_max; | ||||
|    | ||||
|   RCT r; xvt_vobj_get_client_rect(win(), &r); | ||||
|   r.left = CHARX; r.right -= CHARX; | ||||
|   r.top = (int)_bar;  | ||||
|   r.bottom = r.top + 3*CHARY; | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   r.top += 6; | ||||
|   r.bottom -= 6; | ||||
| #endif   | ||||
|   const int width = r.right - r.left; | ||||
|    | ||||
|   RCT b = r; | ||||
|   set_brush(COLOR_BLUE); | ||||
|   b.right = b.left + int(width*prc); | ||||
|   xvt_dwin_draw_rect(win(), &b); | ||||
| 
 | ||||
|   set_brush(COLOR_WHITE); | ||||
|   b.left = b.right; b.right = r.right; | ||||
|   xvt_dwin_draw_rect(win(), &b); | ||||
|    | ||||
|   set_mode(M_XOR); | ||||
|   xvt_dwin_set_fore_color(win(), COLOR_BLUE); | ||||
|   char n[8]; sprintf(n, "%d%%", int(100*prc));                                | ||||
|   xvt_dwin_draw_text(win(), r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1); | ||||
|   set_mode(M_COPY); | ||||
|    | ||||
|   check_stop(); | ||||
| } | ||||
| 
 | ||||
| void TIndwin::update() | ||||
| { | ||||
|   if (_bar) update_bar(); | ||||
| }      | ||||
| 
 | ||||
| 
 | ||||
| void TIndwin::handler(WINDOW w, EVENT* e) | ||||
| { | ||||
|   switch(e->type)  | ||||
|   { | ||||
|   case E_UPDATE: | ||||
|     xvt_dwin_clear(w, COLOR_WHITE); | ||||
|     update(); | ||||
|     return; | ||||
|   case E_CONTROL: | ||||
|     if (e->v.ctl.id == DLG_CANCEL) | ||||
|       dispatch_e_char(w, K_ESC); | ||||
|     break; | ||||
|   case E_CHAR: | ||||
|     // allowed only if cancel button is there
 | ||||
|     if (e->v.chr.ch == K_ESC) | ||||
|     { | ||||
|       if (_cancel)  | ||||
|       { | ||||
|         _flags |= IND_CANCELLED; | ||||
|         check_stop(); | ||||
|       }   | ||||
|       else return; | ||||
|     }  | ||||
|     break; | ||||
|   default: | ||||
|     break; | ||||
|   } | ||||
|   TWindow::handler(w,e); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // TProgind --------------------------------------------------------------
 | ||||
| 
 | ||||
| TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)  | ||||
| : TIndwin(max, txt, cancel, bar, div) | ||||
| {} | ||||
| 
 | ||||
| // TTimerind ------------------------------------------------------------
 | ||||
| 
 | ||||
| long TTimerind::_timer_id = 0L; | ||||
| 
 | ||||
| void TTimerind::handler(WINDOW w, EVENT* e) | ||||
| { | ||||
|   switch(e->type) | ||||
|   { | ||||
|   case E_CREATE: | ||||
|   case E_UPDATE: | ||||
|     if (_status == 0L) | ||||
|       _timer_id = xvt_timer_create(w, _interval); | ||||
|     break; | ||||
|   case E_TIMER: | ||||
|     if (e->v.timer.id == _timer_id) | ||||
|     { | ||||
|       _status += _interval; | ||||
|       force_update(); | ||||
|       xvt_timer_create(w, _interval); | ||||
|     } | ||||
|     break; | ||||
|   default: | ||||
|     break; | ||||
|   } | ||||
|   TIndwin::handler(w,e); | ||||
| } | ||||
| 
 | ||||
| TTimerind::TTimerind(long msec, const char* txt, | ||||
|                      bool cancel, bool bar, int div, int i) : | ||||
|                      TIndwin(msec, txt, cancel, bar, div) | ||||
| { | ||||
|   _interval = i; | ||||
|   _timer_id = 0L; | ||||
| } | ||||
| 
 | ||||
| TTimerind::~TTimerind() | ||||
| { xvt_timer_destroy(_timer_id); } | ||||
| 
 | ||||
| // C-style binding
 | ||||
| // uses static pointer for single instance of TIndwin
 | ||||
| 
 | ||||
| static TIndwin* __indwin__p = NULL; | ||||
| 
 | ||||
| void progind_create(long m, char* t, bool b, bool c, int n) | ||||
| {  | ||||
|   CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator"); | ||||
|   __indwin__p = new TProgind(m,t,b,c,n); | ||||
| } | ||||
| 
 | ||||
| void progind_set_status(long l) | ||||
| { | ||||
|   ((TProgind*)__indwin__p)->setstatus(l); | ||||
| } | ||||
| 
 | ||||
| void progind_cancel() | ||||
| { | ||||
|   __indwin__p->cancel(); | ||||
| } | ||||
| 
 | ||||
| bool  progind_iscancelled() | ||||
| { | ||||
|   return __indwin__p->iscancelled(); | ||||
| } | ||||
| 
 | ||||
| bool  progind_isfinished() | ||||
| { | ||||
|   return __indwin__p->isfinished(); | ||||
| } | ||||
| 
 | ||||
| void progind_destroy() | ||||
| { | ||||
|   delete __indwin__p; | ||||
|   __indwin__p = NULL; | ||||
| } | ||||
| 
 | ||||
| void timerind_create(long l, char* title, bool bar, bool cancel, | ||||
|                      int divisions, int interval) | ||||
| { | ||||
|   CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator"); | ||||
|   __indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval); | ||||
| } | ||||
| 
 | ||||
| void timerind_cancel() | ||||
| { | ||||
|   __indwin__p->cancel(); | ||||
| } | ||||
| 
 | ||||
| bool  timerind_iscancelled() | ||||
| { | ||||
|   return __indwin__p->iscancelled(); | ||||
| } | ||||
| 
 | ||||
| bool  timerind_isfinished() | ||||
| { | ||||
|   return __indwin__p->isfinished(); | ||||
| } | ||||
| 
 | ||||
| void timerind_destroy() | ||||
| { | ||||
|   delete __indwin__p; | ||||
|   __indwin__p = NULL; | ||||
| } | ||||
| 
 | ||||
| //      $Id: progind.cpp,v 1.5 1995-03-22 11:38:57 guy Exp $
 | ||||
| 
 | ||||
| #include <defmask.h> | ||||
| #include <progind.h>   | ||||
| 
 | ||||
| const char* const CANCEL_TEXT = "Annulla"; | ||||
| const char* const TITLE_TEXT  = "Attesa"; | ||||
| 
 | ||||
| word TIndwin::measure_text(TToken_string& s, word& maxlen) const | ||||
| { | ||||
|   word lines = 0; | ||||
|   for(const char* t = s.get(0); t; t = s.get()) | ||||
|   { | ||||
|     const word l = strlen(t); | ||||
|     if (l > maxlen) maxlen = l; | ||||
|     lines++; | ||||
|   } | ||||
|   return lines; | ||||
| } | ||||
| 
 | ||||
| // Certified 70%
 | ||||
| TIndwin::TIndwin(long max, const char* txt, bool cancel,  bool bar, int div) | ||||
| { | ||||
|   _cancel = _bar = _text = NULL_WIN; | ||||
| 
 | ||||
|   _status = 0l; | ||||
|   _max = max; | ||||
|   if (_max <= 0) _max = 1;  | ||||
|   _flags = 0x0; | ||||
| 
 | ||||
|   TToken_string testo(txt, '\n'); | ||||
|   word maxlen = div; | ||||
|   const word lines = measure_text(testo, maxlen); | ||||
|    | ||||
|   int ver = lines+2; | ||||
|    | ||||
|   int hor = maxlen+2; if (hor > 78) hor = 78; | ||||
|    | ||||
|   if (bar)  | ||||
|   { | ||||
|     _bar = ver * CHARY; | ||||
|     ver += 3; | ||||
|   }   | ||||
|   ver += cancel ? 3 : 0; | ||||
| 
 | ||||
|   create(-1, -1, hor, ver, TITLE_TEXT); | ||||
|    | ||||
|   RCT r; r.left = CHARX; r.top = CHARY; r.right = CHARX*(hor-2); r.bottom = r.top + lines*CHARY+4;         | ||||
|   _text = xvt_ctl_create(WC_TEXT, &r, (char*)txt, win(), CTL_FLAG_CENTER_JUST, 0l, DLG_NULL); | ||||
|    | ||||
|   if (cancel) | ||||
|     _cancel = xvt_create_control(WC_PUSHBUTTON, -11, -1, 9, 2, | ||||
|                                  CANCEL_TEXT, win(), 0, 0l, DLG_CANCEL); | ||||
|   open_modal(); | ||||
|   do_events(); | ||||
| }  | ||||
| 
 | ||||
| void TIndwin::set_text(const char* t) | ||||
| { | ||||
|   xvt_vobj_set_title(_text, (char*)t); | ||||
| } | ||||
| 
 | ||||
| TIndwin::~TIndwin() | ||||
| { close_modal(); } | ||||
| 
 | ||||
| bool TIndwin::can_be_closed() const | ||||
| { | ||||
|   const bool ok = (_flags & IND_FINISHED) || (_flags & IND_CANCELLED); | ||||
|   if (!ok) error_box("Attendere la fine dell'operazione prima di chiudere l'applicazione"); | ||||
|   return ok; | ||||
| } | ||||
| 
 | ||||
| KEY TIndwin::check_stop() | ||||
| { | ||||
|   KEY k = 0; | ||||
|   if ((_flags & IND_FINISHED) || (_flags & IND_CANCELLED)) | ||||
|   {         | ||||
|     k = (_flags & IND_FINISHED) ? K_ENTER : K_ESC; | ||||
|     stop_run(k); | ||||
|   }   | ||||
|   return k; | ||||
| } | ||||
| 
 | ||||
| void TIndwin::update_bar() | ||||
| { | ||||
|   if (_status >= _max) | ||||
|   { | ||||
|     _status = _max; | ||||
|     _flags |= IND_FINISHED; | ||||
|   } | ||||
| 
 | ||||
|   const double prc = (double)_status/_max; | ||||
|    | ||||
|   RCT r; xvt_vobj_get_client_rect(win(), &r); | ||||
|   r.left = CHARX; r.right -= CHARX; | ||||
|   r.top = (int)_bar;  | ||||
|   r.bottom = r.top + 3*CHARY; | ||||
| #if XVT_OS == XVT_OS_WIN | ||||
|   r.top += 6; | ||||
|   r.bottom -= 6; | ||||
| #endif   | ||||
|   const int width = r.right - r.left; | ||||
|    | ||||
|   RCT b = r; | ||||
|   set_brush(COLOR_BLUE); | ||||
|   b.right = b.left + int(width*prc); | ||||
|   xvt_dwin_draw_rect(win(), &b); | ||||
| 
 | ||||
|   set_brush(COLOR_WHITE); | ||||
|   b.left = b.right; b.right = r.right; | ||||
|   xvt_dwin_draw_rect(win(), &b); | ||||
|    | ||||
|   set_mode(M_XOR); | ||||
|   xvt_dwin_set_fore_color(win(), COLOR_BLUE); | ||||
|   char n[8]; sprintf(n, "%d%%", int(100*prc));                                | ||||
|   xvt_dwin_draw_text(win(), r.left+width/2-CHARX, (r.bottom+r.top+CHARY)/2-3, n, -1); | ||||
|   set_mode(M_COPY); | ||||
|    | ||||
|   check_stop(); | ||||
| } | ||||
| 
 | ||||
| void TIndwin::update() | ||||
| { | ||||
|   if (_bar) update_bar(); | ||||
| }      | ||||
| 
 | ||||
| 
 | ||||
| void TIndwin::handler(WINDOW w, EVENT* e) | ||||
| { | ||||
|   switch(e->type)  | ||||
|   { | ||||
|   case E_UPDATE: | ||||
|     xvt_dwin_clear(w, COLOR_WHITE); | ||||
|     update(); | ||||
|     return; | ||||
|   case E_CONTROL: | ||||
|     if (e->v.ctl.id == DLG_CANCEL) | ||||
|       dispatch_e_char(w, K_ESC); | ||||
|     break; | ||||
|   case E_CHAR: | ||||
|     // allowed only if cancel button is there
 | ||||
|     if (e->v.chr.ch == K_ESC) | ||||
|     { | ||||
|       if (_cancel)  | ||||
|       { | ||||
|         _flags |= IND_CANCELLED; | ||||
|         check_stop(); | ||||
|       }   | ||||
|       else return; | ||||
|     }  | ||||
|     break; | ||||
|   default: | ||||
|     break; | ||||
|   } | ||||
|   TWindow::handler(w,e); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // TProgind --------------------------------------------------------------
 | ||||
| 
 | ||||
| TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)  | ||||
| : TIndwin(max, txt, cancel, bar, div) | ||||
| {} | ||||
| 
 | ||||
| // TTimerind ------------------------------------------------------------
 | ||||
| 
 | ||||
| long TTimerind::_timer_id = 0L; | ||||
| 
 | ||||
| void TTimerind::handler(WINDOW w, EVENT* e) | ||||
| { | ||||
|   switch(e->type) | ||||
|   { | ||||
|   case E_CREATE: | ||||
|   case E_UPDATE: | ||||
|     if (_status == 0L) | ||||
|       _timer_id = xvt_timer_create(w, _interval); | ||||
|     break; | ||||
|   case E_TIMER: | ||||
|     if (e->v.timer.id == _timer_id) | ||||
|     { | ||||
|       _status += _interval; | ||||
|       force_update(); | ||||
|       xvt_timer_create(w, _interval); | ||||
|     } | ||||
|     break; | ||||
|   default: | ||||
|     break; | ||||
|   } | ||||
|   TIndwin::handler(w,e); | ||||
| } | ||||
| 
 | ||||
| TTimerind::TTimerind(long msec, const char* txt, | ||||
|                      bool cancel, bool bar, int div, int i) : | ||||
|                      TIndwin(msec, txt, cancel, bar, div) | ||||
| { | ||||
|   _interval = i; | ||||
|   _timer_id = 0L; | ||||
| } | ||||
| 
 | ||||
| TTimerind::~TTimerind() | ||||
| { xvt_timer_destroy(_timer_id); } | ||||
| 
 | ||||
| // C-style binding
 | ||||
| // uses static pointer for single instance of TIndwin
 | ||||
| 
 | ||||
| static TIndwin* __indwin__p = NULL; | ||||
| 
 | ||||
| void progind_create(long m, char* t, bool b, bool c, int n) | ||||
| {  | ||||
|   CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator"); | ||||
|   __indwin__p = new TProgind(m,t,b,c,n); | ||||
| } | ||||
| 
 | ||||
| void progind_set_status(long l) | ||||
| { | ||||
|   ((TProgind*)__indwin__p)->setstatus(l); | ||||
| } | ||||
| 
 | ||||
| void progind_cancel() | ||||
| { | ||||
|   __indwin__p->cancel(); | ||||
| } | ||||
| 
 | ||||
| bool  progind_iscancelled() | ||||
| { | ||||
|   return __indwin__p->iscancelled(); | ||||
| } | ||||
| 
 | ||||
| bool  progind_isfinished() | ||||
| { | ||||
|   return __indwin__p->isfinished(); | ||||
| } | ||||
| 
 | ||||
| void progind_destroy() | ||||
| { | ||||
|   delete __indwin__p; | ||||
|   __indwin__p = NULL; | ||||
| } | ||||
| 
 | ||||
| void timerind_create(long l, char* title, bool bar, bool cancel, | ||||
|                      int divisions, int interval) | ||||
| { | ||||
|   CHECK(__indwin__p == NULL, "Cannot have more than one progress indicator"); | ||||
|   __indwin__p = new TTimerind(l,title,bar,cancel,divisions,interval); | ||||
| } | ||||
| 
 | ||||
| void timerind_cancel() | ||||
| { | ||||
|   __indwin__p->cancel(); | ||||
| } | ||||
| 
 | ||||
| bool  timerind_iscancelled() | ||||
| { | ||||
|   return __indwin__p->iscancelled(); | ||||
| } | ||||
| 
 | ||||
| bool  timerind_isfinished() | ||||
| { | ||||
|   return __indwin__p->isfinished(); | ||||
| } | ||||
| 
 | ||||
| void timerind_destroy() | ||||
| { | ||||
|   delete __indwin__p; | ||||
|   __indwin__p = NULL; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| //      $Id: relapp.cpp,v 1.49 1995-03-22 09:06:25 guy Exp $        
 | ||||
| //      $Id: relapp.cpp,v 1.50 1995-03-22 11:38:59 guy Exp $        
 | ||||
| #include <mailbox.h> | ||||
| #include <sheet.h> | ||||
| #include <urldefid.h> | ||||
| @ -446,16 +446,20 @@ bool TRelation_application::modify_mode() | ||||
|   } | ||||
| 
 | ||||
|   _mask = get_mask(MODE_MOD); | ||||
|    | ||||
|   if (changing) | ||||
|   { | ||||
|     _mask->open_modal();                 | ||||
|     delete _maskeys;                    // May conflict! Keep this one
 | ||||
|     _maskeys = new TKey_array(_mask); | ||||
|   } | ||||
|    | ||||
|   set_mode(MODE_MOD); | ||||
| 
 | ||||
|   err = read(*_mask); | ||||
| 
 | ||||
|   if (changing) | ||||
|     _mask->open_modal(); | ||||
| 
 | ||||
|   if (err != NOERR) | ||||
|   { | ||||
|     error_box("Errore di caricamento dati nella maschera: %d", err); | ||||
|     error_box("Errore di caricamento dati: %d", err); | ||||
|     query_mode(); | ||||
|     return FALSE; | ||||
|   } | ||||
|  | ||||
							
								
								
									
										256
									
								
								include/text.h
									
									
									
									
									
								
							
							
						
						
									
										256
									
								
								include/text.h
									
									
									
									
									
								
							| @ -1,128 +1,128 @@ | ||||
| /* actually -*-c++-*- */ | ||||
| #ifndef __TEXTFILE_H | ||||
| #define __TEXTFILE_H | ||||
| 
 | ||||
| #ifndef __STDIO_H | ||||
| #include <stdio.h> | ||||
| #endif                                      | ||||
| 
 | ||||
| #ifndef __STRINGS_H | ||||
| #include <strings.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __WINDOW_H | ||||
| #include <window.h> | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| enum direction {up, down, updown}; | ||||
| enum style     {normal = XVT_FS_NONE, bold = XVT_FS_BOLD, italic = XVT_FS_ITALIC, underlined = XVT_FS_UNDERLINE }; | ||||
| 
 | ||||
| class TTextfile: public TObject | ||||
| { | ||||
|   enum {DEFAULT_PAGESIZE = 128}; | ||||
| 
 | ||||
|   TArray        _page; | ||||
|   TBit_array    _dirty_lines; | ||||
|   long          _page_start; | ||||
|   long          _page_end; | ||||
|   long          _page_size; | ||||
|   long          _lines; | ||||
|   long          _cur_line;                              | ||||
|   TFilename     _filename; | ||||
|   TFilename     _indname; | ||||
|   FILE*         _index; | ||||
|   FILE*         _instr; | ||||
|   direction     _direction; | ||||
|   TToken_string _line; | ||||
|   long          _styles[256]; | ||||
|   int           _item;   | ||||
|   TArray        _hotspots; | ||||
|   TArray        _spots; | ||||
|   bool          _dirty; | ||||
|   bool          _isopen;    | ||||
|   bool          _istemp;         | ||||
|   bool          _accept; | ||||
| 
 | ||||
|   void   _read_page(long line);          | ||||
|   bool   _in_page(long l)         | ||||
|   { return  l >= _page_start && l < _page_end; } | ||||
|   void   _save_changes(); | ||||
|    | ||||
|   //  void   _parse_style(long j);
 | ||||
|   style  _trans_style(char c);           | ||||
|    | ||||
| public: | ||||
|    | ||||
|   long        lines()   { return _lines; } | ||||
|   bool        changed() { return _dirty; }    | ||||
|    | ||||
|   // line() ritorna la stringa di caratteri senza formattazione
 | ||||
|   const char* line(long row, long column = 0, int howmuch = -1); | ||||
|   // line_formatted() la ritorna, come e' logico attendersi, con
 | ||||
|   // la formattazione
 | ||||
|   const char* line_formatted(long row); | ||||
|   // appende una riga al text (con i formati del caso)
 | ||||
|   bool        append(const char* l);   | ||||
|    | ||||
|   // chide tutti i files per poter copiare o eseguire operazioni
 | ||||
|   // dopo close() non si puo' piu' fare nulla
 | ||||
|   void        close(); | ||||
|   void        print();                      | ||||
|   // chiude l'aggiunta di nuove linee
 | ||||
|   void        freeze() { _accept = FALSE; } | ||||
|   bool        frozen() { return  !_accept; } | ||||
|    | ||||
|   // per leggere il testo formattato, si fa prima read_line, poi      
 | ||||
|   // si prende un pezzo per volta 
 | ||||
|   // style() ritorna lo stile (vedi enum) del piece() corrente
 | ||||
|   // se chiamata con parametri ritorna lo stile del carattere alla 
 | ||||
|   // posizione data 
 | ||||
|   // get_background() e get_foreground() ritornano il suo colore di bg e fg
 | ||||
|   // piece() ritorna il pezzo di linea successivo con stile e colore
 | ||||
|   // invarianti, o NULL quando non ce n'e' piu'     
 | ||||
|   // bello, vero?
 | ||||
|    | ||||
|   void        read_line(long j, long b = 0, bool pg = TRUE); | ||||
|   const char* piece();             | ||||
|   int         get_style(int pos = -1); | ||||
|   char        get_background(int pos = -1);               | ||||
|   char        get_foreground(int pos = -1);  | ||||
|    | ||||
|   long        get_attribute(int pos = -1); | ||||
|    | ||||
|   // ritorna la parola alla posizione indicata
 | ||||
|   const char* word_at(long x, long y);                   | ||||
|   // TBI ritorna il pezzo di testo da x a y  
 | ||||
|   // allochera' un altro TText che deve essere disfatto dall'utente
 | ||||
|   TTextfile*  section(TPoint& from, TPoint& to) { return this; }     | ||||
|   const char* name() { return (const char*)_filename; }   | ||||
|    | ||||
|   // scrive il testo (non formattato) su file, da punto a punto
 | ||||
|   // (tutto per default)
 | ||||
|   bool        write(const char* path, TPoint* from = NULL, TPoint* to = NULL); | ||||
|   // disfa tutto e svuota il file
 | ||||
|   void        destroy();  | ||||
| 
 | ||||
|   // search and replace (una riga per volta, rispetta i formati) 
 | ||||
|   // txt = text to search; pos = int to put the char position in;
 | ||||
|   // from = where to start; down = FALSE == up
 | ||||
|   long search (const char* txt,  int& pos, long from = 0,  | ||||
|                bool down = TRUE, bool casesens = FALSE); | ||||
|   // replace txt=txt in line=line at pos=pos for len=len
 | ||||
|   int  replace(long line, const char* txt, int pos = 0, int len = -1); | ||||
| 
 | ||||
|   // hypertext cazzuls                         
 | ||||
|   // le si dice il colore che devono avere i punti selezionabili;
 | ||||
|   // ritorna l'array in cui vengono messi gli hotspots relativi alla
 | ||||
|   // pagina in memoria (come TToken_string con x|y|text)
 | ||||
|   void set_hotspots(char fg, char bg = 'w'); | ||||
|   TArray& hotspots() { return _spots; } | ||||
|    | ||||
|   TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE,  | ||||
|             direction preferred = updown); | ||||
|   virtual ~TTextfile(); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| /* actually -*-c++-*- */ | ||||
| #ifndef __TEXTFILE_H | ||||
| #define __TEXTFILE_H | ||||
| 
 | ||||
| #ifndef __STDIO_H | ||||
| #include <stdio.h> | ||||
| #endif                                      | ||||
| 
 | ||||
| #ifndef __STRINGS_H | ||||
| #include <strings.h> | ||||
| #endif | ||||
| 
 | ||||
| #ifndef __WINDOW_H | ||||
| #include <window.h> | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| enum direction {up, down, updown}; | ||||
| enum style     {normal = XVT_FS_NONE, bold = XVT_FS_BOLD, italic = XVT_FS_ITALIC, underlined = XVT_FS_UNDERLINE }; | ||||
| 
 | ||||
| class TTextfile: public TObject | ||||
| { | ||||
|   enum {DEFAULT_PAGESIZE = 128}; | ||||
| 
 | ||||
|   TArray        _page; | ||||
|   TBit_array    _dirty_lines; | ||||
|   long          _page_start; | ||||
|   long          _page_end; | ||||
|   long          _page_size; | ||||
|   long          _lines; | ||||
|   long          _cur_line;                              | ||||
|   TFilename     _filename; | ||||
|   TFilename     _indname; | ||||
|   FILE*         _index; | ||||
|   FILE*         _instr; | ||||
|   direction     _direction; | ||||
|   TToken_string _line; | ||||
|   long          _styles[256]; | ||||
|   int           _item;   | ||||
|   TArray        _hotspots; | ||||
|   TArray        _spots; | ||||
|   bool          _dirty; | ||||
|   bool          _isopen;    | ||||
|   bool          _istemp;         | ||||
|   bool          _accept; | ||||
| 
 | ||||
|   void   _read_page(long line);          | ||||
|   bool   _in_page(long l)         | ||||
|   { return  l >= _page_start && l < _page_end; } | ||||
|   void   _save_changes(); | ||||
|    | ||||
|   //  void   _parse_style(long j);
 | ||||
|   style  _trans_style(char c);           | ||||
|    | ||||
| public: | ||||
|    | ||||
|   long        lines()   { return _lines; } | ||||
|   bool        changed() { return _dirty; }    | ||||
|    | ||||
|   // line() ritorna la stringa di caratteri senza formattazione
 | ||||
|   const char* line(long row, long column = 0, int howmuch = -1); | ||||
|   // line_formatted() la ritorna, come e' logico attendersi, con
 | ||||
|   // la formattazione
 | ||||
|   const char* line_formatted(long row); | ||||
|   // appende una riga al text (con i formati del caso)
 | ||||
|   bool        append(const char* l);   | ||||
|    | ||||
|   // chide tutti i files per poter copiare o eseguire operazioni
 | ||||
|   // dopo close() non si puo' piu' fare nulla
 | ||||
|   void        close(); | ||||
|   void        print();                      | ||||
|   // chiude l'aggiunta di nuove linee
 | ||||
|   void        freeze() { _accept = FALSE; } | ||||
|   bool        frozen() { return  !_accept; } | ||||
|    | ||||
|   // per leggere il testo formattato, si fa prima read_line, poi      
 | ||||
|   // si prende un pezzo per volta 
 | ||||
|   // style() ritorna lo stile (vedi enum) del piece() corrente
 | ||||
|   // se chiamata con parametri ritorna lo stile del carattere alla 
 | ||||
|   // posizione data 
 | ||||
|   // get_background() e get_foreground() ritornano il suo colore di bg e fg
 | ||||
|   // piece() ritorna il pezzo di linea successivo con stile e colore
 | ||||
|   // invarianti, o NULL quando non ce n'e' piu'     
 | ||||
|   // bello, vero?
 | ||||
|    | ||||
|   void        read_line(long j, long b = 0, bool pg = TRUE); | ||||
|   const char* piece();             | ||||
|   int         get_style(int pos = -1); | ||||
|   char        get_background(int pos = -1);               | ||||
|   char        get_foreground(int pos = -1);  | ||||
|    | ||||
|   long        get_attribute(int pos = -1); | ||||
|    | ||||
|   // ritorna la parola alla posizione indicata
 | ||||
|   const char* word_at(long x, long y);                   | ||||
|   // TBI ritorna il pezzo di testo da x a y  
 | ||||
|   // allochera' un altro TText che deve essere disfatto dall'utente
 | ||||
|   TTextfile*  section(TPoint& from, TPoint& to) { return this; }     | ||||
|   const char* name() { return (const char*)_filename; }   | ||||
|    | ||||
|   // scrive il testo (non formattato) su file, da punto a punto
 | ||||
|   // (tutto per default)
 | ||||
|   bool        write(const char* path, TPoint* from = NULL, TPoint* to = NULL); | ||||
|   // disfa tutto e svuota il file
 | ||||
|   void        destroy();  | ||||
| 
 | ||||
|   // search and replace (una riga per volta, rispetta i formati) 
 | ||||
|   // txt = text to search; pos = int to put the char position in;
 | ||||
|   // from = where to start; down = FALSE == up
 | ||||
|   long search (const char* txt,  int& pos, long from = 0,  | ||||
|                bool down = TRUE, bool casesens = FALSE); | ||||
|   // replace txt=txt in line=line at pos=pos for len=len
 | ||||
|   int  replace(long line, const char* txt, int pos = 0, int len = -1); | ||||
| 
 | ||||
|   // hypertext cazzuls                         
 | ||||
|   // le si dice il colore che devono avere i punti selezionabili;
 | ||||
|   // ritorna l'array in cui vengono messi gli hotspots relativi alla
 | ||||
|   // pagina in memoria (come TToken_string con x|y|text)
 | ||||
|   void set_hotspots(char fg, char bg = 'w'); | ||||
|   TArray& hotspots() { return _spots; } | ||||
|    | ||||
|   TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE,  | ||||
|             direction preferred = updown); | ||||
|   virtual ~TTextfile(); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user