-> Make it compile. Keyboard handling, icon support.
wxListCtrl
- -> Icon support in list mode. Backgroundcolour, font?
+ -> Icon support in list mode
wxClipboard
-> Urgh.
wxTreeItemId(long itemId) { m_pItem = (wxGenericTreeItem *)itemId; }
operator long() const { return (long)m_pItem; }
-protected:
+//protected:
// for wxTreeCtrl usage only
wxTreeItemId(wxGenericTreeItem *pItem) { m_pItem = pItem; }
void OnRadioButtons( wxCommandEvent &event );
void OnSetFont( wxCommandEvent &event );
void OnPageChanged( wxNotebookEvent &event );
+ void OnSliderUpdate( wxCommandEvent &event );
wxListBox *m_listbox;
wxChoice *m_choice;
EVT_BUTTON (ID_RADIOBOX_FONT, MyPanel::OnRadioButtons)
EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
+ EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
END_EVENT_TABLE()
MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
{
-// SetBackgroundColour("cadet blue");
+ SetBackgroundColour("cadet blue");
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
m_text->SetBackgroundColour("wheat");
m_notebook->AddPage(panel, "wxList", FALSE, Image_List);
panel = new wxPanel(m_notebook);
-// panel->SetBackgroundColour("cadet blue");
-// panel->SetForegroundColour("blue");
+ panel->SetBackgroundColour("cadet blue");
+ panel->SetForegroundColour("blue");
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
m_choice->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
panel = new wxPanel(m_notebook);
-// panel->SetBackgroundColour("cadet blue");
-// panel->SetForegroundColour("blue");
+ panel->SetBackgroundColour("cadet blue");
+ panel->SetForegroundColour("blue");
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices );
-// m_combo->SetBackgroundColour("wheat");
+ m_combo->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
m_notebook->AddPage(panel, "wxComboBox", FALSE, Image_Combo);
panel = new wxPanel(m_notebook);
-// panel->SetBackgroundColour("cadet blue");
-// panel->SetForegroundColour("blue");
+ panel->SetBackgroundColour("cadet blue");
+ panel->SetForegroundColour("blue");
wxTextCtrl *tc = new wxTextCtrl( panel, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(350,28));
-// tc->SetBackgroundColour("wheat");
+ tc->SetBackgroundColour("wheat");
tc = new wxTextCtrl( panel, ID_TEXT, "And here.", wxPoint(10,50), wxSize(350,160), wxTE_MULTILINE );
-// tc->SetBackgroundColour("wheat");
+ tc->SetBackgroundColour("wheat");
m_notebook->AddPage(panel, "wxTextCtrl" , FALSE, Image_Text);
wxString choices2[] =
};
panel = new wxPanel(m_notebook);
-// panel->SetBackgroundColour("cadet blue");
-// panel->SetForegroundColour("blue");
+ panel->SetBackgroundColour("cadet blue");
+ panel->SetForegroundColour("blue");
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_HORIZONTAL );
-// m_radio->SetBackgroundColour("wheat");
+ m_radio->SetBackgroundColour("wheat");
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_VERTICAL );
-// m_radio->SetBackgroundColour("wheat");
+ m_radio->SetBackgroundColour("wheat");
(void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
(void)new wxButton( panel, ID_RADIOBOX_FONT, "Set Italic font", wxPoint(180,130), wxSize(140,30) );
m_notebook->AddPage(panel, "wxRadioBox", FALSE, Image_Radio);
panel = new wxPanel(m_notebook);
-// panel->SetBackgroundColour("cadet blue");
-// panel->SetForegroundColour("blue");
+ panel->SetBackgroundColour("cadet blue");
+ panel->SetForegroundColour("blue");
(void)new wxStaticBox( panel, -1, "wxGauge and wxSlider", wxPoint(10,10), wxSize(180,130) );
m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155,-1) );
-// m_gauge->SetBackgroundColour("wheat");
- m_slider = new wxSlider( panel, -1, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) );
-// m_slider->SetBackgroundColour("wheat");
+ m_gauge->SetBackgroundColour("wheat");
+ m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1) );
+ m_slider->SetBackgroundColour("wheat");
+ (void)new wxStaticBox( panel, -1, "Explanation", wxPoint(200,10), wxSize(290,130) );
+ (void)new wxStaticText( panel, -1,
+ "In order see the gauge (aka progress bar)\n"
+ "control do something you have to drag the\n"
+ "handle of the slider to the right.\n"
+ "\n"
+ "This is also supposed to demonstrate how\n"
+ "to use static controls.\n",
+ wxPoint(208,25) );
m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
}
m_text->SetFont( *wxITALIC_FONT );
}
+void MyPanel::OnSliderUpdate( wxCommandEvent &WXUNUSED(event) )
+{
+ m_gauge->SetValue( m_slider->GetValue() );
+}
+
MyPanel::~MyPanel()
{
delete m_notebook->GetImageList();
--- /dev/null
+/* XPM */
+static char * gauge_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"16 16 5 1",
+/* colors */
+" s None c None",
+". c #000000",
+"+ c #000080",
+"@ c #c0c0c0",
+"# c #808080",
+/* pixels */
+" ",
+" ",
+" ",
+"################",
+"#..............#",
+"#.++++++++@@@@@#",
+"#.++++++++@@@@@#",
+"#.++++++++@@@@@#",
+"#.++++++++@@@@@#",
+"#.++++++++@@@@@#",
+"#.++++++++@@@@@#",
+"#.++++++++@@@@@#",
+"################",
+" ",
+" ",
+" "};
GtkWidget *list_item = gtk_list_item_new_with_label( item );
- if (m_widgetStyle) ApplyWidgetStyle();
-
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(list), list_item );
+ if (m_widgetStyle) ApplyWidgetStyle();
+
gtk_widget_show( list_item );
}
{
m_refData = new wxFontRefData();
+ if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS;
+ M_FONTDATA->m_family = FontIdOrFamily;
+
if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) )
{
M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily );
M_FONTDATA->m_fontId = FontIdOrFamily;
M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily );
}
- if (Style == wxDEFAULT) Style = wxSWISS;
+
+ if (Style == wxDEFAULT) Style = wxNORMAL;
M_FONTDATA->m_style = Style;
if (Weight == wxDEFAULT) Weight = wxNORMAL;
M_FONTDATA->m_weight = Weight;
- if (PointSize == wxDEFAULT) PointSize = 10;
+ if (PointSize == wxDEFAULT) PointSize = 12;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
}
else
{
+/*
+ if (int_scale == 100) printf( "int_scale.\n" );
+ if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
+ if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
+ if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
+ if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
+*/
if ((int_scale == 100) &&
- (M_FONTDATA->m_style == wxSWISS) &&
+ (M_FONTDATA->m_family == wxSWISS) &&
+ (M_FONTDATA->m_style == wxNORMAL) &&
(M_FONTDATA->m_pointSize == 12) &&
(M_FONTDATA->m_weight == wxNORMAL) &&
- (M_FONTDATA->m_underlined == FALSE) &&
- (M_FONTDATA->m_style == wxNORMAL))
+ (M_FONTDATA->m_underlined == FALSE))
{
font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
}
if (m_frameToolBar)
{
- gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT );
+ int y = 0;
+ if (m_frameMenuBar) y = wxMENU_HEIGHT;
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y );
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
}
GtkWidget *list_item = gtk_list_item_new_with_label( item );
- if (m_widgetStyle) ApplyWidgetStyle();
-
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(m_list), list_item );
+ if (m_widgetStyle) ApplyWidgetStyle();
+
gtk_widget_show( list_item );
ConnectWidget( list_item );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
- int tmp = 22+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
+ int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
if (tmp > maxLen) maxLen = tmp;
width = m_width-10;
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
int y = 1;
- if (newSize.x == -1) {
+ if (newSize.x == -1)
+ {
char *s = WXSTRINGCAST m_label;
char *nl = strchr(s, '\n');
- if (nl) {
- do {
+ if (nl)
+ {
+ do
+ {
*nl = 0;
- int x = gdk_string_measure( m_widget->style->font, s );
- if (x > newSize.x) {
- newSize.x = x;
- }
+ int x = gdk_string_measure( m_widget->style->font, s ) + 4;
+ if (x > newSize.x) newSize.x = x;
*nl++ = '\n';
- if ((nl = strchr(s = nl, '\n'))) {
+ if ((nl = strchr(s = nl, '\n')))
+ {
++y;
- } else {
- int x = gdk_string_measure( m_widget->style->font, s );
- if (x > newSize.x) {
- newSize.x = x;
- }
+ }
+ else
+ {
+ int x = gdk_string_measure( m_widget->style->font, s ) + 4;
+ if (x > newSize.x) newSize.x = x;
}
} while (nl);
- } else {
- newSize.x = gdk_string_measure( m_widget->style->font, label );
+ }
+ else
+ {
+ newSize.x = gdk_string_measure( m_widget->style->font, label ) + 4;
}
}
- if (newSize.y == -1) {
- if (y == 1) {
+ if (newSize.y == -1)
+ {
+ if (y == 1)
newSize.y = 26;
- } else {
- newSize.y
- = y * (m_widget->style->font->ascent +m_widget->style->font->descent);
- }
+ else
+ newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent);
}
SetSize( newSize.x, newSize.y );
GtkWidget *list_item = gtk_list_item_new_with_label( item );
- if (m_widgetStyle) ApplyWidgetStyle();
-
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(list), list_item );
+ if (m_widgetStyle) ApplyWidgetStyle();
+
gtk_widget_show( list_item );
}
{
m_refData = new wxFontRefData();
+ if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS;
+ M_FONTDATA->m_family = FontIdOrFamily;
+
if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) )
{
M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily );
M_FONTDATA->m_fontId = FontIdOrFamily;
M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily );
}
- if (Style == wxDEFAULT) Style = wxSWISS;
+
+ if (Style == wxDEFAULT) Style = wxNORMAL;
M_FONTDATA->m_style = Style;
if (Weight == wxDEFAULT) Weight = wxNORMAL;
M_FONTDATA->m_weight = Weight;
- if (PointSize == wxDEFAULT) PointSize = 10;
+ if (PointSize == wxDEFAULT) PointSize = 12;
M_FONTDATA->m_pointSize = PointSize;
M_FONTDATA->m_underlined = Underlined;
}
else
{
+/*
+ if (int_scale == 100) printf( "int_scale.\n" );
+ if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
+ if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
+ if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
+ if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
+*/
if ((int_scale == 100) &&
- (M_FONTDATA->m_style == wxSWISS) &&
+ (M_FONTDATA->m_family == wxSWISS) &&
+ (M_FONTDATA->m_style == wxNORMAL) &&
(M_FONTDATA->m_pointSize == 12) &&
(M_FONTDATA->m_weight == wxNORMAL) &&
- (M_FONTDATA->m_underlined == FALSE) &&
- (M_FONTDATA->m_style == wxNORMAL))
+ (M_FONTDATA->m_underlined == FALSE))
{
font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
}
if (m_frameToolBar)
{
- gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT );
+ int y = 0;
+ if (m_frameMenuBar) y = wxMENU_HEIGHT;
+ gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, y );
gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height );
}
GtkWidget *list_item = gtk_list_item_new_with_label( item );
- if (m_widgetStyle) ApplyWidgetStyle();
-
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(m_list), list_item );
+ if (m_widgetStyle) ApplyWidgetStyle();
+
gtk_widget_show( list_item );
ConnectWidget( list_item );
gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), x, y );
- int tmp = 22+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
+ int tmp = 25+gdk_string_measure( GTK_WIDGET(m_radio)->style->font, choices[i] );
if (tmp > maxLen) maxLen = tmp;
width = m_width-10;
gtk_label_set_justify(GTK_LABEL(m_widget), justify);
int y = 1;
- if (newSize.x == -1) {
+ if (newSize.x == -1)
+ {
char *s = WXSTRINGCAST m_label;
char *nl = strchr(s, '\n');
- if (nl) {
- do {
+ if (nl)
+ {
+ do
+ {
*nl = 0;
- int x = gdk_string_measure( m_widget->style->font, s );
- if (x > newSize.x) {
- newSize.x = x;
- }
+ int x = gdk_string_measure( m_widget->style->font, s ) + 4;
+ if (x > newSize.x) newSize.x = x;
*nl++ = '\n';
- if ((nl = strchr(s = nl, '\n'))) {
+ if ((nl = strchr(s = nl, '\n')))
+ {
++y;
- } else {
- int x = gdk_string_measure( m_widget->style->font, s );
- if (x > newSize.x) {
- newSize.x = x;
- }
+ }
+ else
+ {
+ int x = gdk_string_measure( m_widget->style->font, s ) + 4;
+ if (x > newSize.x) newSize.x = x;
}
} while (nl);
- } else {
- newSize.x = gdk_string_measure( m_widget->style->font, label );
+ }
+ else
+ {
+ newSize.x = gdk_string_measure( m_widget->style->font, label ) + 4;
}
}
- if (newSize.y == -1) {
- if (y == 1) {
+ if (newSize.y == -1)
+ {
+ if (y == 1)
newSize.y = 26;
- } else {
- newSize.y
- = y * (m_widget->style->font->ascent +m_widget->style->font->descent);
- }
+ else
+ newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent);
}
SetSize( newSize.x, newSize.y );
MyFrame::MyFrame(void) :
wxFrame( (wxFrame *) NULL, -1, (char *) "Robert's Test application", wxPoint(20,20), wxSize(470,360) )
{
+/*
wxMenu *file_menu = new wxMenu( "Test" );
file_menu->Append( ID_OPEN, "Open..");
file_menu->Append( ID_MSG, "MessageBox..");
menu_bar->Show( TRUE );
SetMenuBar( menu_bar );
+*/
CreateStatusBar( 2 );
m_canvas->SetScrollbars( 10, 10, 50, 50 );
m_tb = CreateToolBar();
- m_tb->SetMargins( 2, 2 );
m_tb->AddTool( 0, wxBitmap( list_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "This is a button" );
m_tb->AddTool( 0, wxBitmap( folder_xpm ), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, "This is a toggle" );
m_tb->Realize();