/* Copyright 1998 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef  __display_h
#define  __display_h

#include "main.h"
#include "gadgets.h"
#include "window.h"
#include "h.palgen.prtablegen"
#include "h.palgen.udpalette"

class calib_table
{
   void copy_calib(const calib_t& c_tab);

   public:
   tables_t tab;

   calib_table& operator =(const calib_table& t_tab);
   void set_default_calib(void);
};

class PalWin : public Window
{
  // this is the class that surrounds a given palette file
  protected:

  int update;
  char *pal_file;
  int datasize;

  // this class parallels the toolbox palette control window.
   WritableField PalVal[22];
   ActionButton  walk, save, refresh;

   palhdr_t palhdr;		// the palette header struct, (palgen.udpalette)
   uint8   *paldata;		// the pointer to the old palette information

   void set_update(int bool);

   // palette methods
   int read_palette();		// return boolean success
   int write_palette();		// writes the structures to the palette file
   void update_cached_palette();

   // toolbox methods
   void DispatchEvent( ToolboxEvent *event, IdBlock *idb );

   public:
   calib_table pal_table;		// the structure for the new palette info
   virtual void write_toolbox_window(void);	// sets the writable values
   virtual void read_toolbox_window(void);	// reads the values form the toolbox

   void OnHasBeenHiddenEvent( WindowHasBeenHiddenEvent *has_been_hidden, IdBlock *idb );

   PalWin(void);
   PalWin(char *palette);	// name of the palette file
   ~PalWin(void);
};

class SpalWin : public PalWin
{
  RadioButton Radio_b_w, Radio_col;

  float max_depletion(void); 		// returns the maximum of the depleted ink
   					// values, this to map the error diffuse
   					// density to this.
  void set_no_black(int bool);		// this sets the writables for only colour info
  // palette methods
  void DispatchEvent( ToolboxEvent *event, IdBlock *idb );

  public:
  void write_toolbox_window(void);	// sets the writable values
  void read_toolbox_window(void);	// reads the values form the toolbox window
  SpalWin(char *palette);
};

#endif
