gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/gui aqua.cpp aqua_glue.h aqua_ogl_glue.cpp


From: Markus Gothe
Subject: [Gnash-commit] gnash/gui aqua.cpp aqua_glue.h aqua_ogl_glue.cpp
Date: Tue, 24 Jul 2007 00:04:40 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Markus Gothe <nihilus>  07/07/24 00:04:40

Modified files:
        gui            : aqua.cpp aqua_glue.h aqua_ogl_glue.cpp 

Log message:
        More Carbon stuff

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/aqua.cpp?cvsroot=gnash&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/aqua_glue.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/aqua_ogl_glue.cpp?cvsroot=gnash&r1=1.14&r2=1.15

Patches:
Index: aqua.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/aqua.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- aqua.cpp    23 Jul 2007 01:13:10 -0000      1.16
+++ aqua.cpp    24 Jul 2007 00:04:39 -0000      1.17
@@ -18,7 +18,7 @@
 // 
 //
 
-/* $Id: aqua.cpp,v 1.16 2007/07/23 01:13:10 nihilus Exp $ */
+/* $Id: aqua.cpp,v 1.17 2007/07/24 00:04:39 nihilus Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -42,31 +42,70 @@
 
 #include <Carbon/Carbon.h>
 
-struct GlobalAppInfo  
+ToolboxObjectClassRef customWindow;
+WindowRef myWindow;
+WindowDefSpec myCustomWindowSpec;
+EventHandlerUPP myCustomWindowUPP;
+Rect theBounds = {200,200,400,400};
+ 
+EventTypeSpec eventList[] = {{kEventClassWindow, kEventWindowDrawFrame},
+                            {kEventClassWindow, kEventWindowHitTest}};
+
+static pascal OSStatus MyCustomWindowEventHandler (
+                                EventHandlerCallRef myHandler,
+                                EventRef theEvent, void* userData)
 {
-  CFBundleRef          mainBundle;
-  IBNibRef                     mainNib;
-  WindowGroupRef       windowGroups[3];
-};
-typedef struct GlobalAppInfo GlobalAppInfo;
-
-GlobalAppInfo  g;
-
-static pascal OSStatus AppEventHandlerProc(EventHandlerCallRef inCallRef, 
EventRef inEvent, void* inUserData)
-{
-  #pragma unused (inCallRef)
-  HICommand                    command;
-  WindowGroupRef               windowGroup;
-  WindowGroupAttributes windowGroupAttributes;
-  UInt32       eventKind       = GetEventKind(inEvent);
-  UInt32       eventClass      = GetEventClass(inEvent);
-  WindowRef    window          = (WindowRef) inUserData;
-  OSStatus     err             = eventNotHandledErr;
 
-  GNASH_REPORT_FUNCTION;
-  return err;  
+    #pragma unused (myHandler,userData)
+ 
+    OSStatus result = eventNotHandledErr;
+ 
+    UInt32 whatHappened;
+    WindowDefPartCode where;
+ 
+    GrafPtr thePort;
+    Rect windBounds;
+ 
+    whatHappened = GetEventKind (theEvent);
+ 
+    switch (whatHappened)
+    {
+        case kEventWindowInit:
+ 
+            GetEventParameter (theEvent, kEventParamDirectObject,
+                                               typeWindowRef, NULL, 
sizeof(WindowRef),
+                                                       NULL, &myWindow);
+                                                       
+            SetThemeWindowBackground (myWindow, 
kThemeBrushMovableModalBackground, true);      // 1
+            result = noErr;
+            break;
+ 
+        case kEventWindowDrawFrame:    // 2
+ 
+            GetPort(&thePort);         // 3
+            GetPortBounds(thePort, &windBounds);
+
+            PenNormal();                       // 4
+            PenSize (10,10);
+            FrameRect(&windBounds);    // 5
+ 
+            result = noErr;
+            break;
+ 
+        case kEventWindowHitTest:      // 6
+ 
+            /* determine what part of the window the user hit */
+            where = wInDrag;
+            SetEventParameter (theEvent, kEventParamWindowDefPart,     // 7
+                                typeWindowDefPartCode,
+                                sizeof(WindowDefPartCode), &where);
+ 
+            result = noErr;
+            break;
+    }
+ 
+    return (result);
 }
