1
0
Fork 0

Incorporated next version of PUI.

This commit is contained in:
curt 1998-07-13 20:59:34 +00:00
parent dbcecbd3b8
commit 06ab581edb
5 changed files with 121 additions and 58 deletions

View file

@ -32,7 +32,7 @@ puSlider *rspeedSlider;
* * * *
\***********************************/ \***********************************/
GLfloat light_diffuse [] = {1.0, 0.0, 0.0, 1.0} ; /* Red diffuse light. */ GLfloat light_diffuse [] = {0.0, 1.0, 0.0, 1.0} ; /* Red diffuse light. */
GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0} ; /* Infinite light location. */ GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0} ; /* Infinite light location. */
GLfloat cube_n[6][3] = /* Normals */ GLfloat cube_n[6][3] = /* Normals */
@ -273,9 +273,11 @@ void sliderCB( puObject *sliderObj)
int main ( int argc, char **argv ) int main ( int argc, char **argv )
{ {
firsttime = TRUE; firsttime = TRUE;
#ifdef VOODOO
glutInitWindowPosition( 0, 0 ) ;
#endif
glutInitWindowSize ( 640, 480 ) ; glutInitWindowSize ( 640, 480 ) ;
glutInit ( &argc, argv ) ; glutInit ( &argc, argv ) ;
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ; glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ;
@ -290,12 +292,12 @@ int main ( int argc, char **argv )
puInit () ; puInit () ;
#ifdef USING_3DFX #ifdef VOODOO
puShowCursor () ; puShowCursor () ;
#endif #endif
puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ; puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ) ;
puSetDefaultColourScheme ( 0.8, 0.2, 0.2 ) ; puSetDefaultColourScheme ( 0.8, 0.8, 0.8 ) ;
timer_text = new puText ( 300, 10 ) ; timer_text = new puText ( 300, 10 ) ;
timer_text -> setColour ( PUCOL_LABEL, 1.0, 1.0, 1.0 ) ; timer_text -> setColour ( PUCOL_LABEL, 1.0, 1.0, 1.0 ) ;

View file

@ -223,7 +223,8 @@ void puInit ( void )
int *tempSize = &fontSize[1]; int *tempSize = &fontSize[1];
if ( ! GetCharWidth32 ( hdc, 1, 255, tempSize ) ) if ( ! GetCharWidth32 ( hdc, 1, 255, tempSize ) &&
! GetCharWidth ( hdc, 1, 255, tempSize ) )
{ {
LPVOID lpMsgBuf ; LPVOID lpMsgBuf ;
@ -235,9 +236,10 @@ void puInit ( void )
(LPTSTR) &lpMsgBuf, (LPTSTR) &lpMsgBuf,
0, NULL ) ; 0, NULL ) ;
fprintf ( stderr, "PUI: Error: %s\n" (char *)lpMsgBuf ) ; fprintf ( stderr, "PUI: Error: %s\n", (char *)lpMsgBuf ) ;
LocalFree ( lpMsgBuf ) ; LocalFree ( lpMsgBuf ) ;
} }
wglUseFontBitmaps ( hdc, 0, 256, fontBase ) ; wglUseFontBitmaps ( hdc, 0, 256, fontBase ) ;
#endif #endif
} }

View file

