http:^^www.cs.washington.edu^education^courses^457^projects^libui^
来自「This data set contains WWW-pages collect」· EDU^EDUCATION^COURSES^457^PROJECTS^LIBUI^ 代码 · 共 1,346 行 · 第 1/4 页
EDU^EDUCATION^COURSES^457^PROJECTS^LIBUI^
1,346 行
<a HREF="#uiAddWindowDef">uiAddWindow()</a></strong>.</dd><p> <dt><samp><a NAME="uiFileBoxCallbackDef">typedef void (* <strong> uiFileBoxCallback</strong>) (char *<VAR>filename</VAR>);</a> </samp></dt> <dd>File-selection dialog callback routine.<p> <dl> <dt><VAR>filename</VAR></dt> <dd>The name of the file that was selected when the OK button was pressed.</dd> </dl></dd><p> <dt><samp><a NAME="uiMenuCallbackDef">uiMenuCallback</samp> <dd> !!!! <p></dl><h4>Image Library types</h4><dl> <dt><samp>typedef enum { <em>SCALAR</em>, <em>VECTOR</em> } <strong> argType</strong>;</samp></dt> <dd>Color depth of an <a href="#???">Image</a>.<p> <dl> <dt><em>SCALAR</em></dt> <dd>Image is black and white</dd> <dt><em>VECTOR</em></dt> <dd>Image is color</dd> </dl></dd><p> <dt><samp>typedef struct {<br> <ul> Real x, y, z;</br> </ul> } <strong>Vector</strong>;</samp></dt><p> <dd>Vector type. For images, x is used as the red component, y is used as green and z is used as blue.</dd><p> <dt><samp>typedef struct {<br> <ul> int _width, _height;<br> argType _type;<br> union { <br> <ul> Real *scal_image;<br> Vector *vec_image;<br> </ul> } _image; int _scale_pixel_values;<br> Real _pixel_scale_factor;<br> </ul> } <strong>Image</strong>;</samp></dt><p> <dd>Image type. Routines are available for accessing all the fields of this structure, so you shouldn't have to worry about them.</dl><hr><h2><a name = "Macros">Macros</h2>The following macros are defined by libui:<dl> <dt><samp>#define <b>MIN(a,b)</b> ((a)<(b)?(a):(b))</samp> <dd>Fairly simple, expands to find the minimum of two items<p> <dt><samp>#define <b>MAX(a,b)</b> ((a)>(b)?(a):(b))</samp> <dd>MIN's complement<p> <dt><samp>#define <b>CLAMP(x,lo,hi)</b> (MAX(MIN(x,hi),lo))</samp> <dd>Clamps number specified by <var>x</var> to be between <var>hi</var> and <var>lo</var></dl> <br><br><hr><!-- --><!-- Routines --><!-- --><h2><a NAME="Reference-Routines">Routines</a></h2><h3><a name="Routines-Init">Initialization routines</a></h3><dl> <dt><samp><a NAME="uiSetControlWidthDef">void <strong>uiSetControlWidth </strong>(int <VAR>width</VAR>);</a></samp><br> <samp><a NAME="uiSetControlHeightDef">void <strong>uiSetControlHeight </strong>(int <VAR>height</VAR>);</a></samp></dt> <dd>Sets the width and height of the control area in which buttons and sliders are placed. The control area is located in the upper-right corner of the main application window.</dd><p> <dt><samp><a NAME="uiSetTextHeightDef">void <strong>uiSetTextHeight</strong> ( int <VAR>height</VAR> );</a></samp></dt> <dd>Sets the height of the text area at the bottom of the application window. The text displayed in this area can be changed and examined by calling <strong><a HREF="#uiSetTextDef">uiSetText()</a></strong> and <strong><a HREF="#uiGetTextDef">uiGetText()</a></strong>.</dd><p> <dt><samp><a NAME="uiSetMainWindowWidthDef">void <strong> uiSetMainWindowWidth</strong> (int <VAR>width</VAR>);</a></samp><br> <samp><a NAME="uiSetMainWindowHeightDef">void <strong> uiSetMainWindowHeight</strong> (int <VAR>height</VAR>);</a></samp></dt> <dd>Sets the size of the main application window. This includes the control area and the text area. It is up to the application to make sure that this window is big enough to hold all of the things it wants to place inside of it.</dd><p> <dt><samp><a NAME="uiInitWindowsDef">uiBool <strong>uiInitWindows</strong> (unsigned int <VAR>argc</VAR>, char **<VAR>argv</VAR>, <a href="#uiAppOptionsDef">uiAppOptions</a> <var>options</var>); </a></samp> <dd>Initializes the interface library and creates the main application window.<p> <dl> <dt><VAR>argc</VAR>, <VAR>argv</VAR></dt> <dd>If you wish, you can pass the arguments from <samp>main</samp> to <samp>uiInitWindows()</samp>. <!!! -- help! --> Normally, you would just pass <samp>0</samp> and <samp>NULL </samp>.</dd> <dt><var>options</var> <dd>Sets what aspects of the application windows will be enabled. You may elect to have a text region, control region, double buffer, or more. See the definition of <a href="#uiAppOptionsDef">uiAppOptions</a> for a complete list of options. To select two or more options, pass in their logical OR. </dl><p> The application should call <samp>uiInitWindows</samp> to initialize the ui Library. This call should be made after the sizes of the parts of the application have been set.</dd><p> <dt><samp><a NAME="uiMainLoopDef">void <strong>uiMainLoop</strong>();</a></samp> <dd>This function starts the applications' main loop. In this loop, libui will process user interaction, and call the appropriate callbacks where defined. <em>NB:</em> This function <em>never</em> returns, so it should be the last statement in your <samp>main()</samp> function.<p></dl><br><hr><br><h3><a name="Routines-Windows">Window routines</a></h3><dl> <dt><samp><a NAME="uiAddWindowDef">uiWindow *<strong>uiAddWindow</strong> (int <VAR>x</VAR>, int <VAR>y</VAR>, int <VAR>width</VAR>, int <VAR>height</VAR>, <a HREF="#uiExposeCallbackDef">uiExposeCallback</a> <VAR>expose</VAR>, <a HREF="#uiMouseCallbackDef">uiMouseCallback</a> <VAR>mouse</VAR>, void *<VAR>userData</VAR> );</a></samp></dt> <dd>Adds a drawing area inside the main window.<p> <dl> <dt><VAR>x</VAR>, <VAR>y</VAR></dt> <dd>The (<VAR>x</VAR>, <VAR>y</VAR>) location of the upper-left corner of the new window relative to the upper-left corner of the main application window. <em>Note:</em> the coordinate system used by this call (unfortunately) considers the origin to be at the upper-left, with <VAR>x</VAR> increasing going to the right and <VAR>y</VAR> increasing going down. This is <STRONG>not</STRONG> the same coordinate system used by OpenGL, which considers the origin to be the lower-left corner, with <var>y</var> increasing going up.</dd> <dt><VAR>width</VAR>, <VAR>height</VAR></dt> <dd>The width and height of the new window.</dd> <dt><VAR>expose</VAR></dt> <dd>A callback to be invoked when the window is exposed. If no callback is to be invoked, pass NULL for the the <var>expose </var> paramater.</dd> <dt><VAR>mouse</VAR></dt> <dd>A callback to be invoked in response to mouse input for this window. If no mouse callback is to be invoked, pass NULL for the <var>mouse</var> paramater.</dd> <dt><VAR>userData</VAR></dt> <dd>A pointer to some private data you wish to associate with this window. If no private data is necessary, pass NULL for the <var>userData</var> paramater.</dd> </dl> Drawing areas are rectangular regions in which the application can do drawing. To specify which window is to be drawn into, the application must call <strong><a HREF="#uiSetCurrentWindowDef"> uiSetCurrentWindow()</a></strong>.</dd><p> <dt><samp><a NAME="uiSetUserDataDef">void <strong>uiSetUserData</strong> ( <a HREF="#uiWindowDef">uiWindow</a> *<VAR>window</VAR>, void *<VAR>data</VAR> );</a></samp></dt> <dd>Sets <VAR>window</VAR>'s private data to point to <VAR>data</VAR>. </dd><p> <dt><samp><a NAME="uiGetUserDataDef">void *<strong>uiGetUserData</strong> ( <a HREF="#uiWindowDef">uiWindow</a> *<VAR>window</VAR> );</a> </samp></dt> <dd>Retrieves <VAR>window</VAR>'s private data.</dd><p> <dt><samp><a NAME="uiSetCurrentWindowDef">void <strong>uiSetCurrentWindow </strong>(<a HREF="#uiWindowDef">uiWindow</a> *<VAR>window</VAR>, <a HREF="#uiDrawingPlaneDef">uiDrawingPlane</a> <VAR>plane</VAR>); </a></samp> <dd>Sets the current drawing window.<p> <dl> <dt><VAR>window</VAR> <dd>The window into which drawing should be done. <dt><VAR>plane</VAR> <dd>The drawing layer onto which drawing should be done. If <VAR>plane</VAR> is <strong>uiNormal</strong>, drawing will take place in the normal drawing window. If <VAR>plane</VAR> is <strong>uiOverlayPlane</strong>, drawing will take place in the <a HREF="#OverlayPlaneDefinition">overlay plane</a>. </dl> Note that the normal drawing plane (<strong>uiNormal</strong>) is a full-color RGB plane, while the overlay plane (<strong>uiOverlayPlane </strong>) is an indexed plane.<p> <dt><samp><a NAME="uiDirtyWindowDef">void <strong>uiDirtyWindow</strong> (<a HREF="#uiWindowDef">uiWindow</a> *<VAR>window</VAR>);</a></samp> <dd>Forces a window's <a HREF="#uiExposeCallbackDef">expose callback</a> to be invoked.<p> <dl> <dt><VAR>window</VAR> <dd>The window whose expose callback is to be invoked. </dl> This call is used to signal a window to redisplay it's contents. This can be useful if the application is written in such a way that drawing is done only (mostly?) inside of expose callbacks. This helps to concentrate the drawing code in one area, which in turn helps to locate drawing-related bugs.<p> <dt><samp><a NAME="uiGetWindowSizeDef">void <strong>uiGetWindowSize</strong> (<a HREF="#uiWindowDef">uiWindow</a> *<VAR>window</VAR>, int *<VAR>width</VAR>, int *<VAR>height</VAR>);</a></samp> <dd>Returns the size of <VAR>window</VAR> in <VAR>width</VAR> and <VAR>height</VAR>. Pass <samp>NULL</samp> to either if you don't care about their values.<p> <dt><samp><a NAME="uiMapCoordinatesDef">void <strong>uiMapCoordinates </strong> (<a HREF="#uiWindowDef">uiWindow</a> *<VAR>src</VAR>, uiWindow *<VAR>dst</VAR>, int *<VAR>x</VAR>, int *<VAR>y</VAR>); </a></samp> <dd>Maps a location from the coordinate space of one window to the coordinate space of another. This is most often used when one window is contained withing another.<p> <dl> <dt><VAR>src</VAR> <dd>The source window, in which the coordinates are initially expressed. <dt><VAR>dst</VAR> <dd>The destination window, to which the coordinates are to be translated. <dt><VAR>x</VAR>, <VAR>y</VAR> <dd>The point in window <var>src</var> to be translated. After the routine returns, they will be set to the transformed coordinates. </dl><p></dl><br><hr><br><h3><a name="Routines-Controls">Control routines</a></h3><dl> <dt><samp><a NAME="uiAddButtonDef">void <strong>uiAddButton</strong> (char *<VAR>label</VAR>, <a HREF="#uiCallbackDef">uiCallback</a> <VAR>pushCallback</VAR>);</a></samp></dt> <dd>Adds a button control to the control area.<p> <dl> <dt><VAR>label</VAR></dt> <dd>The text to be used as a label for the button.</dd> <dt><VAR>pushCallback</VAR></dt> <dd>The callback procedure to be invoked when the button is pushed.</dd> </dl> Controls (buttons, sliders, menus, etc.) are added one below another, starting at the top of the control area.</dd><p> <dt><samp><a NAME="uiAddToggleButtonDef">uiToggleButton <strong> uiAddToggleButton</strong>( char *<VAR>label</VAR>, uiBool <VAR>initialState</VAR>, <a HREF="#uiCallbackDef">uiCallback</a> <VAR>valueChangedCallback</VAR>);</a></samp></dt> <dd>Adds a toggle button to the control area.<p> <dl> <dt><VAR>label</VAR></dt> <dd>The text to be used as a label for the button.</dd> <dt><VAR>initialState</VAR></dt> <dd>The initial state for the toggle button.</dd> <dt><VAR>valueChangedCallback</VAR></dt> <dd>The callback procedure to be invoked when the state of the toggle button changes.</dd> </dl> A toggle button (or checkbox) is a small button which can be set to either True or False by the user. Toggle buttons, like other controls, are added one below another, starting at the top of the control area. </dd><p> <dt><samp><a NAME="uiGetToggleButtonStateDef">uiBool <strong> uiGetToggleButtonState</strong> ( <a HREF="#uiToggleButtonDef"> uiToggleButton</a> <VAR>button</VAR> );</a></samp></dt> <dd>Returns the current state of <VAR>button</VAR>.</dd><p> <dt><samp><a NAME="uiSetToggleButtonStateDef">void <strong> uiSetToggleButtonState</strong> ( <a href="#uiToggleButtonDef"> uiToggleButton</a> <var>button</var>, uiBool <var>state</var>); </a></samp> <dd>Sets the current state of toggle button <var>button</var> to be <var>state</var>.<p> <dt><samp><a NAME="uiAddSliderDef">uiSlider <strong>uiAddSlider</strong> ( char *<VAR>label</VAR>, double <VAR>value</VAR>, double <VAR>min</VAR>, double <VAR>max</VAR>, int <var>decimals</var>, <a HREF="#uiCallbackDef"> uiCallback</a> <VAR>valueChangedCallback</VAR> );</a></samp></dt> <dd>Adds a slider control to the control area.<p> <dl> <dt><VAR>label</VAR></dt> <dd>The name for the slider.</dd> <dt><VAR>value</VAR></dt> <dd>The initial value for the slider.</dd> <dt><VAR>min</VAR>, <VAR>max</VAR></dt> <dd>The minimum and maximum values that the slider can have.</dd> <dt><var>decimals</var> <dd>Number of decimals to use (eg, 10 is 0 decimals, 10.5 is 1, etc.) <dt><VAR>valueChangedCallback</VAR></dt> <dd>The callback procedure to be invoked when the slider's value is changed. Note that you can always get the value of a slider with <strong><a href="#uiGetSliderValueDef">uiGetSliderValue() </a></strong>, so you only really need to use the callback in cases where you want to take some immediate action in response
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?