Annotation of Examples/AppKit/Draw/DrawPageLayout.m, revision 1.1

1.1     ! root        1: #import "draw.h"
        !             2: 
        !             3: @implementation DrawPageLayout
        !             4: /*
        !             5:  * PageLayout is overridden so that the user can set the margins of
        !             6:  * the page.  This is important in a Draw program where the user
        !             7:  * typically wants to maximize the drawable area on the page.
        !             8:  *
        !             9:  * The accessory view is used to add the additional fields, and
        !            10:  * pickedUnits: is overridden so that the margin is displayed in the
        !            11:  * currently selected units.  Note that the accessoryView is set
        !            12:  * in InterfaceBuilder using the outlet mechanism!
        !            13:  *
        !            14:  * This can be used as an example of how to override Application Kit panels.
        !            15:  */
        !            16: 
        !            17: - pickedUnits:sender
        !            18: /*
        !            19:  * Called when the user selects different units (e.g. cm or inches).
        !            20:  * Must update the margin fields.
        !            21:  */
        !            22: {
        !            23:     float old, new;
        !            24: 
        !            25:     [self convertOldFactor:&old newFactor:&new];
        !            26:     [leftMargin setFloatValue:new * [leftMargin floatValue] / old];
        !            27:     [rightMargin setFloatValue:new * [rightMargin floatValue] / old];
        !            28:     [topMargin setFloatValue:new * [topMargin floatValue] / old];
        !            29:     [bottomMargin setFloatValue:new * [bottomMargin floatValue] / old];
        !            30: 
        !            31:     return [super pickedUnits:sender];
        !            32: }
        !            33: 
        !            34: - readPrintInfo
        !            35: /*
        !            36:  * Sets the margin fields from the Application-wide PrintInfo.
        !            37:  */
        !            38: {
        !            39:     PrintInfo *pi;
        !            40:     float conversion, dummy;
        !            41:     NXCoord left, right, top, bottom;
        !            42: 
        !            43:     [super readPrintInfo];
        !            44:     pi = [NXApp printInfo];
        !            45:     [self convertOldFactor:&conversion newFactor:&dummy];
        !            46:     [pi getMarginLeft:&left right:&right top:&top bottom:&bottom];
        !            47:     [leftMargin setFloatValue:left * conversion];
        !            48:     [rightMargin setFloatValue:right * conversion];
        !            49:     [topMargin setFloatValue:top * conversion];
        !            50:     [bottomMargin setFloatValue:bottom * conversion];
        !            51: 
        !            52:     return self;
        !            53: }
        !            54: 
        !            55: - writePrintInfo
        !            56: /*
        !            57:  * Sets the margin values in the Application-wide PrintInfo from
        !            58:  * the margin fields in the panel.
        !            59:  */
        !            60: {
        !            61:     PrintInfo *pi;
        !            62:     float conversion, dummy;
        !            63: 
        !            64:     [super writePrintInfo];
        !            65:     pi = [NXApp printInfo];
        !            66:     [self convertOldFactor:&conversion newFactor:&dummy];
        !            67:     if (conversion) {
        !            68:        [pi setMarginLeft:[leftMargin floatValue] / conversion
        !            69:                    right:[rightMargin floatValue] / conversion
        !            70:                      top:[topMargin floatValue] / conversion
        !            71:                   bottom:[bottomMargin floatValue] / conversion];
        !            72:     }
        !            73: 
        !            74:     return self;
        !            75: }
        !            76: 
        !            77: /* outlet setting methods */
        !            78: 
        !            79: - setTopBotForm:anObject
        !            80: {
        !            81:     [anObject setTarget:ok];
        !            82:     [anObject setAction:@selector(performClick:)];
        !            83:     [anObject setNextText:width];
        !            84:     topMargin = [anObject findCellWithTag:5];
        !            85:     bottomMargin = [anObject findCellWithTag:6];
        !            86:     return self;
        !            87: }
        !            88: 
        !            89: - setSideForm:anObject
        !            90: {
        !            91:     [scale setNextText:anObject];
        !            92:     [anObject setTarget:ok];
        !            93:     [anObject setAction:@selector(performClick:)];
        !            94:     leftMargin = [anObject findCellWithTag:3];
        !            95:     rightMargin = [anObject findCellWithTag:4];
        !            96:     return self;
        !            97: }
        !            98: 
        !            99: @end
        !           100: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.