@ -117,27 +117,27 @@ void puBox::draw ( int dx, int dy, int style, puColour colour[], int am_default
glColor4fv( colour [ mid ] ); glColor4fv( colour [ mid ] );
glVertex2i( dx + min[0] + PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL ); glVertex2i( dx + min[0] + PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL );
if(style==PUSTYLE_SMALL_SHADED) if(style==PUSTYLE_SMALL_SHADED)
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
colour [lo][3] ); colour [lo][3] );
else else
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
colour [hi][3] ); colour [hi][3] );
glVertex2i( dx + min[0] + PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL ); glVertex2i( dx + min[0] + PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL );
glColor4fv( colour [ mid ] ); glColor4fv( colour [ mid ] );
glVertex2i( dx + max[0] - PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL ); glVertex2i( dx + max[0] - PU_SMALL_BEVEL , dy + max[1] - PU_SMALL_BEVEL );
if(style==-PUSTYLE_SMALL_SHADED) if(style==-PUSTYLE_SMALL_SHADED)
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
colour [lo][3] ); colour [lo][3] );
else else
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
colour [hi][3] ); colour [hi][3] );
glVertex2i( dx + max[0] - PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL ); glVertex2i( dx + max[0] - PU_SMALL_BEVEL , dy + min[1] + PU_SMALL_BEVEL );
glEnd(); glEnd();
@ -201,27 +201,27 @@ void puBox::draw ( int dx, int dy, int style, puColour colour[], int am_default
glColor4fv( colour [ mid ] ); glColor4fv( colour [ mid ] );
glVertex2i( dx + min[0] + PU_BEVEL , dy + min[1] + PU_BEVEL ); glVertex2i( dx + min[0] + PU_BEVEL , dy + min[1] + PU_BEVEL );
if(style==PUSTYLE_SHADED) if(style==PUSTYLE_SHADED)
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
colour [lo][3] ); colour [lo][3] );
else else
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
colour [hi][3] ); colour [hi][3] );
glVertex2i( dx + min[0] + PU_BEVEL , dy + max[1] - PU_BEVEL ); glVertex2i( dx + min[0] + PU_BEVEL , dy + max[1] - PU_BEVEL );
glColor4fv( colour [ mid ] ); glColor4fv( colour [ mid ] );
glVertex2i( dx + max[0] - PU_BEVEL , dy + max[1] - PU_BEVEL ); glVertex2i( dx + max[0] - PU_BEVEL , dy + max[1] - PU_BEVEL );
if(style==-PUSTYLE_SHADED) if(style==-PUSTYLE_SHADED)
glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[lo][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[lo][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[lo][2] - colour[mid][2])/2.0f,
colour [lo][3] ); colour [lo][3] );
else else
glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0, glColor4f( colour [mid][0] + (colour[hi][0] - colour[mid][0])/2.0f,
colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0, colour [mid][1] + (colour[hi][1] - colour[mid][1])/2.0f,
colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0, colour [mid][2] + (colour[hi][2] - colour[mid][2])/2.0f,
colour [hi][3] ); colour [hi][3] );
glVertex2i( dx + max[0] - PU_BEVEL , dy + min[1] + PU_BEVEL ); glVertex2i( dx + max[0] - PU_BEVEL , dy + min[1] + PU_BEVEL );
glEnd(); glEnd();

View file

