home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / DLOGManager 1.02 / Source Code / CGestisciTE_v02.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-06  |  8.2 KB  |  339 lines  |  [TEXT/KAHL]

  1. /***
  2.  *    CGestisciTE_v02.h
  3.  *
  4.  *    Handle a textEdit field.
  5.  *    © 1994-96 Francesco Cadili.
  6.  *
  7.  ****/
  8. #ifndef __CGestisciTE__
  9. #define __CGestisciTE__
  10. #ifndef __Cstring_P__
  11. #include "Cstring_P_v32.h"
  12. #endif
  13. #include <Fonts.h>
  14. #include <Events.h>
  15. #include <Dialogs.h>
  16. #include <Controls.h>
  17. #include <QuickDraw.h>
  18.  
  19. class CGestisci_TE
  20. {
  21.     private:
  22.         /*** "InitData(textFont, textHeight)"
  23.          *
  24.          *    Inizializza i dati relativi al DLOG.
  25.          *    (Presuppone che i primi dati della struttura globale
  26.          *    siano presenti).
  27.          *
  28.          *    Par INPUT:    'textFont' la fonte del campo text edit,
  29.          *                'textHeight' l'altezza del campo text edit.
  30.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  31.          *
  32.          ***/
  33.         Boolean InitData(short textFont, short textHeight, Rect &editRect,
  34.                         Boolean hasScroll, Boolean hasOrizScroll, 
  35.                         Boolean noWarpAround, Boolean canModify, 
  36.                         Boolean useChicagoRef, Boolean maximizeField);
  37.  
  38.         /*** clickInEdit(&theEvent);
  39.          *
  40.          *     gestisce il click nel campo Text Edit.
  41.          *
  42.          ****/
  43.         Boolean clickInEdit(EventRecord *theEvent);
  44.  
  45.         /*** "clickInVerScroll(&theEvent)"
  46.          *
  47.          *    Gestisce i click nella scroll Bar verticale.
  48.          *
  49.          *    Non tratta il doppio click e lo scroll mentre il bottone é abbassato.
  50.          *
  51.          *    Par INPUT:    'TEHdl' il puntatore alla struttura dati attuale,
  52.          *                'theEvent' il puntatore al record dell'evento attuale;
  53.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  54.          ***/
  55.         Boolean clickInVerScroll(EventRecord *theEvent);
  56.         
  57.         /*** "clickInHorScroll(&theEvent)"
  58.          *
  59.          *    Gestisce i click nella scroll Bar orizzontale.
  60.          *
  61.          *    Non tratta il doppio click e lo scroll mentre il bottone é abbassato.
  62.          *
  63.          *    Par INPUT:    'TEHdl' il puntatore alla struttura dati attuale,
  64.          *                'theEvent' il puntatore al record dell'evento attuale;
  65.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  66.          ***/
  67.         Boolean clickInHorScroll(EventRecord *theEvent);
  68.  
  69.     protected:
  70.         DialogPtr        theDialog;        // il puntatore al dialog che contiene i campi;
  71.         RGBColor        backGround;        // il colore di BackGround;
  72.         short            linee;            // il numero di linee del campo textEdit;
  73.         Boolean            attivo;            // se il text edit è attivo. 
  74.         short            top;            //    il valore del control
  75.         short            left;            //    il valore del control
  76.         short            styleID;
  77.         int                maxHorChar;
  78.  
  79.         /*** Procedura "mostaTesto()"
  80.          *
  81.          *    Mosta la parte attuale del TextEdit.
  82.          *    Chiamare qggiustaScroll per sistemare il
  83.          *    testo.
  84.          *
  85.          ****/
  86.         void mostraTesto(void);
  87.         
  88.         /*** keyStroke1st(TEHdl);
  89.          *
  90.          *     Gestisce l'inserimento nel text edit
  91.          *
  92.          *    Par INPUT:    'theEvent' il puntatore al record dell'evento attuale;
  93.          *
  94.          *****************************************************************/
  95.         Boolean keyStroke1st(    EventRecord *theEvent, GrafPtr &port,
  96.                                 RGBColor *BackColor, Boolean &modified);
  97.  
  98.         /*** result = sostituisciTesto1st(ptrStr, len);
  99.          *
  100.          *    Sostituisce il contenuto del textEdit con un teso qualunque.
  101.          *
  102.          *    Par INPUT:    'ptrStr' il puntatore alla stringa,
  103.          *                'len' la lunghezza del testo.
  104.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  105.          *
  106.          ***/
  107.         Boolean sostituisciTesto1st(Cstring_P *str);
  108.  
  109.         /*** result = cancellaTesto1st();
  110.          *
  111.          *    Cancella il contenuto del textEdit.
  112.          *
  113.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  114.          *
  115.          ***/
  116.         Boolean cancellaTesto1st();
  117.  
  118.         /*** result = aggiungiTesto1st(str);
  119.          *
  120.          *    Sostituisce il contenuto del textEdit con un teso qualunque.
  121.          *
  122.          *    Par INPUT:    'str' il descrittore della stringa.
  123.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  124.          *
  125.          ***/
  126.         Boolean CGestisci_TE::aggiungiTesto1st(Cstring_P *str);
  127.  
  128.     public:
  129.         TEHandle         edit;            // il campo text edit;
  130.         ControlHandle     scroll;            // il campo di scroll;
  131.         ControlHandle     horScroll;        //    lo scroll orizzontale.
  132.         Boolean         canModify;        // se il text edit èpuò essere modificato (per ora non usato). 
  133.         short             TEitem;            // il numero di item del User Item relativo al Text Edit;
  134.         Boolean         frame;
  135.         Boolean         canModifyApparence;
  136.         Boolean         overBox;
  137.         enum             {kStdFont = systemFont, kStdHeight = 12};
  138.  
  139.         /*** constructor
  140.          *
  141.          ***/
  142.         CGestisci_TE(void);
  143.         
  144.         /*** destructor
  145.          *
  146.          ***/
  147.         ~CGestisci_TE(void);
  148.         
  149.         /*** TEHdl = IGestisci_TE(theDialog, TEitem, CTRLitem, &backGround, textFont, textHeight)
  150.          *
  151.          *    Alloca la struttura dati "gestTERec" nello Heap.
  152.          *
  153.          *    Par INPUT:    'theDialog' il puntatore al dialog,
  154.          *                'TEitem' il numero di item del campo text edit,
  155.          *                'CTRLitem' il numero di item del campo di scroll,
  156.          *                '*backGround' lo sfondo del campo text edit,
  157.          *                'textFont' la fonte del campo text edit,
  158.          *                'textHeight' l'altezza del campo text edit.
  159.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  160.          *
  161.          ***/
  162.         Boolean IGestisci_TE(    DialogPtr theDialog, short TEitem, Rect &editRect, 
  163.                                 RGBColor *backGround, short textFont,
  164.                                 short textHeight, Boolean hasScroll = true,
  165.                                 Boolean hasOrizScroll = false, 
  166.                                 Boolean noWarpAround = false, 
  167.                                 Boolean canModify = true, short    styleID = 0,
  168.                                 Boolean canModifyApparence = true,
  169.                                 Boolean useChicagoRef = false,
  170.                                 Boolean maximizeField = true);
  171.  
  172.         /*** Dispose()
  173.          *
  174.          *    Dealloca la struttura dati "dataHdl".
  175.          *    Nota:    da chiamare prima della deallocazione del
  176.          *            dialog (**TEHdl)->theDialog.
  177.          *
  178.          ***/
  179.         void Dispose(void);
  180.  
  181.         /*** unFrame()
  182.          *
  183.          *    Toglie il frame.
  184.          *
  185.          ***/
  186.         void unFrame(void);
  187.  
  188.         /*** result = cancellaTesto();
  189.          *
  190.          *    Cancella il contenuto del textEdit.
  191.          *
  192.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  193.          *
  194.          ***/
  195.         Boolean cancellaTesto(void);
  196.  
  197.         /*** result = sostituisciTesto(str);
  198.          *
  199.          *    Sostituisce il contenuto del textEdit con un teso qualunque.
  200.          *
  201.          *    Par INPUT:    'str' la stringa.
  202.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  203.          *
  204.          ***/
  205.         Boolean sostituisciTesto(Cstring_P *str);
  206.  
  207.         /*** result = aggiungiTesto(str);
  208.          *
  209.          *    Sostituisce il contenuto del textEdit con un teso qualunque.
  210.          *
  211.          *    Par INPUT:    'ptrStr' il puntatore alla stringa,
  212.          *                'len' la lunghezza del testo.
  213.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  214.          *
  215.          ***/
  216.         Boolean aggiungiTesto(Cstring_P *str);
  217.  
  218.         /*** attivaTesto();
  219.          *
  220.          *     Attiva il Text Edit.
  221.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  222.          *
  223.          ***/
  224.         Boolean attivaTesto(Boolean selectAll = false, Boolean frame = false);
  225.  
  226.         /*** disabilitaTesto();
  227.          *
  228.          *     Attiva il Text Edit.
  229.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  230.          *
  231.          ***/
  232.         Boolean disattivaTesto();
  233.  
  234.         /*** blink(TEHdl);
  235.          *
  236.          *    gestisce il blink del cursore nel Text Edit
  237.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  238.          *
  239.          ****/
  240.         Boolean blink(void);
  241.  
  242.         /*** keyStroke(TEHdl);
  243.          *
  244.          *     Gestisce l'inserimento nel text edit
  245.          *
  246.          *    Par INPUT:    'theEvent' il puntatore al record dell'evento attuale;
  247.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  248.          *
  249.          *****************************************************************/
  250.         virtual Boolean keyStroke(EventRecord *theEvent);
  251.  
  252.         /*** clickInTE(&theEvent);
  253.          *
  254.          *     gestisce il click nel campo Text Edit.
  255.          *    Val OUTPUT:    false se tutto ok, true altrimenti.
  256.          *
  257.          ****/
  258.         Boolean clickInTE(EventRecord *theEvent);
  259.  
  260.         /*** Procedura "AggiustaScroll()"
  261.          *
  262.          *    Aggiusta lo scroll del campo corrente.
  263.          *    Sulla base del contenuto del campo 
  264.          *
  265.          ***/
  266.         void AggiustaScroll(void);
  267.  
  268.         /*** "listaFont()"
  269.          *
  270.          *    Gestisce l'updateEvt nei campi definiti come "user"
  271.          *
  272.          ***/
  273.         void updateEvt(void);
  274.  
  275.         /*** scrollFactor(scrollAmt)
  276.          *
  277.          *    scrolla il testo up and down.
  278.          *
  279.          ***/
  280.         void scrollFactor(short scrollAmt);
  281.  
  282.         /*** "AggiustaTesto()"
  283.          *
  284.          *    Aggiusta l'TE.
  285.          *
  286.          ***/
  287.         void AggiustaTesto(void);
  288.  
  289.         /***
  290.          *
  291.          *    Set the font of a new character
  292.          *
  293.          ***/
  294.         Boolean setFont(short fontNum, Point *thePoint);
  295.  
  296.         /***
  297.          *
  298.          *    Set the size of a new character
  299.          *
  300.          ***/
  301.         Boolean setSize(short fontSize, Point *thePoint);
  302.  
  303.         /***
  304.          *
  305.          *    Set the size of a new character
  306.          *
  307.          ***/
  308.         Boolean setStyle(short fontSize, Point *thePoint);
  309.  
  310.         /*** GetFontInfo()
  311.          *
  312.          *    get the font info.
  313.          *
  314.          ***/
  315.         Boolean GetFontInfo(short *font, short *size, short *face);
  316.  
  317.         /*** copy()
  318.          *
  319.          ***/
  320.         Boolean copy();
  321.  
  322.         /*** paste
  323.          *
  324.          ***/
  325.         Boolean paste();
  326.         
  327.         /*** cut
  328.          *
  329.          ***/
  330.         Boolean cut();
  331.  
  332.         /*** cancel
  333.          *
  334.          ***/
  335.         Boolean cancel();
  336. };
  337. #endif
  338.  
  339.