view dwt/internal/cocoa/NSRulerView.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 * Port to the D Programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.internal.cocoa.NSRulerView;

import dwt.internal.cocoa.CGFloat;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSRulerMarker;
import dwt.internal.cocoa.NSScrollView;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

enum NSRulerOrientation
{
    NSHorizontalRuler,
    NSVerticalRuler
}

alias NSRulerOrientation.NSHorizontalRuler NSHorizontalRuler;
alias NSRulerOrientation.NSVerticalRuler NSVerticalRuler;

public class NSRulerView : NSView
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public NSView accessoryView ()
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_accessoryView);
        return result !is null ? new NSView(result) : null;
    }

    public void addMarker (NSRulerMarker marker)
    {
        OS.objc_msgSend(this.id, OS.sel_addMarker_1, marker !is null ? marker.id : null);
    }

    public CGFloat baselineLocation ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_baselineLocation);
    }

    public NSView clientView ()
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_clientView);
        return result !is null ? new NSView(result) : null;
    }

    public void drawHashMarksAndLabelsInRect (NSRect rect)
    {
        OS.objc_msgSend(this.id, OS.sel_drawHashMarksAndLabelsInRect_1, rect);
    }

    public void drawMarkersInRect (NSRect rect)
    {
        OS.objc_msgSend(this.id, OS.sel_drawMarkersInRect_1, rect);
    }

    public NSRulerView initWithScrollView (NSScrollView scrollView, NSRulerOrientation orientation)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithScrollView_1orientation_1, scrollView !is null ? scrollView.id : null, orientation);
        return result !is null ? this : null;
    }

    public void invalidateHashMarks ()
    {
        OS.objc_msgSend(this.id, OS.sel_invalidateHashMarks);
    }

    public bool isFlipped ()
    {
        return OS.objc_msgSend(this.id, OS.sel_isFlipped) !is null;
    }

    public NSArray markers ()
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_markers);
        return result !is null ? new NSArray(result) : null;
    }

    public NSString measurementUnits ()
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_measurementUnits);
        return result !is null ? new NSString(result) : null;
    }

    public void moveRulerlineFromLocation (CGFloat oldLocation, CGFloat newLocation)
    {
        OS.objc_msgSend(this.id, OS.sel_moveRulerlineFromLocation_1toLocation_1, oldLocation, newLocation);
    }

    public NSRulerOrientation orientation ()
    {
        return OS.objc_msgSend(this.id, OS.sel_orientation);
    }

    public CGFloat originOffset ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_originOffset);
    }

    public static void registerUnitWithName (NSString unitName, NSString abbreviation, CGFloat conversionFactor, NSArray stepUpCycle,
            NSArray stepDownCycle)
    {
        OS.objc_msgSend(OS.class_NSRulerView, OS.sel_registerUnitWithName_1abbreviation_1unitToPointsConversionFactor_1stepUpCycle_1stepDownCycle_1,
                unitName !is null ? unitName.id : null, abbreviation !is null ? abbreviation.id : null, conversionFactor,
                stepUpCycle !is null ? stepUpCycle.id : null, stepDownCycle !is null ? stepDownCycle.id : null);
    }

    public void removeMarker (NSRulerMarker marker)
    {
        OS.objc_msgSend(this.id, OS.sel_removeMarker_1, marker !is null ? marker.id : null);
    }

    public CGFloat requiredThickness ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_requiredThickness);
    }

    public CGFloat reservedThicknessForAccessoryView ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_reservedThicknessForAccessoryView);
    }

    public CGFloat reservedThicknessForMarkers ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_reservedThicknessForMarkers);
    }

    public CGFloat ruleThickness ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_ruleThickness);
    }

    public NSScrollView scrollView ()
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_scrollView);
        return result !is null ? new NSScrollView(result) : null;
    }

    public void setAccessoryView (NSView accessory)
    {
        OS.objc_msgSend(this.id, OS.sel_setAccessoryView_1, accessory !is null ? accessory.id : null);
    }

    public void setClientView (NSView client)
    {
        OS.objc_msgSend(this.id, OS.sel_setClientView_1, client !is null ? client.id : null);
    }

    public void setMarkers (NSArray markers)
    {
        OS.objc_msgSend(this.id, OS.sel_setMarkers_1, markers !is null ? markers.id : null);
    }

    public void setMeasurementUnits (NSString unitName)
    {
        OS.objc_msgSend(this.id, OS.sel_setMeasurementUnits_1, unitName !is null ? unitName.id : null);
    }

    public void setOrientation (NSRulerOrientation orientation)
    {
        OS.objc_msgSend(this.id, OS.sel_setOrientation_1, orientation);
    }

    public void setOriginOffset (CGFloat offset)
    {
        OS.objc_msgSend(this.id, OS.sel_setOriginOffset_1, offset);
    }

    public void setReservedThicknessForAccessoryView (CGFloat thickness)
    {
        OS.objc_msgSend(this.id, OS.sel_setReservedThicknessForAccessoryView_1, thickness);
    }

    public void setReservedThicknessForMarkers (CGFloat thickness)
    {
        OS.objc_msgSend(this.id, OS.sel_setReservedThicknessForMarkers_1, thickness);
    }

    public void setRuleThickness (CGFloat thickness)
    {
        OS.objc_msgSend(this.id, OS.sel_setRuleThickness_1, thickness);
    }

    public void setScrollView (NSScrollView scrollView)
    {
        OS.objc_msgSend(this.id, OS.sel_setScrollView_1, scrollView !is null ? scrollView.id : null);
    }

    public bool trackMarker (NSRulerMarker marker, NSEvent event)
    {
        return OS.objc_msgSend(this.id, OS.sel_trackMarker_1withMouseEvent_1, marker !is null ? marker.id : null, event !is null ? event.id : null) !is null;
    }

}