@ -1,4 +1,5 @@
#include "puLocal.h" #include "puLocal.h"
void puButton::draw ( int dx, int dy ) void puButton::draw ( int dx, int dy )
@ -7,8 +8,15 @@ void puButton::draw ( int dx, int dy )
/* If button is pushed or highlighted - use inverse style for button itself */ /* If button is pushed or highlighted - use inverse style for button itself */
abox . draw ( dx, dy, ( getValue() ^ highlighted ) ? -style : style, colour, int tempStyle;
isReturnDefault() ) ;
if ( parent && ( ( parent->getType() & PUCLASS_POPUPMENU ) ||
( parent->getType() & PUCLASS_MENUBAR ) ) )
tempStyle = ( getValue() ^ highlighted ) ? PUSTYLE_SMALL_SHADED : style ;
else
tempStyle = ( getValue() ^ highlighted ) ? -style : style ;
abox . draw ( dx, dy, tempStyle, colour, isReturnDefault() ) ;
/* If greyed out then halve the opacity when drawing the label and legend */ /* If greyed out then halve the opacity when drawing the label and legend */
@ -33,6 +41,8 @@ void puButton::draw ( int dx, int dy )
void puButton::doHit ( int button, int updown, int, int ) void puButton::doHit ( int button, int updown, int, int )
{ {
if ( button == PU_LEFT_BUTTON ) if ( button == PU_LEFT_BUTTON )
{ {
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ) if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
@ -48,3 +58,4 @@ void puButton::doHit ( int button, int updown, int, int )
lowlight () ; lowlight () ;
} }

View file

@ -1,4 +1,3 @@
#include "puLocal.h" #include "puLocal.h"
#define PUMENU_BUTTON_HEIGHT 25 #define PUMENU_BUTTON_HEIGHT 25
@ -26,17 +25,30 @@ void puPopupMenu::close ( void )
int widest = 0 ; int widest = 0 ;
puObject *ob = dlist ; puObject *ob = dlist ;
for ( ob = dlist ; ob != NULL ; ob = ob -> next ) /*
{ * June 17th, 1998, Shammi
* There seems to be some mismatch with the
* #define pumenusize and the actual size
* There seems to be some overlap resulting
* in more than one option being highlighted.
* By setting the size to the actual values,
* the overlap area seems to be less now.
*/
int w, h ; int w, h ;
for ( ob = dlist ; ob != NULL ; ob = ob -> next )
{
ob -> getSize ( &w, &h ) ; ob -> getSize ( &w, &h ) ;
if ( w > widest ) widest = w ; if ( w > widest ) widest = w ;
} }
for ( ob = dlist ; ob != NULL ; ob = ob -> next ) for ( ob = dlist ; ob != NULL ; ob = ob -> next )
ob -> setSize ( widest, PUMENU_BUTTON_HEIGHT ) ; {
ob -> getSize ( &w, &h ) ;
ob -> setSize ( widest, h ) ;
}
recalc_bbox () ; recalc_bbox () ;
} }
@ -84,18 +96,11 @@ int puPopupMenu::checkHit ( int button, int updown, int x, int y )
int hit = isHit ( x, y ) ; int hit = isHit ( x, y ) ;
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ) /*
{ * June 17th, 1998, Shammi :
hide () ; * There seemed to be a miscalculation with the menus initially
* Therefore I moved the recalculation stuff before the clearing.
/* Turn everything off ready for next time. */ */
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
bo -> clrValue () ;
}
if ( ! hit )
return FALSE ;
/* /*
This might be a bit redundant - but it's too hard to keep This might be a bit redundant - but it's too hard to keep
@ -103,19 +108,61 @@ int puPopupMenu::checkHit ( int button, int updown, int x, int y )
changing sizes. changing sizes.
*/ */
recalc_bbox () ; recalc_bbox();
puObject *bo ;
x -= abox.min[0] ; x -= abox.min[0] ;
y -= abox.min[1] ; y -= abox.min[1] ;
/*
* June 17th, 1998, Shammi :
* Also clear the menu when the dragging the mouse and not hit.
*/
if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ||
( updown == PU_DRAG && !hit ) )
{
/* June 17th, 1998, Shammi :
* Do not hide the menu if mouse is dragged out
*/
if ( updown != PU_DRAG )
hide () ;
/* Turn everything off ready for next time. */
/* June 17th, 1998, Shammi:
* Make sure we check for a hit, if the mouse is moved
* out of the menu.
*/
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
{
if ( ! hit )
bo -> checkHit ( button, updown, x , y ) ;
bo -> clrValue () ;
}
}
if ( ! hit )
return FALSE ;
puObject *bo ;
/* /*
We have to walk the list backwards to ensure that We have to walk the list backwards to ensure that
the click order is the same as the DRAW order. the click order is the same as the DRAW order.
*/ */
/* June 17th, 1998, Shammi :
* If the mouse is dragged and the menuItem is not hit,
* clear it
*/
for ( bo = dlist ; bo->next != NULL ; bo = bo->next ) for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
if ( updown == PU_DRAG && ! bo -> checkHit ( button, updown, x, y ) )
bo -> clrValue () ;
/* Find the last object in our list. */ ; /* Find the last object in our list. */ ;
for ( ; bo != NULL ; bo = bo->prev ) for ( ; bo != NULL ; bo = bo->prev )
@ -125,3 +172,4 @@ int puPopupMenu::checkHit ( int button, int updown, int x, int y )
return FALSE ; return FALSE ;
} }