Unit GLWinMessages

DescriptionusesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Various dialog boxes (asking user for confirmation, question, simple text input etc.) drawn by OpenGL inside TGLWindow window.

Features:

Call MessageXxx functions only when glwin.Closed = false. Note that MessageXxx will do glwin.MakeCurrent (probably more than once). Calling MessageXxx requires one free place on OpenGL attrib stack.

Notes about implementation:

uses

Overview

Classes, Interfaces, Objects and Records

Name Description
record TGLWinMessagesTheme  

Functions and Procedures

procedure MessageOK(glwin: TGLWindow; const s: string; textalign: TTextAlign = taMiddle); overload;
procedure MessageOK(glwin: TGLWindow; const SArray: array of string; textalign: TTextAlign = taMiddle); overload;
procedure MessageOK(glwin: TGLWindow; textlist: TStringList; textalign: TTextAlign = taMiddle); overload;
function MessageInput(glwin: TGLWindow; const s: string; textalign: TTextAlign = taMiddle; const answerDefault: string = ''; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): string; overload;
function MessageInput(glwin: TGLWindow; textlist: TStringList; textalign: TTextAlign = taMiddle; const answerDefault: string = ''; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): string; overload;
function MessageInputQuery(glwin: TGLWindow; const s: string; var answer: string; textalign: TTextAlign; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): boolean; overload;
function MessageInputQuery(glwin: TGLWindow; textlist: TStringList; var answer: string; textalign: TTextAlign; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): boolean; overload;
function MessageChar(glwin: TGLWindow; const s: string; const AllowedChars: TSetOfChars; const ClosingInfo: string; textalign: TTextAlign = taMiddle): char; overload;
function MessageChar(glwin: TGLWindow; const SArray: array of string; const AllowedChars: TSetOfChars; const ClosingInfo: string; textalign: TTextAlign = taMiddle): char; overload;
function MessageChar(glwin: TGLWindow; textlist: TStringList; const AllowedChars: TSetOfChars; const ClosingInfo: string; textalign: TTextAlign = taMiddle): char; overload;
function MessageKey(Glwin: TGLWindow; const S: string; const ClosingInfo: string; TextAlign: TTextAlign): TKey; overload;
function MessageKey(Glwin: TGLWindow; const SArray: array of string; const ClosingInfo: string; TextAlign: TTextAlign): TKey; overload;
function MessageKey(Glwin: TGLWindow; TextList: TStringList; const ClosingInfo: string; TextAlign: TTextAlign): TKey; overload;
procedure MessageKeyMouse(Glwin: TGLWindow; const S: string; const ClosingInfo: string; TextAlign: TTextAlign; out MouseEvent: boolean; out Key: TKey; out MouseButton: TMouseButton); overload;
procedure MessageKeyMouse(Glwin: TGLWindow; TextList: TStringList; const ClosingInfo: string; TextAlign: TTextAlign; out MouseEvent: boolean; out Key: TKey; out MouseButton: TMouseButton); overload;
function MessageYesNo(glwin: TGLWindow; const s: string; textalign: TTextAlign = taMiddle): boolean; overload;
function MessageYesNo(glwin: TGLWindow; const SArray: array of string; textalign: TTextAlign = taMiddle): boolean; overload;
function MessageYesNo(glwin: TGLWindow; textlist: TStringList; textalign: TTextAlign = taMiddle): boolean; overload;
function MessageInputCardinal(glwin: TGLWindow; const s: string; TextAlign: TTextAlign; const AnswerDefault: string): Cardinal; overload;
function MessageInputCardinal(glwin: TGLWindow; const s: string; TextAlign: TTextAlign; AnswerDefault: Cardinal): Cardinal; overload;
function MessageInputQueryCardinal(glwin: TGLWindow; const Title: string; var Value: Cardinal; TextAlign: TTextAlign): boolean;
function MessageInputQueryCardinalHex(glwin: TGLWindow; const Title: string; var Value: Cardinal; TextAlign: TTextAlign; MaxWidth: Cardinal): boolean;
function MessageInputQuery(glwin: TGLWindow; const Title: string; var Value: Extended; TextAlign: TTextAlign): boolean;
function MessageInputQuery(glwin: TGLWindow; const Title: string; var Value: Single; TextAlign: TTextAlign): boolean;
function MessageInputQueryVector3Single( glwin: TGLWindow; const Title: string; var Value: TVector3Single; TextAlign: TTextAlign): boolean;
function MessageInputQueryVector4Single( glwin: TGLWindow; const Title: string; var Value: TVector4Single; TextAlign: TTextAlign): boolean;

