Qt 4.8
Classes | Typedefs | Functions | Variables
qfontdialog_mac.mm File Reference
#include "qfontdialog_p.h"
#include <qapplication.h>
#include <qdialogbuttonbox.h>
#include <qlineedit.h>
#include <private/qapplication_p.h>
#include <private/qfont_p.h>
#include <private/qfontengine_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
#include <qabstracteventdispatcher.h>
#include <qdebug.h>
#include <private/qfontengine_coretext_p.h>
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>

Go to the source code of this file.

Classes

protocol  <NSWindowDelegate >
 
class  QCocoaFontPanelDelegate
 

Typedefs

typedef float CGFloat
 

Functions

NSButton * macCreateButton (const char *text, NSView *superview)
 
void macStartInterceptNSPanelCtor ()
 
void macStopInterceptNSPanelCtor ()
 
static QFont qfontForCocoaFont (NSFont *cocoaFont, const QFont &resolveFont)
 
bool qt_mac_is_macsheet (const QWidget *w)
 

Variables

const CGFloat ButtonBottomMargin = 7.0
 
const CGFloat ButtonMinHeight = 32.0
 
const CGFloat ButtonMinWidth = 78.0
 
const CGFloat ButtonSideMargin = 9.0
 
const CGFloat ButtonSpacing = 0.0
 
const CGFloat ButtonTopMargin = 0.0
 
const CGFloat DialogSideMargin = 9.0
 
const CGFloat DialogTopMargin = 7.0
 
const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
 

Typedef Documentation

◆ CGFloat

typedef float CGFloat

Definition at line 59 of file qfontdialog_mac.mm.

Function Documentation

◆ macCreateButton()

NSButton* macCreateButton ( const char *  text,
NSView *  superview 
)

Definition at line 211 of file qnspanelproxy_mac.mm.

Referenced by QFontDialogPrivate::createNSFontPanelDelegate().

212 {
213  static const NSRect buttonFrameRect = { { 0.0, 0.0 }, { 0.0, 0.0 } };
214 
215  NSButton *button = [[NSButton alloc] initWithFrame:buttonFrameRect];
216  [button setButtonType:NSMomentaryLightButton];
217  [button setBezelStyle:NSRoundedBezelStyle];
218  [button setTitle:(NSString*)(CFStringRef)QCFString(QDialogButtonBox::tr(text)
219  .remove(QLatin1Char('&')))];
220  [[button cell] setFont:[NSFont systemFontOfSize:
221  [NSFont systemFontSizeForControlSize:NSRegularControlSize]]];
222  [superview addSubview:button];
223  return button;
224 }
const struct __CFString * CFStringRef
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80

◆ macStartInterceptNSPanelCtor()

void macStartInterceptNSPanelCtor ( )

Definition at line 150 of file qnspanelproxy_mac.mm.

151 {
153  [NSPanel class],
154  @selector(initWithContentRect:styleMask:backing:defer:),
156  @selector(initWithContentRect:styleMask:backing:defer:),
157  @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:));
159  [NSPanel class],
160  @selector(initWithContentRect:styleMask:backing:defer:screen:),
162  @selector(initWithContentRect:styleMask:backing:defer:screen:),
163  @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:));
164 }
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
#define QT_MANGLE_NAMESPACE(name)
Definition: qglobal.h:106

◆ macStopInterceptNSPanelCtor()

void macStopInterceptNSPanelCtor ( )

Definition at line 169 of file qnspanelproxy_mac.mm.

170 {
172  [NSPanel class],
173  @selector(initWithContentRect:styleMask:backing:defer:screen:),
174  @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:));
176  [NSPanel class],
177  @selector(initWithContentRect:styleMask:backing:defer:),
178  @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:));
179 }
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)

◆ qfontForCocoaFont()

static QFont qfontForCocoaFont ( NSFont *  cocoaFont,
const QFont resolveFont 
)
static

Definition at line 139 of file qfontdialog_mac.mm.

140 {
141  QFont newFont;
142  if (cocoaFont) {
143  int pSize = qRound([cocoaFont pointSize]);
144  CTFontDescriptorRef font = CTFontCopyFontDescriptor((CTFontRef)cocoaFont);
145  // QCoreTextFontDatabase::populateFontDatabase() is using localized names
146  QString family = QCFString::toQString((CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL));
147  QString style = QCFString::toQString((CFStringRef) CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL));
148 
149  newFont = QFontDatabase().font(family, style, pSize);
150  newFont.setUnderline(resolveFont.underline());
151  newFont.setStrikeOut(resolveFont.strikeOut());
152 
153  CFRelease(font);
154  }
155  return newFont;
156 }
const struct __CFString * CFStringRef
QFont font(const QString &family, const QString &style, int pointSize) const
Returns a QFont object that has family family, style style and point size pointSize.
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition: qfont.cpp:1320
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Definition: qfont.cpp:1331
static QString toQString(CFStringRef cfstr)
Definition: qcore_mac.cpp:47
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QFontDatabase class provides information about the fonts available in the underlying window syste...
Definition: qfontdatabase.h:66
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
Definition: qfont.cpp:1378
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
Definition: qfont.cpp:1367
static float pointSize(const QFontDef &fd, int dpi)
Definition: qfont_win.cpp:90
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ qt_mac_is_macsheet()

bool qt_mac_is_macsheet ( const QWidget w)

Definition at line 295 of file qwidget_mac.mm.

Referenced by QFontDialogPrivate::showCocoaFontPanel().

296 {
297  if (!w)
298  return false;
299 
300  Qt::WindowModality modality = w->windowModality();
301  if (modality == Qt::ApplicationModal)
302  return false;
303  return w->parentWidget() && (modality == Qt::WindowModal || w->windowType() == Qt::Sheet);
304 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
Qt::WindowModality windowModality
which windows are blocked by the modal widget
Definition: qwidget.h:156
Qt::WindowType windowType() const
Returns the window type of this widget.
Definition: qwidget.h:937
WindowModality
Definition: qnamespace.h:1683

Variable Documentation

◆ ButtonBottomMargin

const CGFloat ButtonBottomMargin = 7.0

Definition at line 77 of file qfontdialog_mac.mm.

Referenced by QFontDialogPrivate::createNSFontPanelDelegate().

◆ ButtonMinHeight

const CGFloat ButtonMinHeight = 32.0

Definition at line 74 of file qfontdialog_mac.mm.

Referenced by QFontDialogPrivate::createNSFontPanelDelegate().

◆ ButtonMinWidth

const CGFloat ButtonMinWidth = 78.0

Definition at line 73 of file qfontdialog_mac.mm.

◆ ButtonSideMargin

const CGFloat ButtonSideMargin = 9.0

Definition at line 78 of file qfontdialog_mac.mm.

◆ ButtonSpacing

const CGFloat ButtonSpacing = 0.0

Definition at line 75 of file qfontdialog_mac.mm.

◆ ButtonTopMargin

const CGFloat ButtonTopMargin = 0.0

Definition at line 76 of file qfontdialog_mac.mm.

Referenced by QFontDialogPrivate::createNSFontPanelDelegate().

◆ DialogSideMargin

const CGFloat DialogSideMargin = 9.0

Definition at line 82 of file qfontdialog_mac.mm.

Referenced by QFontDialogPrivate::createNSFontPanelDelegate().

◆ DialogTopMargin

const CGFloat DialogTopMargin = 7.0

Definition at line 81 of file qfontdialog_mac.mm.

Referenced by QFontDialogPrivate::createNSFontPanelDelegate().

◆ StyleMask

const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask

Definition at line 84 of file qfontdialog_mac.mm.