wxMac: bring app into foreground? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
iaj
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Feb 17, 2006 7:50 am
Location: Switzerland

wxMac: bring app into foreground?

Post by iaj » Fri Feb 17, 2006 9:00 am

Hallo everyone,

wxMac 2.6.2, OS X 10.3.9

New to wxWidgets, and new to GUI programming on OS X, so this is probably trivial for all you gurus :-)

wxMac compiled fine, I built some samples without problems, but when
I run the exectubales, the windows appear and stay in the background,
there is no menu bar for the application, and the buttons and so on
do not get the focus.

I think I need to create .app bundles, but I don't know how. Could someone please point me at a concrete example or some documentation?

Many thanks

iaj

Ryan Wilcox
I live to help wx-kind
I live to help wx-kind
Posts: 194
Joined: Mon Aug 30, 2004 1:26 pm
Location: PA, USA
Contact:

Post by Ryan Wilcox » Fri Feb 17, 2006 4:34 pm

Correct. Below you'll find a Makefile that will generate the correct app bundle, or you can use bakefile to generate makefiles for a ton of operating systems/development toolchains. (I would probably go the bakefile route myself)

Code: Select all

################################################################################
# Makefile created by CHB from a
# Makefile generated by DialogBlocks
#
# Adapted to the minimal sample
#
################################################################################

PROGRAM=Minimal

OBJECTS=minimal.o \


ICONFILE=minimal.icns
BUNDLESIGNATURE=????
OUTPUTPATH=$(PROGRAM)Mac

BUNDLE=$(OUTPUTPATH)/$(PROGRAM).app

WXCONFIG=wx-config

CXX=g++

MACPACKAGEINFO=$(BUNDLE)/Contents/PkgInfo
LIBS=`$(WXCONFIG) --inplace  --libs`

LINKERFLAGS=
WARNINGFLAGS=
OPTFLAGS=
DEBUGFLAGS=

CPPINC=`$(WXCONFIG) --inplace --cxxflags`
LDFLAGS=$(LIBS) $(LINKERFLAGS)
CPPFLAGS=$(CPPINC) $(GCCFLAGS) $(DEBUGFLAGS) $(OPTFLAGS) $(WARNINGFLAGS)


all: $(BUNDLE)/Contents/MacOS/$(PROGRAM) $(MACPACKAGEINFO)

$(OUTPUTPATH):
     mkdir -p $(OUTPUTPATH)

clean:
     rm -f $(OBJECTS)
     rm -fr $(BUNDLE)

help:
     @echo "Usage: make -f Makefile [all|clean|help]"

# This builds the executable right inside the bundle.
$(BUNDLE)/Contents/MacOS/$(PROGRAM): $(OBJECTS) $(BUNDLE)
     $(CXX) -o $(BUNDLE)/Contents/MacOS/$(PROGRAM) $(OBJECTS) $(LDFLAGS)

# And here we build the Bundle
$(BUNDLE): Info.plist $(ICONFILE)
     @echo " Building: $(BUNDLE)"
     mkdir -p $(BUNDLE)/Contents
     mkdir -p $(BUNDLE)/Contents/MacOS
     mkdir -p $(BUNDLE)/Contents/Resources
     cp Info.plist $(BUNDLE)/Contents/Info.plist
     echo -n "APPL$(BUNDLESIGNATURE)" > $(MACPACKAGEINFO)
#    cp -f $(ICONFILE) $(BUNDLE)/Contents/Resources/$(ICONFILE)
     cp -f $(ICONFILE) $(BUNDLE)/Contents/Resources/wxmac.icns


$(OBJECTS): %.o: %.cpp %.h # each file depends on it's own code and 
headers, at least!
      $(CXX) -c -o [email protected] $(CPPFLAGS) $<

..PHONY:    all clean
Hope this helps,
_Ryan Wilcox[/url]
Ryan Wilcox
Wilcox Development Solutions
http://www.wilcoxd.com

iaj
In need of some credit
In need of some credit
Posts: 2
Joined: Fri Feb 17, 2006 7:50 am
Location: Switzerland

Post by iaj » Sat Feb 18, 2006 10:05 am

Ryan,

That was exactly what I needed to get me going. I hacked up an Info.plist by copying the one from Apple's Calculator and deleting
uninteresting keys, and it works great!

Thanks very much for your help.

iaj

Post Reply