Types

TTextAlign = (...);
TGLWinMessageNotify = procedure(Text: TStringList);

Constants

GLWinMessagesTheme_Default: TGLWinMessagesTheme = ( RectColor: (0, 0, 0, 1); RectBorderCol: (1, 1, 0.33); ScrollBarCol: (0.5, 0.5, 0.5); ClosingInfoCol: (1, 1, 0.33); AdditionalStrCol: (0.33, 1, 1); TextCol: (1, 1, 1); RectStipple: nil; Font: nil; );
GLWinMessagesTheme_TypicalGUI: TGLWinMessagesTheme = ( RectColor: (0.75, 0.75, 0.66, 1); RectBorderCol: (0.87, 0.87, 0.81); ScrollBarCol: (0.87, 0.87, 0.81); ClosingInfoCol: (0.4, 0, 1); AdditionalStrCol: (0, 0.4, 0); TextCol: (0, 0, 0); RectStipple: nil; Font: nil; );

Variables

GLWinMessagesTheme: TGLWinMessagesTheme;
OnGLWinMessage: TGLWinMessageNotify;

Description

Functions and Procedures

procedure MessageOK(glwin: TGLWindow; const s: string; textalign: TTextAlign = taMiddle); overload;

Ask user for simple confirmation. In other words, this is the standard and simplest "OK" dialog box.

procedure MessageOK(glwin: TGLWindow; const SArray: array of string; textalign: TTextAlign = taMiddle); overload;
 
procedure MessageOK(glwin: TGLWindow; textlist: TStringList; textalign: TTextAlign = taMiddle); overload;
 
function MessageInput(glwin: TGLWindow; const s: string; textalign: TTextAlign = taMiddle; const answerDefault: string = ''; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): string; overload;

Ask user to input a string. User must give an answer (there is no "Cancel" button) — see MessageInputQuery if you want "Cancel" button.

Parameters
AnswerMaxLen
0 (zero) means that there's no maximum answer length.
function MessageInput(glwin: TGLWindow; textlist: TStringList; textalign: TTextAlign = taMiddle; const answerDefault: string = ''; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): string; overload;
 
function MessageInputQuery(glwin: TGLWindow; const s: string; var answer: string; textalign: TTextAlign; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): boolean; overload;

Ask user to input a string, or cancel. Returns True and sets Answer if user accepted some text. Note that initial Answer value is the answer proposed to the user.

Parameters
AnswerMaxLen
0 (zero) means that there's no maximum answer length.
function MessageInputQuery(glwin: TGLWindow; textlist: TStringList; var answer: string; textalign: TTextAlign; answerMinLen: integer = 0; answerMaxLen: integer = 0; const answerAllowedChars: TSetOfChars = AllChars): boolean; overload;
 
function MessageChar(glwin: TGLWindow; const s: string; const AllowedChars: TSetOfChars; const ClosingInfo: string; textalign: TTextAlign = taMiddle): char; overload;

Ask user to input a single character from a given set. This is good when user has a small, finite number of answers for some question, and each answer can be assigned some key. For example, MessageYesNo is built on top of this procedure: keys "y" and "n" are allowed characters that user can input.

Parameters
ClosingInfo
This is a text to indicate to user what keys can be pressed and what they mean. ClosingInfo is displayed below basic Text of the message, and in a different color. If may be '' if you don't want this.
function MessageChar(glwin: TGLWindow; const SArray: array of string; const AllowedChars: TSetOfChars; const ClosingInfo: string; textalign: TTextAlign = taMiddle): char; overload;
 
function MessageChar(glwin: TGLWindow; textlist: TStringList; const AllowedChars: TSetOfChars; const ClosingInfo: string; textalign: TTextAlign = taMiddle): char; overload;
 
function MessageKey(Glwin: TGLWindow; const S: string; const ClosingInfo: string; TextAlign: TTextAlign): TKey; overload;

Ask user to press any key, return this key as Keys.TKey.

Never returns K_None (which means that keys that cannot be interpreted as Keys.TKey will be ignored, and will not close the dialog box).

function MessageKey(Glwin: TGLWindow; const SArray: array of string; const ClosingInfo: string; TextAlign: TTextAlign): TKey; overload;
 
function MessageKey(Glwin: TGLWindow; TextList: TStringList; const ClosingInfo: string; TextAlign: TTextAlign): TKey; overload;
 
procedure MessageKeyMouse(Glwin: TGLWindow; const S: string; const ClosingInfo: string; TextAlign: TTextAlign; out MouseEvent: boolean; out Key: TKey; out MouseButton: TMouseButton); overload;