-static pascal OSStatus SimpleWindowEventHandlerProc(EventHandlerCallRef 
inCallRef, EventRef inEvent, void* inUserData);
 
 namespace gnash {
        
@@ -87,50 +126,9 @@
 
 bool AquaGui::run()
 {
-       OSErr                                           err;
-       static const EventTypeSpec      sApplicationEvents[] =  {  
{kEventClassCommand, kEventCommandProcess}  };
-  
        GNASH_REPORT_FUNCTION;
-       BlockZero(&g, sizeof(g));
-
-       g.mainBundle = CFBundleGetMainBundle();
-       if (g.mainBundle == NULL) 
-       {
-               err = false;
-               goto Bail;
-       }
-  
-       err = CreateNibReferenceWithCFBundle(g.mainBundle, CFSTR("aqua"), 
&g.mainNib);
-       if (err != noErr)goto Bail;
-       if (g.mainNib == NULL)
-       {
-               err = false;
-               goto Bail;
-       }
-               
-       err = SetMenuBarFromNib(g.mainNib, CFSTR("aqua"));
-       if (err != noErr)goto Bail;
-
-       InstallApplicationEventHandler(NewEventHandlerUPP(AppEventHandlerProc), 
GetEventTypeCount(sApplicationEvents), sApplicationEvents, 0, NULL);
-
-       //  Force the document group to be created first, so we can position 
our groups between the floating and document groups
-       (void) GetWindowGroupOfClass(kDocumentWindowClass);
-  
-       //  Create our default WindowGroups and set their z-order
-       err = CreateWindowGroup(0, &g.windowGroups[0]);
-       err = CreateWindowGroup(0, &g.windowGroups[1]);
-       err = CreateWindowGroup(0, &g.windowGroups[2]);
-
-       //  Position our groups behind the floating group and in front of the 
document group
-       SendWindowGroupBehind(g.windowGroups[2], 
GetWindowGroupOfClass(kDocumentWindowClass));
-       SendWindowGroupBehind(g.windowGroups[1], g.windowGroups[2]);
-       SendWindowGroupBehind(g.windowGroups[0], g.windowGroups[1]);
-    
-       RunApplicationEventLoop();
+    ShowWindow(myWindow);
     return true;
-
-Bail:
-       return err;    
 }
 
 void AquaGui::renderBuffer()
@@ -143,18 +141,36 @@
 AquaGui::setInvalidatedRegions(const InvalidatedRanges& ranges)
 {
        GNASH_REPORT_FUNCTION;
+#if 0  
     _glue.setInvalidatedRegions(ranges);
+#endif
 }
 
 bool AquaGui::init(int argc, char ***argv) /* Self-explainatory */
 {
+  
        GNASH_REPORT_FUNCTION;
   
-       _glue.init (argc, argv);
+       myCustomWindowUPP = NewEventHandlerUPP(MyCustomWindowEventHandler);
+ 
+       RegisterToolboxObjectClass(CFSTR("com.myCompany.myApp.customWindow"),   
// 2
+                                                               NULL, 
GetEventTypeCount(eventList), eventList,
+                                       myCustomWindowUPP, NULL, &customWindow);
+ 
+       myCustomWindowSpec.defType = kWindowDefObjectClass; // 3
+       myCustomWindowSpec.u.classRef = customWindow; // 4
+ 
+       CreateCustomWindow (&myCustomWindowSpec,kMovableModalWindowClass,       
// 5
+                       kWindowStandardHandlerAttribute,
+                       &theBounds,
+                       &myWindow);
+                    
+       _glue.init(argc, argv);
 
     _renderer = _glue.createRenderHandler();
     if(!_renderer)return false;    
     return true;       
+
 }
 
 void AquaGui::setTimeout(unsigned int timeout)
@@ -183,6 +199,7 @@
 #endif        
 }
 
+
 bool AquaGui::createWindow(const char* title, int width, int height)
 {
        _glue.prepDrawingArea(_width, _height);

Index: aqua_glue.h
===================================================================
RCS file: /sources/gnash/gnash/gui/aqua_glue.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- aqua_glue.h 23 Jul 2007 00:00:51 -0000      1.7
+++ aqua_glue.h 24 Jul 2007 00:04:39 -0000      1.8
@@ -18,7 +18,7 @@
 // 
 //
 
-/* $Id: aqua_glue.h,v 1.7 2007/07/23 00:00:51 nihilus Exp $ */
+/* $Id: aqua_glue.h,v 1.8 2007/07/24 00:04:39 nihilus Exp $ */
 
 #ifndef AQUA_GLUE_H
 #define AQUA_GLUE_H
@@ -34,7 +34,6 @@
   public:
     virtual ~AquaGlue() { }
     virtual bool init(int argc, char **argv[]) = 0;
-    virtual void setInvalidatedRegions(const InvalidatedRanges& /* ranges */) 
{}
     virtual bool prepDrawingArea(int width, int height) = 0;
     virtual render_handler* createRenderHandler() = 0;
     virtual void render() = 0;

Index: aqua_ogl_glue.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/aqua_ogl_glue.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- aqua_ogl_glue.cpp   23 Jul 2007 01:13:10 -0000      1.14
+++ aqua_ogl_glue.cpp   24 Jul 2007 00:04:39 -0000      1.15
@@ -18,7 +18,7 @@
 // 
 //
 
-/* $Id: aqua_ogl_glue.cpp,v 1.14 2007/07/23 01:13:10 nihilus Exp $ */
+/* $Id: aqua_ogl_glue.cpp,v 1.15 2007/07/24 00:04:39 nihilus Exp $ */
 
 
 #include "aqua_ogl_glue.h"
@@ -79,8 +79,9 @@
 
 bool AquaOglGlue::prepDrawingArea(int width, int height)
 {
+       GNASH_REPORT_FUNCTION;
     //SDL_SetVideoMode(width, height, _bpp, sdl_flags | SDL_OPENGL);
-
+#if 0
      // Turn on alpha blending.
     glEnable(GL_BLEND);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -99,7 +100,7 @@
     // We don't need lighting effects
     glDisable(GL_LIGHTING);
     glPushAttrib (GL_ALL_ATTRIB_BITS);         
-
+#endif
 #ifdef FIX_I810_LOD_BIAS
     glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 
_tex_lod_bias);
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]