Wxwidgets create file dialog
Here is a very simple dialog box, it contains three controls, a text control and two buttons. The dialog box itself has a location on screen relative to its parent window and a height and a width. Each of the controls has a location relative to the dialog which is the parent window of the controls, and each of the controls has a size. Here you can see how we call the dialog.
The dialog is instantiated in the BasicFrame's About method. The custom dialog can also have one other construction parameter inherited from wxDialog and that is a name. This property has limited, if any, use in Windows. BasicDialog declares two public members apart from its constructor.
There is a text control and a member function which returns a string. Please enable JavaScript to pass antispam protection! Antispam by CleanTalk. Initializing the file selection dialog isn't hard--we just declare a new wxFileDialog object and initialize it with the following arguments: A parent window.
We'll just use this. The title for the dialog window. They are customisable. We can change icons and buttons that will be shown in a dialog. In our example, we have created four buttons and put them in a grid sizer. These buttons will show four different dialog windows. We create them by specifying different style flags. The creation of the message dialog is simple. We set the dialog to be a toplevel window by providing NULL as a parent. The two strings provide the message text and the dialog title.
To show the dialog on screen, we call the ShowModal method. CanAcceptFocusFromKeyboard const. Can this window be assigned focus from keyboard right now? HasFocus const. Returns true if the window or in case of composite controls, its main child window has focus. SetCanFocus bool canFocus. EnableVisibleFocus bool enable. Enables or disables visible indication of keyboard focus. This sets the window to receive keyboard input. This function is called by wxWidgets keyboard navigation code when the user gives the focus to this window from keyboard e.
Adds a child window. Destroys all children of a window. FindWindow long id const. Find a child of this window, by id. Find a child of this window, by name. Returns a reference to the list of the window's children. GetChildren const. Returns a const reference to the list of the window's children. Removes a child window. GetGrandParent const. Returns the grandparent of a window, or NULL if there isn't one. GetNextSibling const. Returns the next window after this one among the parent's children or NULL if this window is the last child.
GetParent const. Returns the parent of the window, or NULL if there is no parent. GetPrevSibling const. Returns the previous window before this one among the parent's children or NULL if this window is the first child.
Check if the specified window is a descendant of this one. Reparents the window, i. Call this function to force one or both scrollbars to be always shown, even if the window is big enough to show its entire contents without scrolling. GetScrollPos int orientation const. Returns the built-in scrollbar position. GetScrollRange int orientation const. Returns the built-in scrollbar range.
GetScrollThumb int orientation const. Returns the built-in scrollbar thumb size. CanScroll int orient const. Returns true if this window can have a scroll bar in this orientation. HasScrollbar int orient const. Returns true if this window currently has a scroll bar for this orientation. IsScrollbarAlwaysShown int orient const. Return whether a scrollbar is always shown. ScrollLines int lines. Scrolls the window by the given number of lines down if lines is positive or up.
ScrollPages int pages. Scrolls the window by the given number of pages down if pages is positive or up. Physically scrolls the pixels in the window and move child windows accordingly. Same as ScrollLines Same as ScrollLines 1. Same as ScrollPages Same as ScrollPages 1. Sets the position of one of the built-in scrollbars. Sets the scrollbar properties of a built-in scrollbar. A synonym for Centre. A synonym for CentreOnParent. Centres the window. Centres the window on its parent.
This gets the position of the window in pixels, relative to the parent window for the child windows or relative to the display origin for the top level windows. GetPosition const. GetRect const. Returns the position and size of the window as a wxRect object.
Returns the window position in screen coordinates, whether the window is a child window or a top level one. GetScreenPosition const. GetScreenRect const. Returns the position and size of the window on the screen as a wxRect object. GetClientAreaOrigin const.
Get the origin of the client area of the window relative to the window top left corner the client area may be shifted because of the borders, scrollbars, other decorations GetClientRect const. Get the client rectangle in window i. Moves the window to the given position. Moves the window to the specified position. Converts to screen coordinates from coordinates relative to this window. Converts a point or size from dialog units to pixels.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument s it accepts. Converts a point or size from pixels to dialog units. Converts from screen to client window coordinates. Clears the window by filling it with the current background colour. Freezes the window or, in other words, prevents any updates from taking place on screen, the window is not redrawn at all.
Re-enables window updating after a previous call to Freeze. IsFrozen const. Returns true if the window is currently frozen by a call to Freeze. GetBackgroundColour const. Returns the background colour of the window.
GetBackgroundStyle const. Returns the background style of the window. GetCharHeight const. Returns the character height for this window. GetCharWidth const. Returns the average character width for this window. GetDefaultAttributes const. GetDPI const. Return the DPI of the display used by this window. GetFont const. Returns the font for this window. GetForegroundColour const.
Returns the foreground colour of the window. Gets the dimensions of the string as it would be drawn on the window with the currently selected font. GetUpdateRegion const. Returns the region specifying which parts of the window have been damaged. GetUpdateClientRect const. Get the update rectangle bounding box in client coords. Returns true if this window background is transparent as, for example, for wxStaticText and should show the parent window background. Causes this window, and all of its children recursively, to be repainted.
Redraws the contents of the given rectangle: only the area inside it will be repainted. Calling this method immediately repaints the invalidated area of the window and all of its children recursively this normally only happens when the flow of control returns to the event loop.
Sets the background colour of the window. SetBackgroundStyle wxBackgroundStyle style. Sets the background style of the window. Checks whether using transparent background might work. Sets the font for this window. Sets the foreground colour of the window. Sets the background colour of the window but prevents it from being inherited by the children of this window. InheritsBackgroundColour const.
Return true if this window inherits the background colour from its parent. UseBgCol const. Return true if a background colour has been set for this window.
UseBackgroundColour const. Sets the font of the window but prevents it from being inherited by the children of this window. Sets the foreground colour of the window but prevents it from being inherited by the children of this window.
UseForegroundColour const. Return true if a foreground colour has been set for this window. InheritsForegroundColour const. Return true if this window inherits the foreground colour from its parent. ShouldInheritColours const. Return true from here to allow the colours of this window to be changed by InheritAttributes.
SetThemeEnabled bool enable. This function tells a window if it should use the system's "theme" code to draw the windows' background instead of its own background drawing code.
GetThemeEnabled const. Returns true if the window uses the system theme for drawing its background. GetEventHandler const. Returns the event handler for this window. This function will generate the appropriate call to Navigate if the key event is one normally used for keyboard navigation and return true in this case. Shorthand for: More Convenient wrapper for ProcessEvent.
Removes and returns the top-most event handler on the event handler stack. Pushes this event handler onto the event stack for the window. Find the given handler in the windows event handler stack and removes but does not delete it from the stack. Sets the event handler for this window. GetExtraStyle const. Returns the extra style bits for the window. GetWindowStyleFlag const. Gets the window style that was passed to the constructor or Create method.
GetWindowStyle const. See GetWindowStyleFlag for more info. HasExtraStyle int exFlag const. Returns true if the window has the given exFlag bit set in its extra styles. HasFlag int flag const. Returns true if the window has the given flag bit set.
SetExtraStyle long exStyle. Sets the extra style bits for the window. SetWindowStyleFlag long style. Sets the style of the window. SetWindowStyle long style. See SetWindowStyleFlag for more info. ToggleWindowStyle int flag. Turns the given flag on if it's currently turned off and vice versa. Moves this window in the tab navigation order after the specified win. Same as MoveAfterInTabOrder except that it inserts this window just before win instead of putting it right after it.
0コメント