/* LIBPIKA - The PIKA Library
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 *
 * pika.h
 *
 * This library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <https://www.gnu.org/licenses/>.
 */

#ifndef __PIKA_H__
#define __PIKA_H__

#include <cairo.h>
#include <glib-object.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <pango/pango.h>

#include <libpikabase/pikabase.h>
#include <libpikacolor/pikacolor.h>
#include <libpikaconfig/pikaconfig.h>
#include <libpikamath/pikamath.h>

#define __PIKA_H_INSIDE__

#include <libpika/pikaenums.h>
#include <libpika/pikatypes.h>

#include <libpika/pikabatchprocedure.h>
#include <libpika/pikabrush.h>
#include <libpika/pikachannel.h>
#include <libpika/pikadisplay.h>
#include <libpika/pikadrawable.h>
#include <libpika/pikafont.h>
#include <libpika/pikapikarc.h>
#include <libpika/pikagradient.h>
#include <libpika/pikaimage.h>
#include <libpika/pikaimagecolorprofile.h>
#include <libpika/pikaimagemetadata.h>
#include <libpika/pikaimageprocedure.h>
#include <libpika/pikaitem.h>
#include <libpika/pikalayer.h>
#include <libpika/pikalayermask.h>
#include <libpika/pikaloadprocedure.h>
#include <libpika/pikapalette.h>
#include <libpika/pikaparamspecs.h>
#include <libpika/pikapattern.h>
#include <libpika/pikapdb.h>
#include <libpika/pikaplugin.h>
#include <libpika/pikaprocedureconfig.h>
#include <libpika/pikaprocedure-params.h>
#include <libpika/pikaprogress.h>
#include <libpika/pikaresource.h>
#include <libpika/pikasaveprocedure.h>
#include <libpika/pikaselection.h>
#include <libpika/pikatextlayer.h>
#include <libpika/pikathumbnailprocedure.h>
#include <libpika/pikavectors.h>

/* Resources and their widgets. Order important. */
#include <libpika/pikaresourceselect.h>

#include <libpika/pika_pdb_headers.h>

#undef __PIKA_H_INSIDE__

#ifdef G_OS_WIN32
#include <stdlib.h> /* For __argc and __argv */
#endif

G_BEGIN_DECLS


/**
 * PIKA_MAIN:
 * @plug_in_type: The #GType of the plug-in's #PikaPlugIn subclass
 *
 * A macro that expands to the appropriate main() function for the
 * platform being compiled for.
 *
 * To use this macro, simply place a line that contains just the code
 *
 * PIKA_MAIN (MY_TYPE_PLUG_IN)
 *
 * at the toplevel of your file. No semicolon should be used.
 *
 * Since: 3.0
 **/

#ifdef G_OS_WIN32

/* Define WinMain() because plug-ins are built as GUI applications. Also
 * define a main() in case some plug-in still is built as a console
 * application.
 */
#  ifdef __GNUC__
#    ifndef _stdcall
#      define _stdcall __attribute__((stdcall))
#    endif
#  endif

#  define PIKA_MAIN(plug_in_type)                       \
   struct HINSTANCE__;                                  \
                                                        \
   int _stdcall                                         \
   WinMain (struct HINSTANCE__ *hInstance,              \
            struct HINSTANCE__ *hPrevInstance,          \
            char *lpszCmdLine,                          \
            int   nCmdShow);                            \
                                                        \
   int _stdcall                                         \
   WinMain (struct HINSTANCE__ *hInstance,              \
            struct HINSTANCE__ *hPrevInstance,          \
            char *lpszCmdLine,                          \
            int   nCmdShow)                             \
   {                                                    \
     return pika_main (plug_in_type,                    \
                       __argc, __argv);                 \
   }                                                    \
                                                        \
   int                                                  \
   main (int argc, char *argv[])                        \
   {                                                    \
     /* Use __argc and __argv here, too, as they work   \
      * better with mingw-w64.                          \
      */                                                \
     return pika_main (plug_in_type,                    \
                       __argc, __argv);                 \
   }
#else
#  define PIKA_MAIN(plug_in_type)                       \
   int                                                  \
   main (int argc, char *argv[])                        \
   {                                                    \
     return pika_main (plug_in_type,                    \
                       argc, argv);                     \
   }
#endif


/* The main procedure that must be called with the plug-in's
 * PikaPlugIn subclass type and the 'argc' and 'argv' that are passed
 * to "main".
 */
gint                pika_main                 (GType  plug_in_type,
                                               gint   argc,
                                               gchar *argv[]);

/* Return the PikaPlugIn singleton of this plug-in process
 */
PikaPlugIn        * pika_get_plug_in          (void);

/* Return the PikaPDB singleton of this plug-in process
 */
PikaPDB           * pika_get_pdb              (void);

/* Forcefully causes the pika library to exit and
 * close down its connection to main pika application.
 */
void                pika_quit                 (void) G_GNUC_NORETURN;

/* Return various constants given by the PIKA core at plug-in config time.
 */
guint               pika_tile_width           (void) G_GNUC_CONST;
guint               pika_tile_height          (void) G_GNUC_CONST;
gboolean            pika_show_help_button     (void) G_GNUC_CONST;
gboolean            pika_export_color_profile (void) G_GNUC_CONST;
gboolean            pika_export_comment       (void) G_GNUC_CONST;
gboolean            pika_export_exif          (void) G_GNUC_CONST;
gboolean            pika_export_xmp           (void) G_GNUC_CONST;
gboolean            pika_export_iptc          (void) G_GNUC_CONST;
gboolean            pika_export_thumbnail     (void) G_GNUC_CONST;
gint                pika_get_num_processors   (void) G_GNUC_CONST;
PikaCheckSize       pika_check_size           (void) G_GNUC_CONST;
PikaCheckType       pika_check_type           (void) G_GNUC_CONST;
const PikaRGB     * pika_check_custom_color1  (void) G_GNUC_CONST;
const PikaRGB *     pika_check_custom_color2  (void) G_GNUC_CONST;
PikaDisplay       * pika_default_display      (void) G_GNUC_CONST;
const gchar       * pika_wm_class             (void) G_GNUC_CONST;
const gchar       * pika_display_name         (void) G_GNUC_CONST;
gint                pika_monitor_number       (void) G_GNUC_CONST;
guint32             pika_user_time            (void) G_GNUC_CONST;
const gchar       * pika_icon_theme_dir       (void) G_GNUC_CONST;

const gchar       * pika_get_progname         (void) G_GNUC_CONST;


G_END_DECLS

#endif /* __PIKA_H__ */
