Difference between revisions of "Mac OS X Porting - Native Controls"

From Apache OpenOffice Wiki
Jump to: navigation, search
(salnativewidgets.cxx)
(List of all the controls to change + pictures (VCL<->Apple) equivalent)
Line 31: Line 31:
 
This header file describes all the structures, classes and constants used to get the state and properties of the VCL controls. It is necessary to be familiar with this file since its content will be used to translate the state and properties to their Carbon equivalent.
 
This header file describes all the structures, classes and constants used to get the state and properties of the VCL controls. It is necessary to be familiar with this file since its content will be used to translate the state and properties to their Carbon equivalent.
  
==List of all the controls to change + pictures (VCL<->Apple) equivalent==
+
==All the controls==
 +
Here is a list of all the controls that need to be native. Since some of them do not have the same name in VCL and Carbon, they are listed in this format: <VCL name> - <Carbon name> when they are different.
 +
 
 +
===Push Button===
 +
This is the regular OK, Cancel buttons.
 +
 
 +
===Radio Button===
 +
This is the regular radio button.
 +
 
 +
===Check Box===
 +
This is the regular check box.
 +
 
 +
More to come...
 +
 
 +
<!--
 +
// Combobox, i.e. a ListBox
 +
// that allows data entry by user
 +
#define CTRL_COMBOBOX 20
 +
 
 +
// Control that allows text entry
 +
#define CTRL_EDITBOX 30
 +
 
 +
// Control that allows text entry, but without the usual border
 +
// Has to be handled separately, because this one cannot handle
 +
// HAS_BACKGROUND_TEXTURE, which is drawn in the edit box'es
 +
// border window.
 +
#define CTRL_EDITBOX_NOBORDER 31
 +
 
 +
// Control that allows text entry
 +
// ( some systems distingish between single and multi line edit boxes )
 +
#define CTRL_MULTILINE_EDITBOX 32
 +
 
 +
// Control that pops up a menu,
 +
// but does NOT allow data entry
 +
#define CTRL_LISTBOX 35
 +
 
 +
// An edit field together with two little
 +
// buttons on the side (aka spin field)
 +
#define CTRL_SPINBOX 40
 +
 
 +
// Two standalone spin buttons
 +
// without an edit field
 +
#define CTRL_SPINBUTTONS 45
 +
 
 +
// A single tab
 +
#define CTRL_TAB_ITEM 50
 +
 
 +
// The border around a tab area,
 +
// but without the tabs themselves.
 +
// May have a gap at the top for
 +
// the active tab
 +
#define CTRL_TAB_PANE 55
 +
 
 +
// Background of a Tab Pane
 +
#define CTRL_TAB_BODY 56
 +
 
 +
// Normal scrollbar, including
 +
// all parts like slider, buttons
 +
#define CTRL_SCROLLBAR 60
 +
 
 +
// Border around a group of related
 +
// items, perhaps also displaying
 +
// a label of identification
 +
#define CTRL_GROUPBOX 70
 +
 
 +
// A separator line
 +
#define CTRL_FIXEDLINE 80
 +
 
 +
// A rectangular border, like a
 +
// Tab Pane, but without the
 +
// possible gap for a tab
 +
#define CTRL_FIXEDBORDER 90
 +
 
 +
// A toolbar control with buttons and a grip
 +
#define CTRL_TOOLBAR     100
 +
 
 +
// The menubar
 +
#define CTRL_MENUBAR     120
 +
// popup menu
 +
#define CTRL_MENU_POPUP        121
 +
 
 +
// The statusbar
 +
#define CTRL_STATUSBAR     130
 +
 
 +
// tool tips
 +
#define CTRL_TOOLTIP            140 -->
 +
 
 
==To do==
 
==To do==
 
==Pictures of the current state==
 
==Pictures of the current state==

Revision as of 21:55, 2 September 2006

Native Controls

Introduction

The purpose of this article is to present our current knowledge and progress of the implementation of native controls in the native Mac OS X version of OpenOffice.org. Our goal by implementing native controls is to remove the win32 look as much as possible and replace it by the Aqua look and feel using the Carbon API.

Apple Documentation and References

The Appearance Manager and HITheme

Apple provides an easy way to change a custom user interface to an aqua interface by using the Appearance Manager(AM). This API was first developed for Mac OS 8 and is centered around QuickDraw. The AM is less and less supported by Apple since 10.2 and any implementation needs to be replaced with the HIToolbox version: HITheme. The problem with HITheme is that its implementation started on Mac OS X 10.2 (Jaguar) and has since gone under many revisions and new functions have been progressively added with each new version of OS X. Therefore some functions in the 10.4 version might not be in 10.3 or 10.2. This will probably be one of the reason why the native version of OpenOffice.org will run on Mac OS X 10.4 and higher only.

Using HITheme

Unfortunately there is not much documentation provided by Apple about HITheme. Thus we have to look at the HITheme.h header file directly and read the extensive comments to understand how to use this API. All the constants used to describe the type of controls that we want to implement is still the same as in the AM. This is the reason why the AM reference document is still useful and should always be opened when implementing native controls. The AM and HITheme are very similar in the way they approach the implementation of native controls, most of the time the functions have similar names and the arguments different types so you can always use the AM reference to give you an idea about the procedure to follow.

Native controls in VCL

Native Controls Files in VCL

salnativewidgets.cxx

This file was copied directly from the Windows implementation of native controls. All the useless functions were removed and we are left with 6 functions:

  • isNativeControlSupported: function called to see if a control should be implemented natively or not. A big switch statement that goes through all the controls and part of controls possible. Returns true when a control is supported. Each time a new control is implemented this function should be modified so the new native code is used at compile time.
  • hitTestNativeControl: [TO DO]
  • getState: a translation from the VCL constants to the Carbon constants of the state of controls.
  • drawNativeControl: the most important function. This is where the code for new native controls is written. Again it is a big switch statment that lists each control with the corresponding implementation. Needs to be modified each time a new control is implemented.
  • drawNativeControlText: [TO DO]
  • getNativeControlRegion: [TO DO]

salnativewidgets.hxx

This header file describes all the structures, classes and constants used to get the state and properties of the VCL controls. It is necessary to be familiar with this file since its content will be used to translate the state and properties to their Carbon equivalent.

All the controls

Here is a list of all the controls that need to be native. Since some of them do not have the same name in VCL and Carbon, they are listed in this format: <VCL name> - <Carbon name> when they are different.

Push Button

This is the regular OK, Cancel buttons.

Radio Button

This is the regular radio button.

Check Box

This is the regular check box.

More to come...


To do

Pictures of the current state

-- Pdefilippis aliscafo@gmail.com

Personal tools