Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 30, 2011, 10:18 PM   #1
syl22-00
macrumors newbie
 
Join Date: Apr 2011
Carbon's HTML rendering library not showing images

Hi,

I am working on porting an old program that uses an embedded browser using the HTML Rendering library from Carbon. I am migrating it from codewarrior to Xcode, using the 10.4 SDK. The HTML page is displayed correctly, including links but images don't show up. I can see the alt content, and dimensions are properly set with the width and height fields.

I am doing the initialization with:

Code:
OSErr err = HRNewReference(m_HRRef, kHRRendererHTML32Type,
            GetWindowPort((WindowRef) m_pWindow));
And then I open my local HTML file with:

Code:
err = HRGoToFSRef(m_HRRef, &f, false, false);
My images are also stored locally but just do not appear, it was working fine previously on my ppc only codewarrior compilation.

I tried with web pages on Internet with HRGoToURL, and I tried replacing my pictures src fields with http:// or file:// links to images, in jpg, gif and png, always with the same result.

Are you aware of any issue like this? I know I could, and probably should, migrate to WebKit but that would me more involved.

Sylvain
syl22-00 is offline   0 Reply With Quote
Old May 30, 2011, 10:27 PM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Those functions were deprecated in 10.4, so I wouldn't be surprised to hear it's not working in 10.6.

Same thing for QuickDraw, and I've seen issues with that on 10.6.

Quote:
Originally Posted by syl22-00 View Post
I know I could, and probably should, migrate to WebKit but that would me more involved.
Accessing the WebKit From Carbon Applications

Looks pretty simple to me
kainjow is offline   0 Reply With Quote
Old May 31, 2011, 03:05 AM   #3
syl22-00
Thread Starter
macrumors newbie
 
Join Date: Apr 2011
Quote:
Originally Posted by kainjow View Post
Thank you.

Yes it does not look too complicated to me, however, I can't get the Cocoa view in my Carbon app. WebView and WebFrame are both defined in WebView.h and I am getting plenty of conflicts when I try to include that file. I am reading about Cocoa-Carbon integration, but getting either deprecated material or things relevant to the 10.5+ SDK, and I am using the 10.4 SDK (I have to).
syl22-00 is offline   0 Reply With Quote
Old May 31, 2011, 01:58 PM   #4
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
If you're using code from the sample LoadURL function, that needs to be compiled in a separate Objective-C file (with .m extension).
kainjow is offline   0 Reply With Quote
Old Jun 1, 2011, 06:29 AM   #5
syl22-00
Thread Starter
macrumors newbie
 
Join Date: Apr 2011
Quote:
Originally Posted by kainjow View Post
If you're using code from the sample LoadURL function, that needs to be compiled in a separate Objective-C file (with .m extension).
Thank you Kainjow for your help. I have never used Objective-C before.

So I added a new empty file to my project, called loadurl.m, added the code inside and tried to import a few header files (such as WebKit/WebView.h), I always get errors related to objc.h.

I found that gcc is called with -x c++, but File Type is set to sourcecode.c.obj. Am I doing something wrong?

Thanks a lot for your patience

Sylvain
syl22-00 is offline   0 Reply With Quote
Old Jun 1, 2011, 10:07 PM   #6
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Where do the errors originate? Usually if errors are coming from within a framework's header, the build window will show the file in your code where the #include/#import originated.

Can you post the code for the .h/.m files? Which version of Xcode are you using?
kainjow is offline   0 Reply With Quote
Old Jun 3, 2011, 05:28 AM   #7
syl22-00
Thread Starter
macrumors newbie
 
Join Date: Apr 2011
Quote:
Originally Posted by kainjow View Post
Where do the errors originate? Usually if errors are coming from within a framework's header, the build window will show the file in your code where the #include/#import originated.

Can you post the code for the .h/.m files? Which version of Xcode are you using?
I found that in my project, I was forcing files to be compiled in C++, that's why it could not compile my objective-c file although is was sourcecode-objc type. The problem is that when I changed my project to compile files depending on their type, I am getting thousand of errors in my own code (or the code I should make my own). It might be because my .h files are all set as c header files, I am trying to change them as c++ header files without much success so far...
syl22-00 is offline   0 Reply With Quote
Old Jun 7, 2011, 02:12 PM   #8
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
If you were compiling the source code using C++, compile them using Objective C++. That might help.
__________________
Get out of my mind, idea! I already have an idea in here!
Madd the Sane is offline   0 Reply With Quote
Old Jun 10, 2011, 06:42 AM   #9
syl22-00
Thread Starter
macrumors newbie
 
Join Date: Apr 2011
Thank you Madd and Kainjow,

I finally managed to have things working... well I can't see the web page yet, but it is just a matter of getting to know how to use the webkit API as the app compiles and links successfully.

In case it can help other people, here were the issues:

. My app was set to be compiled in C++, so even .m files would be compiled in c++. After changing "Compile source as" from "C++" to "according to file type", I would then have thousand of error because of my precompiled headers being compiled in C. The solution was to include the header files inside a "#if defined __cplusplus". Apparently the reason is that the compiler will attempt to compile the precompiled header both in C and C++, and you don't want them to be compiled in C.

. In the header file for the loadURL function, you need a extern "C" directive if compiled in C++ because C++ would mangle the names, not objective C.

So here are the .h and .m files:

loadurl.h:
Code:
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#import <Carbon/Carbon.h>
#import <webkit/WebView.h>
#endif

EXTERN_C void LoadURL( HIViewRef inView, CFURLRef inURL );
loadurl.m:
Code:
#import <webkit/webkit.h>
#import <webkit/HIWebView.h>
#import "loadurl.h"

void LoadURL( HIViewRef inView, CFURLRef inURL )
{
    WebView*            nativeView;
    NSURLRequest*       request;
    WebFrame*           mainFrame;
	
    nativeView = HIWebViewGetWebView( inView ); // get the Cocoa view
	
    // Use Objective-C calls to load the actual content
    request = [NSURLRequest requestWithURL:(NSURL*)inURL];
    mainFrame = [nativeView mainFrame];
    [mainFrame loadRequest:request];
}
syl22-00 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Moved iTunes library - music showing up as Shared Library vorpel Mac Basics and Help 0 Dec 9, 2013 11:55 PM
Need help with inserting Images in Wordpress(basic html question) Arkados Web Design and Development 7 Aug 4, 2013 03:01 AM
Issue with HTML Signature images in Mail 6.5 Devision Mac Applications and Mac App Store 1 Jun 14, 2013 09:48 AM
Resolved: Safari can't load images/javascript/html 5 on certain website. Traisoon OS X 1 Nov 23, 2012 09:31 AM

Forum Jump

All times are GMT -5. The time now is 11:39 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC