OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
chooseco.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of Choose Color Common Dialog class
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_CHOOSECO_H)
10#define OWL_CHOOSECO_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/commdial.h>
18#include <owl/color.h>
19#include <vector>
20
21namespace owl {
22
23#include <owl/preclass.h>
24
25/// \addtogroup commdlg
26/// @{
27/// \class TChooseColorDialog
28// ~~~~~ ~~~~~~~~~~~~~~~~~~
29/// Wrapper for the Choose-Color common dialog.
30//
31/// TChooseColorDialog objects represent modal dialog box interface elements that
32/// allow color selection and custom color adjustment. TChooseColorDialog can be
33/// made to appear modeless to the user by creating the dialog's parent as an
34/// invisible pop-up window and making the pop-up window a child of the main
35/// application window. TChooseColorDialog uses the TChooseColor::TData struct to
36/// initialize the dialog box with the user's color selection.
37//
39 public:
40
41/// Defines information necessary to initialize the dialog box with the user's color
42/// selection.
44 public:
45 TData(uint32 flags = 0, bool allocCustColor = false);
46 TData(uint32 flags, const TColor& initColor,
47 bool allocCustColors = false);
48
49 TData(const TData& other);
50 TData& operator =(const TData& other);
51
52/// Flags can be a combination of the following values that control the appearance
53/// and functionality of the dialog box:
54/// - \c \b CC_FULLOPEN Causes the entire dialog box to appear when the dialog box is
55/// created.
56/// - \c \b CC_PREVENTFULLOPEN Disables the "Define Custom Colors" push button.
57/// - \c \b CC_RGBINIT Causes the dialog box to use the color specified in rgbResult as the
58/// initial color selection.
59/// - \c \b CC_SHOWHELP Causes the dialog box to show the Help push button.
61
62/// If the dialog box is successfully executed, Error is 0. Otherwise, it
63/// contains one of the following codes:
64/// - \c \b CDERR_DIALOGFAILURE Failed to create a dialog box.
65/// - \c \b CDERR_FINDRESFAILURE Failed to find a specified resource.
66/// - \c \b CDERR_LOADRESFAILURE Failed to load a specified resource.
67/// - \c \b CDERR_LOCKRESOURCEFAILURE Failed to lock a specified resource.
68/// - \c \b CDERR_LOADSTRFAILURE Failed to load a specified string.
70
71/// Specifies the color that is initially selected when the dialog box is created.
72/// Contains the user's color selection when the dialog box is closed.
74
75/// Points to an array of 16 colors.
77
78 protected:
79 std::vector<TColor> CustColorsArray;
80 };
81
83 TData& data,
85 LPCTSTR title = 0,
86 TModule* module = 0);
87
89
90 ~TChooseColorDialog() override;
91
92 // Set the current RGB color in this dialog
93 //
94 void SetRGBColor(const TColor& color);
95
96 protected:
97 void Init(TResId templateId);
98 TData& GetData();
99 void SetData(const TData& data);
100
101 CHOOSECOLOR& GetCC();
102 void SetCC(const CHOOSECOLOR& cc);
103
104 auto DoExecute() -> int override;
105 auto DialogFunction(TMsgId, TParam1, TParam2) -> INT_PTR override;
106
107 TResult EvSetRGBColor(TParam1, TParam2); // EV_REGISTERED(SETRGBSTRING,
108
109 /// Registered messages this class sends (to itself)
110 //
112
114/// Stores the length of the TChooseColorDialog structure, the window that owns the
115/// dialog box, and the data block that contains the dialog template. It also points
116/// to an array of 16 RGB values for the custom color boxes in the dialog box, and
117/// specifies the dialog-box initialization flags.
118 union {
119 CHOOSECOLOR Cc; ///< New name
120 CHOOSECOLOR cc; ///< Old name
121 };
122
123/// Data is a reference to the TData object passed in the constructor.
124 TData& Data;
125
126 private:
128 TChooseColorDialog& operator=(const TChooseColorDialog&);
129
132};
133/// @}
134
135
136#include <owl/posclass.h>
137
138
139//----------------------------------------------------------------------------
140// Inline implementations
141//
142
143//
144/// Sets the current RGB color for the open dialog box by sending a SetRGBMsgId. You
145/// can use SetRGBColor() to send a message to change the current color selection.
146//
150
151//
152/// Return the data object for this common dialog.
153//
157
158//
159/// Sets the data for this common dialog.
160//
162 Data = data;
163}
164
165//
166/// Return the CHOOSECOLOR data structure for this dialog.
167//
169 return Cc;
170}
171
172//
173/// Set the CHOOSECOLOR data structure for this dialog.
174/// Use this function with caution!
175//
177 Cc = c;
178}
179
180//
181/// The user has clicked on a color.
182//
183/// Responds to the message sent by SetRGBColor by forwarding the to the original
184/// class. This event handler is not in the response table.
185//
189
190//
191//
192//
194 Flags = flags;
195 if (allocCustColor)
196 {
197 CustColorsArray.resize(16);
199 }
200 else
201 {
202 CustColors = nullptr;
203 }
204}
205
206//
207//
208//
210 const TColor& initColor,
211 bool allocCustColor) {
212 Flags = flags;
213 Color = initColor;
214 if (allocCustColor)
215 {
216 CustColorsArray.resize(16);
217 CustColors = &CustColorsArray[0];
218 }
219 else
220 {
221 CustColors = nullptr;
222 }
223}
224
225
226} // OWL namespace
227
228#endif // OWL_CHOOSECO_H
Defines information necessary to initialize the dialog box with the user's color selection.
Definition chooseco.h:43
uint32 Flags
Flags can be a combination of the following values that control the appearance and functionality of t...
Definition chooseco.h:60
TColor * CustColors
Points to an array of 16 colors.
Definition chooseco.h:76
std::vector< TColor > CustColorsArray
Definition chooseco.h:79
uint32 Error
If the dialog box is successfully executed, Error is 0.
Definition chooseco.h:69
TColor Color
Specifies the color that is initially selected when the dialog box is created.
Definition chooseco.h:73
TData(uint32 flags=0, bool allocCustColor=false)
Definition chooseco.h:193
Wrapper for the Choose-Color common dialog.
Definition chooseco.h:38
static uint SetRGBMsgId
Registered messages this class sends (to itself)
Definition chooseco.h:111
void SetData(const TData &data)
Sets the data for this common dialog.
Definition chooseco.h:161
void SetCC(const CHOOSECOLOR &cc)
Set the CHOOSECOLOR data structure for this dialog.
Definition chooseco.h:176
void SetRGBColor(const TColor &color)
Sets the current RGB color for the open dialog box by sending a SetRGBMsgId.
Definition chooseco.h:147
CHOOSECOLOR & GetCC()
Return the CHOOSECOLOR data structure for this dialog.
Definition chooseco.h:168
CHOOSECOLOR cc
Old name.
Definition chooseco.h:120
TResult EvSetRGBColor(TParam1, TParam2)
The user has clicked on a color.
Definition chooseco.h:186
CHOOSECOLOR Cc
New name.
Definition chooseco.h:119
TData & GetData()
Return the data object for this common dialog.
Definition chooseco.h:154
Class wrapper for management of color values.
Definition color.h:245
Derived from TDialog, TCommonDialog is the abstract base class for TCommonDialog objects.
Definition commdial.h:62
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
Definition window.cpp:852
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
Definition of windowing system color classes.
Definition of Common Dialog abstract base class.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_CASTABLE
Definition objstrm.h:1440
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
unsigned long uint32
Definition number.h:34
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338