~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to intern/ghost/intern/GHOST_WindowCarbon.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: GHOST_WindowCarbon.cpp,v 1.10 2003/12/26 20:12:40 rwenzlaff Exp $
 
2
 * $Id: GHOST_WindowCarbon.cpp,v 1.15 2005/06/08 18:54:17 ton Exp $
3
3
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or
31
31
 
32
32
/**
33
33
 
34
 
 * $Id: GHOST_WindowCarbon.cpp,v 1.10 2003/12/26 20:12:40 rwenzlaff Exp $
 
34
 * $Id: GHOST_WindowCarbon.cpp,v 1.15 2005/06/08 18:54:17 ton Exp $
35
35
 * Copyright (C) 2001 NaN Technologies B.V.
36
36
 * @author      Maarten Gribnau
37
37
 * @date        May 10, 2001
66
66
AGL_NONE,
67
67
};
68
68
 
 
69
 
 
70
 
69
71
WindowRef ugly_hack=NULL;
70
72
 
 
73
const EventTypeSpec     kWEvents[] = {
 
74
        { kEventClassWindow, kEventWindowZoom },  /* for new zoom behaviour */ 
 
75
};
 
76
 
 
77
static OSStatus myWEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData) {
 
78
        WindowRef mywindow;
 
79
        GHOST_WindowCarbon *ghost_window;
 
80
        OSStatus err;
 
81
        int theState;
 
82
        
 
83
        if (::GetEventKind(event) == kEventWindowZoom) {
 
84
                err =  ::GetEventParameter (event,kEventParamDirectObject,typeWindowRef,NULL,sizeof(mywindow),NULL, &mywindow);
 
85
                ghost_window = (GHOST_WindowCarbon *) GetWRefCon(mywindow);
 
86
                theState = ghost_window->getMac_windowState();
 
87
                if (theState == 1) 
 
88
                        ghost_window->setMac_windowState(2);
 
89
                else if (theState == 2)
 
90
                        ghost_window->setMac_windowState(1);
 
91
 
 
92
        }
 
93
        return eventNotHandledErr;
 
94
}
 
95
 
71
96
GHOST_WindowCarbon::GHOST_WindowCarbon(
72
97
        const STR_String& title,
73
98
        GHOST_TInt32 left,
86
111
        m_fullScreenDirty(false)
87
112
{
88
113
    Str255 title255;
 
114
        OSStatus err;
 
115
        
 
116
        //fprintf(stderr," main screen top %i left %i height %i width %i\n", top, left, height, width);
 
117
        
 
118
        if (state >= GHOST_kWindowState8Normal ) {
 
119
                if(state == GHOST_kWindowState8Normal) state= GHOST_kWindowStateNormal;
 
120
                else if(state == GHOST_kWindowState8Maximized) state= GHOST_kWindowStateMaximized;
 
121
                else if(state == GHOST_kWindowState8Minimized) state= GHOST_kWindowStateMinimized;
 
122
                else if(state == GHOST_kWindowState8FullScreen) state= GHOST_kWindowStateFullScreen;
 
123
                
 
124
                // state = state - 8;   this was the simple version of above code, doesnt work in gcc 4.0
 
125
                
 
126
                setMac_windowState(1);
 
127
        } else 
 
128
                setMac_windowState(0);
89
129
 
90
130
        if (state != GHOST_kWindowStateFullScreen) {
91
131
        Rect bnds = { top, left, top+height, left+width };
92
 
        Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized);
 
132
        // Boolean visible = (state == GHOST_kWindowStateNormal) || (state == GHOST_kWindowStateMaximized); /*unused*/
93
133
        gen2mac(title, title255);
94
134
        
95
 
        m_windowRef = ::NewCWindow(
96
 
            nil,                                                        // Storage 
97
 
            &bnds,                                                      // Bounding rectangle of the window
98
 
            title255,                                           // Title of the window
99
 
            visible,                                            // Window initially visible
100
 
            kWindowFullZoomGrowDocumentProc, //kWindowGrowDocumentProc,         // procID
101
 
            (WindowRef)-1L,                                     // Put window before all other windows
102
 
            true,                                                       // Window has minimize box
103
 
            (SInt32)this);                                      // Store a pointer to the class in the refCon
 
135
                err =  ::CreateNewWindow( kDocumentWindowClass,
 
136
                                                                 kWindowStandardDocumentAttributes+kWindowLiveResizeAttribute,
 
137
                                                                 &bnds,
 
138
                                                                 &m_windowRef);
 
139
                
 
140
                if ( err != noErr) {
 
141
                        fprintf(stderr," error creating window %i \n",err);
 
142
                } else {
 
143
                        
 
144
                        ::SetWRefCon(m_windowRef,(SInt32)this);
 
145
                        setTitle(title);
 
146
                        err = InstallWindowEventHandler (m_windowRef, myWEventHandlerProc, GetEventTypeCount(kWEvents), kWEvents,NULL,NULL); 
 
147
                        if ( err != noErr) {
 
148
                                fprintf(stderr," error creating handler %i \n",err);
 
149
                        } else {
 
150
                                //      ::TransitionWindow (m_windowRef,kWindowZoomTransitionEffect,kWindowShowTransitionAction,NULL);
 
151
                                ::ShowWindow(m_windowRef);
 
152
                                ::MoveWindow (m_windowRef, left, top,true);
 
153
                                
 
154
                        }
 
155
                }
104
156
        if (m_windowRef) {
105
157
            m_grafPtr = ::GetWindowPort(m_windowRef);
106
158
            setDrawingContextType(type);
602
654
        return GHOST_kSuccess;
603
655
}
604
656
 
 
657
#if 0
605
658
/** Reverse the bits in a GHOST_TUns8 */
606
659
static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
607
660
{
610
663
        ch= ((ch>>4)&0x0F) | ((ch<<4)&0xF0);
611
664
        return ch;
612
665
}
 
666
#endif
 
667
 
613
668
 
614
669
/** Reverse the bits in a GHOST_TUns16 */
615
670
static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
652
707
GHOST_TSuccess GHOST_WindowCarbon::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2], 
653
708
                                                                                                GHOST_TUns8 mask[16][2], int hotX, int hotY)
654
709
{
655
 
        setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1);
 
710
        return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1);
 
711
}
 
712
 
 
713
 
 
714
void GHOST_WindowCarbon::setMac_windowState(short value)
 
715
{
 
716
        mac_windowState = value;
 
717
}
 
718
 
 
719
short GHOST_WindowCarbon::getMac_windowState()
 
720
{
 
721
        return mac_windowState;
656
722
}