#include "diawxgtk.h" PUBLIC wxBOOK::wxBOOK (wxFORMBASE *_parent, const char *_id) : wxNotebook (_parent,-1), FORMBASE(_parent,_parent,_id) { focusid = NULL; const char *pt = rem_getvar ("focus"); if (pt != NULL){ focusid = strdup(pt); } //SetPadding (wxSize(10,0)); lastsel = -1; } PUBLIC wxBOOK::~wxBOOK() { free (focusid); } /* Perform a Fit in this form and then a Fit in the parent up to the top */ PUBLIC void wxBOOK::fit2top() { extern int layout_indent; layout_debug (id,"book fit2top start\n"); layout_indent++; wxWindow *p = GetParent(); while (p != NULL){ p->Fit(); p = p->GetParent(); } layout_indent--; layout_debug (id,"book fit2top end\n"); } PUBLIC void wxBOOK::selpage (wxFORMBASE *f) { for (int i=0; ic; if (page == f){ SetSelection(i); sendfocus(NULL); break; } } } PUBLIC bool wxBOOK::may_stretch() { bool ret = false; for (int i=0; ic; if (c->type == T_FORM){ if (page->may_stretch()){ ret = true; break; } } } //layout_debug (id,"wxBOOK::may_stretch %d\n",ret); return ret; } PUBLIC void wxBOOK::New_page (wxFORMBASE *sub, const char *s) { //wxNotebookPage *p = new wxNotebookPage (); AddPage(sub,s,true); MFORM_C *m = alloc_mf(); m->c = sub; m->type = T_FORM; } PUBLIC MFORM *wxBOOK::New_form (const char *s) { MFORM *ret = new MFORM (this,this,""); AddPage (ret,s,true); MFORM_C *m = alloc_mf(); m->c = ret; m->type = T_FORM; return ret; } /* Delete one sub-form */ PUBLIC void wxBOOK::delform(wxWindow *fl) { int pos = 0; for (int i=0; ic == fl){ DeletePage(i); delete c; }else{ tbc[pos] = tbc[i]; pos++; } } nbc = pos; sendfocus (NULL); } PRIVATE void wxBOOK::sendfocus (wxMouseEvent *ev) { if (focusid != NULL){ int bstate = 0; if (ev != NULL) bstate = mform_mev2state(*ev); int formx=0,formy=0; char path[300]; formbase_getabspath(this,path); remadmin_setcursor (cursor_wait); int nopage = GetSelection(); //fprintf (stderr,"focus action %s %s %d %d %d %d\n",path,focusid,bstate // ,formx,formy,nopage); fprintf (mform_fout,"action %s %s %d %d %d %d\n",path,focusid,bstate ,formx,formy,nopage); fflush (mform_fout); } } PUBLIC void wxBOOK::changed (wxNotebookEvent &ev) { sendfocus (NULL); //fprintf (stderr,"Changed %ld %ld\n",ev.GetInt(),ev.GetExtraLong()); } PUBLIC void wxBOOK::changing (wxNotebookEvent &ev) { //fprintf (stderr,"Changing %d\n",ev.GetSelection()); } PUBLIC void wxBOOK::mouseev (wxMouseEvent &ev) { //fprintf (stderr,"mousev %d %d %d -> %d\n",ev.LeftDown(),ev.MiddleDown(),ev.RightDown(),GetSelection()); lastev = ev; lastsel = GetSelection(); ev.Skip(); } /* We want an event sent to the application whenever we click in a notebook tab, even if this does not change the selected page. In mouseev(), we note the current selected page and here, we check if this has not changed */ PUBLIC void wxBOOK::mouseev_up (wxMouseEvent &ev) { //fprintf (stderr,"mousev_up %d %d %d\n",ev.LeftDown(),ev.MiddleDown(),ev.RightDown()); //if (lastsel == GetSelection()){ // sendfocus(&ev); //} sendfocus(&lastev); ev.Skip(); } PUBLIC void wxBOOK::getweight (int &w, int &h) { int totalh = 0, totalv = 0; for (int i=0; ic; if (c->type == T_FORM){ int w,h; page->getweight(w,h); if (w !=0) totalh = 1; if (h !=0) totalv = 1; } } w = totalh; h = totalv; // fprintf (stderr,"getweight %d %d\n",totalh,totalv); } #ifndef PROTO_SKIP BEGIN_EVENT_TABLE(wxBOOK, wxNotebook) EVT_NOTEBOOK_PAGE_CHANGED(-1,wxBOOK::changed) EVT_NOTEBOOK_PAGE_CHANGING(-1,wxBOOK::changing) EVT_LEFT_DOWN(wxBOOK::mouseev) EVT_MIDDLE_DOWN(wxBOOK::mouseev) EVT_RIGHT_DOWN(wxBOOK::mouseev) EVT_LEFT_UP(wxBOOK::mouseev_up) EVT_MIDDLE_UP(wxBOOK::mouseev_up) EVT_RIGHT_UP(wxBOOK::mouseev_up) END_EVENT_TABLE() #endif