Ask user to press any key or mouse button, return that key (as Keys.TKey) or mouse button. The natural use for this is to allow user to configure keybindings of your program, like for MatrixNavigator.TInputShortcut.

If user pressed a key, returns MouseEvent = False and appropriate Key (it's for sure <> K_None). If user pressed a mouse button, returns MouseEvent = True and appropriate MouseButton.

procedure MessageKeyMouse(Glwin: TGLWindow; TextList: TStringList; const ClosingInfo: string; TextAlign: TTextAlign; out MouseEvent: boolean; out Key: TKey; out MouseButton: TMouseButton); overload;
 
function MessageYesNo(glwin: TGLWindow; const s: string; textalign: TTextAlign = taMiddle): boolean; overload;
 
function MessageYesNo(glwin: TGLWindow; const SArray: array of string; textalign: TTextAlign = taMiddle): boolean; overload;
 
function MessageYesNo(glwin: TGLWindow; textlist: TStringList; textalign: TTextAlign = taMiddle): boolean; overload;
 
function MessageInputCardinal(glwin: TGLWindow; const s: string; TextAlign: TTextAlign; const AnswerDefault: string): Cardinal; overload;

Ask user to input an unsigned integer.

This is actually a shortcut for simple MessageInput with answerMinLength = 1 and AllowedChars = ['0'..'9'], since this guarantees input of some unsigned integer number.

Note that AnswerDefault below may be given as Cardinal or as a string. The latter is useful if you want the default answer to be '', i.e. empty string — no default answer.

function MessageInputCardinal(glwin: TGLWindow; const s: string; TextAlign: TTextAlign; AnswerDefault: Cardinal): Cardinal; overload;
 
function MessageInputQueryCardinal(glwin: TGLWindow; const Title: string; var Value: Cardinal; TextAlign: TTextAlign): boolean;
 
function MessageInputQueryCardinalHex(glwin: TGLWindow; const Title: string; var Value: Cardinal; TextAlign: TTextAlign; MaxWidth: Cardinal): boolean;

Ask user to input a value in hexadecimal. Give MaxWidth = 0 to say that there is no maximum width.

function MessageInputQuery(glwin: TGLWindow; const Title: string; var Value: Extended; TextAlign: TTextAlign): boolean;
 
function MessageInputQuery(glwin: TGLWindow; const Title: string; var Value: Single; TextAlign: TTextAlign): boolean;
 
function MessageInputQueryVector3Single( glwin: TGLWindow; const Title: string; var Value: TVector3Single; TextAlign: TTextAlign): boolean;
 
function MessageInputQueryVector4Single( glwin: TGLWindow; const Title: string; var Value: TVector4Single; TextAlign: TTextAlign): boolean;
 

Types

TTextAlign = (...);

Specifies text alignment for MessageXxx functions in GLWinMessages unit.

Values
  • taLeft:
  • taMiddle:
  • taRight:
TGLWinMessageNotify = procedure(Text: TStringList);
 

Constants

GLWinMessagesTheme_Default: TGLWinMessagesTheme = ( RectColor: (0, 0, 0, 1); RectBorderCol: (1, 1, 0.33); ScrollBarCol: (0.5, 0.5, 0.5); ClosingInfoCol: (1, 1, 0.33); AdditionalStrCol: (0.33, 1, 1); TextCol: (1, 1, 1); RectStipple: nil; Font: nil; );
 
GLWinMessagesTheme_TypicalGUI: TGLWinMessagesTheme = ( RectColor: (0.75, 0.75, 0.66, 1); RectBorderCol: (0.87, 0.87, 0.81); ScrollBarCol: (0.87, 0.87, 0.81); ClosingInfoCol: (0.4, 0, 1); AdditionalStrCol: (0, 0.4, 0); TextCol: (0, 0, 0); RectStipple: nil; Font: nil; );
 

Variables

GLWinMessagesTheme: TGLWinMessagesTheme;

The way MessageXxx procedures in this unit are displayed. By default it is equal to GLWinMessagesTheme_Default.

Note that all procedures in this unit are re-entrant (safe for recursive calls, and in threads), unless you modify this variable. When you modify this from one thread, be sure that you don't currently use it in some MessageXxx (in other thread, or maybe you're in Glwm.OnIdle or such that is called while other window is in MessageXxx).

OnGLWinMessage: TGLWinMessageNotify;

If non-nil, this will be notified about every MessageXxx call.


Generated by PasDoc 0.10.0 on 2008-02-25 00:00:31