Subversion Repositories filter_foundry

Rev

Rev 430 | Rev 477 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.     This file is part of a common library for Adobe(R) plugins
  3.     Copyright (C) 2002-2010 Toby Thain, toby@telegraphics.com.au
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. */
  19.  
  20. /* Cross-platform user interface defines */
  21.  
  22. #ifndef UI_COMPAT_H_
  23. #define UI_COMPAT_H_
  24.  
  25. #if macintosh
  26.         #include <qdoffscreen.h>
  27.         #include <sound.h>
  28.         #include <dialogs.h>
  29.         #include <controls.h>
  30.  
  31.         #include "dlg.h"
  32.         #include "menu.h"
  33.  
  34.         typedef DialogRef DIALOGREF;
  35.         typedef ControlRef CTLREF;
  36.         typedef struct MACBITMAP {
  37.                 GWorldPtr gw;
  38.                 PixMapHandle pm;
  39.         } *BITMAPREF;
  40.         typedef Rect UIRECT;
  41.  
  42.         #define LOCKBITMAP(pb) LockPixels(pb->pm)
  43.         #define UNLOCKBITMAP(pb) UnlockPixels(pb->pm)
  44.         #define ROWBYTES(pb) GetPixRowBytes(pb->pm)
  45.         #define BASEADDR(pb) GetPixBaseAddr(pb->pm)
  46.  
  47.         #define ENABLECONTROL(c) HiliteControl(c,0)
  48.         #define DISABLECONTROL(c)  HiliteControl(c,255)
  49.         #define ENABLEDLGITEM EnableDlgControl
  50.         #define DISABLEDLGITEM DisableDlgControl
  51.  
  52.         #define SELECTDLGITEMTEXT SelectDialogItemText
  53.         #define CHECKDLGBUTTON SetDlgControlValue
  54.         #define SETBUTTONVALUE SetControlValue
  55. //              ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),
  56. //                SetControlValue((ControlHandle)itemHdl,v) )
  57.         #define ISDLGBUTTONCHECKED GetDlgControlValue
  58. //              ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),
  59. //                GetControlValue((ControlHandle)itemHdl) )
  60.  
  61.         #define GETSLIDERVALUE GetDlgControlValue
  62.         #define SETSLIDERVALUE SetDlgControlValue
  63.         #define GETCTLTEXT getctltext
  64.         #define SETCTLTEXT setctltext
  65.         #define GETCTLTEXTINT getctltextint
  66.         #define SETCTLTEXTINT setctltextint
  67.         #define SELECTCTLTEXT selectctltext
  68.         // TODO
  69.         #define REPAINTCTL(d,i)
  70.  
  71. /*
  72.         #define ENABLECONTROL(d,i) \
  73.                 ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\
  74.                   HiliteControl((ControlHandle)itemHdl,0) )
  75.         #define DISABLECONTROL(d,i) \
  76.                 ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\
  77.                   HiliteControl((ControlHandle)itemHdl,255) )
  78.         #define SETDLGITEMINT(d,i,v,bsigned) \
  79.                 ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\
  80.                   NumToString(v,itemStr),\
  81.                   SetDialogItemText(itemHdl,itemStr) )
  82.         #define GETDLGITEMINT(d,i,bpresult,bsigned) \
  83.                 ( GetDialogItem(d,i,&itemType,&itemHdl,&itemRect),\
  84.                   GetDialogItemText(itemHdl,itemStr),\
  85.                   StringToNum(itemStr,&itemNum),\
  86.                   itemNum )
  87. */
  88.  
  89. /* note menu item indices are ZERO based in the following two calls (like Win32 Combo Box) */
  90.         #define SETMENUCURSEL(c,v) SetControlValue(c,(v)+1)
  91.         #define GETMENUCURSEL(c) (GetControlValue(c)-1)
  92.         #define MENUADDCSTR menuaddcstr
  93.                 //(c,s) myc2pstr(s),AppendMenu(GetControlPopupMenuHandle(c),(StringPtr)s),myp2cstr((StringPtr)s)
  94.         #define GETDLGCTLREF (ControlRef)get_item_handle
  95.  
  96.         #define INITCURSOR InitCursor
  97.  
  98.         #define INVALWINDOWRECT(dp,rp) InvalWindowRect(GetDialogWindow(dp),rp)
  99.         #define SYSBEEP SysBeep
  100.  
  101.         #define ERASERECT EraseRect
  102.  
  103.         #if TARGET_CPU_68K
  104.                 // for Universal Interfaces 3.3 (CW 68K build)
  105.                 #define SetPortDialogPort SetGrafPortOfDialog
  106.                 #define GetDialogPort
  107.         #endif
  108.  
  109. //      #define GetPixRowBytes(pm) ((*(pm))->rowBytes & 0x3fff) // "The high 2 bits of rowBytes are used as flags."
  110.  
  111.         #if !TARGET_CARBON
  112.                 #define InvalWindowRect my_InvalWindowRect
  113.         #endif
  114.  
  115.         long GetDlgItemText(DIALOGREF d,int i,char *s,long n); // see dialog.c
  116.         long SetDlgItemText(DIALOGREF d,int i,char *s);
  117.         void SetDlgControlValue(DIALOGREF d,int i,int v);
  118.         int GetDlgControlValue(DIALOGREF d,int i);
  119.  
  120.         void EnableDlgControl(DIALOGREF d,int i);
  121.         void DisableDlgControl(DIALOGREF d,int i);
  122.         Boolean SetDlgItemInt(DIALOGREF d,int i,long v,Boolean bsigned);
  123.         long GetDlgItemInt(DIALOGREF d,int i,Boolean *presult,Boolean bsigned);
  124.  
  125.         OSStatus my_InvalWindowRect(WindowRef window,const Rect *bounds);
  126.         pascal Boolean standardfilter(DialogRef dialog,EventRecord *event,short *item);
  127.         pascal Boolean aboutfilter(DialogRef dialog,EventRecord *event,short *item);
  128.         Handle get_item_handle(DIALOGREF d,int i);
  129.         long getctltext(DIALOGREF d,int i,char *s,long n);
  130.         long setctltext(DIALOGREF d,int i,char *s);
  131.         Boolean setctltextint(DIALOGREF d,int i,long v,Boolean bsigned);
  132.         long getctltextint(DIALOGREF d,int i,Boolean *presult,Boolean bsigned);
  133.         long selectctltext(DIALOGREF d,int i,int start,int end);
  134.  
  135.         void menuaddcstr(CTLREF m,char *s);
  136.  
  137.         enum{IDOK = ok,IDCANCEL = cancel};
  138.  
  139. #else
  140.         #include <windows.h>
  141.         #include <windowsx.h>
  142.         #include <commctrl.h> // for TBM_SETPOS, etc
  143.  
  144.         #include "compat_win.h"
  145.  
  146.         typedef HWND DIALOGREF,CTLREF;
  147.         typedef struct{
  148.                 HBITMAP hbmp;
  149.                 BITMAPINFO bmi;
  150.                 unsigned char *pbits;
  151.                 long rowbytes;
  152.         } *BITMAPREF;
  153.         typedef RECT UIRECT;
  154.  
  155.         #define LOCKBITMAP(pb) true
  156.         #define UNLOCKBITMAP(pb)
  157.         #define ROWBYTES(pb) (pb)->rowbytes
  158.         #define BASEADDR(pb) (pb)->pbits
  159.  
  160.         #define ENABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),TRUE)
  161.         #define DISABLEDLGITEM(d,i) EnableWindow(GetDlgItem(d,i),FALSE)
  162.         #define ENABLECONTROL(c) EnableWindow(c,TRUE)
  163.         #define DISABLECONTROL(c) EnableWindow(c,FALSE)
  164.         #define SETDLGITEMINT SetDlgItemInt
  165.         #define GETDLGITEMINT GetDlgItemInt
  166.         #define SELECTDLGITEMTEXT(d,i,start,end) \
  167.                 ( SendDlgItemMessage(d,i,EM_SETSEL,start,end), \
  168.                   SendDlgItemMessage(d,i,EM_SCROLLCARET,0,0), \
  169.                   SetFocus(GetDlgItem(d,i)) )
  170.         #define ISDLGBUTTONCHECKED IsDlgButtonChecked
  171.         #define CHECKDLGBUTTON CheckDlgButton
  172.         #define SETBUTTONVALUE(c,v) SendMessage(c,BM_SETCHECK,v,0)
  173. //      #define HideDialogItem SendDlgItemMessage(d,i,SW_HIDE,0,0) //ShowWindow(GetDlgItem(d,i),SW_HIDE)
  174. //      #define ShowDialogItem SendDlgItemMessage(d,i,SW_SHOW,0,0)
  175.         #define HideDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_HIDE)
  176.         #define ShowDialogItem(d,i) ShowWindow(GetDlgItem(d,i),SW_SHOW)
  177.  
  178.         // from PLUGIN.DLL
  179.         extern int SetSliderPos(HWND hWnd, int nPos, BOOL bRepaint);
  180.         extern int GetSliderPos(HWND hWnd, BOOL bPixelPosition);
  181.  
  182.         #define GETSLIDERVALUE(d,i) (gdata->pluginDllSliderMessageId == 0 ? (int)SendDlgItemMessage((d), (i), TBM_GETPOS, 0, 0) : GetSliderPos(GetDlgItem((d), (i)), false))
  183.         #define SETSLIDERVALUE(d,i,v) (gdata->pluginDllSliderMessageId == 0 ? SendDlgItemMessage((d), (i), TBM_SETPOS, TRUE, (v)) : SetSliderPos(GetDlgItem((d), (i)), (v), true))
  184.         #define GETCTLTEXT GetDlgItemTextA
  185.         #define SETCTLTEXT SetDlgItemTextA
  186.         #define SELECTCTLTEXT SELECTDLGITEMTEXT
  187.         #define GETCTLTEXTINT GetDlgItemInt
  188.         #define SETCTLTEXTINT SetDlgItemInt
  189.         #define REPAINTCTL(d,i) InvalidateRect(GetDlgItem(d, i), NULL, TRUE);UpdateWindow(GetDlgItem(d, i));
  190.  
  191.         #define SETMENUCURSEL ComboBox_SetCurSel
  192.         #define GETMENUCURSEL ComboBox_GetCurSel
  193.         #define MENUADDCSTR ComboBox_AddString
  194.         #define GETDLGCTLREF GetDlgItem
  195.  
  196.         #define INITCURSOR()
  197.         #define DLGVARS
  198.         #define INVALWINDOWRECT(dp,rp) RedrawWindow(dp,rp,NULL,RDW_ERASE|RDW_INVALIDATE)
  199.         #define SYSBEEP(x) MessageBeep(MB_ICONEXCLAMATION)
  200.  
  201.         void centre_window(HWND hwnd);
  202. #endif
  203.  
  204.  
  205. // implemented as functions on both platforms
  206. #define GETDLGITEMCSTR GetDlgItemText
  207. #define SETDLGITEMCSTR SetDlgItemText
  208. Boolean newbitmap(BITMAPREF *pb,int depth,UIRECT *bounds);
  209. void disposebitmap(BITMAPREF pb);
  210. #define NEWBITMAP newbitmap
  211. #define DISPOSEBITMAP disposebitmap
  212.  
  213. #endif
  214.