cxWidgets 1.0
cxSearchPanel.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXSEARCHPANEL_H__
3#define __CXSEARCHPANEL_H__
4
5// Copyright (c) 2006-2007 Michael H. Kinney
6//
7// This class is based on cxPanel, and it contains a cxForm at the
8// top and a cxMenu below the form.
9
10#include "cxPanel.h"
11#include "cxForm.h"
12#include "cxMenu.h"
13#include <string>
14#include <memory>
15
16namespace cx {
17
24class cxSearchPanel : public cxPanel
25{
26 public:
40 explicit cxSearchPanel(cxWindow *pParentWindow = nullptr,
41 int pRow = 0, int pCol = 0,
42 int pHeight = DEFAULT_HEIGHT,
43 int pWidth = DEFAULT_WIDTH,
44 const std::string& pFormTitle = "",
45 const std::string& pMenuTitle = "",
46 eBorderStyle pFormBorderStyle = eBS_SINGLE_LINE,
47 eBorderStyle pMenuBorderStyle = eBS_SINGLE_LINE);
48
54 cxSearchPanel(const cxSearchPanel& pPanel);
55
56 virtual ~cxSearchPanel();
57
63 const std::shared_ptr<cxForm>& getForm() const;
64
70 const std::shared_ptr<cxMenu>& getMenu() const;
71
94 virtual std::shared_ptr<cxMultiLineInput> appendToForm(int pRow, int pCol, int pHeight,
95 int pWidth, const std::string& pLabel,
96 const std::string& pValidator = "",
97 const std::string& pHelpString = "",
98 eInputOptions pInputKind = eINPUT_EDITABLE,
99 const std::string& pName = "",
100 std::string *pExtValue = nullptr);
101
122 virtual std::shared_ptr<cxComboBox> appendComboBoxToForm(int pRow, int pCol, int pHeight,
123 int pWidth, const std::string& pLabel,
124 const std::string& pValidator = "",
125 const std::string& pHelpString = "",
126 eInputOptions pInputKind = eINPUT_EDITABLE,
127 const std::string& pName = "",
128 std::string *pExtValue = nullptr);
129
141 virtual void appendToMenu(const std::string& pDisplayText, long pReturnCode,
142 const std::string& pHelpString = "",
143 const std::string& pItemText = "",
145
157 virtual void appendToMenu(const std::string& pDisplayText, const std::string& pHelpString = "",
158 const std::string& pItemText = "",
160
168 virtual void clearFormInputs(bool pRefresh = false, bool pOnlyEditable = false);
169
175 virtual void clearMenu(bool pRefresh = false);
176
192 void setFormOnFocusFunction(funcPtr4 pFuncPtr, void *p1, void *p2,
193 void *p3, void *p4, bool pUseVal = false,
194 bool pExitAfterRun = false);
195
209 void setFormOnFocusFunction(funcPtr2 pFuncPtr, void *p1, void *p2,
210 bool pUseVal = false,
211 bool pExitAfterRun = false);
212
224 void setFormOnFocusFunction(funcPtr0 pFuncPtr, bool pUseVal = false,
225 bool pExitAfterRun = false);
226
237 void setFormOnLeaveFunction(funcPtr4 pFuncPtr, void *p1, void *p2,
238 void *p3, void *p4);
239
248 void setFormOnLeaveFunction(funcPtr2 pFuncPtr, void *p1, void *p2);
249
256 void setFormOnLeaveFunction(funcPtr0 pFuncPtr);
257
271 virtual void setMenuOnFocusFunction(funcPtr4 pFunction, void *p1, void *p2,
272 void *p3, void *p4, bool pUseVal = false,
273 bool pExitAfterRun = false);
274
286 virtual void setMenuOnFocusFunction(funcPtr2 pFunction, void *p1, void *p2,
287 bool pUseVal = false, bool pExitAfterRun = false);
288
298 virtual void setMenuOnFocusFunction(funcPtr0 pFunction,
299 bool pUseVal = false, bool pExitAfterRun = false);
300
311 virtual void setMenuOnLeaveFunction(funcPtr4 pFunction, void *p1, void *p2,
312 void *p3, void *p4);
313
322 virtual void setMenuOnLeaveFunction(funcPtr2 pFunction, void *p1, void *p2);
323
330 virtual void setMenuOnLeaveFunction(funcPtr0 pFunction);
331
340 virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh = true) override;
341
349 virtual void setFormHeight(int pNewHeight, bool pRefresh = true);
350
358 virtual void setMenuHeight(int pNewHeight, bool pRefresh = true);
359
365 virtual std::string cxTypeStr() const override;
366
380 virtual bool setFormOnEnterFunction(funcPtr4 pFunction, void *p1, void *p2,
381 void *p3, void *p4);
382
394 virtual bool setFormOnEnterFunction(funcPtr2 pFunction, void *p1, void *p2);
395
405 virtual bool setFormOnEnterFunction(funcPtr0 pFunction);
406
410 virtual void clearFormOnEnterFunction();
411
435 virtual bool setFormKeyFunction(int pFunctionKey, funcPtr4 pFunction,
436 void *p1, void *p2, void *p3, void *p4,
437 bool pUseReturnVal = false,
438 bool pExitAfterRun = false,
439 bool pRunOnLeaveFunction = true);
440
462 virtual bool setFormKeyFunction(int pFunctionKey, funcPtr2 pFunction,
463 void *p1, void *p2,
464 bool pUseReturnVal = false,
465 bool pExitAfterRun = false,
466 bool pRunOnLeaveFunction = true);
467
487 virtual bool setFormKeyFunction(int pFunctionKey, funcPtr0 pFunction,
488 bool pUseReturnVal = false,
489 bool pExitAfterRun = false,
490 bool pRunOnLeaveFunction = true);
491
498 virtual void clearFormKeyFunction(int pFunctionKey);
499
503 virtual void clearFormKeyFunctions();
504
514 virtual bool formHasKeyFunction(int pFunctionKey) const;
515
539 virtual bool setMenuKeyFunction(int pFunctionKey, funcPtr4 pFunction,
540 void *p1, void *p2, void *p3, void *p4,
541 bool pUseReturnVal = false,
542 bool pExitAfterRun = false,
543 bool pRunOnLeaveFunction = true);
544
566 virtual bool setMenuKeyFunction(int pFunctionKey, funcPtr2 pFunction,
567 void *p1, void *p2,
568 bool pUseReturnVal = false,
569 bool pExitAfterRun = false,
570 bool pRunOnLeaveFunction = true);
571
591 virtual bool setMenuKeyFunction(int pFunctionKey, funcPtr0 pFunction,
592 bool pUseReturnVal = false,
593 bool pExitAfterRun = false,
594 bool pRunOnLeaveFunction = true);
595
602 virtual void clearMenuKeyFunction(int pFunctionKey);
603
607 virtual void clearMenuKeyFunctions();
608
618 virtual bool menuHasKeyFunction(int pFunctionKey) const;
619
637 virtual bool setMenuOnSelectItemFunction(funcPtr4 pFunction, void *p1,
638 void *p2, void *p3, void *p4,
639 bool pExitAfterRun,
640 bool pRunOnLeaveFunction);
641
657 virtual bool setMenuOnSelectItemFunction(funcPtr2 pFunction, void *p1,
658 void *p2, bool pExitAfterRun,
659 bool pRunOnLeaveFunction);
660
674 virtual bool setMenuOnSelectItemFunction(funcPtr0 pFunction,
675 bool pExitAfterRun,
676 bool pRunOnLeaveFunction);
677
683 virtual bool itemWasSelected() const;
684
695 virtual std::string getSelectedItem(bool pDisplayText = true) const;
696
702 virtual bool setFormCurrent();
703
709 virtual bool setMenuCurrent();
710
711 protected:
717 void copyCxSearchPanelStuff(const cxSearchPanel* pThatPanel);
718
719 private:
720 std::shared_ptr<cxForm> mForm; // Pointer to the form on the panel
721 std::shared_ptr<cxMenu> mMenu; // Pointer to the menu on the panel
722
723 // This function is used when copying another cxSearchPanel. It checks
724 // event function pointers (onFocus, onLeave, mFormOnEnterFunction) to
725 // see if any of their parameters point to another cxSearchPanel or its
726 // form or menu, and if so, has them point to this one or mForm or
727 // mMenu.
728 //
729 // Parameters:
730 // pPanel: Another cxSearchPanel being copied. Its event function
731 // parameters will be checked when a cxSearchPanel is being copied.
732 void checkEventFunctionPointers(const cxSearchPanel& pPanel);
733
734 // Don't allow assignment with = (this causes segfaults)
735 cxSearchPanel& operator =(const cxSearchPanel& pPanel);
736
737 // This is an event function for when the user presses the up arrow or
738 // shift-tab in the cxForm. If they are on the first input, it will go
739 // to the last input on the form. Otherise, it will go to the previous
740 // input as usual.
741 static std::string formReverseNavigation(void *theSearchPanel, void *unused);
742
743 // This is an event function for when the user presses the ESCAPE in
744 // the cxMenu. It will clear the form fields, the menu items, and
745 // apply focus to the first field on the form.
746 static std::string menuOnESC(void *theSearchPanel, void *unused);
747
748 // This is an event function for when the user selects an item in the
749 // menu.
750 static std::string menuOnSelect(void *theSearchPanel, void *unused);
751};
752
753} // namespace cx
754
755#endif
cxPanel is a window that contains other windows. When showModal()
Definition cxPanel.h:46
This class is based on cxPanel, and it contains a cxForm at the top.
Definition cxSearchPanel.h:25
virtual std::shared_ptr< cxComboBox > appendComboBoxToForm(int pRow, int pCol, int pHeight, int pWidth, const std::string &pLabel, const std::string &pValidator="", const std::string &pHelpString="", eInputOptions pInputKind=eINPUT_EDITABLE, const std::string &pName="", std::string *pExtValue=nullptr)
Adds a combo box to the form. Returns a pointer to the new input.
Definition cxSearchPanel.cpp:133
virtual std::string getSelectedItem(bool pDisplayText=true) const
Returns text of the item selected from the menu, if there was.
Definition cxSearchPanel.cpp:558
virtual void clearFormKeyFunctions()
Clears the form's list of external functions fired by hotkeys.
Definition cxSearchPanel.cpp:405
cxSearchPanel(cxWindow *pParentWindow=nullptr, int pRow=0, int pCol=0, int pHeight=DEFAULT_HEIGHT, int pWidth=DEFAULT_WIDTH, const std::string &pFormTitle="", const std::string &pMenuTitle="", eBorderStyle pFormBorderStyle=eBS_SINGLE_LINE, eBorderStyle pMenuBorderStyle=eBS_SINGLE_LINE)
Default constructor.
const std::shared_ptr< cxForm > & getForm() const
Returns a pointer to the cxForm on the panel.
Definition cxSearchPanel.cpp:114
virtual void clearFormOnEnterFunction()
Removes the onEnter function from the form.
Definition cxSearchPanel.cpp:334
virtual bool setFormCurrent()
Makes the form be the current window.
Definition cxSearchPanel.cpp:573
virtual void clearFormInputs(bool pRefresh=false, bool pOnlyEditable=false)
Clears the inputs on the form.
Definition cxSearchPanel.cpp:159
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class ("cxSearchPanel").
Definition cxSearchPanel.cpp:284
virtual bool setFormKeyFunction(int pFunctionKey, funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Adds a function to the form to call when the user presses some.
Definition cxSearchPanel.cpp:347
virtual void setMenuOnFocusFunction(funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pUseVal=false, bool pExitAfterRun=false)
Sets the onFocus function for the menu.
Definition cxSearchPanel.cpp:203
virtual void clearMenu(bool pRefresh=false)
Removes the menu items.
Definition cxSearchPanel.cpp:164
virtual void setMenuHeight(int pNewHeight, bool pRefresh=true)
Sets the menu's height. The form will also be re-sized accordingly.
Definition cxSearchPanel.cpp:270
virtual void resize(int pNewHeight, int pNewWidth, bool pRefresh=true) override
Changes the width and height, and re-sizes the form and menu.
Definition cxSearchPanel.cpp:237
virtual void clearMenuKeyFunction(int pFunctionKey)
Removes a hotkey from the menu so that it will not.
Definition cxSearchPanel.cpp:472
virtual void appendToMenu(const std::string &pDisplayText, long pReturnCode, const std::string &pHelpString="", const std::string &pItemText="", cxMenuItemType pType=cxITEM_NORMAL)
Adds a string item to the end of the menu.
virtual void appendToMenu(const std::string &pDisplayText, const std::string &pHelpString="", const std::string &pItemText="", cxMenuItemType pType=cxITEM_NORMAL)
Adds a string item to the end of the menu, defaulting the.
void setFormOnFocusFunction(funcPtr4 pFuncPtr, void *p1, void *p2, void *p3, void *p4, bool pUseVal=false, bool pExitAfterRun=false)
Sets the onFocus funtion for the form.
Definition cxSearchPanel.cpp:169
virtual bool setMenuCurrent()
Makes the menu be the current window.
Definition cxSearchPanel.cpp:578
void copyCxSearchPanelStuff(const cxSearchPanel *pThatPanel)
Makes a copy of another cxSearchPanel.
Definition cxSearchPanel.cpp:585
virtual bool setMenuKeyFunction(int pFunctionKey, funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Adds a function to the menu to call when the user presses some.
Definition cxSearchPanel.cpp:425
virtual bool itemWasSelected() const
Returns whether or not an item was selected from the menu.
Definition cxSearchPanel.cpp:546
const std::shared_ptr< cxMenu > & getMenu() const
Returns a pointer to the cxMenu on the panel.
Definition cxSearchPanel.cpp:119
virtual void setFormHeight(int pNewHeight, bool pRefresh=true)
Sets the form's height. The menu will also be re-sized accordingly.
Definition cxSearchPanel.cpp:256
virtual void setMenuOnLeaveFunction(funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4)
Sets the onLeave function for the menu.
Definition cxSearchPanel.cpp:221
virtual bool setFormOnEnterFunction(funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4)
Sets a function to be called when the enter key is pressed on.
Definition cxSearchPanel.cpp:289
virtual bool menuHasKeyFunction(int pFunctionKey) const
Returns whether the menu has a function hotkey set up to.
Definition cxSearchPanel.cpp:488
virtual bool setMenuOnSelectItemFunction(funcPtr4 pFunction, void *p1, void *p2, void *p3, void *p4, bool pExitAfterRun, bool pRunOnLeaveFunction)
Sets a function to run when the user selects an item from the.
Definition cxSearchPanel.cpp:500
virtual std::shared_ptr< cxMultiLineInput > appendToForm(int pRow, int pCol, int pHeight, int pWidth, const std::string &pLabel, const std::string &pValidator="", const std::string &pHelpString="", eInputOptions pInputKind=eINPUT_EDITABLE, const std::string &pName="", std::string *pExtValue=nullptr)
Adds an input to the form and returns a pointer to the new.
Definition cxSearchPanel.cpp:124
virtual void clearMenuKeyFunctions()
Clears the menu's list of external functions fired by hotkeys.
Definition cxSearchPanel.cpp:480
virtual ~cxSearchPanel()
Definition cxSearchPanel.cpp:110
void setFormOnLeaveFunction(funcPtr4 pFuncPtr, void *p1, void *p2, void *p3, void *p4)
Sets the onLeave function for the form.
Definition cxSearchPanel.cpp:187
virtual bool formHasKeyFunction(int pFunctionKey) const
Returns whether the form has a function hotkey set up to.
Definition cxSearchPanel.cpp:413
virtual void clearFormKeyFunction(int pFunctionKey)
Removes a hotkey from the form so that it will not.
Definition cxSearchPanel.cpp:397
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
#define DEFAULT_HEIGHT
Definition cxWindow.h:68
#define DEFAULT_WIDTH
Definition cxWindow.h:69
cxBorderChars.h - Defines border characters to be used in drawing a box (i.e., in cxWindow and all it...
Definition cxApp.cpp:5
std::string(* funcPtr4)(void *p1, void *p2, void *p3, void *p4)
Definition cxFunction.h:21
std::string(* funcPtr0)()
Definition cxFunction.h:19
std::string(* funcPtr2)(void *p1, void *p2)
Definition cxFunction.h:20
cxMenuItemType
Definition cxMenuItemType.h:14
@ cxITEM_NORMAL
Definition cxMenuItemType.h:15
eInputOptions
Definition cxInputOptions.h:20
@ eINPUT_EDITABLE
Definition cxInputOptions.h:21
eBorderStyle
Definition cxBorderStyles.h:26
@ eBS_SINGLE_LINE
Definition cxBorderStyles.h:28