Package org.rococoa.cocoa.foundation

Examples of org.rococoa.cocoa.foundation.NSString


    }

    private void check(NSDictionary dictionary) {
        assertEquals(2, dictionary.count());
               
        NSString value = Rococoa.cast(
                dictionary.objectForKey(NSString.stringWithString("string key")),
                NSString.class);
        assertEquals("string value", value.toString());
   
        NSNumber value2 = Rococoa.cast(
                dictionary.objectForKey("int key"),
                NSNumber.class);
        assertEquals(42, value2.intValue());
View Full Code Here


        panel.setDelegate(ocProxy.id());
        int button = panel.runModalForTypes(null);
//              or, eg       
//                NSArray.CLASS.arrayWithObjects(
//                    NSString.stringWithString("txt"), null));
        NSString filenameAsNSString = panel.filename();
        if (button == NSOpenPanel.NSOKButton) {
            assertTrue(filenameAsNSString.toString().startsWith("/Users"));
        } else {
            assertEquals(NSOpenPanel.NSCancelButton, button);
            assertNull(filenameAsNSString);
        }
    }
View Full Code Here

        assertFalse(fortyTwo.equals(fortyThree));
        assertFalse(fortyTwo.equals(null));
    }
       
    @Test public void testEqualsMapsToIsEqual() {
        NSString s1 = NSString.stringWithString("string");
        NSString s2 = NSString.stringWithString("STRING").lowercaseString();
        assertNotSame(s1, s2);
        assertFalse(s1.id().equals(s2.id()));
        assertEquals(s1, s2);
    }
View Full Code Here

        assertEquals(0, e.compare(e));
        assertEquals(1, fortyTwo.compare(e));
    }
   
    @Test public void testStringMarshalling() {
        NSString string = NSString.CLASS.stringWithString("Hello world");
        assertTrue(string.isEqualToString("Hello world"));
        assertFalse(string.isEqualToString("Hello worldy"));
    }
View Full Code Here

        NSNumber fortyTwo = NSNumber.CLASS.numberWithInt(42);
        assertEquals("42", fortyTwo.toString());       
    }
   
    @Test public void testGeneratedClassName() {
        NSString string = NSString.stringWithString("Hello World");
        Class<? extends NSString> stringClass = string.getClass();
        assertEquals(NSString.class.getPackage(), stringClass.getPackage());
        assertEquals("NSString$$ByRococoa", stringClass.getSimpleName());
    }
View Full Code Here

        assertEquals("(\n    Hello,\n    Goodbye\n)", array.description());
       
        NSObject first = array.objectAtIndex(0);
        assertEquals(NSString.stringWithString("Hello"), first);
       
        NSString firstAsString = Rococoa.cast(first, NSString.class);
        assertEquals("Hello", firstAsString.toString());
        assertEquals("Goodbye",
                Rococoa.cast(array.objectAtIndex(1), NSString.class).toString());
    }  
View Full Code Here

                // Obtain a CFDictionary containing this window's information dictionary
                Pointer pointer = CoreFoundationLibrary.INSTANCE.CFArrayGetValueAtIndex(originalArray, i);
                CFDictionaryRef dictionaryRef = new CFDictionaryRef(pointer);

                // Determine the process ID of this window
                NSString kCGWindowOwnerPID = CoreGraphicsLibrary.kCGWindowOwnerPID;
                Pointer pidPointer = CoreFoundationLibrary.INSTANCE.CFDictionaryGetValue(dictionaryRef, kCGWindowOwnerPID.id());
                NativeLongByReference longByReference = new NativeLongByReference();
                CoreFoundationLibrary.INSTANCE.CFNumberGetValue(pidPointer, CoreFoundationLibrary.CFNumberType.kCFNumberLongType, longByReference.getPointer());
                long pidLong = longByReference.getValue().longValue();

                if (pidLong == pid) {
                    // This window is a Hearthstone window

                    // When running in full-screen mode, Hearthstone has two windows: one for the game and one that appears to be a temporary desktop or space for the game to run in.
                    // The game window always has a kCGWindowLayer of zero, whereas the desktop has a non-zero kCGWindowLayer.
                    NSString kCGWindowLayer = CoreGraphicsLibrary.kCGWindowLayer;
                    Pointer windowLayerPointer = CoreFoundationLibrary.INSTANCE.CFDictionaryGetValue(dictionaryRef, kCGWindowLayer.id());
                    IntByReference windowLayerRef = new IntByReference();
                    CoreFoundationLibrary.INSTANCE.CFNumberGetValue(windowLayerPointer, CoreFoundationLibrary.CFNumberType.kCFNumberFloatType, windowLayerRef.getPointer());
                    int windowLayer = windowLayerRef.getValue();

                    if (windowLayer == 0) {
                        // This window has a zero kCGWindowLayer so it must be the main Hearthstone window

                        NSString kCGWindowNumber = CoreGraphicsLibrary.kCGWindowNumber;
                        Pointer windowNumberPointer = CoreFoundationLibrary.INSTANCE.CFDictionaryGetValue(dictionaryRef, kCGWindowNumber.id());
                        IntByReference windowIdRef = new IntByReference();
                        CoreFoundationLibrary.INSTANCE.CFNumberGetValue(windowNumberPointer, CoreFoundationLibrary.CFNumberType.kCFNumberIntType, windowIdRef.getPointer());
                        int windowId = windowIdRef.getValue();

                        return windowId;
View Full Code Here

        // Obtain a CFDictionary containing this window's information dictionary
        Pointer pointer = CoreFoundationLibrary.INSTANCE.CFArrayGetValueAtIndex(originalArray, i);
        CFDictionaryRef dictionaryRef = new CFDictionaryRef(pointer);

        // Determine the ID of this window
        NSString kCGWindowNumber = CoreGraphicsLibrary.kCGWindowNumber;
        Pointer windowNumberPointer = CoreFoundationLibrary.INSTANCE.CFDictionaryGetValue(dictionaryRef, kCGWindowNumber.id());
        IntByReference windowIdRef = new IntByReference();
        CoreFoundationLibrary.INSTANCE.CFNumberGetValue(windowNumberPointer, CoreFoundationLibrary.CFNumberType.kCFNumberIntType, windowIdRef.getPointer());
        int thisWindowId = windowIdRef.getValue();

        if (thisWindowId == _windowId) {

          // Determine the bounds of this window
          NSString kCGWindowBounds = CoreGraphicsLibrary.kCGWindowBounds;
          Pointer boundPointer = CoreFoundationLibrary.INSTANCE.CFDictionaryGetValue(dictionaryRef, kCGWindowBounds.id());

          CoreGraphicsLibrary.CGRectRef rect = new CoreGraphicsLibrary.CGRectRef();
          boolean result = CoreGraphicsLibrary.INSTANCE.CGRectMakeWithDictionaryRepresentation(boundPointer, rect);

          int x = (int) rect.origin.x;
View Full Code Here

TOP

Related Classes of org.rococoa.cocoa.foundation.NSString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.