// real construction (Init() must have been called before!) bool wxWindowDFB::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !m_tlw && parent ) m_tlw = parent->GetTLW(); if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; if ( parent ) parent->AddChild(this); // set the size to something bogus initially, in case some code tries to // create wxWindowDC before SetSize() is called below: m_rect.width = m_rect.height = 1; int x, y, w, h; x = pos.x, y = pos.y; if ( x == -1 ) x = 0; if ( y == -1 ) y = 0; w = WidthDefault(size.x); h = HeightDefault(size.y); SetSize(x, y, w, h); return true; }
// real construction (Init() must have been called before!) bool wxWindowMGL::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; if ( parent ) parent->AddChild(this); int x, y, w, h; x = pos.x, y = pos.y; if ( x == -1 ) x = 0; // FIXME_MGL, something better, see GTK+ if ( y == -1 ) y = 0; // FIXME_MGL, something better, see GTK+ AdjustForParentClientOrigin(x, y, 0); w = WidthDefault(size.x); h = HeightDefault(size.y); long mgl_style = 0; window_t *wnd_parent = parent ? parent->GetHandle() : NULL; if ( style & wxFULL_REPAINT_ON_RESIZE ) { mgl_style |= MGL_WM_FULL_REPAINT_ON_RESIZE; } if ( style & wxSTAY_ON_TOP ) { mgl_style |= MGL_WM_ALWAYS_ON_TOP; } if ( style & wxPOPUP_WINDOW ) { mgl_style |= MGL_WM_ALWAYS_ON_TOP; // it is created hidden as other top level windows m_isShown = false; wnd_parent = NULL; } window_t *wnd = MGL_wmCreateWindow(g_winMng, wnd_parent, x, y, w, h); MGL_wmSetWindowFlags(wnd, mgl_style); MGL_wmShowWindow(wnd, m_isShown); SetMGLwindow_t(wnd); return true; }
bool wxTopLevelWindowMac::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { int w = WidthDefault(size.x); int h = HeightDefault(size.y); if ( !wxNonOwnedWindow::Create(parent, id, pos, wxSize(w,h), style, name) ) return false; wxWindow::SetLabel( title ) ; m_nowpeer->SetTitle(title, GetFont().GetEncoding() ); wxTopLevelWindows.Append(this); return true; }
void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { OSStatus err = noErr ; SetName(name); m_windowStyle = style; m_isShown = FALSE; // create frame. Rect theBoundsRect; m_x = (int)pos.x; m_y = (int)pos.y; if ( m_y < 50 ) m_y = 50 ; if ( m_x < 20 ) m_x = 20 ; m_width = WidthDefault(size.x); m_height = HeightDefault(size.y); ::SetRect(&theBoundsRect, m_x, m_y , m_x + m_width, m_y + m_height); // translate the window attributes in the appropriate window class and attributes WindowClass wclass = 0; WindowAttributes attr = kWindowNoAttributes ; if ( HasFlag( wxFRAME_TOOL_WINDOW) ) { if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || HasFlag( wxSYSTEM_MENU ) || HasFlag( wxCAPTION ) || HasFlag(wxTINY_CAPTION_HORIZ) || HasFlag(wxTINY_CAPTION_VERT) ) { wclass = kFloatingWindowClass ; if ( HasFlag(wxTINY_CAPTION_VERT) ) { attr |= kWindowSideTitlebarAttribute ; } } else { #if TARGET_CARBON wclass = kPlainWindowClass ; #else wclass = kFloatingWindowClass ; #endif } } else if ( HasFlag( wxCAPTION ) ) { wclass = kDocumentWindowClass ; } else { if ( HasFlag( wxMINIMIZE_BOX ) || HasFlag( wxMAXIMIZE_BOX ) || HasFlag( wxCLOSE_BOX ) || HasFlag( wxSYSTEM_MENU ) ) { wclass = kDocumentWindowClass ; } else { #if TARGET_CARBON wclass = kPlainWindowClass ; #else wclass = kModalWindowClass ; #endif } } if ( HasFlag( wxMINIMIZE_BOX ) ) { attr |= kWindowCollapseBoxAttribute ; } if ( HasFlag( wxMAXIMIZE_BOX ) ) { attr |= kWindowFullZoomAttribute ; } if ( HasFlag( wxRESIZE_BORDER ) ) { attr |= kWindowResizableAttribute ; } if ( HasFlag( wxCLOSE_BOX) ) { attr |= kWindowCloseBoxAttribute ; } if (UMAGetSystemVersion() >= 0x1000) { //turn on live resizing (OS X only) attr |= kWindowLiveResizeAttribute; } #if TARGET_CARBON #if 0 // having problems right now with that if (HasFlag(wxSTAY_ON_TOP)) wclass = kUtilityWindowClass; #endif #endif //this setup lets us have compositing and non-compositing //windows in the same application. #if UNIVERSAL_INTERFACES_VERSION >= 0x0400 if ( wxTopLevelWindowMac::s_macWindowCompositing ) { attr |= kWindowCompositingAttribute; m_macUsesCompositing = TRUE; } else #endif { m_macUsesCompositing = FALSE; } #if TARGET_CARBON if ( HasFlag(wxFRAME_SHAPED) ) { WindowDefSpec customWindowDefSpec; customWindowDefSpec.defType = kWindowDefProcPtr; customWindowDefSpec.u.defProc = NewWindowDefUPP(wxShapedMacWindowDef); err = ::CreateCustomWindow( &customWindowDefSpec, wclass, attr, &theBoundsRect, (WindowRef*) &m_macWindow); } else #endif { err = ::CreateNewWindow( wclass , attr , &theBoundsRect , (WindowRef*)&m_macWindow ) ; } wxCHECK_RET( err == noErr, wxT("Mac OS error when trying to create new window") ); wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ; UMASetWTitle( (WindowRef)m_macWindow , title , m_font.GetEncoding() ) ; if ( wxTopLevelWindowMac::s_macWindowCompositing ) { ::GetRootControl( (WindowRef)m_macWindow, (ControlHandle*)&m_macRootControl ) ; } else { ::CreateRootControl( (WindowRef)m_macWindow , (ControlHandle*)&m_macRootControl ) ; } #if TARGET_CARBON InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(), GetEventTypeCount(eventList), eventList, this, (EventHandlerRef *)&m_macEventHandler); #endif m_macFocus = NULL ; #if TARGET_CARBON if ( HasFlag(wxFRAME_SHAPED) ) { // default shape matches the window size wxRegion rgn(0, 0, m_width, m_height); SetShape(rgn); } #endif wxWindowCreateEvent event(this); GetEventHandler()->ProcessEvent(event); }
bool wxTopLevelWindowGTK::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& sizeOrig, long style, const wxString &name ) { // always create a frame of some reasonable, even if arbitrary, size (at // least for MSW compatibility) wxSize size = sizeOrig; size.x = WidthDefault(size.x); size.y = HeightDefault(size.y); wxTopLevelWindows.Append( this ); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") ); return false; } m_title = title; // NB: m_widget may be !=NULL if it was created by derived class' Create, // e.g. in wxTaskBarIconAreaGTK if (m_widget == NULL) { #if wxUSE_LIBHILDON || wxUSE_LIBHILDON2 // we must create HildonWindow and not a normal GtkWindow as the latter // doesn't look correctly in Maemo environment and it must also be // registered with the main program object m_widget = hildon_window_new(); hildon_program_add_window(wxTheApp->GetHildonProgram(), HILDON_WINDOW(m_widget)); #else // !wxUSE_LIBHILDON || !wxUSE_LIBHILDON2 m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) { // Tell WM that this is a dialog window and make it center // on parent by default (this is what GtkDialog ctor does): gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_position(GTK_WINDOW(m_widget), GTK_WIN_POS_CENTER_ON_PARENT); } else { if (style & wxFRAME_TOOL_WINDOW) { gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_UTILITY); // On some WMs, like KDE, a TOOL_WINDOW will still show // on the taskbar, but on Gnome a TOOL_WINDOW will not. // For consistency between WMs and with Windows, we // should set the NO_TASKBAR flag which will apply // the set_skip_taskbar_hint if it is available, // ensuring no taskbar entry will appear. style |= wxFRAME_NO_TASKBAR; } } #endif // wxUSE_LIBHILDON || wxUSE_LIBHILDON2/!wxUSE_LIBHILDON || !wxUSE_LIBHILDON2 g_object_ref(m_widget); } wxWindow *topParent = wxGetTopLevelParent(m_parent); if (topParent && (((GTK_IS_WINDOW(topParent->m_widget)) && (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)) || (style & wxFRAME_FLOAT_ON_PARENT))) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(topParent->m_widget) ); } if (style & wxFRAME_NO_TASKBAR) { gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE); } if (style & wxSTAY_ON_TOP) { gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE); } if (style & wxMAXIMIZE) gtk_window_maximize(GTK_WINDOW(m_widget)); #if 0 if (!name.empty()) gtk_window_set_role( GTK_WINDOW(m_widget), wxGTK_CONV( name ) ); #endif gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); gtk_widget_set_can_focus(m_widget, false); g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_frame_delete_callback), this); // m_mainWidget is a GtkVBox, holding the bars and client area (m_wxwindow) m_mainWidget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_show( m_mainWidget ); gtk_widget_set_can_focus(m_mainWidget, false); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); // m_wxwindow is the client area m_wxwindow = wxPizza::New(); gtk_widget_show( m_wxwindow ); gtk_box_pack_start(GTK_BOX(m_mainWidget), m_wxwindow, true, true, 0); // we donm't allow the frame to get the focus as otherwise // the frame will grab it at arbitrary focus changes gtk_widget_set_can_focus(m_wxwindow, false); if (m_parent) m_parent->AddChild( this ); g_signal_connect(m_wxwindow, "size_allocate", G_CALLBACK(size_allocate), this); PostCreation(); #ifndef __WXGTK3__ if ((m_x != -1) || (m_y != -1)) gtk_widget_set_uposition( m_widget, m_x, m_y ); #endif // for some reported size corrections g_signal_connect (m_widget, "map_event", G_CALLBACK (gtk_frame_map_callback), this); // for iconized state g_signal_connect (m_widget, "window_state_event", G_CALLBACK (gtk_frame_window_state_callback), this); // for wxMoveEvent g_signal_connect (m_widget, "configure_event", G_CALLBACK (gtk_frame_configure_callback), this); // activation g_signal_connect_after (m_widget, "focus_in_event", G_CALLBACK (gtk_frame_focus_in_callback), this); g_signal_connect_after (m_widget, "focus_out_event", G_CALLBACK (gtk_frame_focus_out_callback), this); // GTK processes key events at the top level first, which handles for // menu accelerators and shortcuts before passing the event on to the // focus child window to begin propagation. We want to propagate // first, so we connect gtk_window_propagate_key_event to // key_press_event. g_signal_connect (m_widget, "key_press_event", G_CALLBACK (gtk_window_propagate_key_event), NULL); #ifdef GDK_WINDOWING_X11 #ifdef __WXGTK3__ if (GDK_IS_X11_SCREEN(gtk_window_get_screen(GTK_WINDOW(m_widget)))) #endif { gtk_widget_add_events(m_widget, GDK_PROPERTY_CHANGE_MASK); g_signal_connect(m_widget, "property_notify_event", G_CALLBACK(property_notify_event), this); } #endif // GDK_WINDOWING_X11 // translate wx decorations styles into Motif WM hints (they are recognized // by other WMs as well) // always enable moving the window as we have no separate flag for enabling // it m_gdkFunc = GDK_FUNC_MOVE; if ( style & wxCLOSE_BOX ) m_gdkFunc |= GDK_FUNC_CLOSE; if ( style & wxMINIMIZE_BOX ) m_gdkFunc |= GDK_FUNC_MINIMIZE; if ( style & wxMAXIMIZE_BOX ) m_gdkFunc |= GDK_FUNC_MAXIMIZE; if ( (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER) ) { m_gdkDecor = 0; } else // have border { m_gdkDecor = GDK_DECOR_BORDER; if ( style & wxCAPTION ) m_gdkDecor |= GDK_DECOR_TITLE; if ( style & wxSYSTEM_MENU ) m_gdkDecor |= GDK_DECOR_MENU; if ( style & wxMINIMIZE_BOX ) m_gdkDecor |= GDK_DECOR_MINIMIZE; if ( style & wxMAXIMIZE_BOX ) m_gdkDecor |= GDK_DECOR_MAXIMIZE; if ( style & wxRESIZE_BORDER ) { m_gdkFunc |= GDK_FUNC_RESIZE; m_gdkDecor |= GDK_DECOR_RESIZEH; } } // GTK sometimes chooses very small size if max size hint is not explicitly set DoSetSizeHints(m_minWidth, m_minHeight, m_maxWidth, m_maxHeight, m_incWidth, m_incHeight); m_decorSize = GetCachedDecorSize(); int w, h; GTKDoGetSize(&w, &h); gtk_window_set_default_size(GTK_WINDOW(m_widget), w, h); return true; }
bool wxTopLevelWindowGTK::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& sizeOrig, long style, const wxString &name ) { // always create a frame of some reasonable, even if arbitrary, size (at // least for MSW compatibility) wxSize size = sizeOrig; size.x = WidthDefault(size.x); size.y = HeightDefault(size.y); wxTopLevelWindows.Append( this ); m_needParent = false; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") ); return false; } m_title = title; m_insertCallback = (wxInsertChildFunction) wxInsertChildInTopLevelWindow; // NB: m_widget may be !=NULL if it was created by derived class' Create, // e.g. in wxTaskBarIconAreaGTK if (m_widget == NULL) { if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) { m_widget = gtk_window_new(GTK_WINDOW_DIALOG); } else { m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); #if GTK_CHECK_VERSION(2,1,0) if (!gtk_check_version(2,1,0)) { if (style & wxFRAME_TOOL_WINDOW) { gtk_window_set_type_hint(GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_UTILITY); // On some WMs, like KDE, a TOOL_WINDOW will still show // on the taskbar, but on Gnome a TOOL_WINDOW will not. // For consistency between WMs and with Windows, we // should set the NO_TASKBAR flag which will apply // the set_skip_taskbar_hint if it is available, // ensuring no taskbar entry will appear. style |= wxFRAME_NO_TASKBAR; } } #endif } } wxWindow *topParent = wxGetTopLevelParent(m_parent); if (topParent && (((GTK_IS_WINDOW(topParent->m_widget)) && (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)) || (style & wxFRAME_FLOAT_ON_PARENT))) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(topParent->m_widget) ); } if (!name.empty()) gtk_window_set_wmclass( GTK_WINDOW(m_widget), wxGTK_CONV( name ), wxGTK_CONV( name ) ); gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); // m_mainWidget holds the toolbar, the menubar and the client area m_mainWidget = gtk_pizza_new(); gtk_widget_show( m_mainWidget ); GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); if (m_miniEdge == 0) // wxMiniFrame has its own version. { // For m_mainWidget themes gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); } // m_wxwindow only represents the client area without toolbar and menubar m_wxwindow = gtk_pizza_new(); gtk_widget_show( m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); // we donm't allow the frame to get the focus as otherwise // the frame will grab it at arbitrary focus changes GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); if (m_parent) m_parent->AddChild( this ); // the user resized the frame by dragging etc. gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); PostCreation(); if ((m_x != -1) || (m_y != -1)) gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_window_set_default_size( GTK_WINDOW(m_widget), m_width, m_height ); // we cannot set MWM hints and icons before the widget has // been realized, so we do this directly after realization gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); // map and unmap for iconized state gtk_signal_connect( GTK_OBJECT(m_widget), "map_event", GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event", GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this ); // the only way to get the window size is to connect to this event gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); // disable native tab traversal gtk_signal_connect( GTK_OBJECT(m_widget), "focus", GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this ); // activation gtk_signal_connect( GTK_OBJECT(m_widget), "focus_in_event", GTK_SIGNAL_FUNC(gtk_frame_focus_in_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "focus_out_event", GTK_SIGNAL_FUNC(gtk_frame_focus_out_callback), (gpointer)this ); // decorations if ((m_miniEdge > 0) || (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER)) { m_gdkDecor = 0; m_gdkFunc = 0; } else { m_gdkDecor = (long) GDK_DECOR_BORDER; m_gdkFunc = (long) GDK_FUNC_MOVE; // All this is for Motif Window Manager "hints" and is supposed to be // recognized by other WMs as well. if ((style & wxCAPTION) != 0) { m_gdkDecor |= GDK_DECOR_TITLE; } if ((style & wxCLOSE_BOX) != 0) { m_gdkFunc |= GDK_FUNC_CLOSE; } if ((style & wxSYSTEM_MENU) != 0) { m_gdkDecor |= GDK_DECOR_MENU; } if ((style & wxMINIMIZE_BOX) != 0) { m_gdkFunc |= GDK_FUNC_MINIMIZE; m_gdkDecor |= GDK_DECOR_MINIMIZE; } if ((style & wxMAXIMIZE_BOX) != 0) { m_gdkFunc |= GDK_FUNC_MAXIMIZE; m_gdkDecor |= GDK_DECOR_MAXIMIZE; } if ((style & wxRESIZE_BORDER) != 0) { m_gdkFunc |= GDK_FUNC_RESIZE; m_gdkDecor |= GDK_DECOR_RESIZEH; } } return true; }