////////////////////////////////////////////////// // Constructor AddToProjectDialog::AddToProjectDialog(FXWindow* owner, const FXString& title) : FXDialogBox(owner, title, DECOR_ALL), tgtFile(file), tgtProject(project), tgtDir(dir), tgtFiletype(filetype) { FXVerticalFrame *frm = new FXVerticalFrame(this, LAYOUT_FILL_X|LAYOUT_FILL_Y); new DialogTitle(frm, "Add file to project?"); FXHorizontalFrame *hfrm; // Filename hfrm = new FXHorizontalFrame(frm, LAYOUT_FILL_X); new FXLabel(hfrm, "Filename:"); new FXTextField(hfrm, 15, &tgtFile, FXDataTarget::ID_VALUE, TEXTFIELD_NORMAL|TEXTFIELD_READONLY); // Project hfrm = new FXHorizontalFrame(frm, LAYOUT_FILL_X); new FXLabel(hfrm, "Project:"); combo = new FXComboBox(hfrm, 15, &tgtProject, FXDataTarget::ID_VALUE, COMBOBOX_STATIC|FRAME_NORMAL); // get MainWindow FXWindow *mainWindow = getOwner(); while (!dynamic_cast<MainWindow*>(mainWindow)) mainWindow = mainWindow->getOwner(); mw = dynamic_cast<MainWindow*>(mainWindow); // fill ComboBox for (int i = 0; i < mw->projects.no(); ++i) combo->appendItem(mw->projects[i]->getProjectName()); // directory and filetype hfrm = new FXHorizontalFrame(frm, LAYOUT_FILL_X); FXGroupBox *gp = new FXGroupBox(hfrm, "Directory", FRAME_LINE); FXVerticalFrame *vfrm = new FXVerticalFrame(gp, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXRadioButton(vfrm, "src", &tgtDir, FXDataTarget::ID_OPTION+0); new FXRadioButton(vfrm, "include", &tgtDir, FXDataTarget::ID_OPTION+1); new FXRadioButton(vfrm, "doc", &tgtDir, FXDataTarget::ID_OPTION+2); new FXRadioButton(vfrm, "ressource", &tgtDir, FXDataTarget::ID_OPTION+3); new FXRadioButton(vfrm, "project root", &tgtDir, FXDataTarget::ID_OPTION+4); gp = new FXGroupBox(hfrm, "Filetype", FRAME_LINE); vfrm = new FXVerticalFrame(gp, LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXRadioButton(vfrm, "C++ Source", &tgtFiletype, FXDataTarget::ID_OPTION+0); new FXRadioButton(vfrm, "C++ Header", &tgtFiletype, FXDataTarget::ID_OPTION+1); new FXRadioButton(vfrm, "Textfile", &tgtFiletype, FXDataTarget::ID_OPTION+2); new FXRadioButton(vfrm, "Ressource file", &tgtFiletype, FXDataTarget::ID_OPTION+3); // Buttons hfrm = new FXHorizontalFrame(frm, LAYOUT_FILL_X); new FXButton(hfrm, "&Cancel", NULL, this, FXDialogBox::ID_CANCEL, BUTTON_DEFAULT|LAYOUT_LEFT|FRAME_RAISED|FRAME_THICK, 0, 0, 0, 0, 12, 12, 4, 4); new FXButton(hfrm, "&Ok", NULL, this, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK, 0, 0, 0, 0, 12, 12, 4, 4); }
GUIMainWindow* TraCIServerAPI_GUI::getMainWindow() { FXWindow* w = FXApp::instance()->getRootWindow()->getFirst(); while (w != 0 && dynamic_cast<GUIMainWindow*>(w) == 0) { w = w->getNext(); } if (w == 0) { // main window not found return 0; } return dynamic_cast<GUIMainWindow*>(w); }
// Need to uninstall accelerator FXMenuCommand::~FXMenuCommand(){ FXAccelTable *table; FXWindow *own; if(acckey){ own=getShell()->getOwner(); if(own){ table=own->getAccelTable(); if(table){ table->removeAccel(acckey); } } } }
// Focus moved to previous long FXComposite::onFocusPrev(FXObject*,FXSelector sel,void* ptr){ FXWindow *child; if(getFocus()) child=getFocus()->getPrev(); else child=getLast(); while(child){ if(child->shown()){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; if(child->handle(this,sel,ptr)) return 1; } child=child->getPrev(); } return 0; }
// Focus moved to right long FXMenuBar::onFocusRight(FXObject*,FXSelector,void* ptr){ FXWindow *child; if(getFocus()){ child=getFocus()->getNext(); while(child){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; child=child->getNext(); } child=getFirst(); while(child){ if(child->handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr)) return 1; child=child->getNext(); } } return 0; }
// Command menu item FXMenuCommand::FXMenuCommand(FXComposite* p,const FXString& text,FXIcon* ic,FXObject* tgt,FXSelector sel,FXuint opts): FXMenuCaption(p,text,ic,opts){ FXAccelTable *table; FXWindow *own; flags|=FLAG_ENABLED; defaultCursor=getApp()->getDefaultCursor(DEF_RARROW_CURSOR); target=tgt; message=sel; accel=text.section('\t',1); acckey=parseAccel(accel); if(acckey){ own=getShell()->getOwner(); if(own){ table=own->getAccelTable(); if(table){ table->addAccel(acckey,this,FXSEL(SEL_COMMAND,ID_ACCEL)); } } } }
// Recalculate layout void FXStatusBar::layout(){ FXint left,right,top,bottom; FXint remain,extra_space,total_space,t; FXint x,y,w,h; FXint numc=0; FXint sumexpand=0; FXint numexpand=0; FXint e=0; FXuint hints; FXWindow* child; // Placement rectangle; right/bottom non-inclusive left=border+padleft; right=width-border-padright; top=border+padtop; bottom=height-border-padbottom; remain=right-left; // Find number of paddable children and total width for(child=corner->getNext(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); if(hints&LAYOUT_FIX_WIDTH) w=child->getWidth(); else w=child->getDefaultWidth(); FXASSERT(w>=0); if((hints&LAYOUT_CENTER_X) || ((hints&LAYOUT_FILL_X) && !(hints&LAYOUT_FIX_WIDTH))){ sumexpand+=w; numexpand+=1; } else{ remain-=w; } numc++; } } // Child spacing if(numc>1) remain-=hspacing*(numc-1); // Substract corner width if((options&STATUSBAR_WITH_DRAGCORNER) && (numc>1)){ right-=corner->getDefaultWidth(); remain-=corner->getDefaultWidth(); } // Do the layout for(child=corner->getNext(); child; child=child->getNext()){ if(child->shown()){ hints=child->getLayoutHints(); // Layout child in Y y=child->getY(); if(hints&LAYOUT_FIX_HEIGHT) h=child->getHeight(); else h=child->getDefaultHeight(); extra_space=0; if((hints&LAYOUT_FILL_Y) && !(hints&LAYOUT_FIX_HEIGHT)){ h=bottom-top; if(h<0) h=0; } else if(hints&LAYOUT_CENTER_Y){ if(h<(bottom-top)) extra_space=(bottom-top-h)/2; } if(hints&LAYOUT_BOTTOM) y=bottom-extra_space-h; else /*hints&LAYOUT_TOP*/ y=top+extra_space; // Layout child in X x=child->getX(); if(hints&LAYOUT_FIX_WIDTH) w=child->getWidth(); else w=child->getDefaultWidth(); extra_space=0; total_space=0; if((hints&LAYOUT_FILL_X) && !(hints&LAYOUT_FIX_WIDTH)){ if(sumexpand>0){ t=w*remain; FXASSERT(sumexpand>0); w=t/sumexpand; e+=t%sumexpand; if(e>=sumexpand){w++;e-=sumexpand;} } else{ FXASSERT(numexpand>0); w=remain/numexpand; e+=remain%numexpand; if(e>=numexpand){w++;e-=numexpand;} } } else if(hints&LAYOUT_CENTER_X){ if(sumexpand>0){ t=w*remain; FXASSERT(sumexpand>0); total_space=t/sumexpand-w; e+=t%sumexpand; if(e>=sumexpand){total_space++;e-=sumexpand;} } else{ FXASSERT(numexpand>0); total_space=remain/numexpand-w; e+=remain%numexpand; if(e>=numexpand){total_space++;e-=numexpand;} } extra_space=total_space/2; } if(hints&LAYOUT_RIGHT){ x=right-w-extra_space; right=right-w-hspacing-total_space; } else{/*hints&LAYOUT_LEFT*/ x=left+extra_space; left=left+w+hspacing+total_space; } child->position(x,y,w,h); } } // Just make sure corner grip's on top if((options&STATUSBAR_WITH_DRAGCORNER)){ if(numc>1) corner->position(width-border-corner->getDefaultWidth(),height-border-corner->getDefaultHeight(),corner->getDefaultWidth(),corner->getDefaultHeight()); else corner->position(width-padright-border-corner->getDefaultWidth(),height-border-padbottom-corner->getDefaultHeight(),corner->getDefaultWidth(),corner->getDefaultHeight()); corner->show(); corner->raise(); } else{ corner->hide(); } flags&=~FLAG_DIRTY; }
long FXEmbedApp::dispatchEvent(FXID hwnd, unsigned int iMsg, unsigned int wParam, long lParam) { FXbool processed = FALSE; long result; switch(iMsg) { case WM_ACTIVATE: { if(wParam != WA_INACTIVE) { // Activate // Dispatch this event to the original FXApp message proc and then fool it // that we have got a WM_SETFOCUS event, in order the focusWindow member to be correctly updated result = FXApp::dispatchEvent(hwnd, iMsg, wParam, lParam); FXApp::dispatchEvent(hwnd, WM_SETFOCUS, lParam, 0); } else { // Deactivate // Dispatch this event to the original FXApp message proc and then fool it // that we have got a WM_KILLFOCUS event, in ordser the focusWindow member to be correctly updated result = FXApp::dispatchEvent(hwnd, iMsg, wParam, lParam); FXApp::dispatchEvent(hwnd, WM_KILLFOCUS, lParam, 0); } processed = TRUE; break; } case WM_MOUSEACTIVATE: { // This message is processed in order for us to know if an embedded window is about to // receive the input focus. // If so, we set Fox's logical focus to the FXEmbedderWindow parent, so when the // main window is deactivated and then activated again, FXEmbedderWindow will get FocusIn event // and will return the focus to the embedded window // // The way the activated window is detected is a bit hackish, but I don't think there is a way around it POINT pt; if(GetCursorPos(&pt) == 0) { DWORD pos = GetMessagePos(); pt.x = (short)(pos&0xFFFF); pt.y = (short)(pos >> 16); } HWND hitWindow = WindowFromPoint(pt); FXWindow* window = NULL; if(findWindowWithId(hitWindow) == NULL) { // OK. not a Fox window HWND hwnd = hitWindow; while(window == NULL) { if((hwnd = GetParent(hwnd)) == 0) break; window = findWindowWithId(hwnd); } } if(window != NULL) window->setFocus(); else { if(getFocusWindow() != NULL) { HWND winFocusWindowId = ::GetFocus(); HWND foxFocusWindowId = (HWND)getFocusWindow()->id(); if(foxFocusWindowId != winFocusWindowId && IsChild(foxFocusWindowId, winFocusWindowId)) // Return the focus to the top window ::SetFocus(foxFocusWindowId); } } break; } case WM_SETFOCUS: case WM_KILLFOCUS: { // We *should not* delegate these to the original FXApp message proc, because // we can now have focus set inside embedded window, which FXApp cannot deal with because // it expects the focus to be always in the main window // // Fox should really handle WM_ACTIVATE instead of WM_SETFOCUS/WM_KILLFOCUS result = DefWindowProc((HWND)hwnd, iMsg, wParam, lParam); processed = TRUE; break; } case TRAYMESSAGE: { FXWindow* tray = findWindowWithId(hwnd); if(tray != NULL) { switch(lParam) { case WM_LBUTTONDOWN: SetForegroundWindow((HWND)tray->id()); tray->handle(tray, FXSEL(SEL_COMMAND, FXTray::ID_TRAY_CLICKED), NULL); break; case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: SetForegroundWindow((HWND)tray->id()); tray->handle(tray, FXSEL(SEL_COMMAND, FXTray::ID_TRAY_DBLCLICKED), NULL); break; case WM_RBUTTONUP: SetForegroundWindow((HWND)tray->id()); tray->handle(tray, FXSEL(SEL_COMMAND, FXTray::ID_TRAY_CONTEXT_MENU), NULL); break; } processed = TRUE; } break; } }