eudora-mac/peteuserpane.c

1 line
14 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "peteuserpane.h" #define FILE_NUM 119 #pragma segment Util static pascal void PeteUserPaneIdle (ControlHandle theControl); static pascal void PeteUserPaneDraw (ControlHandle theControl, SInt16 part); static pascal ControlPartCode PeteUserPaneKeyDown (ControlHandle control, SInt16 keyCode, SInt16 charCode, SInt16 modifiers); static pascal ControlPartCode PeteUserPaneFocus (ControlHandle control, ControlFocusPart action); extern void DoKeyDown(WindowPtr topWin,EventRecord *event); // // CreatePeteUserPane // // Creates a user pane that contains a PETE field. This allows fields in dialogs to act // like PETE fields instead of TE fields. PETE user panes are given a control property // with the tag 'pete' (and the boolean value, true) so that we can easily determine that // this is a PETE control. Ordinarily, this might not be all that important since (for // instance) a window might be able to easily specify which of it's controls are or are // not of a specific type. In a dialog, however, this is not quite so easy since most // dialog handling code is bottlenecked to handle most of the dialog processing in an // application. By assigning a unique property to these controls the bottle neck routines // are able to look at a ControlHandle and determine whether or not it is a PETE user pane. // // We also set up a number of user pane procs to handle a the processing of a PETE control // in response to idle, keyDown and draw events. // // Lastly, the PETEHandle itself is stuffed into the control's refcon field. // // If we are unable to create the PETE user pane, we dispose of the PETE and return nil. // // Note: In order to use a PETE in a user pane of a dialog, you'll need to do the following // to your dialog and control: // 1. Create a 'CNTL' resource with a procID of 256 // 2. Your dialog must have a root control. This means that the dialog // must have the "use control hierarchy" bit set, so you'll have to // add your dialog to the 'hlist' variable in AddDlgx. // 3. After creating your dialog (with GetNewMyDialog), call CreatePeteUserPane // for any controls that are to contain PETE's. // 4. Initialize the win->pte pointer for your dialog to point to the PETEHandle // returned from CreatePeteUserPane. // // To get to the PETEHandle itself, use GetPeteDItem. // // Don't forget to PeteDispose the PETEHandle