I am not sure what is happening, but the tooltips and popup menu appear to be 
using the screen as it's parent --- seems FLTK is placing the tootip and popup 
using screen coordinates instead of the widgets parent.

The test menubar.cxx works, so I am assuming there is something wrong with the 
constructor? Thanks in advance.

/*
vim:expandtab:softtabstop=2:tabstop=2:shiftwidth=2:nowrap:ruler
*/
#if !defined(__kvc_app_hxx__)

#include <stdlib.h>

#include <FL/Fl.H>
#include <FL/Enumerations.H>
#include <FL/filename.H>
#include <FL/fl_utf8.h>
#include <FL/Fl_Widget.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Check_Browser.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_Output.H>
#include <FL/Fl_Return_Button.H>

#include "mjo_array.h"
#include "mjo_rect_int.h"

#include "kvc_text.h"
#include "kvc_icon.hxx"
#include "kvc_dbm.hxx"

#ifndef CHANGE_DOS_FILE_SEP_SWITCH
# if defined(WIN32) || defined(__EMX__) && !defined(__CYGWIN__)
#   define CHANGE_DOS_FILE_SEP_SWITCH
# endif
#endif

static char const                       kvc_dialog_open_database_filter[]= 
{"KVC\t*." kvc_db_suffix_grid};

