| Description | uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables |
Various dialog boxes (asking user for confirmation, question, simple text input etc.) drawn by OpenGL inside TGLWindow window.
Features:
MessageInputXxx ask user to enter some text.
The dialog boxes have vertical scroll bar, displayed when needed. So don't worry about displaying long text. Scroll bar can be operated with keys (up/down, ctrl+up/down, page up/down, home/end) and mouse (drag the scroll bar, or click below/above it).
Long text lines are automatically broken, so don't worry about displaying text with long lines.
We will try to break text only at whitespace. Note that our "line breaking" works correctly for all fonts (see TGLWinMessagesTheme.Font), even if font is not fixed-character-width font.
If you pass a text as a single string parameter, then our "line breaking" works correctly even for text that already contains newline characters (they are correctly recognized as forcing line break).
If you pass a text as an "array of string" or TStringList, it's expected that strings inside don't contain newline characters anymore. It's undefined what will happen (i.e. whether they will be correctly broken) otherwise. Of course, TStringList contents used to pass text to MessageXxx will never be modified in any way.
User is allowed to resize the window while MessageXxx works. (As long as TGLWindow.ResizeAllowed = raAllowed, of course.) Long lines are automatically broken taking into account current window width.
You can configure dialog boxes look using GLWinMessagesTheme variable. For example, you can make the dialog box background partially transparent (by real transparency or by OpenGL stipple pattern).
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:
It's implemented using GLWinModes approach. Which means that when you call some MessageXxx procedure, it temporarily switches all TGLWindow callbacks (OnDraw, OnKeyDown, OnMouseDown, OnIdle etc.) for it's own. So you can be sure that e.g. no glwin callbacks that you registered in your own programs/units will be called while MessageXxx works. When message box ends (e.g. for simple MessageOk, this happens when user will accept it by Enter key or clicking OK), original callbacks are restored.
This way you can call MessageXxx procedures in virtually any place of your program, and things will magically work — inside MessageXxx we wait until user answers the dialog box.
This also means that this units is only able to work when GLWindow unit implements Glwm.ProcessMessage routine. For now this means that GLWindow unit must not work on top of glut (GLWINDOW_GLUT must not be defined while compiling GLWindow), other GLWindow implementations are OK.
Be careful if you use Glwm callbacks, OnIdle / OnTimer. They are tied to GL window manager, Glwn, not to any particular window, and so they continue to work even while we're inside MessageXxx procedure.
While this can be useful, you should be careful when implementing these Glwm callbacks. When they access some TGLWindow instance, it may be currently inside MessageXxx call.
The whole MessageXxx is supposed to start and end on an open TGLWindow instance, so no Init or Close methods of TGLWindow will be called during MessageXxx.
OnCloseQuery during MessageXxx calls prevents user from exiting the program, actually OnCloseQuery callback is simple no-op. Which means, among other things, that you can safely use MessageXxx inside your own OnCloseQuery, for example you can implement you OnCloseQuery like
if MessageYesNo('Are you sure ?') then Glwin.Close;
| Name | Description |
|---|---|
record TGLWinMessagesTheme |
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; |
TTextAlign = (...); |
TGLWinMessageNotify = procedure(Text: TStringList); |
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;
); |
GLWinMessagesTheme: TGLWinMessagesTheme; |
OnGLWinMessage: TGLWinMessageNotify; |
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
|
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 Parameters
|
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
|
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 = |
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; |
TTextAlign = (...); |
|
Specifies text alignment for MessageXxx functions in GLWinMessages unit. Values
|
TGLWinMessageNotify = procedure(Text: TStringList); |
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;
); |
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. |