class kvc_app :
  public Fl_Double_Window
{

public:

kvc_app(
  int const                             i_x_len,
  int const                             i_y_len,
  char const*                           i_label= 0);

virtual
~kvc_app();

void
kvc_app_disconnect();

void
kvc_app_connect(
  char const*                           i_path);

void
kvc_app_get_fence(
  unsigned*const                        o_count) const;

void
kvc_app_get_tuple(
  unsigned*const                        o_tuple) const;

void
kvc_app_read(
  unsigned const                        i_tuple);

void
kvc_app_table_close(
  char const*                           i_name);

void
kvc_app_table_open(
  char const*                           i_name);

void
kvc_app_table_close_all();



virtual void
resize(
  int const                             i_x_pos,
  int const                             i_y_pos,
  int const                             i_x_len,
  int const                             i_y_len);

protected:

  enum
  {
    menu_extra_items                    = 3,
    menu_table_slot                     = 2
  };


  Fl_Box                                m_toolbar;
  Fl_Button                             m_open;
  Fl_Menu_Button                        m_table;
  Fl_Button                             m_nav;
  Fl_Button                             m_first;
  Fl_Button                             m_next;
  Fl_Button                             m_prev;
  Fl_Button                             m_last;

  kvc_dbm                               m_dbm;
  mjo_array                             m_menu;

private:

kvc_app();

kvc_app(
  kvc_app const&);

kvc_app&
operator=(
  kvc_app const&);

kvc_app(
  int const                             i_x_pos,
  int const                             i_y_pos,
  int const                             i_x_len,
  int const                             i_y_len,
  char const*                           i_label= 0);

static void
kvc_app_callback_connect(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

static void
kvc_app_callback_close_all(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

void
kvc_app_menu_find(
  Fl_Menu_Item**                        o_item,
  char const*                           i_name);

void
kvc_app_menu_load();

static void
kvc_app_callback_disconnect(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

static void
kvc_app_callback_first(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

static void
kvc_app_callback_last(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

static void
kvc_app_callback_next(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

static void
kvc_app_callback_prev(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

static void
kvc_app_callback_table_toggle(
  Fl_Widget*                            i_widget,
  void*                                 i_user);

};

inline void
kvc_app::kvc_app_get_fence(
  unsigned*const                        o_count) const
{
  m_dbm.kvc_dbm_get_fence(o_count);
}

inline void
kvc_app::kvc_app_get_tuple(
  unsigned*const                        o_tuple) const
{
  m_dbm.kvc_dbm_get_tuple(o_tuple);
}

#define __kvc_app_hxx__
#endif




/*
vim:expandtab:softtabstop=2:tabstop=2:shiftwidth=2:nowrap:ruler
*/
#include "kvc_app.hxx"

enum
{
  edge_len                              = 2,
  sides_len                             = (2*edge_len),
  btn_x_len                             = 25,
  btn_y_len                             = 25,
  tool_y_len                            = (btn_y_len + (2*sides_len))
};

kvc_app::kvc_app(
  int const                             i_x_len,
  int const                             i_y_len,
  char const*                           i_label) :
  Fl_Double_Window(i_x_len, i_y_len, i_label),
  m_toolbar(0, 0, i_x_len, tool_y_len),
  m_open(0, 0, 0, 0),
  m_table(0, 0, 0, 0),
  m_nav(0, 0, 0, 0),
  m_first(0, 0, 0, 0),
  m_next(0, 0, 0, 0),
  m_prev(0, 0, 0, 0),
  m_last(0, 0, 0, 0),
  m_dbm(),
  m_menu()
{
  int                                   l_x_pos;
  int                                   l_y_pos;
  int                                   l_x_len;
  int                                   l_y_len;

  m_toolbar.box(FL_BORDER_BOX);

  m_open.tooltip(_("open database"));
  m_open.image(kvc_icon::kvc_icon_get_database());
  l_x_pos= m_toolbar.x() + sides_len;
  l_y_pos= m_toolbar.y() + sides_len;
  l_x_len= btn_x_len;
  l_y_len= btn_y_len;
  m_open.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);
  m_open.callback(kvc_app_callback_connect, this);

  m_table.deactivate();
  m_table.align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
  m_table.tooltip(_("open/close tables"));
  m_table.image(kvc_icon::kvc_icon_get_database_table());
  l_x_pos+= m_open.w();
  l_x_len= (2 * btn_x_len);
  m_table.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);

  m_nav.deactivate();
  m_nav.tooltip(_("explorer"));
  m_nav.image(kvc_icon::kvc_icon_get_find());
  l_x_pos+= (m_table.w() + btn_x_len);
  l_x_len= btn_x_len;
  m_nav.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);

  m_first.deactivate();
  m_first.tooltip(_("first"));
  m_first.image(kvc_icon::kvc_icon_get_resultset_first());
  l_x_pos+= (m_nav.w() + btn_x_len);
  m_first.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);
  m_first.callback(kvc_app_callback_first, this);

  m_next.deactivate();
  m_next.tooltip(_("next"));
  m_next.image(kvc_icon::kvc_icon_get_resultset_next());
  l_x_pos+= m_first.w();
  m_next.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);
  m_next.callback(kvc_app_callback_next, this);

  m_prev.deactivate();
  m_prev.tooltip(_("previous"));
  m_prev.image(kvc_icon::kvc_icon_get_resultset_previous());
  l_x_pos+= m_next.w();
  m_prev.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);
  m_prev.callback(kvc_app_callback_prev, this);

  m_last.deactivate();
  m_last.tooltip(_("last"));
  m_last.image(kvc_icon::kvc_icon_get_resultset_last());
  l_x_pos+= m_prev.w();
  m_last.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);
  m_last.callback(kvc_app_callback_last, this);

  mjo_array_assign(&m_menu);
  mjo_array_set_object_size(&m_menu, sizeof(Fl_Menu_Item));

  return;
}

/*virtual*/
kvc_app::~kvc_app()
{
  mjo_array_unassign(&m_menu);
  return;
}

/*virtual*/ void
kvc_app::resize(
  int const                             i_x_pos,
  int const                             i_y_pos,
  int const                             i_x_len,
  int const                             i_y_len)
{
  int                                   l_x_pos;
  int                                   l_y_pos;
  int                                   l_x_len;
  int                                   l_y_len;


  do
  {

    if ((i_x_len == w()) && (i_y_len == h()))
    {
      break;
    }

    Fl_Widget::resize(i_x_pos, i_y_pos, i_x_len, i_y_len);

    l_x_pos= 0;
    l_y_pos= 0;
    l_x_len= w();
    l_y_len= m_toolbar.h();

    m_toolbar.resize(l_x_pos, l_y_pos, l_x_len, l_y_len);

/*
    l_x_pos= edge_len;
    l_y_pos= l_toolbar.y() + l_toolbar.h() + edge_len;
    l_x_len= l_toolbar.w();
    l_y_len= h() - l_rect.l_y_pos;

    l_grid.resize(
      l_x_pos,
      l_y_pos,
      l_x_len,
      l_y_len);
*/

  }while(0);

  return;
}

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to